From aca4634e048e8c8c920df80553da31d4abf92877 Mon Sep 17 00:00:00 2001 From: Johan Lind Date: Sun, 18 Feb 2024 20:46:37 +0100 Subject: [PATCH] jleAssert and jleCommon header files --- engine/cAnimator.h | 2 +- engine/cAseprite.h | 2 +- engine/cCamera.h | 2 +- engine/cCameraFPV.h | 2 +- engine/cLight.h | 2 +- engine/cMesh.h | 2 +- engine/cRigidbody.cpp | 2 +- engine/cRigidbody.h | 2 +- engine/cSpriteDepth.h | 2 +- engine/cTransformNetSync.h | 2 +- engine/cUITransformUpdater.h | 2 +- engine/editor/jleConsoleEditorWindow.h | 2 +- engine/editor/jleEditorBuild.h | 2 +- engine/editor/jleEditorGizmos.h | 2 +- engine/editor/jleEditorSaveState.h | 2 +- engine/editor/jleEditorTextEdit.h | 2 +- engine/editor/jleGameEditorWindow.h | 2 +- engine/jle3DGraph.h | 2 +- engine/jle3DRenderer.h | 2 +- engine/jleAnimation.cpp | 2 +- engine/jleAnimation.h | 2 +- engine/jleAnimationBone.h | 2 +- engine/jleAnimationFinalMatrices.h | 2 +- engine/jleAssert.h | 55 ++++++++++++++++++++++++++ engine/jleCamera.h | 2 +- engine/jleCommandArguments.h | 2 +- engine/jleCommon.h | 24 +++++++++++ engine/jleCompileHelper.h | 2 +- engine/jleComponent.h | 2 +- engine/jleEngineSettings.h | 2 +- engine/jleFont.h | 2 +- engine/jleFrameBufferInterface.cpp | 6 +-- engine/jleFrameBufferInterface.h | 2 +- engine/jleFramebufferMultisample.cpp | 2 +- engine/jleFramebufferPicking.h | 2 +- engine/jleFramebufferScreen.h | 2 +- engine/jleFramebufferShadowCubeMap.h | 2 +- engine/jleFramebufferShadowMap.h | 2 +- engine/jleGame.h | 2 +- engine/jleGameEngine.h | 2 +- engine/jleInput.h | 2 +- engine/jleKeyboardInput.h | 2 +- engine/jleKickStarter.h | 2 +- engine/jleLuaScriptComponent.h | 2 +- engine/jleMaterial.h | 2 +- engine/jleMesh.h | 2 +- engine/jleNetworkEvent.h | 2 +- engine/jleObject.cpp | 2 +- engine/jleObject.h | 2 +- engine/jlePathDefines.h | 2 +- engine/jlePhysics.h | 2 +- engine/jlePhysicsDebugDrawer.h | 2 +- engine/jleProfiler.h | 2 +- engine/jleQuadRendering.h | 2 +- engine/jleQuads.h | 2 +- engine/jleRGB.h | 2 +- engine/jleRendering.h | 2 +- engine/jleResource.h | 2 +- engine/jleResourceInterface.h | 2 +- engine/jleScene.h | 2 +- engine/jleSceneClient.h | 2 +- engine/jleSceneServer.h | 2 +- engine/jleScopeProfileLog.h | 2 +- engine/jleSerializedResource.h | 2 +- engine/jleShader.h | 2 +- engine/jleSkinnedMesh.cpp | 4 +- engine/jleSkinnedMesh.h | 2 +- engine/jleSkybox.h | 2 +- engine/jleTexture.h | 2 +- engine/jleTextureRefOrRGBA.h | 2 +- engine/jleTransform.cpp | 9 +++-- engine/jleTransform.h | 2 +- engine/jleTypeReflectionUtils.h | 2 +- engine/jleWindow.h | 2 +- engine/jleWindowSettings.h | 2 +- engine/precompile.h | 2 +- 76 files changed, 161 insertions(+), 79 deletions(-) create mode 100644 engine/jleAssert.h create mode 100644 engine/jleCommon.h diff --git a/engine/cAnimator.h b/engine/cAnimator.h index 20d7e6a9..60d2b4b5 100644 --- a/engine/cAnimator.h +++ b/engine/cAnimator.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jleAnimation.h" #include "jleComponent.h" diff --git a/engine/cAseprite.h b/engine/cAseprite.h index 16897845..4342ef97 100644 --- a/engine/cAseprite.h +++ b/engine/cAseprite.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jleAseprite.h" #include "jleComponent.h" diff --git a/engine/cCamera.h b/engine/cCamera.h index 9d29eb67..70117b59 100644 --- a/engine/cCamera.h +++ b/engine/cCamera.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jleAseprite.h" #include "jleComponent.h" diff --git a/engine/cCameraFPV.h b/engine/cCameraFPV.h index e4396357..c1d0ddb0 100644 --- a/engine/cCameraFPV.h +++ b/engine/cCameraFPV.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "cCamera.h" #include "jleCamera.h" diff --git a/engine/cLight.h b/engine/cLight.h index ac28a36b..5bd6e850 100644 --- a/engine/cLight.h +++ b/engine/cLight.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jleComponent.h" diff --git a/engine/cMesh.h b/engine/cMesh.h index 72f7560c..6be3c971 100644 --- a/engine/cMesh.h +++ b/engine/cMesh.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jleComponent.h" #include "jleMaterial.h" diff --git a/engine/cRigidbody.cpp b/engine/cRigidbody.cpp index c8aa38b5..63a7a084 100644 --- a/engine/cRigidbody.cpp +++ b/engine/cRigidbody.cpp @@ -81,7 +81,7 @@ cRigidbody::setWorldTransform(const btTransform ¢erOfMassWorldTrans) std::unique_ptr cRigidbody::createRigidbody(bool isDynamic, btCollisionShape *shape) { - btAssert((!shape || shape->getShapeType() != INVALID_SHAPE_PROXYTYPE)); + jleAssert((!shape || shape->getShapeType() != INVALID_SHAPE_PROXYTYPE)); btVector3 localInertia(0, 0, 0); if (isDynamic) { diff --git a/engine/cRigidbody.h b/engine/cRigidbody.h index c3ddcadd..21e73284 100644 --- a/engine/cRigidbody.h +++ b/engine/cRigidbody.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jleComponent.h" #include "jleMaterial.h" diff --git a/engine/cSpriteDepth.h b/engine/cSpriteDepth.h index 32a6fb7e..a8d54ac3 100644 --- a/engine/cSpriteDepth.h +++ b/engine/cSpriteDepth.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jleComponent.h" #include "jleTransform.h" diff --git a/engine/cTransformNetSync.h b/engine/cTransformNetSync.h index 03ca8a60..38cb9b01 100644 --- a/engine/cTransformNetSync.h +++ b/engine/cTransformNetSync.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jleComponent.h" diff --git a/engine/cUITransformUpdater.h b/engine/cUITransformUpdater.h index dc74ca5f..722bc3a4 100644 --- a/engine/cUITransformUpdater.h +++ b/engine/cUITransformUpdater.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" /* diff --git a/engine/editor/jleConsoleEditorWindow.h b/engine/editor/jleConsoleEditorWindow.h index e7f1f622..31d67b8e 100644 --- a/engine/editor/jleConsoleEditorWindow.h +++ b/engine/editor/jleConsoleEditorWindow.h @@ -17,7 +17,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #if JLE_BUILD_EDITOR diff --git a/engine/editor/jleEditorBuild.h b/engine/editor/jleEditorBuild.h index 21aa624c..c5a0c681 100644 --- a/engine/editor/jleEditorBuild.h +++ b/engine/editor/jleEditorBuild.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #if JLE_BUILD_EDITOR diff --git a/engine/editor/jleEditorGizmos.h b/engine/editor/jleEditorGizmos.h index 2b601708..e0dd0581 100644 --- a/engine/editor/jleEditorGizmos.h +++ b/engine/editor/jleEditorGizmos.h @@ -16,7 +16,7 @@ #ifndef JLE_EDITORGIZMOS_H #define JLE_EDITORGIZMOS_H -#include "jleBuildConfig.h" +#include "jleCommon.h" #if JLE_BUILD_EDITOR diff --git a/engine/editor/jleEditorSaveState.h b/engine/editor/jleEditorSaveState.h index 7781eaed..1f5cdbb8 100644 --- a/engine/editor/jleEditorSaveState.h +++ b/engine/editor/jleEditorSaveState.h @@ -16,7 +16,7 @@ #ifndef JLE_EDITORSAVESTATE #define JLE_EDITORSAVESTATE -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jleSerializedResource.h" #include "jleTypeReflectionUtils.h" diff --git a/engine/editor/jleEditorTextEdit.h b/engine/editor/jleEditorTextEdit.h index 41dbfaf2..a9965194 100644 --- a/engine/editor/jleEditorTextEdit.h +++ b/engine/editor/jleEditorTextEdit.h @@ -16,7 +16,7 @@ #ifndef JLEEDITORTEXTEDIT_H #define JLEEDITORTEXTEDIT_H -#include "jleBuildConfig.h" +#include "jleCommon.h" #if JLE_BUILD_EDITOR diff --git a/engine/editor/jleGameEditorWindow.h b/engine/editor/jleGameEditorWindow.h index 7d45644f..ec3cad05 100644 --- a/engine/editor/jleGameEditorWindow.h +++ b/engine/editor/jleGameEditorWindow.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #if JLE_BUILD_EDITOR diff --git a/engine/jle3DGraph.h b/engine/jle3DGraph.h index 38c31390..3da4c7a6 100644 --- a/engine/jle3DGraph.h +++ b/engine/jle3DGraph.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include diff --git a/engine/jle3DRenderer.h b/engine/jle3DRenderer.h index 6129f700..268cea7d 100644 --- a/engine/jle3DRenderer.h +++ b/engine/jle3DRenderer.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jle3DGraph.h" #include "jle3DSettings.h" diff --git a/engine/jleAnimation.cpp b/engine/jleAnimation.cpp index e4318879..5f92253c 100644 --- a/engine/jleAnimation.cpp +++ b/engine/jleAnimation.cpp @@ -124,7 +124,7 @@ jleAnimation::readBonesFromMesh(const aiAnimation *animation, const aiMesh *mesh void jleAnimation::readHierarchyData(jleAnimationNode &dest, aiNode *src) { - assert(src); + jleAssert(src); dest.name = src->mName.C_Str(); dest.transformation = glm::transpose(glm::make_mat4(&src->mTransformation.a1)); diff --git a/engine/jleAnimation.h b/engine/jleAnimation.h index 19ccfad8..532bc3f9 100644 --- a/engine/jleAnimation.h +++ b/engine/jleAnimation.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jleAnimationBone.h" #include "jleSkinnedMesh.h" diff --git a/engine/jleAnimationBone.h b/engine/jleAnimationBone.h index 6224f1cd..e43e2af6 100644 --- a/engine/jleAnimationBone.h +++ b/engine/jleAnimationBone.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include #include diff --git a/engine/jleAnimationFinalMatrices.h b/engine/jleAnimationFinalMatrices.h index f904ec9c..66dc63e9 100644 --- a/engine/jleAnimationFinalMatrices.h +++ b/engine/jleAnimationFinalMatrices.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include #include diff --git a/engine/jleAssert.h b/engine/jleAssert.h new file mode 100644 index 00000000..af9f66c8 --- /dev/null +++ b/engine/jleAssert.h @@ -0,0 +1,55 @@ +/********************************************************************************************* + * * + * , . , . ,--. * + * | | | | | o * + * | ,-. |- -- | ,-: ,-: ,-: ,-. ,-| |- ;-. ,-: . ;-. ,-. * + * | |-' | | | | | | | | |-' | | | | | | | | | | |-' * + * -' `-' `-' `--' `-` `-| `-| `-' `-' `--' ' ' `-| ' ' ' `-' * + * * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * + * Jet-Lagged Engine (jle) is licenced under GNU General Public License v3.0. * + * The licence can be found here: https://github.com/Mormert/jle/blob/master/LICENSE * + * Copyright (c) 2020-2024 Johan Lind. All rights reserved. * + * * + *********************************************************************************************/ + +#ifndef JLE_ASSERT_H +#define JLE_ASSERT_H + +#ifndef NDEBUG + +#include + +#ifdef _WIN32 +#include +#define JLE_DEBUG_BREAK __debugbreak() +#else +#include +#define JLE_DEBUG_BREAK raise(SIGTRAP) +#endif + +// Will only assert once, which can be convenient sometimes to avoid assertion spam +#define jleAssertOnce(condition) \ + do { \ + static bool triggeredOnce{false}; \ + if (!(condition) && !triggeredOnce) { \ + triggeredOnce = true; \ + LOGE << "Assertion failed: " << #condition << " at " << __FILE__ << ":" << __LINE__ << std::endl; \ + JLE_DEBUG_BREAK; \ + } \ + } while (0) + +#define jleAssert(condition) \ + do { \ + if (!(condition)) { \ + LOGE << "Assertion failed: " << #condition << " at " << __FILE__ << ":" << __LINE__ << std::endl; \ + JLE_DEBUG_BREAK; \ + } \ + } while (0) + +#else +#define jleAssert(condition) ((void)0) +#define jleAssertOnce(condition) ((void)0) +#endif + +#endif // JLE_ASSERT_H diff --git a/engine/jleCamera.h b/engine/jleCamera.h index 7cedb42e..ff67791c 100644 --- a/engine/jleCamera.h +++ b/engine/jleCamera.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include diff --git a/engine/jleCommandArguments.h b/engine/jleCommandArguments.h index 8b25def3..b49104e2 100644 --- a/engine/jleCommandArguments.h +++ b/engine/jleCommandArguments.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include #include diff --git a/engine/jleCommon.h b/engine/jleCommon.h new file mode 100644 index 00000000..1dd1e787 --- /dev/null +++ b/engine/jleCommon.h @@ -0,0 +1,24 @@ +/********************************************************************************************* + * * + * , . , . ,--. * + * | | | | | o * + * | ,-. |- -- | ,-: ,-: ,-: ,-. ,-| |- ;-. ,-: . ;-. ,-. * + * | |-' | | | | | | | | |-' | | | | | | | | | | |-' * + * -' `-' `-' `--' `-` `-| `-| `-' `-' `--' ' ' `-| ' ' ' `-' * + * * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * + * Jet-Lagged Engine (jle) is licenced under GNU General Public License v3.0. * + * The licence can be found here: https://github.com/Mormert/jle/blob/master/LICENSE * + * Copyright (c) 2020-2024 Johan Lind. All rights reserved. * + * * + *********************************************************************************************/ + +#ifndef JLE_COMMON_H +#define JLE_COMMON_H + +#include "jleBuildConfig.h" +#include "jleAssert.h" + +#include + +#endif //JLE_COMMON_H diff --git a/engine/jleCompileHelper.h b/engine/jleCompileHelper.h index 83abd8d1..530ffcfc 100644 --- a/engine/jleCompileHelper.h +++ b/engine/jleCompileHelper.h @@ -16,7 +16,7 @@ #ifndef JLE_COMPILE_HELPER #define JLE_COMPILE_HELPER -#include "jleBuildConfig.h" +#include "jleCommon.h" // These macros are used to reduce compile times by having the serialisation function from cereal // only be compiled once for the archives used in jle, in one .cpp file, and not spread out across multiple. diff --git a/engine/jleComponent.h b/engine/jleComponent.h index 0496e1df..83019f1f 100644 --- a/engine/jleComponent.h +++ b/engine/jleComponent.h @@ -16,7 +16,7 @@ #ifndef JLE_COMPONENT #define JLE_COMPONENT -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jleTypeReflectionUtils.h" diff --git a/engine/jleEngineSettings.h b/engine/jleEngineSettings.h index 9eed73fc..7fbb8b98 100644 --- a/engine/jleEngineSettings.h +++ b/engine/jleEngineSettings.h @@ -16,7 +16,7 @@ #ifndef JLE_ENGINESETTINGS #define JLE_ENGINESETTINGS -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jleSerializedResource.h" #include "jleTypeReflectionUtils.h" diff --git a/engine/jleFont.h b/engine/jleFont.h index 768b6c65..03867f52 100644 --- a/engine/jleFont.h +++ b/engine/jleFont.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include #include diff --git a/engine/jleFrameBufferInterface.cpp b/engine/jleFrameBufferInterface.cpp index 37b9ee44..54809e7c 100644 --- a/engine/jleFrameBufferInterface.cpp +++ b/engine/jleFrameBufferInterface.cpp @@ -33,8 +33,8 @@ jleFramebufferInterface::~jleFramebufferInterface() void jleFramebufferInterface::blitToOther(jleFramebufferInterface &framebuffer, bool includeDepth) { - assert(width() == framebuffer.width()); - assert(height() == framebuffer.height()); + jleAssert(width() == framebuffer.width()); + jleAssert(height() == framebuffer.height()); glBindFramebuffer(GL_READ_FRAMEBUFFER, _framebuffer); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer._framebuffer); @@ -80,7 +80,7 @@ unsigned int jleFramebufferInterface::texture() const { // Note: the framebuffer doesn't have to keep a texture! - assert(_texture > 0); + jleAssert(_texture > 0); return _texture; } diff --git a/engine/jleFrameBufferInterface.h b/engine/jleFrameBufferInterface.h index 86ceb169..2553c64d 100644 --- a/engine/jleFrameBufferInterface.h +++ b/engine/jleFrameBufferInterface.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include #include diff --git a/engine/jleFramebufferMultisample.cpp b/engine/jleFramebufferMultisample.cpp index 44eaf39f..730c7aef 100644 --- a/engine/jleFramebufferMultisample.cpp +++ b/engine/jleFramebufferMultisample.cpp @@ -90,7 +90,7 @@ jleFramebufferMultisample::setSamples(unsigned int samples) { int highestSamples; glGetIntegerv(GL_SAMPLES, &highestSamples); - assert(samples < highestSamples); + jleAssert(samples < highestSamples); _msaaSamples = samples; resize(_width, _height); diff --git a/engine/jleFramebufferPicking.h b/engine/jleFramebufferPicking.h index 37bbe358..d38a279e 100644 --- a/engine/jleFramebufferPicking.h +++ b/engine/jleFramebufferPicking.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jleFrameBufferInterface.h" diff --git a/engine/jleFramebufferScreen.h b/engine/jleFramebufferScreen.h index 2752ca7c..b4cb8846 100644 --- a/engine/jleFramebufferScreen.h +++ b/engine/jleFramebufferScreen.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jleFrameBufferInterface.h" diff --git a/engine/jleFramebufferShadowCubeMap.h b/engine/jleFramebufferShadowCubeMap.h index a5e3260c..898fa41b 100644 --- a/engine/jleFramebufferShadowCubeMap.h +++ b/engine/jleFramebufferShadowCubeMap.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jleFrameBufferInterface.h" diff --git a/engine/jleFramebufferShadowMap.h b/engine/jleFramebufferShadowMap.h index 5e12b236..84e64f32 100644 --- a/engine/jleFramebufferShadowMap.h +++ b/engine/jleFramebufferShadowMap.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jleFrameBufferInterface.h" diff --git a/engine/jleGame.h b/engine/jleGame.h index a397cd65..194ceacb 100644 --- a/engine/jleGame.h +++ b/engine/jleGame.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include #include diff --git a/engine/jleGameEngine.h b/engine/jleGameEngine.h index 2f8c1189..30041bc1 100644 --- a/engine/jleGameEngine.h +++ b/engine/jleGameEngine.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include #include diff --git a/engine/jleInput.h b/engine/jleInput.h index 6b0f1ec7..cbdc40a6 100644 --- a/engine/jleInput.h +++ b/engine/jleInput.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jleKeyboardInput.h" #include "jleMouseInput.h" diff --git a/engine/jleKeyboardInput.h b/engine/jleKeyboardInput.h index a4c86243..15dd2c94 100644 --- a/engine/jleKeyboardInput.h +++ b/engine/jleKeyboardInput.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include diff --git a/engine/jleKickStarter.h b/engine/jleKickStarter.h index 70f5600e..208db3f3 100644 --- a/engine/jleKickStarter.h +++ b/engine/jleKickStarter.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "editor/jleEditor.h" #include "jleCommandArguments.h" diff --git a/engine/jleLuaScriptComponent.h b/engine/jleLuaScriptComponent.h index 89517903..04a5e93c 100644 --- a/engine/jleLuaScriptComponent.h +++ b/engine/jleLuaScriptComponent.h @@ -16,7 +16,7 @@ #ifndef JLE_LUASCRIPTCOMPONENT_H #define JLE_LUASCRIPTCOMPONENT_H -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jleLuaScript.h" diff --git a/engine/jleMaterial.h b/engine/jleMaterial.h index 199c12c9..1b5efb2c 100644 --- a/engine/jleMaterial.h +++ b/engine/jleMaterial.h @@ -16,7 +16,7 @@ #ifndef JLE_MATERIAL_H #define JLE_MATERIAL_H -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jleCompileHelper.h" #include "jleResourceInterface.h" diff --git a/engine/jleMesh.h b/engine/jleMesh.h index d6454005..7b37daa3 100644 --- a/engine/jleMesh.h +++ b/engine/jleMesh.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "BulletCollision/CollisionShapes/btTriangleMesh.h" #include "jleResourceInterface.h" diff --git a/engine/jleNetworkEvent.h b/engine/jleNetworkEvent.h index 6d798e3a..e3836e2b 100644 --- a/engine/jleNetworkEvent.h +++ b/engine/jleNetworkEvent.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jleNetworkEventRegistrator.h" diff --git a/engine/jleObject.cpp b/engine/jleObject.cpp index 932d59d1..72708bd9 100644 --- a/engine/jleObject.cpp +++ b/engine/jleObject.cpp @@ -173,7 +173,7 @@ void jleObject::attachChildObject(const std::shared_ptr &object) { // The objects must live in the same scene - assert(object->_containedInScene == _containedInScene); + jleAssert(object->_containedInScene == _containedInScene); if (object->_parentObject) { // Remove the object from previous parent, if any auto it = std::find( diff --git a/engine/jleObject.h b/engine/jleObject.h index 3bd6cfa1..f6d89774 100644 --- a/engine/jleObject.h +++ b/engine/jleObject.h @@ -16,7 +16,7 @@ #ifndef JLE_OBJECT #define JLE_OBJECT -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jlePath.h" #include "jleSerializedResource.h" diff --git a/engine/jlePathDefines.h b/engine/jlePathDefines.h index 69c2362c..fad31501 100644 --- a/engine/jlePathDefines.h +++ b/engine/jlePathDefines.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include diff --git a/engine/jlePhysics.h b/engine/jlePhysics.h index 45b14dac..8c11d9e2 100644 --- a/engine/jlePhysics.h +++ b/engine/jlePhysics.h @@ -16,7 +16,7 @@ #ifndef JLE_PHYSICS_H #define JLE_PHYSICS_H -#include "jleBuildConfig.h" +#include "jleCommon.h" #include #include diff --git a/engine/jlePhysicsDebugDrawer.h b/engine/jlePhysicsDebugDrawer.h index 5d746745..60574a88 100644 --- a/engine/jlePhysicsDebugDrawer.h +++ b/engine/jlePhysicsDebugDrawer.h @@ -16,7 +16,7 @@ #ifndef JLE_PHYSICSDEBUGDRAWER_H #define JLE_PHYSICSDEBUGDRAWER_H -#include "jleBuildConfig.h" +#include "jleCommon.h" #include #include diff --git a/engine/jleProfiler.h b/engine/jleProfiler.h index c4477f0e..4588ebec 100644 --- a/engine/jleProfiler.h +++ b/engine/jleProfiler.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jlePathDefines.h" #include diff --git a/engine/jleQuadRendering.h b/engine/jleQuadRendering.h index 2a7c8065..7451065e 100644 --- a/engine/jleQuadRendering.h +++ b/engine/jleQuadRendering.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "glm/ext/scalar_constants.hpp" #include "jleCamera.h" diff --git a/engine/jleQuads.h b/engine/jleQuads.h index 8677323f..e1a3bb47 100644 --- a/engine/jleQuads.h +++ b/engine/jleQuads.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jleTexture.h" #include diff --git a/engine/jleRGB.h b/engine/jleRGB.h index 1eb19b17..311b5dee 100644 --- a/engine/jleRGB.h +++ b/engine/jleRGB.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jleExternalSerialization.h" diff --git a/engine/jleRendering.h b/engine/jleRendering.h index 628988de..968fb7f2 100644 --- a/engine/jleRendering.h +++ b/engine/jleRendering.h @@ -17,7 +17,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jle3DRenderer.h" #include "jleCamera.h" diff --git a/engine/jleResource.h b/engine/jleResource.h index 7d85cf28..907a8de9 100644 --- a/engine/jleResource.h +++ b/engine/jleResource.h @@ -16,7 +16,7 @@ #ifndef JLE_RESOURCE #define JLE_RESOURCE -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jlePath.h" #include "jleResourceInterface.h" diff --git a/engine/jleResourceInterface.h b/engine/jleResourceInterface.h index 319d144f..32b77151 100644 --- a/engine/jleResourceInterface.h +++ b/engine/jleResourceInterface.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jleCompileHelper.h" #include "jlePath.h" diff --git a/engine/jleScene.h b/engine/jleScene.h index c92187db..0a514da9 100644 --- a/engine/jleScene.h +++ b/engine/jleScene.h @@ -16,7 +16,7 @@ #ifndef JLE_SCENE #define JLE_SCENE -#include "jleBuildConfig.h" +#include "jleCommon.h" #include #include diff --git a/engine/jleSceneClient.h b/engine/jleSceneClient.h index c26659b4..abbe3dac 100644 --- a/engine/jleSceneClient.h +++ b/engine/jleSceneClient.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jleSceneNetworked.h" #include "jleNetworkEventOutQueue.h" diff --git a/engine/jleSceneServer.h b/engine/jleSceneServer.h index b6336897..0dfaafdd 100644 --- a/engine/jleSceneServer.h +++ b/engine/jleSceneServer.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jleSceneNetworked.h" #include "jleNetworkEventOutQueue.h" diff --git a/engine/jleScopeProfileLog.h b/engine/jleScopeProfileLog.h index c2a2707f..54c0367c 100644 --- a/engine/jleScopeProfileLog.h +++ b/engine/jleScopeProfileLog.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jleSTL/jleStringView.h" #include diff --git a/engine/jleSerializedResource.h b/engine/jleSerializedResource.h index 6e7a5aa7..2a7645a4 100644 --- a/engine/jleSerializedResource.h +++ b/engine/jleSerializedResource.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jleResourceInterface.h" diff --git a/engine/jleShader.h b/engine/jleShader.h index 61f6a381..aaf8f7dc 100644 --- a/engine/jleShader.h +++ b/engine/jleShader.h @@ -16,7 +16,7 @@ #ifndef JLE_SHADER_H #define JLE_SHADER_H -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jleResourceInterface.h" #include "jleTextureRules.h" diff --git a/engine/jleSkinnedMesh.cpp b/engine/jleSkinnedMesh.cpp index 50bca5c7..54538b9f 100644 --- a/engine/jleSkinnedMesh.cpp +++ b/engine/jleSkinnedMesh.cpp @@ -112,7 +112,7 @@ jleSkinnedMesh::loadAssimpSkinnedMesh(aiMesh *assimpMesh, } else { boneId = out_boneMapping[boneName].index; } - assert(boneId != -1); + jleAssert(boneId != -1); auto weights = assimpMesh->mBones[boneIndex]->mWeights; const int numWeights = assimpMesh->mBones[boneIndex]->mNumWeights; @@ -120,7 +120,7 @@ jleSkinnedMesh::loadAssimpSkinnedMesh(aiMesh *assimpMesh, for (int weightIndex = 0; weightIndex < numWeights; weightIndex++) { int vertexId = weights[weightIndex].mVertexId; float weight = weights[weightIndex].mWeight; - assert(vertexId <= out_positions.size()); + jleAssert(vertexId <= out_positions.size()); const auto setVertexBoneData = [&](int vertexId, int boneId, float weight) { for (int i = 0; i < 4; i++) { diff --git a/engine/jleSkinnedMesh.h b/engine/jleSkinnedMesh.h index 5115c8d3..2323c63a 100644 --- a/engine/jleSkinnedMesh.h +++ b/engine/jleSkinnedMesh.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jleMesh.h" diff --git a/engine/jleSkybox.h b/engine/jleSkybox.h index deaad34a..2c8c0137 100644 --- a/engine/jleSkybox.h +++ b/engine/jleSkybox.h @@ -16,7 +16,7 @@ #ifndef JLE_SKYBOX_H #define JLE_SKYBOX_H -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jleSerializedResource.h" #include "jleTypeReflectionUtils.h" diff --git a/engine/jleTexture.h b/engine/jleTexture.h index 8fb9ca46..b80083ce 100644 --- a/engine/jleTexture.h +++ b/engine/jleTexture.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jlePath.h" #include "jleSerializedResource.h" diff --git a/engine/jleTextureRefOrRGBA.h b/engine/jleTextureRefOrRGBA.h index 14c13a94..4c30d761 100644 --- a/engine/jleTextureRefOrRGBA.h +++ b/engine/jleTextureRefOrRGBA.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jleCompileHelper.h" #include "jleResourceRef.h" diff --git a/engine/jleTransform.cpp b/engine/jleTransform.cpp index d19f7763..64a3498d 100644 --- a/engine/jleTransform.cpp +++ b/engine/jleTransform.cpp @@ -30,7 +30,7 @@ struct jleTransformPropagateEvent : public jleServerToClientEvent { execute() override { auto &scene = getSceneClient(); - if(auto object = scene.getObjectFromNetId(netId)) { + if (auto object = scene.getObjectFromNetId(netId)) { object->getTransform().setLocalMatrix(localMatrix); } } @@ -187,6 +187,8 @@ jleTransform::propagateMatrixChildren() void jleTransform::setLocalMatrix(const glm::mat4 &matrix) { + jleAssertOnce(!glm::isnan(matrix[0][0]) && "Matrix should not contain NaN values"); + _local = matrix; propagateMatrix(); } @@ -222,9 +224,10 @@ jleTransform::removeRotations() } void -jleTransform::rotateTowardsPoint(const glm::vec3& position, const glm::vec3& up) +jleTransform::rotateTowardsPoint(const glm::vec3 &position, const glm::vec3 &up) { - glm::mat4 viewMatrix = glm::lookAt(getLocalPosition(), position, up); + const auto &pos = getLocalPosition(); + glm::mat4 viewMatrix = glm::lookAt(pos, position, up); glm::mat4 rotationMatrix = glm::inverse(viewMatrix); setLocalMatrix(rotationMatrix); } diff --git a/engine/jleTransform.h b/engine/jleTransform.h index c9636de9..b846a684 100644 --- a/engine/jleTransform.h +++ b/engine/jleTransform.h @@ -16,7 +16,7 @@ #ifndef JLE_TRANSFORM #define JLE_TRANSFORM -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jleCompileHelper.h" #include "jleExternalSerialization.h" diff --git a/engine/jleTypeReflectionUtils.h b/engine/jleTypeReflectionUtils.h index ca803580..700644af 100644 --- a/engine/jleTypeReflectionUtils.h +++ b/engine/jleTypeReflectionUtils.h @@ -16,7 +16,7 @@ #ifndef JLE_TYPE_REFLECTION_UTILS #define JLE_TYPE_REFLECTION_UTILS -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jlePath.h" #include "jleResource.h" diff --git a/engine/jleWindow.h b/engine/jleWindow.h index 601ac538..5f23e674 100644 --- a/engine/jleWindow.h +++ b/engine/jleWindow.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jleWindowSettings.h" #include "jleIncludeGL.h" diff --git a/engine/jleWindowSettings.h b/engine/jleWindowSettings.h index 981e96ac..b369cda3 100644 --- a/engine/jleWindowSettings.h +++ b/engine/jleWindowSettings.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include "jleCompileHelper.h" #include "jlePath.h" diff --git a/engine/precompile.h b/engine/precompile.h index 3fe13c4f..a1cbfbbf 100644 --- a/engine/precompile.h +++ b/engine/precompile.h @@ -15,7 +15,7 @@ #pragma once -#include "jleBuildConfig.h" +#include "jleCommon.h" #include #include