mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-21 01:49:44 +00:00
feat: entity rotation interpolation
This commit is contained in:
parent
e24bae86eb
commit
9846ad289a
9 changed files with 82 additions and 15 deletions
|
|
@ -403,6 +403,9 @@ void Entities::update(float delta) {
|
|||
if (skeleton.interpolation.isEnabled()) {
|
||||
skeleton.interpolation.updateTimer(delta);
|
||||
}
|
||||
if (skeleton.rotationInterpolation.isEnabled()) {
|
||||
skeleton.rotationInterpolation.updateTimer(delta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,13 +20,20 @@ void Entity::setInterpolatedPosition(const glm::vec3& position) {
|
|||
|
||||
glm::vec3 Entity::getInterpolatedPosition() const {
|
||||
if (auto skeleton = getSkeleton()) {
|
||||
if (skeleton->interpolation.isEnabled()) {
|
||||
return skeleton->interpolation.getCurrent();
|
||||
const auto& interpolation = skeleton->interpolation;
|
||||
if (interpolation.isEnabled() && interpolation.isRefreshed()) {
|
||||
return interpolation.getCurrent();
|
||||
}
|
||||
}
|
||||
return getTransform().pos;
|
||||
}
|
||||
|
||||
void Entity::setInterpolatedRotation(const glm::quat& rotation) {
|
||||
if (auto skeleton = getSkeleton()) {
|
||||
skeleton->rotationInterpolation.refresh(rotation);
|
||||
}
|
||||
}
|
||||
|
||||
void Entity::destroy() {
|
||||
if (isValid()) {
|
||||
entities.despawn(id);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include <string>
|
||||
#include <entt/fwd.hpp>
|
||||
#include <glm/vec3.hpp>
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
|
||||
class Entities;
|
||||
struct EntityDef;
|
||||
|
|
@ -72,6 +73,8 @@ public:
|
|||
|
||||
glm::vec3 getInterpolatedPosition() const;
|
||||
|
||||
void setInterpolatedRotation(const glm::quat& rotation);
|
||||
|
||||
entt::entity getHandler() const {
|
||||
return entity;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#include "maths/util.hpp"
|
||||
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
|
||||
static debug::Logger logger("entity-transform");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue