From: Mikko Rasa Date: Fri, 12 Nov 2021 19:30:21 +0000 (+0200) Subject: Remove the transform function from Renderer X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=175153f224916b92d02a325aac5628956cda8daf;p=libs%2Fgl.git Remove the transform function from Renderer Renderables are encouraged to set a world-space model matrix directly, as some scenes and effects won't work properly with incremental matrices. --- diff --git a/source/animation/animatedobject.cpp b/source/animation/animatedobject.cpp index a551d1a7..f02ff3e3 100644 --- a/source/animation/animatedobject.cpp +++ b/source/animation/animatedobject.cpp @@ -40,7 +40,7 @@ void AnimatedObject::set_uniform(const string &name, const KeyFrame::AnimatedUni void AnimatedObject::setup_render(Renderer &renderer, Tag) const { - renderer.transform(matrix); + renderer.set_matrix(matrix); renderer.add_shader_data(shdata); } diff --git a/source/render/objectinstance.cpp b/source/render/objectinstance.cpp index bdbdffd1..235a1ad6 100644 --- a/source/render/objectinstance.cpp +++ b/source/render/objectinstance.cpp @@ -18,7 +18,7 @@ void ObjectInstance::render(Renderer &renderer, Tag tag) const void ObjectInstance::setup_render(Renderer &renderer, Tag) const { - renderer.transform(matrix); + renderer.set_matrix(matrix); } unsigned ObjectInstance::get_level_of_detail(const Renderer &renderer) const diff --git a/source/render/occludedscene.cpp b/source/render/occludedscene.cpp index 0d8a5b85..644e380d 100644 --- a/source/render/occludedscene.cpp +++ b/source/render/occludedscene.cpp @@ -143,7 +143,7 @@ void OccludedScene::render(Renderer &renderer, Tag tag) const { QueryPool::Activate activate_query(renderer, queries, i-occluded_cache.begin()); Renderer::Push push2(renderer); - renderer.transform(Matrix(*i->renderable->get_matrix()) + renderer.set_matrix(Matrix(*i->renderable->get_matrix()) .translate(i->bounding_sphere->get_center()) .scale(i->bounding_sphere->get_radius())); bounding_mesh.draw(renderer); diff --git a/source/render/renderer.cpp b/source/render/renderer.cpp index d53d7145..999ff1a2 100644 --- a/source/render/renderer.cpp +++ b/source/render/renderer.cpp @@ -95,12 +95,6 @@ void Renderer::set_matrix(const Matrix &matrix) changed |= MATRIX; } -void Renderer::transform(const Matrix &matrix) -{ - get_state().model_matrix *= matrix; - changed |= MATRIX; -} - void Renderer::set_framebuffer(const Framebuffer *f) { get_state().framebuffer = f; diff --git a/source/render/renderer.h b/source/render/renderer.h index 4c24068e..575dbe67 100644 --- a/source/render/renderer.h +++ b/source/render/renderer.h @@ -137,9 +137,6 @@ public: /** Replaces the Renderer's model matrix. */ void set_matrix(const Matrix &); - /** Applies a transform to the Renderer's model matrix. */ - void transform(const Matrix &); - /** Returns the current model matrix. */ const Matrix &get_matrix() const { return get_state().model_matrix; }