Browse Source

Improve 3D transform struct

master
C. J. Howard 1 year ago
parent
commit
3ce188c876
28 changed files with 277 additions and 264 deletions
  1. +1
    -3
      src/engine/animation/pose.cpp
  2. +1
    -1
      src/engine/animation/pose.hpp
  3. +1
    -3
      src/engine/math/math.hpp
  4. +4
    -0
      src/engine/math/matrix.hpp
  5. +7
    -0
      src/engine/math/quaternion.hpp
  6. +0
    -103
      src/engine/math/transform-functions.hpp
  7. +0
    -63
      src/engine/math/transform-operators.hpp
  8. +0
    -59
      src/engine/math/transform-type.hpp
  9. +235
    -0
      src/engine/math/transform.hpp
  10. +3
    -3
      src/engine/physics/kinematics/rigid-body.hpp
  11. +0
    -1
      src/engine/render/context.hpp
  12. +1
    -1
      src/engine/render/passes/sky-pass.cpp
  13. +4
    -4
      src/engine/scene/billboard.cpp
  14. +2
    -2
      src/engine/scene/object.hpp
  15. +1
    -1
      src/engine/scene/static-mesh.cpp
  16. +1
    -1
      src/engine/scene/text.cpp
  17. +1
    -2
      src/game/ant/ant-morphogenesis.cpp
  18. +1
    -1
      src/game/ant/ant-swarm.cpp
  19. +2
    -2
      src/game/commands/commands.cpp
  20. +1
    -1
      src/game/commands/commands.hpp
  21. +1
    -1
      src/game/components/transform-component.hpp
  22. +1
    -1
      src/game/loaders/entity-archetype-loader.cpp
  23. +2
    -2
      src/game/spawn.cpp
  24. +4
    -2
      src/game/states/nest-selection-state.cpp
  25. +2
    -2
      src/game/states/nuptial-flight-state.cpp
  26. +0
    -1
      src/game/systems/collision-system.cpp
  27. +1
    -3
      src/game/systems/constraint-system.cpp
  28. +0
    -1
      src/game/systems/physics-system.cpp

+ 1
- 3
src/engine/animation/pose.cpp View File

