PRetty good collision detection but there is still some small bug I don't know about
This commit is contained in:
@ -40,10 +40,13 @@ void Transform::updateLocalTransformFromLocalValues() {
|
||||
}
|
||||
|
||||
void Transform::updateWorldTransformFromLocalTransform() {
|
||||
glm::mat4 newWorld(1.0f);
|
||||
auto parent = this->getParent();
|
||||
if(parent != nullptr) newWorld = parent->getWorldTransform();
|
||||
this->transformWorld = newWorld * transformLocal;
|
||||
if(parent != nullptr) {
|
||||
auto newWorld = parent->getWorldTransform();
|
||||
this->transformWorld = newWorld * transformLocal;
|
||||
} else {
|
||||
this->transformWorld = transformLocal;
|
||||
}
|
||||
}
|
||||
|
||||
void Transform::updateLocalTransformFromWorldTransform() {
|
||||
@ -128,7 +131,7 @@ void Transform::setLocalTransform(glm::mat4 transform) {
|
||||
}
|
||||
|
||||
glm::vec3 Transform::getWorldPosition() {
|
||||
return glm::vec3(this->transformWorld[3]);
|
||||
return glm::inverse(this->transformWorld)[3];
|
||||
}
|
||||
|
||||
glm::mat4 Transform::getWorldTransform() {
|
||||
|
Reference in New Issue
Block a user