Restore the original floor behavior.

This commit is contained in:
Andrzej Kapolka 2013-05-23 10:32:12 -07:00
parent 1878ac8610
commit 34b526f15c
3 changed files with 19 additions and 4 deletions

View file

@ -58,10 +58,16 @@ void Environment::renderAtmospheres(Camera& camera) {
}
glm::vec3 Environment::getGravity (const glm::vec3& position) {
// the "original gravity"
glm::vec3 gravity;
if (position.x > 0.0f && position.x < 10.0f && position.y > 0.0f &&
position.y < 3.0f && position.z > 0.0f && position.z < 10.0f) {
gravity = glm::vec3(0.0f, -1.0f, 0.0f);
}
// get the lock for the duration of the call
QMutexLocker locker(&_mutex);
glm::vec3 gravity;
foreach (const ServerData& serverData, _data) {
foreach (const EnvironmentData& environmentData, serverData) {
glm::vec3 vector = environmentData.getAtmosphereCenter() - position;
@ -94,11 +100,18 @@ const EnvironmentData Environment::getClosestData(const glm::vec3& position) {
bool Environment::findCapsulePenetration(const glm::vec3& start, const glm::vec3& end,
float radius, glm::vec3& penetration) {
// collide with the "floor"
bool found = false;
penetration = glm::vec3(0.0f, 0.0f, 0.0f);
float floorDist = qMin(start.y, end.y) - radius;
if (floorDist < 0.0f) {
penetration.y = -floorDist;
found = true;
}
// get the lock for the duration of the call
QMutexLocker locker(&_mutex);
bool found = false;
penetration = glm::vec3(0.0f, 0.0f, 0.0f);
foreach (const ServerData& serverData, _data) {
foreach (const EnvironmentData& environmentData, serverData) {
glm::vec3 vector = computeVectorFromPointToSegment(environmentData.getAtmosphereCenter(), start, end);

View file

@ -14,7 +14,7 @@
// GameEngine.cpp
EnvironmentData::EnvironmentData(int id) :
_id(id),
_gravity(1.0f),
_gravity(0.0f),
_atmosphereCenter(0, -1000, 0),
_atmosphereInnerRadius(1000),
_atmosphereOuterRadius(1025),

View file

@ -559,10 +559,12 @@ int main(int argc, const char * argv[]) {
// for now, initialize the environments with fixed values
environmentData[1].setID(1);
environmentData[1].setGravity(1.0f);
environmentData[1].setAtmosphereCenter(glm::vec3(0.5, 0.5, (0.25 - 0.06125)) * (float)TREE_SCALE);
environmentData[1].setAtmosphereInnerRadius(0.030625f * TREE_SCALE);
environmentData[1].setAtmosphereOuterRadius(0.030625f * TREE_SCALE * 1.025f);
environmentData[2].setID(2);
environmentData[2].setGravity(1.0f);
environmentData[2].setAtmosphereCenter(glm::vec3(0.5f, 0.5f, 0.5f) * (float)TREE_SCALE);
environmentData[2].setAtmosphereInnerRadius(0.1875f * TREE_SCALE);
environmentData[2].setAtmosphereOuterRadius(0.1875f * TREE_SCALE * 1.025f);