mirror of
https://github.com/minetest/minetest.git
synced 2024-07-04 15:05:27 +02:00
Rename matrix methods
This commit is contained in:
parent
1bcb5bd620
commit
5e34862440
@ -24,7 +24,7 @@ namespace core
|
||||
{
|
||||
|
||||
//! 4x4 matrix. Mostly used as transformation matrix for 3d calculations.
|
||||
/** The matrix is a D3D style matrix, row major with translations in the 4th row. */
|
||||
/** The matrix is stored in column major order, with translations in the 4th row. */
|
||||
template <class T>
|
||||
class CMatrix4
|
||||
{
|
||||
@ -242,17 +242,11 @@ class CMatrix4
|
||||
//! Translate a vector by the inverse of the translation part of this matrix.
|
||||
void inverseTranslateVect(vector3df &vect) const;
|
||||
|
||||
//! Rotate a vector by the inverse of the rotation part of this matrix.
|
||||
void inverseRotateVect(vector3df &vect) const;
|
||||
//! Scale a vector, then rotate by the inverse of the rotation part of this matrix.
|
||||
void scaleThenInvRotVect(vector3df &vect) const;
|
||||
|
||||
//! Rotate a vector by the rotation part of this matrix.
|
||||
void rotateVect(vector3df &vect) const;
|
||||
|
||||
//! An alternate transform vector method, writing into a second vector
|
||||
void rotateVect(core::vector3df &out, const core::vector3df &in) const;
|
||||
|
||||
//! An alternate transform vector method, writing into an array of 3 floats
|
||||
void rotateVect(T *out, const core::vector3df &in) const;
|
||||
//! Rotate and scale a vector. Applies both rotation & scale part of the matrix.
|
||||
void rotateAndScaleVect(vector3df &vect) const;
|
||||
|
||||
//! Transforms the vector by this matrix
|
||||
/** This operation is performed as if the vector was 4d with the 4th component =1 */
|
||||
@ -1154,7 +1148,7 @@ inline bool CMatrix4<T>::isIdentity_integer_base() const
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void CMatrix4<T>::rotateVect(vector3df &vect) const
|
||||
inline void CMatrix4<T>::rotateAndScaleVect(vector3df &vect) const
|
||||
{
|
||||
vector3d<T> tmp(static_cast<T>(vect.X), static_cast<T>(vect.Y), static_cast<T>(vect.Z));
|
||||
vect.X = static_cast<f32>(tmp.X * M[0] + tmp.Y * M[4] + tmp.Z * M[8]);
|
||||
@ -1162,26 +1156,8 @@ inline void CMatrix4<T>::rotateVect(vector3df &vect) const
|
||||
vect.Z = static_cast<f32>(tmp.X * M[2] + tmp.Y * M[6] + tmp.Z * M[10]);
|
||||
}
|
||||
|
||||
//! An alternate transform vector method, writing into a second vector
|
||||
template <class T>
|
||||
inline void CMatrix4<T>::rotateVect(core::vector3df &out, const core::vector3df &in) const
|
||||
{
|
||||
out.X = in.X * M[0] + in.Y * M[4] + in.Z * M[8];
|
||||
out.Y = in.X * M[1] + in.Y * M[5] + in.Z * M[9];
|
||||
out.Z = in.X * M[2] + in.Y * M[6] + in.Z * M[10];
|
||||
}
|
||||
|
||||
//! An alternate transform vector method, writing into an array of 3 floats
|
||||
template <class T>
|
||||
inline void CMatrix4<T>::rotateVect(T *out, const core::vector3df &in) const
|
||||
{
|
||||
out[0] = in.X * M[0] + in.Y * M[4] + in.Z * M[8];
|
||||
out[1] = in.X * M[1] + in.Y * M[5] + in.Z * M[9];
|
||||
out[2] = in.X * M[2] + in.Y * M[6] + in.Z * M[10];
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void CMatrix4<T>::inverseRotateVect(vector3df &vect) const
|
||||
inline void CMatrix4<T>::scaleThenInvRotVect(vector3df &vect) const
|
||||
{
|
||||
vector3d<T> tmp(static_cast<T>(vect.X), static_cast<T>(vect.Y), static_cast<T>(vect.Z));
|
||||
vect.X = static_cast<f32>(tmp.X * M[0] + tmp.Y * M[1] + tmp.Z * M[2]);
|
||||
@ -1248,7 +1224,7 @@ inline void CMatrix4<T>::transformPlane(core::plane3d<f32> &plane) const
|
||||
// Transform the normal by the transposed inverse of the matrix
|
||||
CMatrix4<T> transposedInverse(*this, EM4CONST_INVERSE_TRANSPOSED);
|
||||
vector3df normal = plane.Normal;
|
||||
transposedInverse.rotateVect(normal);
|
||||
transposedInverse.rotateAndScaleVect(normal);
|
||||
plane.setPlane(member, normal.normalize());
|
||||
}
|
||||
|
||||
|
@ -388,7 +388,7 @@ bool CB3DMeshFileLoader::readChunkVRTS(CSkinnedMesh::SJoint *inJoint)
|
||||
|
||||
// Transform the Vertex position by nested node...
|
||||
inJoint->GlobalMatrix.transformVect(Vertex.Pos);
|
||||
inJoint->GlobalMatrix.rotateVect(Vertex.Normal);
|
||||
inJoint->GlobalMatrix.rotateAndScaleVect(Vertex.Normal);
|
||||
|
||||
// Add it...
|
||||
BaseVertices.push_back(Vertex);
|
||||
|
@ -350,8 +350,7 @@ static void transformVertices(std::vector<video::S3DVertex> &vertices, const cor
|
||||
// Apply scaling, rotation and rotation (in that order) to the position.
|
||||
transform.transformVect(vertex.Pos);
|
||||
// For the normal, we do not want to apply the translation.
|
||||
// TODO note that this also applies scaling; the Irrlicht method is misnamed.
|
||||
transform.rotateVect(vertex.Normal);
|
||||
transform.rotateAndScaleVect(vertex.Normal);
|
||||
// Renormalize (length might have been affected by scaling).
|
||||
vertex.Normal.normalize();
|
||||
}
|
||||
|
@ -511,7 +511,7 @@ void CSkinnedMesh::skinJoint(SJoint *joint, SJoint *parentJoint)
|
||||
jointVertexPull.transformVect(thisVertexMove, weight.StaticPos);
|
||||
|
||||
if (AnimateNormals)
|
||||
jointVertexPull.rotateVect(thisNormalMove, weight.StaticNormal);
|
||||
jointVertexPull.rotateAndScaleVect(thisNormalMove = weight.StaticNormal);
|
||||
|
||||
if (!(*(weight.Moved))) {
|
||||
*(weight.Moved) = true;
|
||||
|
@ -404,10 +404,10 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 tool_reload_ratio)
|
||||
|
||||
// Compute absolute camera position and target
|
||||
m_headnode->getAbsoluteTransformation().transformVect(m_camera_position, rel_cam_pos);
|
||||
m_headnode->getAbsoluteTransformation().rotateVect(m_camera_direction, rel_cam_target - rel_cam_pos);
|
||||
m_headnode->getAbsoluteTransformation().rotateAndScaleVect(m_camera_direction = rel_cam_target - rel_cam_pos);
|
||||
|
||||
v3f abs_cam_up;
|
||||
m_headnode->getAbsoluteTransformation().rotateVect(abs_cam_up, rel_cam_up);
|
||||
v3f abs_cam_up = rel_cam_up;
|
||||
m_headnode->getAbsoluteTransformation().rotateAndScaleVect(abs_cam_up);
|
||||
|
||||
// Separate camera position for calculation
|
||||
v3f my_cp = m_camera_position;
|
||||
|
@ -1004,7 +1004,7 @@ int ClientMap::getBackgroundBrightness(float max_d, u32 daylight_factor,
|
||||
core::CMatrix4<f32> a;
|
||||
a.buildRotateFromTo(v3f(0,1,0), z_dir);
|
||||
v3f dir = m_camera_direction;
|
||||
a.rotateVect(dir);
|
||||
a.rotateAndScaleVect(dir);
|
||||
int br = 0;
|
||||
float step = BS*1.5;
|
||||
if(max_d > 35*BS)
|
||||
|
@ -512,7 +512,7 @@ void Hud::drawLuaElements(const v3s16 &camera_offset)
|
||||
// Angle according to camera view
|
||||
v3f fore(0.f, 0.f, 1.f);
|
||||
scene::ICameraSceneNode *cam = client->getSceneManager()->getActiveCamera();
|
||||
cam->getAbsoluteTransformation().rotateVect(fore);
|
||||
cam->getAbsoluteTransformation().rotateAndScaleVect(fore);
|
||||
int angle = - fore.getHorizontalAngle().Y;
|
||||
|
||||
// Limit angle and ajust with given offset
|
||||
|
@ -357,8 +357,8 @@ void ParticleSpawner::spawnParticle(ClientEnvironment *env, float radius,
|
||||
|
||||
if (attached_absolute_pos_rot_matrix) {
|
||||
// Apply attachment rotation
|
||||
attached_absolute_pos_rot_matrix->rotateVect(pp.vel);
|
||||
attached_absolute_pos_rot_matrix->rotateVect(pp.acc);
|
||||
attached_absolute_pos_rot_matrix->rotateAndScaleVect(pp.vel);
|
||||
attached_absolute_pos_rot_matrix->rotateAndScaleVect(pp.acc);
|
||||
}
|
||||
|
||||
if (attractor_obj)
|
||||
@ -366,7 +366,7 @@ void ParticleSpawner::spawnParticle(ClientEnvironment *env, float radius,
|
||||
if (attractor_direction_obj) {
|
||||
auto *attractor_absolute_pos_rot_matrix = attractor_direction_obj->getAbsolutePosRotMatrix();
|
||||
if (attractor_absolute_pos_rot_matrix)
|
||||
attractor_absolute_pos_rot_matrix->rotateVect(attractor_direction);
|
||||
attractor_absolute_pos_rot_matrix->rotateAndScaleVect(attractor_direction);
|
||||
}
|
||||
|
||||
pp.expirationtime = r_exp.pickWithin();
|
||||
|
@ -137,7 +137,7 @@ void DirectionalLight::update_frustum(const Camera *cam, Client *client, bool fo
|
||||
v3s16 cam_offset = cam->getOffset();
|
||||
if (cam_offset != shadow_frustum.camera_offset) {
|
||||
v3f rotated_offset;
|
||||
shadow_frustum.ViewMat.rotateVect(rotated_offset, intToFloat(cam_offset - shadow_frustum.camera_offset, BS));
|
||||
shadow_frustum.ViewMat.rotateAndScaleVect(rotated_offset = intToFloat(cam_offset - shadow_frustum.camera_offset, BS));
|
||||
shadow_frustum.ViewMat.setTranslation(shadow_frustum.ViewMat.getTranslation() + rotated_offset);
|
||||
shadow_frustum.player += intToFloat(shadow_frustum.camera_offset - cam->getOffset(), BS);
|
||||
shadow_frustum.camera_offset = cam_offset;
|
||||
|
@ -848,10 +848,10 @@ void Sky::updateStars()
|
||||
v3f p1 = v3f(d, 1, -d);
|
||||
v3f p2 = v3f(d, 1, d);
|
||||
v3f p3 = v3f(-d, 1, d);
|
||||
a.rotateVect(p);
|
||||
a.rotateVect(p1);
|
||||
a.rotateVect(p2);
|
||||
a.rotateVect(p3);
|
||||
a.rotateAndScaleVect(p);
|
||||
a.rotateAndScaleVect(p1);
|
||||
a.rotateAndScaleVect(p2);
|
||||
a.rotateAndScaleVect(p3);
|
||||
m_stars->Vertices.push_back(video::S3DVertex(p, {}, fallback_color, {}));
|
||||
m_stars->Vertices.push_back(video::S3DVertex(p1, {}, fallback_color, {}));
|
||||
m_stars->Vertices.push_back(video::S3DVertex(p2, {}, fallback_color, {}));
|
||||
|
@ -226,7 +226,7 @@ void GUIScene::setCameraRotation(v3f rot)
|
||||
mat.setRotationDegrees(rot);
|
||||
|
||||
m_cam_pos = v3f(0.f, 0.f, m_cam_distance);
|
||||
mat.rotateVect(m_cam_pos);
|
||||
mat.rotateAndScaleVect(m_cam_pos);
|
||||
|
||||
m_cam_pos += m_target_pos;
|
||||
m_cam->setPosition(m_cam_pos);
|
||||
|
Loading…
Reference in New Issue
Block a user