@ -18,8 +18,6 @@
*/
#include <engine/animation/pose.hpp>
#include <engine/math/transform-operators.hpp>
#include <engine/math/transform-functions.hpp>
void concatenate(const pose& bone_space, pose& skeleton_space)
{
@ -52,6 +50,6 @@ void matrix_palette(const pose& inverse_bind_pose, const pose& pose, float4x4* p
for (auto&& [bone, transform]: pose)
{
auto index = ::bone_index(bone);
palette[index] = math::matrix_cast(inverse_bind_pose.at(bone) * transform);
palette[index] = (inverse_bind_pose.at(bone) * transform).matrix();
}
}

+ 1
- 1
src/engine/animation/pose.hpp View File

@ -21,7 +21,7 @@
#define ANTKEEPER_ANIMATION_POSE_HPP
#include <engine/animation/bone.hpp>
#include <engine/math/transform-type.hpp>
#include <engine/math/transform.hpp>
#include <engine/utility/fundamental-types.hpp>
#include <map>

+ 1
- 3
src/engine/math/math.hpp View File

@ -28,9 +28,7 @@ namespace math {}
#include <engine/math/quaternion.hpp>
#include <engine/math/se3.hpp>
#include <engine/math/transform-type.hpp>
#include <engine/math/transform-functions.hpp>
#include <engine/math/transform-operators.hpp>
#include <engine/math/transform.hpp>
#include <engine/math/angles.hpp>
#include <engine/math/numbers.hpp>

+ 4
- 0
src/engine/math/matrix.hpp View File

@ -91,9 +91,13 @@ struct matrix
[[nodiscard]] inline constexpr matrix<T, P, O> size_cast(std::index_sequence<I...>) const noexcept
{
if constexpr (O == M)
{
return {((I < N) ? columns[I] : matrix<T, P, O>::identity()[I]) ...};
}
else
{
return {((I < N) ? vector<T, O>(columns[I]) : matrix<T, P, O>::identity()[I]) ...};
}
}
/**

+ 7
- 0
src/engine/math/quaternion.hpp View File

@ -151,6 +151,7 @@ struct quaternion
*
* @return Rotation matrix.
*/
/// @{
[[nodiscard]] constexpr explicit operator matrix_type() const noexcept
{
const T xx = x() * x();
@ -171,6 +172,12 @@ struct quaternion
};
}
[[nodiscard]] inline constexpr matrix_type matrix() const noexcept
{
return matrix_type(*this);
}
/// @}
/**
* Casts the quaternion to a 4-element vector, with the real part as the first element and the imaginary part as the following three elements.
*

+ 0
- 103
src/engine/math/transform-functions.hpp View File

@ -1,103 +0,0 @@
/*
* Copyright (C) 2023 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_MATH_TRANSFORM_FUNCTIONS_HPP
#define ANTKEEPER_MATH_TRANSFORM_FUNCTIONS_HPP
#include <engine/math/transform-type.hpp>
#include <engine/math/quaternion.hpp>
namespace math {
/**
* Calculates the inverse of a transform.
*
* @param t Transform of which to take the inverse.
*/
template <class T>
[[nodiscard]] transform<T> inverse(const transform<T>& t);
/**
* Converts a transform to a transformation matrix.
*
* @param t Transform.
* @return Matrix representing the transformation described by `t`.
*/
template <class T>
[[nodiscard]] matrix<T, 4, 4> matrix_cast(const transform<T>& t);
/**
* Multiplies two transforms.
*
* @param x First transform.
* @param y Second transform.
* @return Product of the two transforms.
*/
template <class T>
[[nodiscard]] transform<T> mul(const transform<T>& x, const transform<T>& y);
/**
* Multiplies a vector by a transform.
*
* @param t Transform.
* @param v Vector.
* @return Product of the transform and vector.
*/
template <class T>
[[nodiscard]] vector<T, 3> mul(const transform<T>& t, const vector<T, 3>& v);
template <class T>
transform<T> inverse(const transform<T>& t)
{
transform<T> inverse_t;
inverse_t.scale = {T(1) / t.scale.x(), T(1) / t.scale.y(), T(1) / t.scale.z()};
inverse_t.rotation = conjugate(t.rotation);
inverse_t.translation = negate(mul(inverse_t.rotation, t.translation));
return inverse_t;
}
template <class T>
matrix<T, 4, 4> matrix_cast(const transform<T>& t)
{
matrix<T, 4, 4> transformation = matrix<T, 4, 4>(matrix<T, 3, 3>(t.rotation));
transformation[3] = {t.translation[0], t.translation[1], t.translation[2], T(1)};
return scale(transformation, t.scale);
}
template <class T>
transform<T> mul(const transform<T>& x, const transform<T>& y)
{
return
{
mul(x, y.translation),
normalize(mul(x.rotation, y.rotation)),
mul(x.scale, y.scale)
};
}
template <class T>
vector<T, 3> mul(const transform<T>& t, const vector<T, 3>& v)
{
return add(t.translation, (mul(t.rotation, mul(v, t.scale))));
}
} // namespace math
#endif // ANTKEEPER_MATH_TRANSFORM_FUNCTIONS_HPP

+ 0
- 63
src/engine/math/transform-operators.hpp View File

