1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-22 02:12:45 +01:00

Remove getTimeAdjustedTransform

This commit is contained in:
Daniel Evans 2019-05-13 21:36:16 +01:00
parent 8af04b48cf
commit 77b405b7c5
5 changed files with 9 additions and 35 deletions

View File

@ -18,7 +18,7 @@ GameObject::~GameObject() {
}
void GameObject::setPosition(const glm::vec3& pos) {
_lastPosition = position = pos;
position = pos;
}
void GameObject::setRotation(const glm::quat& orientation) {
@ -36,16 +36,7 @@ void GameObject::setHeading(float heading) {
setRotation(quat);
}
glm::mat4 GameObject::getTimeAdjustedTransform(float alpha) const {
glm::mat4 t{1.0f};
t = glm::translate(t, glm::mix(_lastPosition, getPosition(), alpha));
t = t * glm::mat4_cast(glm::slerp(_lastRotation, getRotation(), alpha));
return t;
}
void GameObject::updateTransform(const glm::vec3& pos, const glm::quat& rot) {
_lastPosition = position;
_lastRotation = rotation;
position = pos;
rotation = rot;

View File

@ -23,8 +23,6 @@ class GameWorld;
* tracking used to make tunnels work.
*/
class GameObject {
glm::vec3 _lastPosition;
glm::quat _lastRotation;
GameObjectID objectID = 0;
BaseModelInfo* modelinfo_;
@ -62,12 +60,7 @@ public:
GameObject(GameWorld* engine, const glm::vec3& pos, const glm::quat& rot,
BaseModelInfo* modelinfo)
: _lastPosition(pos)
, _lastRotation(rot)
, modelinfo_(modelinfo)
, position(pos)
, rotation(rot)
, engine(engine) {
: modelinfo_(modelinfo), position(pos), rotation(rot), engine(engine) {
if (modelinfo_) {
modelinfo_->addReference();
}
@ -148,9 +141,6 @@ public:
const glm::vec3& getPosition() const {
return position;
}
const glm::vec3& getLastPosition() const {
return _lastPosition;
}
const glm::quat& getRotation() const {
return rotation;
@ -229,17 +219,6 @@ public:
virtual void tick(float dt) = 0;
/**
* @brief Function used to modify the last transform
* @param newPos
*/
void _updateLastTransform() {
_lastPosition = getPosition();
_lastRotation = getRotation();
}
glm::mat4 getTimeAdjustedTransform(float alpha) const;
enum ObjectLifetime {
/// lifetime has not been set
UnknownLifetime,

View File

@ -349,7 +349,12 @@ RenderList GameRenderer::createObjectRenderList(const GameWorld *world) {
if (blip.second.target > 0) {
auto object = world->getBlipTarget(blip.second);
if (object) {
model = object->getTimeAdjustedTransform(_renderAlpha);
auto& clump = object->getClump();
auto& atomic = object->getAtomic();
if (clump)
model = clump->getFrame()->getWorldTransform();
else if (atomic)
model = atomic->getFrame()->getWorldTransform();
}
} else {
model = translate(model, blip.second.coord);

View File

@ -605,7 +605,6 @@ void RWGame::tickObjects(float dt) const {
RW_PROFILE_SCOPEC("allObjects", MP_HOTPINK1);
RW_PROFILE_COUNTER_SET("tickObjects/allObjects", world->allObjects.size());
for (auto &object : world->allObjects) {
object->_updateLastTransform();
object->tick(dt);
}
}

View File

@ -439,7 +439,7 @@ const ViewCamera& IngameState::getCamera(float alpha) {
bool lookright = held(GameInputState::LookRight);
btCollisionObject* physTarget = player->getCharacter()->physObject.get();
auto targetTransform = target->getTimeAdjustedTransform(alpha);
auto targetTransform = target->getClump()->getFrame()->getWorldTransform();
glm::vec3 targetPosition(targetTransform[3]);
glm::vec3 lookTargetPosition(targetPosition);