Feature/matrix maintenance (#2875)

* Split RenderableSphere class into a local and an online sphere

* Make the video sphere derive from the regular sphere

* Make RenderableTimeVaryingSphere derive from RenderableSphere

* Some clean up

* Add general functions for renderable matrix calculations

* Make RenderableSphere and Plane use them

* Fix an issue with the RenderablePlane shader

* Make one function that returns all three types of render matrices

* Make more Renderables use the general matric calculation function

* Make more Renderable use the general matrix function

* Simplify alternative transforms for matrix calculations

* Small clean-up

* Update RenderableModel (again) to use new transform functions

* Make calc all matrix function to return tuple

* Update some more places
This commit is contained in:
Malin E
2023-09-21 14:22:36 +02:00
committed by GitHub
parent 36ee6840b5
commit ce789fcd22
42 changed files with 270 additions and 317 deletions

View File

@@ -629,17 +629,14 @@ void RenderableGalaxy::renderPoints(const RenderData& data) {
glm::rotate(glm::dmat4(1.0), 4.45741, glm::dvec3(0.0, 0.0, 1.0)
);
glm::dmat4 modelMatrix =
glm::translate(glm::dmat4(1.0), data.modelTransform.translation) *
glm::dmat4(data.modelTransform.rotation) * rotMatrix *
glm::scale(glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale));
AlternativeTransform altTransform;
altTransform.rotation = glm::dmat4(data.modelTransform.rotation) * rotMatrix;
glm::dmat4 modelTransform = calcModelTransform(data, altTransform);
glm::dmat4 projectionMatrix = glm::dmat4(data.camera.projectionMatrix());
glm::dmat4 cameraViewProjectionMatrix =
glm::dmat4(data.camera.projectionMatrix()) * data.camera.combinedViewMatrix();
glm::dmat4 cameraViewProjectionMatrix = projectionMatrix *
data.camera.combinedViewMatrix();
_pointsProgram->setUniform(_uniformCachePoints.modelMatrix, modelMatrix);
_pointsProgram->setUniform(_uniformCachePoints.modelMatrix, modelTransform);
_pointsProgram->setUniform(
_uniformCachePoints.cameraViewProjectionMatrix,
cameraViewProjectionMatrix
@@ -682,17 +679,14 @@ void RenderableGalaxy::renderBillboards(const RenderData& data) {
glm::rotate(glm::dmat4(1.0), 4.45741, glm::dvec3(0.0, 0.0, 1.0)
);
glm::dmat4 modelMatrix =
glm::translate(glm::dmat4(1.0), data.modelTransform.translation) *
glm::dmat4(data.modelTransform.rotation) * rotMatrix *
glm::scale(glm::dmat4(1.0), data.modelTransform.scale);
AlternativeTransform altTransform;
altTransform.rotation = glm::dmat4(data.modelTransform.rotation) * rotMatrix;
glm::dmat4 modelTransform = calcModelTransform(data, altTransform);
glm::dmat4 projectionMatrix = glm::dmat4(data.camera.projectionMatrix());
glm::dmat4 cameraViewProjectionMatrix =
glm::dmat4(data.camera.projectionMatrix()) * data.camera.combinedViewMatrix();
glm::dmat4 cameraViewProjectionMatrix = projectionMatrix *
data.camera.combinedViewMatrix();
_billboardsProgram->setUniform(_uniformCacheBillboards.modelMatrix, modelMatrix);
_billboardsProgram->setUniform(_uniformCacheBillboards.modelMatrix, modelTransform);
_billboardsProgram->setUniform(
_uniformCacheBillboards.cameraViewProjectionMatrix,
cameraViewProjectionMatrix