@ -1,63 +0,0 @@
/*
* Copyright (C) 2023 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_MATH_TRANSFORM_OPERATORS_HPP
#define ANTKEEPER_MATH_TRANSFORM_OPERATORS_HPP
#include <engine/math/transform-type.hpp>
#include <engine/math/transform-functions.hpp>
/// @copydoc math::mul(const math::transform<T>&, const math::transform<T>&)
template <class T>
[[nodiscard]] math::transform<T> operator*(const math::transform<T>& x, const math::transform<T>& y);
/// @copydoc math::mul(const math::transform<T>&, const math::vector<T, 3>&)
template <class T>
[[nodiscard]] math::vector<T, 3> operator*(const math::transform<T>& t, const math::vector<T, 3>& v);
/**
* Multiplies two transforms and stores the result in the first transform.
*
* @param x First transform.
* @param y Second transform.
* @return Reference to the first transform.
*/
template <class T>
math::transform<T>& operator*=(math::transform<T>& x, const math::transform<T>& y);
template <class T>
inline math::transform<T> operator*(const math::transform<T>& x, const math::transform<T>& y)
{
return mul(x, y);
}
template <class T>
inline math::vector<T, 3> operator*(const math::transform<T>& t, const math::vector<T, 3>& v)
{
return mul(t, v);
}
template <class T>
inline math::transform<T>& operator*=(math::transform<T>& x, const math::vector<T, 3>& y)
{
return (x = x * y);
}
#endif // ANTKEEPER_MATH_TRANSFORM_OPERATORS_HPP

+ 0
- 59
src/engine/math/transform-type.hpp View File

@ -1,59 +0,0 @@
/*
* Copyright (C) 2023 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_MATH_TRANSFORM_TYPE_HPP
#define ANTKEEPER_MATH_TRANSFORM_TYPE_HPP
#include <engine/math/vector.hpp>
#include <engine/math/quaternion.hpp>
namespace math {
/**
* Represents 3D TRS transformation.
*
* @tparam T Scalar type.
*/
template <class T>
struct transform
{
/// Translation vector
vector<T, 3> translation;
/// Rotation quaternion
quaternion<T> rotation;
/// Scale vector
vector<T, 3> scale;
/// Identity transform.
static const transform identity;
};
template <class T>
const transform<T> transform<T>::identity =
{
vector<T, 3>::zero(),
quaternion<T>::identity(),
vector<T, 3>::one()
};
} // namespace math
#endif // ANTKEEPER_MATH_TRANSFORM_TYPE_HPP

+ 235
- 0
src/engine/math/transform.hpp View File

