pub trait NodeTrait:
BaseNodeTrait
+ Reflect
+ Visit
+ ComponentProvider {
Show 14 methods
// Required methods
fn local_bounding_box(&self) -> AxisAlignedBoundingBox;
fn world_bounding_box(&self) -> AxisAlignedBoundingBox;
fn id(&self) -> Uuid;
// Provided methods
fn on_removed_from_graph(&mut self, graph: &mut Graph) { ... }
fn on_unlink(&mut self, graph: &mut Graph) { ... }
fn sync_native(
&self,
self_handle: Handle<Node>,
context: &mut SyncContext<'_, '_>,
) { ... }
fn on_global_transform_changed(
&self,
new_global_transform: &Matrix4<f32>,
context: &mut SyncContext<'_, '_>,
) { ... }
fn on_local_transform_changed(&self, context: &mut SyncContext<'_, '_>) { ... }
fn is_alive(&self) -> bool { ... }
fn update(&mut self, context: &mut UpdateContext<'_>) { ... }
fn collect_render_data(&self, ctx: &mut RenderContext<'_>) -> RdcControlFlow { ... }
fn should_be_rendered(&self, frustum: Option<&Frustum>) -> bool { ... }
fn debug_draw(&self, ctx: &mut SceneDrawingContext) { ... }
fn validate(&self, scene: &Scene) -> Result<(), String> { ... }
}
Expand description
A main trait for any scene graph node.
Required Methods§
Sourcefn local_bounding_box(&self) -> AxisAlignedBoundingBox
fn local_bounding_box(&self) -> AxisAlignedBoundingBox
Returns axis-aligned bounding box in local space of the node.
Sourcefn world_bounding_box(&self) -> AxisAlignedBoundingBox
fn world_bounding_box(&self) -> AxisAlignedBoundingBox
Returns axis-aligned bounding box in world space of the node.
§Important notes
World bounding box will become valid only after first update
call of the parent scene.
It is because to calculate world bounding box we must get world transform first, but it
can be calculated with a knowledge of parent world transform, so node on its own cannot know
its world bounding box without additional information.
Provided Methods§
Sourcefn on_removed_from_graph(&mut self, graph: &mut Graph)
fn on_removed_from_graph(&mut self, graph: &mut Graph)
Gives an opportunity to perform clean up after the node was extracted from the scene graph (or deleted).
Sourcefn on_unlink(&mut self, graph: &mut Graph)
fn on_unlink(&mut self, graph: &mut Graph)
The method is called when the node was detached from its parent node.
Sourcefn sync_native(
&self,
self_handle: Handle<Node>,
context: &mut SyncContext<'_, '_>,
)
fn sync_native( &self, self_handle: Handle<Node>, context: &mut SyncContext<'_, '_>, )
Synchronizes internal state of the node with components of scene graph. It has limited usage
and mostly allows you to sync the state of backing entity with the state of the node.
For example the engine use it to sync native rigid body properties after some property was
changed in the crate::scene::rigidbody::RigidBody
node.
Sourcefn on_global_transform_changed(
&self,
new_global_transform: &Matrix4<f32>,
context: &mut SyncContext<'_, '_>,
)
fn on_global_transform_changed( &self, new_global_transform: &Matrix4<f32>, context: &mut SyncContext<'_, '_>, )
Called when node’s global transform changes.
Sourcefn on_local_transform_changed(&self, context: &mut SyncContext<'_, '_>)
fn on_local_transform_changed(&self, context: &mut SyncContext<'_, '_>)
Called when node’s local transform changed.
Sourcefn is_alive(&self) -> bool
fn is_alive(&self) -> bool
The methods is used to manage lifetime of scene nodes, depending on their internal logic.
Sourcefn update(&mut self, context: &mut UpdateContext<'_>)
fn update(&mut self, context: &mut UpdateContext<'_>)
Updates internal state of the node.
Sourcefn collect_render_data(&self, ctx: &mut RenderContext<'_>) -> RdcControlFlow
fn collect_render_data(&self, ctx: &mut RenderContext<'_>) -> RdcControlFlow
Allows the node to emit a set of render data. This is a high-level rendering method which can only do culling and provide render data. Render data is just a surface (vertex + index buffers) and a material.
Sourcefn should_be_rendered(&self, frustum: Option<&Frustum>) -> bool
fn should_be_rendered(&self, frustum: Option<&Frustum>) -> bool
Checks if the node should be rendered or not. A node should be rendered if it is enabled, visible and (optionally) is inside some viewing frustum.
Sourcefn debug_draw(&self, ctx: &mut SceneDrawingContext)
fn debug_draw(&self, ctx: &mut SceneDrawingContext)
Allows the node to draw simple shapes to visualize internal data structures for debugging purposes.