Ignored first two seconds of triggering to give switches time to position themselves.

This commit is contained in:
Steffen Fündgens 2015-03-02 14:28:19 +01:00
parent 986ed9ea8e
commit 9555786a09
3 changed files with 10 additions and 8 deletions

View File

@ -56,8 +56,8 @@ void Level::render(ACGL::OpenGL::SharedShaderProgram shader, bool lightingPass,
} }
} }
void Level::update(float runTime, glm::vec2 mouseDelta, bool wPressed, bool aPressed, bool sPressed, bool dPressed,bool kPressed, bool lPressed) { void Level::update(float runTimeSinceLastUpdate, float runTime, glm::vec2 mouseDelta, bool wPressed, bool aPressed, bool sPressed, bool dPressed,bool kPressed, bool lPressed) {
physics.takeUpdateStep(runTime); physics.takeUpdateStep(runTimeSinceLastUpdate);
// Ignore first two mouse updates, because they are incorrect // Ignore first two mouse updates, because they are incorrect
// DON'T try to move this functionallity elsewhere // DON'T try to move this functionallity elsewhere
@ -102,9 +102,11 @@ void Level::update(float runTime, glm::vec2 mouseDelta, bool wPressed, bool aPre
skydome->setPosition(glm::vec3(cameraCenter->getPosition().x, skydome->setPosition(glm::vec3(cameraCenter->getPosition().x,
0.0f, cameraCenter->getPosition().z)); 0.0f, cameraCenter->getPosition().z));
for(unsigned int i = 0; i<triggers.size(); i++) { if (runTime > 2.0f) {
triggers.at(i).triggerUpdate(); for(unsigned int i = 0; i<triggers.size(); i++) {
triggers.at(i).triggerUpdate();
}
} }
} }

View File

@ -24,7 +24,7 @@ class Level {
Level(); Level();
~Level(); ~Level();
void load(); void load();
void update(float runTime, glm::vec2 mouseDelta,bool wPressed, bool aPressed,bool sPressed, bool dPressed, bool kPressed, bool lPressed); void update(float runTimeSinceLastUpdate, float runTime, glm::vec2 mouseDelta,bool wPressed, bool aPressed,bool sPressed, bool dPressed, bool kPressed, bool lPressed);
void render(ACGL::OpenGL::SharedShaderProgram shader, bool lightingPass, void render(ACGL::OpenGL::SharedShaderProgram shader, bool lightingPass,
glm::mat4* viewProjectionMatrix, std::vector<glm::mat4>* shadowVPs=0); glm::mat4* viewProjectionMatrix, std::vector<glm::mat4>* shadowVPs=0);
glm::vec3 getAmbientLight(); glm::vec3 getAmbientLight();

View File

@ -161,13 +161,13 @@ int main( int argc, char *argv[] )
double xpos, ypos; double xpos, ypos;
glfwGetCursorPos(window, &xpos, &ypos); glfwGetCursorPos(window, &xpos, &ypos);
glfwSetCursorPos(window, app.getGraphics()->getWindowSize().x/2, app.getGraphics()->getWindowSize().y/2); glfwSetCursorPos(window, app.getGraphics()->getWindowSize().x/2, app.getGraphics()->getWindowSize().y/2);
app.getLevel()->update(now - lastUpdate, app.getLevel()->update(now - lastUpdate, now,
glm::vec2((float)ypos-app.getGraphics()->getWindowSize().y/2, glm::vec2((float)ypos-app.getGraphics()->getWindowSize().y/2,
(float)xpos-app.getGraphics()->getWindowSize().x/2), (float)xpos-app.getGraphics()->getWindowSize().x/2),
stateW == GLFW_PRESS,stateA == GLFW_PRESS,stateS == GLFW_PRESS,stateD == GLFW_PRESS,stateK == GLFW_PRESS,stateL == GLFW_PRESS); stateW == GLFW_PRESS,stateA == GLFW_PRESS,stateS == GLFW_PRESS,stateD == GLFW_PRESS,stateK == GLFW_PRESS,stateL == GLFW_PRESS);
} }
else { else {
app.getLevel()->update(now - lastUpdate, glm::vec2(0.0f, 0.0f), false, false, false, false,false,false); app.getLevel()->update(now - lastUpdate, now, glm::vec2(0.0f, 0.0f), false, false, false, false,false,false);
if (app.isLocked()) { if (app.isLocked()) {
app.ignoredOneMouseUpdate(); app.ignoredOneMouseUpdate();
} }