38 m_operations.resize(m_model->get_groups().size());
39 for (std::size_t i = 0; i < m_operations.size(); ++i)
41 const auto& group = m_model->get_groups()[i];
42 auto& operation = m_operations[i];
44 operation.primitive_topology = group.primitive_topology;
45 operation.vertex_array = m_model->get_vertex_array().get();
46 operation.vertex_buffer = m_model->get_vertex_buffer().get();
47 operation.vertex_offset = m_model->get_vertex_offset();
48 operation.vertex_stride = m_model->get_vertex_stride();
49 operation.first_vertex = group.first_vertex;
50 operation.vertex_count = group.vertex_count;
51 operation.first_instance = 0;
52 operation.instance_count = 1;
53 operation.material = group.material;
68 m_operations[index].material = material;
72 m_operations[index].material = m_model->get_groups()[index].material;
78 for (std::size_t i = 0; i < m_operations.size(); ++i)
80 m_operations[i].material = m_model->get_groups()[i].material;
84 void static_mesh::update_bounds()
89 const auto& model_bounds = m_model->get_bounds();
93 for (std::size_t i = 0; i < 8; ++i)
104 void static_mesh::transformed()
109 for (
auto& operation: m_operations)
111 operation.transform = transform_matrix;
118 for (
auto& operation: m_operations)
120 operation.depth = depth;
constexpr const view_frustum_type & get_view_frustum() const noexcept
Returns the camera's view frustum.
constexpr std::uint32_t get_layer_mask() const noexcept
Returns the layer mask of the object.
constexpr const vector_type & get_translation() const noexcept
Returns the translation of the object.
constexpr const transform_type & get_transform() const noexcept
Returns the transform of the object.
static_mesh()=default
Constructs a model instance.
void render(render::context &ctx) const override
Adds render operations to a render context.
void set_material(std::size_t index, std::shared_ptr< render::material > material)
Overwrites the material of a model group for this model instance.
void set_model(std::shared_ptr< render::model > model)
Sets the model with which this model instance is associated.
void reset_materials()
Resets all overwritten materials.
constexpr T distance(const vector_type &point) const noexcept
Calculates the signed distance from the hyperplane to a point.
void extend(const vector_type &point) noexcept
Extends the hyperrectangle to include a point.
constexpr const plane_type & near() const noexcept
Returns the near clipping plane.
n by m column-major matrix.
static constexpr vector infinity() noexcept
Returns a vector of infinities, where every element is equal to infinity.
const scene::camera * camera
Pointer to the camera.
std::vector< const operation * > operations
Render operations generated by visible objects.