mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-21 12:29:04 -06:00
Remove caching of inverse model transform for every scene graph node
This commit is contained in:
@@ -36,7 +36,7 @@ namespace ghoul { class Dictionary; }
|
||||
namespace ghoul::opengl {
|
||||
class ProgramObject;
|
||||
class Texture;
|
||||
}
|
||||
} // namespace ghoul::opengl
|
||||
|
||||
namespace openspace {
|
||||
|
||||
|
||||
@@ -120,7 +120,6 @@ public:
|
||||
glm::dvec3 worldPosition() const;
|
||||
const glm::dmat3& worldRotationMatrix() const;
|
||||
glm::dmat4 modelTransform() const;
|
||||
glm::dmat4 inverseModelTransform() const;
|
||||
glm::dvec3 worldScale() const;
|
||||
bool isTimeFrameActive(const Time& time) const;
|
||||
|
||||
@@ -176,7 +175,6 @@ private:
|
||||
glm::dvec3 _worldScaleCached = glm::dvec3(1.0);
|
||||
|
||||
glm::dmat4 _modelTransformCached = glm::dmat4(1.0);
|
||||
glm::dmat4 _inverseModelTransformCached = glm::dmat4(1.0);
|
||||
|
||||
properties::FloatProperty _boundingSphere;
|
||||
properties::BoolProperty _computeScreenSpaceValues;
|
||||
|
||||
@@ -521,7 +521,9 @@ void GlobeBrowsingModule::goToChunk(const globebrowsing::RenderableGlobe& globe,
|
||||
);
|
||||
return;
|
||||
}
|
||||
const glm::dmat4 inverseModelTransform = globeSceneGraphNode->inverseModelTransform();
|
||||
const glm::dmat4 inverseModelTransform = glm::inverse(
|
||||
globeSceneGraphNode->modelTransform()
|
||||
);
|
||||
const glm::dvec3 cameraPositionModelSpace =
|
||||
glm::dvec3(inverseModelTransform * glm::dvec4(cameraPosition, 1.0));
|
||||
const SurfacePositionHandle posHandle = globe.calculateSurfacePositionHandle(
|
||||
@@ -551,7 +553,9 @@ void GlobeBrowsingModule::goToGeodetic2(const globebrowsing::RenderableGlobe& gl
|
||||
LERROR("Error when going to Geodetic2");
|
||||
}
|
||||
|
||||
const glm::dmat4 inverseModelTransform = globeSceneGraphNode->inverseModelTransform();
|
||||
const glm::dmat4 inverseModelTransform = glm::inverse(
|
||||
globeSceneGraphNode->modelTransform()
|
||||
);
|
||||
|
||||
const glm::dvec3 cameraPositionModelSpace =
|
||||
glm::dvec3(inverseModelTransform * glm::dvec4(cameraPosition, 1.0));
|
||||
|
||||
@@ -329,7 +329,7 @@ int getGeoPositionForCamera(lua_State* L) {
|
||||
const glm::dvec3 cameraPosition = global::navigationHandler.camera()->positionVec3();
|
||||
const SceneGraphNode* anchor =
|
||||
global::navigationHandler.orbitalNavigator().anchorNode();
|
||||
const glm::dmat4 inverseModelTransform = anchor->inverseModelTransform();
|
||||
const glm::dmat4 inverseModelTransform = glm::inverse(anchor->modelTransform());
|
||||
const glm::dvec3 cameraPositionModelSpace =
|
||||
glm::dvec3(inverseModelTransform * glm::dvec4(cameraPosition, 1.0));
|
||||
const SurfacePositionHandle posHandle = globe->calculateSurfacePositionHandle(
|
||||
|
||||
@@ -153,7 +153,7 @@ void DashboardItemGlobeLocation::render(glm::vec2& penPosition) {
|
||||
}
|
||||
|
||||
const glm::dvec3 cameraPosition = global::navigationHandler.camera()->positionVec3();
|
||||
const glm::dmat4 inverseModelTransform = n->inverseModelTransform();
|
||||
const glm::dmat4 inverseModelTransform = glm::inverse(n->modelTransform());
|
||||
const glm::dvec3 cameraPositionModelSpace =
|
||||
glm::dvec3(inverseModelTransform * glm::dvec4(cameraPosition, 1.0));
|
||||
const SurfacePositionHandle posHandle = globe->calculateSurfacePositionHandle(
|
||||
|
||||
@@ -843,6 +843,8 @@ void RenderableGlobe::render(const RenderData& data, RendererTasks& rendererTask
|
||||
}
|
||||
|
||||
void RenderableGlobe::update(const UpdateData& data) {
|
||||
ZoneScoped
|
||||
|
||||
if (_localRenderer.program && _localRenderer.program->isDirty()) {
|
||||
_localRenderer.program->rebuildFromFile();
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include <ghoul/font/fontrenderer.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <ghoul/misc/dictionary.h>
|
||||
#include <ghoul/misc/profiling.h>
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
#include <ghoul/opengl/textureunit.h>
|
||||
@@ -379,6 +380,8 @@ void RingsComponent::draw(const RenderData& data,
|
||||
}
|
||||
|
||||
void RingsComponent::update(const UpdateData& data) {
|
||||
ZoneScoped
|
||||
|
||||
if (_shader && _shader->isDirty()) {
|
||||
compileShadowShader();
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <ghoul/io/texture/texturereader.h>
|
||||
#include <ghoul/misc/dictionary.h>
|
||||
#include <ghoul/misc/profiling.h>
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
#include <ghoul/opengl/textureunit.h>
|
||||
@@ -437,6 +438,8 @@ void ShadowComponent::end() {
|
||||
}
|
||||
|
||||
void ShadowComponent::update(const UpdateData&) {
|
||||
ZoneScoped
|
||||
|
||||
_sunPosition = global::renderEngine.scene()->sceneGraphNode("Sun")->worldPosition();
|
||||
|
||||
glm::ivec2 renderingResolution = global::renderEngine.renderingResolution();
|
||||
|
||||
@@ -789,7 +789,7 @@ bool OrbitalNavigator::shouldFollowAnchorRotation(const glm::dvec3& cameraPositi
|
||||
}
|
||||
|
||||
const glm::dmat4 modelTransform = _anchorNode->modelTransform();
|
||||
const glm::dmat4 inverseModelTransform = _anchorNode->inverseModelTransform();
|
||||
const glm::dmat4 inverseModelTransform = glm::inverse(modelTransform);
|
||||
const glm::dvec3 cameraPositionModelSpace = glm::dvec3(inverseModelTransform *
|
||||
glm::dvec4(cameraPosition, 1.0));
|
||||
|
||||
@@ -843,8 +843,8 @@ OrbitalNavigator::CameraRotationDecomposition
|
||||
const glm::dvec3 cameraViewDirection =
|
||||
cameraPose.rotation * glm::dvec3(0.0, 0.0, -1.0);
|
||||
|
||||
const glm::dmat4 inverseModelTransform = reference.inverseModelTransform();
|
||||
const glm::dmat4 modelTransform = reference.modelTransform();
|
||||
const glm::dmat4 inverseModelTransform = glm::inverse(modelTransform);
|
||||
const glm::dvec3 cameraPositionModelSpace = glm::dvec3(inverseModelTransform *
|
||||
glm::dvec4(cameraPose.position, 1));
|
||||
|
||||
@@ -1407,7 +1407,7 @@ SurfacePositionHandle OrbitalNavigator::calculateSurfacePositionHandle(
|
||||
const SceneGraphNode& node,
|
||||
const glm::dvec3 cameraPositionWorldSpace)
|
||||
{
|
||||
const glm::dmat4 inverseModelTransform = node.inverseModelTransform();
|
||||
const glm::dmat4 inverseModelTransform = glm::inverse(node.modelTransform());
|
||||
const glm::dvec3 cameraPositionModelSpace =
|
||||
glm::dvec3(inverseModelTransform * glm::dvec4(cameraPositionWorldSpace, 1));
|
||||
const SurfacePositionHandle posHandle =
|
||||
|
||||
@@ -467,10 +467,12 @@ void SceneGraphNode::update(const UpdateData& data) {
|
||||
newUpdateData.modelTransform.translation
|
||||
);
|
||||
glm::dmat4 rotation = glm::dmat4(newUpdateData.modelTransform.rotation);
|
||||
glm::dmat4 scaling = glm::scale(glm::dmat4(1.0), newUpdateData.modelTransform.scale);
|
||||
glm::dmat4 scaling = glm::scale(
|
||||
glm::dmat4(1.0),
|
||||
newUpdateData.modelTransform.scale
|
||||
);
|
||||
|
||||
_modelTransformCached = translation * rotation * scaling;
|
||||
_inverseModelTransformCached = glm::inverse(_modelTransformCached);
|
||||
|
||||
if (_renderable && _renderable->isReady() &&
|
||||
(_renderable->isEnabled() || _renderable->shouldUpdateIfDisabled()))
|
||||
@@ -769,10 +771,6 @@ glm::dmat4 SceneGraphNode::modelTransform() const {
|
||||
return _modelTransformCached;
|
||||
}
|
||||
|
||||
glm::dmat4 SceneGraphNode::inverseModelTransform() const {
|
||||
return _inverseModelTransformCached;
|
||||
}
|
||||
|
||||
glm::dvec3 SceneGraphNode::worldScale() const {
|
||||
return _worldScaleCached;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user