PRetty good collision detection but there is still some small bug I don't know about

This commit is contained in:
2023-02-24 23:37:27 -08:00
parent d5fdc29cb4
commit b32c7e8af6
15 changed files with 124 additions and 43 deletions

View File

@ -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() {