mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 14:03:55 +02:00
Merge pull request #404 from ey6es/master
Restore the original floor behavior so we don't sink into the ground.
This commit is contained in:
commit
4e119419c3
3 changed files with 22 additions and 4 deletions
|
@ -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,13 +100,23 @@ 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) {
|
||||
if (environmentData.getGravity() == 0.0f) {
|
||||
continue; // don't bother colliding with gravity-less environments
|
||||
}
|
||||
glm::vec3 vector = computeVectorFromPointToSegment(environmentData.getAtmosphereCenter(), start, end);
|
||||
float vectorLength = glm::length(vector);
|
||||
float distance = vectorLength - environmentData.getAtmosphereInnerRadius() - radius;
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue