From 54d21397e110a94ba0e9f160d8c54b84167ca16f Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Wed, 5 Apr 2023 22:13:24 -0700 Subject: [PATCH] Fixed weird fmod bug I guess --- src/dawn/display/RenderPipeline.cpp | 4 +--- src/dawn/display/RenderPipeline.hpp | 1 - src/dawn/display/shader/ShaderManager.cpp | 1 + src/dawn/display/shader/ShaderManager.hpp | 2 +- src/dawn/scene/debug/SceneDebugLine.cpp | 5 +++++ src/dawn/util/random.hpp | 3 +-- src/dawnopengl/display/RenderManager.cpp | 3 ++- src/dawnrose/scene/components/entity/EntityAIWalk.cpp | 9 +++++---- 8 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/dawn/display/RenderPipeline.cpp b/src/dawn/display/RenderPipeline.cpp index 9c0c3b1e..32a3b6ef 100644 --- a/src/dawn/display/RenderPipeline.cpp +++ b/src/dawn/display/RenderPipeline.cpp @@ -18,7 +18,6 @@ RenderPipeline::RenderPipeline(RenderManager *renderManager) { } void RenderPipeline::init() { - this->renderManager->getShaderManager()->lockShader(); } void RenderPipeline::render() { @@ -160,7 +159,7 @@ void RenderPipeline::renderSceneCamera(Scene *scene, Camera *camera) { &lineMesh, &lineIndex, camera, - this->renderManager->getShaderManager()->getShader(this->simpleTexturedShaderLock) + this->renderManager->simpleTexturedShader ); shaderPassItems.push_back(item); itDebugLine = scene->debugLines.erase(itDebugLine); @@ -262,5 +261,4 @@ void RenderPipeline::renderSceneCamera(Scene *scene, Camera *camera) { } RenderPipeline::~RenderPipeline() { - this->renderManager->getShaderManager()->releaseShader(this->simpleTexturedShaderLock); } \ No newline at end of file diff --git a/src/dawn/display/RenderPipeline.hpp b/src/dawn/display/RenderPipeline.hpp index a57d4acf..da1bcd64 100644 --- a/src/dawn/display/RenderPipeline.hpp +++ b/src/dawn/display/RenderPipeline.hpp @@ -17,7 +17,6 @@ namespace Dawn { class RenderPipeline { private: int_fast16_t renderId = -1; - shaderlock_t simpleTexturedShaderLock; public: RenderManager *renderManager; diff --git a/src/dawn/display/shader/ShaderManager.cpp b/src/dawn/display/shader/ShaderManager.cpp index 33f92a0b..527a4cf7 100644 --- a/src/dawn/display/shader/ShaderManager.cpp +++ b/src/dawn/display/shader/ShaderManager.cpp @@ -8,6 +8,7 @@ using namespace Dawn; ShaderManager::ShaderManager() { + this->nextId = 0; this->nextLock = 0; } diff --git a/src/dawn/display/shader/ShaderManager.hpp b/src/dawn/display/shader/ShaderManager.hpp index 042c466d..88d494a3 100644 --- a/src/dawn/display/shader/ShaderManager.hpp +++ b/src/dawn/display/shader/ShaderManager.hpp @@ -59,7 +59,7 @@ namespace Dawn { shaderId = shader->shaderId; } - shaderlock_t lock = this->nextId++; + shaderlock_t lock = this->nextLock++; this->shaderLocks[lock] = shaderId; this->shaderLocksByShader[shaderId].push_back(lock); return lock; diff --git a/src/dawn/scene/debug/SceneDebugLine.cpp b/src/dawn/scene/debug/SceneDebugLine.cpp index e6954cec..82c404fe 100644 --- a/src/dawn/scene/debug/SceneDebugLine.cpp +++ b/src/dawn/scene/debug/SceneDebugLine.cpp @@ -20,6 +20,11 @@ struct ShaderPassItem SceneDebugLine::createShaderItem( Camera *camera, SimpleTexturedShader *shader ) { + assertNotNull(mesh); + assertNotNull(lineIndex); + assertNotNull(camera); + assertNotNull(shader); + struct ShaderPassItem item; item.priority = this->priority; diff --git a/src/dawn/util/random.hpp b/src/dawn/util/random.hpp index 0d10da91..fc55f99b 100644 --- a/src/dawn/util/random.hpp +++ b/src/dawn/util/random.hpp @@ -44,8 +44,7 @@ namespace Dawn { } static inline float_t randRange(float_t min, float_t max) { - float_t n = randomGenerate(); - return mathMod(n, (max - min)) + min; + return mathMod(randomGenerate(), (max - min)) + min; } static inline glm::vec2 randRange(glm::vec2 min, glm::vec2 max) { diff --git a/src/dawnopengl/display/RenderManager.cpp b/src/dawnopengl/display/RenderManager.cpp index dbf4c45c..f004107a 100644 --- a/src/dawnopengl/display/RenderManager.cpp +++ b/src/dawnopengl/display/RenderManager.cpp @@ -19,8 +19,9 @@ RenderManager::RenderManager(DawnGame *game) : void RenderManager::init() { // Lock the common shaders this->lockSimpleTextured = this->shaderManager.lockShader(); - this->lockUIShaderProgram = this->shaderManager.lockShader(); this->simpleTexturedShader = this->shaderManager.getShader(this->lockSimpleTextured); + + this->lockUIShaderProgram = this->shaderManager.lockShader(); this->uiShader = this->shaderManager.getShader(this->lockUIShaderProgram); this->renderPipeline.init(); diff --git a/src/dawnrose/scene/components/entity/EntityAIWalk.cpp b/src/dawnrose/scene/components/entity/EntityAIWalk.cpp index b05cca38..3538ad45 100644 --- a/src/dawnrose/scene/components/entity/EntityAIWalk.cpp +++ b/src/dawnrose/scene/components/entity/EntityAIWalk.cpp @@ -50,8 +50,8 @@ void EntityAIWalk::updateWander(float_t delta) { wanderTimeToNextDecision = randRange(wanderTimeRandomRange.x, wanderTimeRandomRange.y); // Do we want to move? - float_t rr = randRange(0.0f, 3.0f); - if(rr < wanderDoNotMoveChance) { + float_t n = randRange(0.0f, 1.0f); + if(n < wanderDoNotMoveChance) { wanderDestination = physics3Dto2D(transform->getLocalPosition()); return; } @@ -81,9 +81,10 @@ void EntityAIWalk::updateWander(float_t delta) { // Stop moving if we're close enough if(glm::length(diff) < 0.1f) { - wanderTimeToNextDecision = 0; + entityMove->direction = glm::vec2(0, 0); + } else { + entityMove->direction = diff; } - entityMove->direction = diff; } void EntityAIWalk::updateFollowTarget(float_t delta) {