@ -0,0 +1,235 @@
/*
* Copyright (C) 2023 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_MATH_TRANSFORM_HPP
#define ANTKEEPER_MATH_TRANSFORM_HPP
#include <engine/math/vector.hpp>
#include <engine/math/quaternion.hpp>
#include <engine/math/matrix.hpp>
namespace math {
/**
* 3D transformation.
*
* Transformations are applied in the following order: scale, rotation, translation.
*
* @tparam T Scalar type.
*/
template <class T>
struct transform
{
/// Scalar type.
using scalar_type = T;
/// Vector type.
using vector_type = vector<T, 3>;
/// Quaternion type.
using quaternion_type = quaternion<T>;
/// Transformation matrix type.
using matrix_type = matrix<T, 4, 4>;
/// Translation vector.
vector_type translation;
/// Rotation quaternion.
quaternion_type rotation;
/// Scale vector.
vector_type scale;
/**
* Constructs a matrix representing the transformation.
*
* @return Transformation matrix.
*/
/// @{
[[nodiscard]] constexpr explicit operator matrix_type() const noexcept
{
matrix_type matrix = matrix_type(quaternion_type::matrix_type(rotation));
matrix[0][0] *= scale[0];
matrix[0][1] *= scale[0];
matrix[0][2] *= scale[0];
matrix[1][0] *= scale[1];
matrix[1][1] *= scale[1];
matrix[1][2] *= scale[1];
matrix[2][0] *= scale[2];
matrix[2][1] *= scale[2];
matrix[2][2] *= scale[2];
matrix[3][0] = translation[0];
matrix[3][1] = translation[1];
matrix[3][2] = translation[2];
return matrix;
}
[[nodiscard]] inline constexpr matrix_type matrix() const noexcept
{
return matrix_type(*this);
}
/// @}
/*
* Type-casts the transform scalars using `static_cast`.
*
* @tparam U Target scalar type.
*
* @return Type-casted transform.
*/
template <class U>
[[nodiscard]] inline constexpr explicit operator transform<U>() const noexcept
{
return {math::vector<U, 3>(translation), math::quaternion<U>(rotation), math::vector<U, 3>(scale)};
}
/// Returns an identity transform.
[[nodiscard]] static inline constexpr transform identity() noexcept
{
return {vector_type::zero(), quaternion_type::identity(), vector_type::one()};
}
};
/**
* Calculates the inverse of a transform.
*
* @param t Transform of which to take the inverse.
*/
template <class T>
[[nodiscard]] transform<T> inverse(const transform<T>& t) noexcept;
/**
* Combines two transforms.
*
* @param x First transform.
* @param y Second transform.
*
* @return Product of the two transforms.
*/
template <class T>
[[nodiscard]] transform<T> mul(const transform<T>& x, const transform<T>& y);
/**
* Transforms a vector by a transform.
*
* @param t Transform.
* @param v Vector.
*
* @return Transformed vector.
*/
template <class T>
[[nodiscard]] constexpr vector<T, 3> mul(const transform<T>& t, const vector<T, 3>& v) noexcept;
/**
* Transforms a vector by the inverse of a transform.
*
* @param v Vector.
* @param t Transform.
*
* @return Transformed vector.
*/
template <class T>
[[nodiscard]] constexpr vector<T, 3> mul(const vector<T, 3>& v, const transform<T>& t) noexcept;
template <class T>
transform<T> inverse(const transform<T>& t) noexcept
{
transform<T> inverse_t;
inverse_t.scale = T{1} / t.scale;
inverse_t.rotation = conjugate(t.rotation);
inverse_t.translation = -(inverse_t.rotation * t.translation);
return inverse_t;
}
template <class T>
transform<T> mul(const transform<T>& x, const transform<T>& y)
{
return
{
mul(x, y.translation),
normalize(x.rotation * y.rotation),
x.scale * y.scale
};
}
template <class T>
constexpr vector<T, 3> mul(const transform<T>& t, const vector<T, 3>& v) noexcept
{
return t.translation + t.rotation * (t.scale * v);
}
template <class T>
inline constexpr vector<T, 3> mul(const vector<T, 3>& v, const transform<T>& t) noexcept
{
return mul(inverse(t), v);
}
namespace operators {
/// @copydoc math::mul(const math::transform<T>&, const math::transform<T>&)
template <class T>
[[nodiscard]] inline math::transform<T> operator*(const math::transform<T>& x, const math::transform<T>& y)
{
return mul(x, y);
}
/// @copydoc math::mul(const math::transform<T>&, const math::vector<T, 3>&)
template <class T>
[[nodiscard]] inline constexpr math::vector<T, 3> operator*(const math::transform<T>& t, const math::vector<T, 3>& v) noexcept
{
return mul(t, v);
}
/// @copydoc math::mul(const math::vector<T, 3>&, const math::transform<T>&)
template <class T>
[[nodiscard]] inline constexpr math::vector<T, 3> operator*(const math::vector<T, 3>& v, const math::transform<T>& t) noexcept
{
return mul(v, t);
}
/**
* Combines two transforms and stores the result in the first transform.
*
* @param x First transform.
* @param y Second transform.
*
* @return Reference to the first transform.
*/
template <class T>
inline math::transform<T>& operator*=(math::transform<T>& x, const math::transform<T>& y)
{
return (x = x * y);
}
} // namespace operators
} // namespace math
// Bring transform operators into global namespace
using namespace math::operators;
#endif // ANTKEEPER_MATH_TRANSFORM_HPP

+ 3
- 3
src/engine/physics/kinematics/rigid-body.hpp View File

