Fixed weird fmod bug I guess

This commit is contained in:
2023-04-05 22:13:24 -07:00
parent b5707ed888
commit 54d21397e1
8 changed files with 16 additions and 12 deletions

View File

@ -18,7 +18,6 @@ RenderPipeline::RenderPipeline(RenderManager *renderManager) {
} }
void RenderPipeline::init() { void RenderPipeline::init() {
this->renderManager->getShaderManager()->lockShader<SimpleTexturedShader>();
} }
void RenderPipeline::render() { void RenderPipeline::render() {
@ -160,7 +159,7 @@ void RenderPipeline::renderSceneCamera(Scene *scene, Camera *camera) {
&lineMesh, &lineMesh,
&lineIndex, &lineIndex,
camera, camera,
this->renderManager->getShaderManager()->getShader<SimpleTexturedShader>(this->simpleTexturedShaderLock) this->renderManager->simpleTexturedShader
); );
shaderPassItems.push_back(item); shaderPassItems.push_back(item);
itDebugLine = scene->debugLines.erase(itDebugLine); itDebugLine = scene->debugLines.erase(itDebugLine);
@ -262,5 +261,4 @@ void RenderPipeline::renderSceneCamera(Scene *scene, Camera *camera) {
} }
RenderPipeline::~RenderPipeline() { RenderPipeline::~RenderPipeline() {
this->renderManager->getShaderManager()->releaseShader<SimpleTexturedShader>(this->simpleTexturedShaderLock);
} }

View File

@ -17,7 +17,6 @@ namespace Dawn {
class RenderPipeline { class RenderPipeline {
private: private:
int_fast16_t renderId = -1; int_fast16_t renderId = -1;
shaderlock_t simpleTexturedShaderLock;
public: public:
RenderManager *renderManager; RenderManager *renderManager;

View File

@ -8,6 +8,7 @@
using namespace Dawn; using namespace Dawn;
ShaderManager::ShaderManager() { ShaderManager::ShaderManager() {
this->nextId = 0;
this->nextLock = 0; this->nextLock = 0;
} }

View File

@ -59,7 +59,7 @@ namespace Dawn {
shaderId = shader->shaderId; shaderId = shader->shaderId;
} }
shaderlock_t lock = this->nextId++; shaderlock_t lock = this->nextLock++;
this->shaderLocks[lock] = shaderId; this->shaderLocks[lock] = shaderId;
this->shaderLocksByShader[shaderId].push_back(lock); this->shaderLocksByShader[shaderId].push_back(lock);
return lock; return lock;

View File

@ -20,6 +20,11 @@ struct ShaderPassItem SceneDebugLine::createShaderItem(
Camera *camera, Camera *camera,
SimpleTexturedShader *shader SimpleTexturedShader *shader
) { ) {
assertNotNull(mesh);
assertNotNull(lineIndex);
assertNotNull(camera);
assertNotNull(shader);
struct ShaderPassItem item; struct ShaderPassItem item;
item.priority = this->priority; item.priority = this->priority;

View File

@ -44,8 +44,7 @@ namespace Dawn {
} }
static inline float_t randRange(float_t min, float_t max) { static inline float_t randRange(float_t min, float_t max) {
float_t n = randomGenerate<float_t>(); return mathMod(randomGenerate<float_t>(), (max - min)) + min;
return mathMod(n, (max - min)) + min;
} }
static inline glm::vec2 randRange(glm::vec2 min, glm::vec2 max) { static inline glm::vec2 randRange(glm::vec2 min, glm::vec2 max) {

View File

@ -19,8 +19,9 @@ RenderManager::RenderManager(DawnGame *game) :
void RenderManager::init() { void RenderManager::init() {
// Lock the common shaders // Lock the common shaders
this->lockSimpleTextured = this->shaderManager.lockShader<SimpleTexturedShader>(); this->lockSimpleTextured = this->shaderManager.lockShader<SimpleTexturedShader>();
this->lockUIShaderProgram = this->shaderManager.lockShader<SimpleTexturedShader>();
this->simpleTexturedShader = this->shaderManager.getShader<SimpleTexturedShader>(this->lockSimpleTextured); this->simpleTexturedShader = this->shaderManager.getShader<SimpleTexturedShader>(this->lockSimpleTextured);
this->lockUIShaderProgram = this->shaderManager.lockShader<SimpleTexturedShader>();
this->uiShader = this->shaderManager.getShader<SimpleTexturedShader>(this->lockUIShaderProgram); this->uiShader = this->shaderManager.getShader<SimpleTexturedShader>(this->lockUIShaderProgram);
this->renderPipeline.init(); this->renderPipeline.init();

View File

@ -50,8 +50,8 @@ void EntityAIWalk::updateWander(float_t delta) {
wanderTimeToNextDecision = randRange(wanderTimeRandomRange.x, wanderTimeRandomRange.y); wanderTimeToNextDecision = randRange(wanderTimeRandomRange.x, wanderTimeRandomRange.y);
// Do we want to move? // Do we want to move?
float_t rr = randRange(0.0f, 3.0f); float_t n = randRange(0.0f, 1.0f);
if(rr < wanderDoNotMoveChance) { if(n < wanderDoNotMoveChance) {
wanderDestination = physics3Dto2D(transform->getLocalPosition()); wanderDestination = physics3Dto2D(transform->getLocalPosition());
return; return;
} }
@ -81,10 +81,11 @@ void EntityAIWalk::updateWander(float_t delta) {
// Stop moving if we're close enough // Stop moving if we're close enough
if(glm::length(diff) < 0.1f) { 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) { void EntityAIWalk::updateFollowTarget(float_t delta) {