render: add M2 build resource snapshot
This commit is contained in:
@@ -14,20 +14,19 @@ const ACTION_ADVANCE_WITHOUT_MATERIALIZATION := &"advance_without_materializatio
|
||||
## Returns a detached action/transition plan for one M2 build operation.
|
||||
func plan_step(
|
||||
batch_count: int,
|
||||
animation_request_pending: bool,
|
||||
has_animated_prototype: bool,
|
||||
has_static_mesh: bool,
|
||||
static_model_missing: bool
|
||||
resource_snapshot: RefCounted
|
||||
) -> Dictionary:
|
||||
if animation_request_pending:
|
||||
if resource_snapshot == null:
|
||||
return _wait_plan(ACTION_WAIT_FOR_STATIC_MESH)
|
||||
if bool(resource_snapshot.call("animation_request_pending")):
|
||||
return _wait_plan(ACTION_WAIT_FOR_ANIMATION)
|
||||
if batch_count <= 0:
|
||||
return _advance_plan(ACTION_ADVANCE_WITHOUT_MATERIALIZATION, false)
|
||||
if has_animated_prototype:
|
||||
if bool(resource_snapshot.call("has_animated_prototype")):
|
||||
return _advance_plan(ACTION_MATERIALIZE_ANIMATED, true)
|
||||
if has_static_mesh:
|
||||
if bool(resource_snapshot.call("has_static_mesh")):
|
||||
return _advance_plan(ACTION_MATERIALIZE_STATIC, true)
|
||||
if static_model_missing:
|
||||
if bool(resource_snapshot.call("static_model_missing")):
|
||||
return _advance_plan(ACTION_ADVANCE_WITHOUT_MATERIALIZATION, true)
|
||||
return _wait_plan(ACTION_WAIT_FOR_STATIC_MESH)
|
||||
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
class_name M2BuildResourceSnapshot
|
||||
extends RefCounted
|
||||
|
||||
## Holds one M2 build-step resource observation without owning engine lifetime.
|
||||
|
||||
var _normalized_relative_path: String
|
||||
var _animated_prototype: Node3D
|
||||
var _animation_request_pending: bool
|
||||
var _static_mesh: Mesh = null
|
||||
var _static_model_missing: bool = false
|
||||
|
||||
|
||||
func _init(
|
||||
normalized_relative_path: String,
|
||||
animated_prototype: Node3D,
|
||||
animation_request_pending: bool
|
||||
) -> void:
|
||||
_normalized_relative_path = normalized_relative_path
|
||||
_animated_prototype = animated_prototype
|
||||
_animation_request_pending = animation_request_pending
|
||||
|
||||
|
||||
## Returns the normalized M2 path observed by the loader.
|
||||
func normalized_relative_path() -> String:
|
||||
return _normalized_relative_path
|
||||
|
||||
|
||||
## Returns the borrowed animated prototype without transferring ownership.
|
||||
func animated_prototype() -> Node3D:
|
||||
return _animated_prototype
|
||||
|
||||
|
||||
## Returns whether an animated prototype was observed.
|
||||
func has_animated_prototype() -> bool:
|
||||
return _animated_prototype != null
|
||||
|
||||
|
||||
## Returns whether the animation request remains pending.
|
||||
func animation_request_pending() -> bool:
|
||||
return _animation_request_pending
|
||||
|
||||
|
||||
## Adopts the optional static Mesh and terminal missing-model observation.
|
||||
func adopt_static_observation(static_mesh: Mesh, static_model_missing: bool) -> void:
|
||||
_static_mesh = static_mesh
|
||||
_static_model_missing = static_model_missing
|
||||
|
||||
|
||||
## Returns the borrowed static Mesh without transferring ownership.
|
||||
func static_mesh() -> Mesh:
|
||||
return _static_mesh
|
||||
|
||||
|
||||
## Returns whether a prepared static Mesh was observed.
|
||||
func has_static_mesh() -> bool:
|
||||
return _static_mesh != null
|
||||
|
||||
|
||||
## Returns whether the static model lookup reached a terminal missing outcome.
|
||||
func static_model_missing() -> bool:
|
||||
return _static_model_missing
|
||||
|
||||
|
||||
## Returns detached path/availability diagnostics without engine references.
|
||||
func diagnostic_snapshot() -> Dictionary:
|
||||
return {
|
||||
"normalized_relative_path": _normalized_relative_path,
|
||||
"has_animated_prototype": has_animated_prototype(),
|
||||
"animation_request_pending": _animation_request_pending,
|
||||
"has_static_mesh": has_static_mesh(),
|
||||
"static_model_missing": _static_model_missing,
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://cgleoy15rtmby
|
||||
Reference in New Issue
Block a user