@ -23,7 +23,7 @@
#include <engine/math/vector.hpp>
#include <engine/math/quaternion.hpp>
#include <engine/physics/kinematics/collider.hpp>
#include <engine/math/transform-type.hpp>
#include <engine/math/transform.hpp>
#include <memory>
namespace physics {
@ -457,10 +457,10 @@ public:
private:
/// Transformation representing the current state of the rigid body.
math::transform<float> m_current_transform{math::transform<float>::identity};
math::transform<float> m_current_transform{math::transform<float>::identity()};
/// Transformation representing the previous state of the rigid body.
math::transform<float> m_previous_transform{math::transform<float>::identity};
math::transform<float> m_previous_transform{math::transform<float>::identity()};
/// Center of mass.
math::vector<float, 3> m_center_of_mass{math::vector<float, 3>::zero()};

+ 0
- 1
src/engine/render/context.hpp View File

@ -21,7 +21,6 @@
#define ANTKEEPER_RENDER_CONTEXT_HPP
#include <engine/utility/fundamental-types.hpp>
#include <engine/math/transform-operators.hpp>
#include <engine/render/operation.hpp>
#include <vector>

+ 1
- 1
src/engine/render/passes/sky-pass.cpp View File

@ -318,7 +318,7 @@ void sky_pass::render(render::context& ctx)
moon_transform.rotation = moon_rotation_tween.interpolate(ctx.alpha);
moon_transform.scale = {moon_radius, moon_radius, moon_radius};
model = math::matrix_cast(moon_transform);
model = moon_transform.matrix();
float3x3 normal_model = math::transpose(math::inverse(float3x3(model)));
rasterizer->use_program(*moon_shader_program);

+ 4
- 4
src/engine/scene/billboard.cpp View File

@ -97,7 +97,7 @@ void billboard::render(render::context& ctx) const
transform.rotation = math::normalize(math::look_rotation(ctx.camera->get_forward(), ctx.camera->get_up()) * transform.rotation);
m_render_op.transform = math::matrix_cast(transform);
m_render_op.transform = transform.matrix();
break;
}
@ -112,7 +112,7 @@ void billboard::render(render::context& ctx) const
const auto up = math::cross(look, right);
transform.rotation = math::normalize(math::look_rotation(look, up) * transform.rotation);
m_render_op.transform = math::matrix_cast(transform);
m_render_op.transform = transform.matrix();
break;
}
@ -140,7 +140,7 @@ void billboard::set_billboard_type(billboard_type type)
if (m_billboard_type == scene::billboard_type::flat)
{
m_render_op.transform = math::matrix_cast(get_transform());
m_render_op.transform = get_transform().matrix();
}
}
@ -150,7 +150,7 @@ void billboard::transformed()
if (m_billboard_type == scene::billboard_type::flat)
{
m_render_op.transform = math::matrix_cast(get_transform());
m_render_op.transform = get_transform().matrix();
}
}

+ 2
- 2
src/engine/scene/object.hpp View File

