/* orxonox - the future of 3D-vertical-scrollers Copyright (C) 2004 orx This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. ### File Specific: main-programmer: Patrick Boenzli co-programmer: ... */ #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_COLLISION_REACTION #include "collision.h" #include "collision_event.h" #include "physics_interface.h" #include "world_entity.h" #include "cr_physics_ground_walk.h" #include using namespace std; /** * standard constructor */ CRPhysicsGroundWalk::CRPhysicsGroundWalk () : CollisionReaction() { this->setClassID(CL_CR_PHYSICS_GROUND_WALK, "CRPhysicsGroundWalk"); } /** * standard deconstructor */ CRPhysicsGroundWalk::~CRPhysicsGroundWalk () { } /** * caluculates and applys the reaction to a specific collision * @param collision the collision */ void CRPhysicsGroundWalk::reactToCollision(Collision* collision) { // CollisionEvent* ce = collision->getCollisionEvents().front(); // Vector normal = ce->getGroundNormal(); // normal.normalize(); // // Vector position = ce->getCollisionPosition(); if( this->lastPosition != collision->getEntityB()->getAbsCoor()) { // put it back PRINTF(0)("putting it back to: \n"); this->lastPosition.debug(); collision->getEntityB()->setVelocity(Vector()); // collision->getEntityB()->setAbsCoorSoft(this->lastPosition, 0.1); collision->getEntityB()->setAbsCoor(this->lastPosition); } } /** * use this to do some collision offline calculations, only called for bContinuousPoll == true */ void CRPhysicsGroundWalk::update(WorldEntity* owner) { this->lastPosition = owner->getAbsCoor(); this->lastDirection = owner->getAbsDir(); PRINTF(0)("no collision: saving location: \n"); this->lastPosition.debug(); }