Skip to content

Commit

Permalink
Small fixes to compilation and profiling regarding animations
Browse files Browse the repository at this point in the history
  • Loading branch information
Mormert committed Aug 25, 2023
1 parent 432b1ce commit 7c9c6ba
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 10 deletions.
3 changes: 2 additions & 1 deletion engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ add_library(engine STATIC
"jleSkinnedMesh.cpp"
"jleAnimationBone.cpp"
"jleAnimation.cpp"
"cSkinnedMesh.cpp")
"cSkinnedMesh.cpp"
"jleAnimationFinalMatrices.cpp")

if (BUILD_EDITOR)
target_sources(engine PRIVATE
Expand Down
4 changes: 4 additions & 0 deletions engine/cAnimator.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// Copyright (c) 2023. Johan Lind

#include "cAnimator.h"

#include "jleResourceRef.h"
#include "jle3DGraph.h"
#include "cSkinnedMesh.h"
#include "jleProfiler.h"

JLE_EXTERN_TEMPLATE_CEREAL_CPP(cAnimator)

Expand All @@ -29,6 +31,8 @@ cAnimator::update(float dt)
{
if(auto skinnedMeshComponent = _attachedToObject->getComponent<cSkinnedMesh>()){

JLE_SCOPE_PROFILE_CPU(cAnimator_Skinning)

_deltaTime = dt;
if(_currentAnimation){
_currentTime += _currentAnimation->getTicksPerSec() * dt;
Expand Down
2 changes: 0 additions & 2 deletions engine/jle3DGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

#include "jle3DGraph.h"
#include "jleMaterial.h"
#include "jleMesh.h"
#include "jleAnimationFinalMatrices.h"

void
jle3DGraph::sendMesh(std::shared_ptr<jleMesh> &mesh,
Expand Down
2 changes: 1 addition & 1 deletion engine/jle3DGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class jleMaterial;
class jleMesh;
class jleSkinnedMesh;
class jleAnimationFinalMatrices;
struct jleAnimationFinalMatrices;

struct jle3DRendererLight {
glm::vec3 position;
Expand Down
2 changes: 2 additions & 0 deletions engine/jle3DRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ jle3DRenderer::renderMeshes(const jleCamera &camera,
const jle3DSettings &settings)
{
for (auto &&mesh : meshes) {
JLE_SCOPE_PROFILE_GPU(MeshRender);
if (!mesh.material || !mesh.material->getShader()) {
_shaders->missingMaterialShader->use();
_shaders->missingMaterialShader->SetMat4("uView", camera.getViewMatrix());
Expand Down Expand Up @@ -205,6 +206,7 @@ jle3DRenderer::renderSkinnedMeshes(const jleCamera &camera,
const jle3DSettings &settings)
{
for (auto &&mesh : skinnedMeshes) {
JLE_SCOPE_PROFILE_GPU(SkinnedMeshRender);
if (!mesh.material || !mesh.material->getShader()) {
_shaders->missingMaterialShader->use();
_shaders->missingMaterialShader->SetMat4("uView", camera.getViewMatrix());
Expand Down
11 changes: 11 additions & 0 deletions engine/jleAnimationFinalMatrices.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (c) 2023. Johan Lind

#include "jleAnimationFinalMatrices.h"

jleAnimationFinalMatrices::jleAnimationFinalMatrices()
{
matrices.reserve(100);
for(int i = 0; i < 100; ++i){
matrices.emplace_back(1.f);
}
}
7 changes: 1 addition & 6 deletions engine/jleAnimationFinalMatrices.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,5 @@
struct jleAnimationFinalMatrices{
std::vector<glm::mat4> matrices;

jleAnimationFinalMatrices() {
matrices.reserve(100);
for(int i = 0; i < 100; ++i){
matrices.emplace_back(1.f);
}
}
jleAnimationFinalMatrices();
};

0 comments on commit 7c9c6ba

Please sign in to comment.