From 131f0b370f52f70f3dc4a6341d543ef2329cc00e Mon Sep 17 00:00:00 2001 From: quou Date: Sun, 29 Dec 2024 23:33:39 +1100 Subject: add a seperate update_cbuffers function to models to avoid doing it on every render --- model.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'model.cpp') diff --git a/model.cpp b/model.cpp index dd14085..3b0e90f 100644 --- a/model.cpp +++ b/model.cpp @@ -156,16 +156,13 @@ void Model::update_transforms() { meshes[i].get_world(*this); } -void Model::render( +void Model::update_cbuffers( Device* dev, - Arena* a, - Render_Pass& pass, const m4f& transform, const m4f& view_projection ) { int i, c = mesh_count; Mesh* meshes = get_meshes(); - Context& ctx = dev->get_ctx(); MVP_Cbuffer* cbuffers = (MVP_Cbuffer*)dev->map_buffer( mvp, 0, @@ -175,8 +172,18 @@ void Model::render( cbuffers[i].view_projection = view_projection; cbuffers[i].model = transform * meshes[i].world; } - bool depth_only = !pass.colour_count; dev->unmap_buffer(mvp); +} + +void Model::render( + Device* dev, + Arena* a, + Render_Pass& pass +) { + int i, c = mesh_count; + Mesh* meshes = get_meshes(); + Context& ctx = dev->get_ctx(); + bool depth_only = !pass.colour_count; for (i = 0; i < c; i++) { Mesh& mesh = meshes[i]; Shader& shader = dev->get_shader(mesh.shader); -- cgit v1.2.3-54-g00ecf