mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-21 09:59: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
|
|
@ -201,7 +201,9 @@ static int l_is_interpolated(lua::State* L) {
|
|||
|
||||
static int l_set_interpolated(lua::State* L) {
|
||||
if (auto skeleton = get_skeleton(L)) {
|
||||
skeleton->interpolation.setEnabled(lua::toboolean(L, 2));
|
||||
bool enabled = lua::toboolean(L, 2);
|
||||
skeleton->interpolation.setEnabled(enabled);
|
||||
skeleton->rotationInterpolation.setEnabled(enabled);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,9 +61,11 @@ static int l_get_rot(lua::State* L) {
|
|||
|
||||
static int l_set_rot(lua::State* L) {
|
||||
if (auto entity = get_entity(L, 1)) {
|
||||
auto matrix = lua::tomat4(L, 2);
|
||||
glm::mat3 matrix(lua::tomat4(L, 2));
|
||||
check_valid(matrix);
|
||||
entity->getTransform().setRot(matrix);
|
||||
auto rotation = glm::normalize(glm::quat_cast(matrix));
|
||||
entity->getTransform().setRot(glm::mat3_cast(rotation));
|
||||
entity->setInterpolatedRotation(rotation);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue