simvx.graphics.scene_adapter¶
Adapter to bridge SceneTree nodes to Renderer submissions.
Module Contents¶
Classes¶
Bridges SceneTree to Renderer (Vulkan). |
Data¶
API¶
- simvx.graphics.scene_adapter.__all__¶
[‘SceneAdapter’]
- simvx.graphics.scene_adapter.log¶
‘getLogger(…)’
- class simvx.graphics.scene_adapter.SceneAdapter(engine: Any, renderer: Any)[source]¶
Bridges SceneTree to Renderer (Vulkan).
Responsibilities:
Register meshes with the GPU
Convert materials to Vulkan format
Traverse scene tree and submit instances
Initialization
- register_mesh(mesh: Any) Any | None[source]¶
Register mesh with Vulkan engine, return MeshHandle.
Returns None if the mesh has no vertex data (skipped gracefully).
- register_skinned_mesh(mesh: Any) Any | None[source]¶
Register skinned mesh with Vulkan engine, return MeshHandle.
Returns None if the mesh has no vertex data.
- register_material(material: simvx.core.Material | None) int[source]¶
Convert simvx.core Material to Vulkan material index.
Deduplicates materials by content: two Material objects with identical rendering properties share the same SSBO slot.
- release_material(mat_id: int, slot_idx: int) None[source]¶
Reclaim a material SSBO slot.
Called by the weakref.finalize attached to a Material when it goes out of scope. Pushes the slot onto the free list, clears the dedup/registry entries, and zeroes the SSBO row so stale colour data doesn’t leak through if the slot is re-used before upload_materials runs this frame.
- submit_scene(tree: simvx.core.SceneTree) None[source]¶
Walk scene tree and submit instances to renderer.
Performs a single tree traversal to collect all renderable node types, then passes the pre-collected lists to individual submission methods.
Gracefully handles scenes with no Camera3D (e.g. editor UI-only scenes) by skipping 3D submission while still processing 2D overlays.
- render_to_target(cmd, target, tree: simvx.core.SceneTree, *, camera=None, screen_size: tuple[float, float] | None = None, draw2d_batches: list | None = None) None[source]¶
Render a scene tree into an offscreen render target.
Encapsulates the full offscreen render pipeline: frame setup, scene submission, transform upload, and render pass recording. Camera and viewport state on the tree is temporarily overridden and restored.
Args: cmd: Active Vulkan command buffer (from pre_render callback). target: Offscreen render target with begin_pass/end_pass/width/height/ready. tree: SceneTree to render. camera: Optional camera override (e.g. editor orbit camera). screen_size: Optional 2D screen size override (for 2D viewport rendering). draw2d_batches: Pre-extracted Draw2D batches to render as a 2D overlay on top of the 3D content. Requires target to have a
render_draw2d(cmd, batches)method (GameViewportRenderer).