@ -23,7 +23,7 @@
#include <engine/geom/primitives/box.hpp>
#include <engine/math/vector.hpp>
#include <engine/math/quaternion.hpp>
#include <engine/math/transform-type.hpp>
#include <engine/math/transform.hpp>
#include <engine/render/context.hpp>
#include <atomic>
#include <cstdint>
@ -141,7 +141,7 @@ private:
*/
inline virtual void transformed() {}
transform_type m_transform{transform_type::identity};
transform_type m_transform{transform_type::identity()};
};
/**

+ 1
- 1
src/engine/scene/static-mesh.cpp View File

@ -104,7 +104,7 @@ void static_mesh::transformed()
{
update_bounds();
const float4x4 transform_matrix = math::matrix_cast(get_transform());
const float4x4 transform_matrix = get_transform().matrix();
for (auto& operation: m_operations)
{
operation.transform = transform_matrix;

+ 1
- 1
src/engine/scene/text.cpp View File

@ -137,7 +137,7 @@ void text::transformed()
m_world_bounds.extend(get_transform() * m_local_bounds.corner(i));
}
m_render_op.transform = math::matrix_cast(get_transform());
m_render_op.transform = get_transform().matrix();
}
void text::update_content()

+ 1
- 2
src/game/ant/ant-morphogenesis.cpp View File

@ -20,7 +20,6 @@
#include "game/ant/ant-morphogenesis.hpp"
#include <engine/render/material.hpp>
#include <engine/render/vertex-attribute.hpp>
#include <engine/math/transform-operators.hpp>
#include <engine/math/quaternion.hpp>
#include <engine/debug/log.hpp>
#include <engine/geom/primitives/box.hpp>
@ -816,7 +815,7 @@ std::unique_ptr ant_morphogenesis(const ant_phenome& phenome)
const ::skeleton* hindwings_skeleton = (phenome.wings->present) ? &phenome.wings->hindwings_model->get_skeleton() : nullptr;
// Calculate transformations from part space to body space
const math::transform<float> legs_to_body = math::transform<float>::identity;
const math::transform<float> legs_to_body = math::transform<float>::identity();
const math::transform<float> head_to_body = bind_pose_ss.at(*bones.mesosoma) * mesosoma_skeleton.bind_pose.at(mesosoma_skeleton.bone_map.at("head"));
const math::transform<float> mandible_l_to_body = bind_pose_ss.at(*bones.head) * head_skeleton.bind_pose.at(head_skeleton.bone_map.at("mandible_l"));
const math::transform<float> mandible_r_to_body = bind_pose_ss.at(*bones.head) * head_skeleton.bind_pose.at(head_skeleton.bone_map.at("mandible_r"));

+ 1
- 1
src/game/ant/ant-swarm.cpp View File

@ -64,7 +64,7 @@ entity::id create_ant_swarm(::game& ctx)
// Init transform component
::transform_component transform;
transform.local = math::transform<float>::identity;
transform.local = math::transform<float>::identity();
transform.world = transform.local;
// Init picking component

+ 2
- 2
src/game/commands/commands.cpp View File

@ -152,7 +152,7 @@ math::transform get_local_transform(entity::registry& registry, entity::i
return transform->local;
}
return math::transform<float>::identity;
return math::transform<float>::identity();
}
math::transform<float> get_world_transform(entity::registry& registry, entity::id eid)
@ -163,7 +163,7 @@ math::transform get_world_transform(entity::registry& registry, entity::i
return transform->world;
}
return math::transform<float>::identity;
return math::transform<float>::identity();
}
} // namespace command

+ 1
- 1
src/game/commands/commands.hpp View File

@ -23,7 +23,7 @@
#include <engine/entity/id.hpp>
#include <engine/entity/registry.hpp>
#include <engine/utility/fundamental-types.hpp>
#include <engine/math/transform-type.hpp>
#include <engine/math/transform.hpp>
/// Commands which operate on entity::id components

+ 1
- 1
src/game/components/transform-component.hpp View File

@ -20,7 +20,7 @@
#ifndef ANTKEEPER_GAME_TRANSFORM_COMPONENT_HPP
#define ANTKEEPER_GAME_TRANSFORM_COMPONENT_HPP
#include <engine/math/transform-type.hpp>
#include <engine/math/transform.hpp>
struct transform_component

+ 1
- 1
src/game/loaders/entity-archetype-loader.cpp View File

@ -219,7 +219,7 @@ static bool load_component_orbit(entity::archetype& archetype, const json& eleme
static bool load_component_transform(entity::archetype& archetype, const json& element)
{
::transform_component component;
component.local = math::transform<float>::identity;
component.local = math::transform<float>::identity();
if (element.contains("translation"))
{

+ 2
- 2
src/game/spawn.cpp View File

@ -29,7 +29,7 @@ entity::id spawn_ant_egg(::game& ctx, const ant_genome& genome, bool fertilized,
// Construct transform component
transform_component transform_component;
transform_component.local = math::transform<float>::identity;
transform_component.local = math::transform<float>::identity();
transform_component.local.translation = position;
transform_component.world = transform_component.local;
ctx.entity_registry->emplace<::transform_component>(egg_eid, transform_component);
@ -47,7 +47,7 @@ entity::id spawn_ant_larva(::game& ctx, const ant_genome& genome, const float3&
// Construct transform component
transform_component transform_component;
transform_component.local = math::transform<float>::identity;
transform_component.local = math::transform<float>::identity();
transform_component.local.translation = position;
transform_component.world = transform_component.local;
ctx.entity_registry->emplace<::transform_component>(larva_eid, transform_component);

+ 4
- 2
src/game/states/nest-selection-state.cpp View File

@ -102,6 +102,8 @@ nest_selection_state::nest_selection_state(::game& ctx):
worker_model = ant_morphogenesis(worker_phenome);
debug::log::trace("Generated worker model");
// Create floor plane
auto floor_archetype = ctx.resource_manager->load<entity::archetype>("desert-scrub-plane.ent");
@ -128,7 +130,7 @@ nest_selection_state::nest_selection_state(::game& ctx):
// Create worker entity(s)
worker_ant_eid = ctx.entity_registry->create();
transform_component worker_transform_component;
worker_transform_component.local = math::transform<float>::identity;
worker_transform_component.local = math::transform<float>::identity();
worker_transform_component.local.translation = {0, 0.5f, -4};
worker_transform_component.world = worker_transform_component.local;
ctx.entity_registry->emplace<transform_component>(worker_ant_eid, worker_transform_component);
@ -281,7 +283,7 @@ void nest_selection_state::create_first_person_camera_rig()
{
// Construct first person camera rig transform component
transform_component first_person_camera_rig_transform;
first_person_camera_rig_transform.local = math::transform<float>::identity;
first_person_camera_rig_transform.local = math::transform<float>::identity();
first_person_camera_rig_transform.local.translation = {0, 10, 0};
first_person_camera_rig_transform.world = first_person_camera_rig_transform.local;

+ 2
- 2
src/game/states/nuptial-flight-state.cpp View File

@ -250,7 +250,7 @@ void nuptial_flight_state::create_camera_rig()
// Construct camera rig focus transform component
transform_component camera_rig_focus_transform;
camera_rig_focus_transform.local = math::transform<float>::identity;
camera_rig_focus_transform.local = math::transform<float>::identity();
camera_rig_focus_transform.world = camera_rig_focus_transform.local;
// Construct camera rig focus entity
@ -331,7 +331,7 @@ void nuptial_flight_state::create_camera_rig()
// Construct camera rig transform component
transform_component camera_rig_transform;
camera_rig_transform.local = math::transform<float>::identity;
camera_rig_transform.local = math::transform<float>::identity();
camera_rig_transform.world = camera_rig_transform.local;
// Construct camera rig camera component

+ 0
- 1
src/game/systems/collision-system.cpp View File

@ -23,7 +23,6 @@
#include "game/components/rigid-body-component.hpp"
#include <engine/geom/intersection.hpp>
#include <engine/geom/primitives/plane.hpp>
#include <engine/math/transform-operators.hpp>
#include <limits>

+ 1
- 3
src/game/systems/constraint-system.cpp View File

@ -19,9 +19,7 @@
#include "game/systems/constraint-system.hpp"
#include "game/components/constraint-stack-component.hpp"
#include <engine/math/quaternion.hpp>
#include <engine/math/transform-operators.hpp>
#include <engine/math/quaternion.hpp>
constraint_system::constraint_system(entity::registry& registry):
updatable_system(registry)
{

+ 0
- 1
src/game/systems/physics-system.cpp View File

@ -25,7 +25,6 @@
#include <algorithm>
#include <engine/debug/log.hpp>
#include <engine/entity/id.hpp>
#include <engine/math/transform-operators.hpp>
#include <engine/physics/kinematics/colliders/plane-collider.hpp>
#include <engine/physics/kinematics/colliders/sphere-collider.hpp>
#include <engine/physics/kinematics/colliders/box-collider.hpp>

Loading…
Cancel
Save