|
Physics Simulation & Visualization Tool 0.1
A C++ physics simulation engine with real-time 3D visualization
|
Interface for objects that support GPU instanced rendering. More...
#include <IDrawable.h>
Public Member Functions | |
| virtual glm::mat4 | getModelMatrix () const =0 |
| Gets the model transformation matrix for this instance. | |
| virtual Rendering::InstanceData | getInstanceData () const |
| Gets the complete per-instance data for GPU upload. | |
Public Member Functions inherited from IDrawable | |
| virtual | ~IDrawable ()=default |
| Virtual destructor for proper cleanup of derived classes. | |
| virtual Shader * | getShader () const =0 |
| Gets the shader used to render this object. | |
| virtual Mesh * | getMesh () const =0 |
| Gets the mesh geometry for this object. | |
| virtual uint32_t | getObjectID () const =0 |
| Gets the unique identifier for this object. | |
Interface for objects that support GPU instanced rendering.
Objects implementing this interface can be efficiently batched and rendered together when they share the same mesh and shader. The Scene groups compatible objects and renders them in a single instanced draw call, significantly reducing CPU overhead and draw call count.
This is the preferred rendering path for most scene objects (SceneObject, etc.) as it provides optimal performance for large numbers of similar objects.
Example usage:
Definition at line 111 of file IDrawable.h.
|
inlinevirtual |
Gets the complete per-instance data for GPU upload.
Constructs an InstanceData structure containing the model matrix, object ID, and any additional per-instance attributes. This data is uploaded to the GPU's instance buffer for instanced rendering.
The default implementation provides model matrix and object ID. Override to add custom attributes (e.g., per-instance color).
Implemented in SceneObject.
Definition at line 145 of file IDrawable.h.
|
pure virtual |
Gets the model transformation matrix for this instance.
The model matrix transforms vertices from model space to render space. World-space drawables should subtract SceneObject::getRenderOrigin() before uploading instance data. Simulation, picking, and serialization must keep using world-space transforms.
Implemented in SceneObject.