Update GetJointAbsPosition()

This commit is contained in:
Sezz 2022-09-09 16:33:30 +10:00
parent 3cad0113cc
commit aa99fab70b
4 changed files with 17 additions and 16 deletions

View file

@ -579,27 +579,28 @@ Vector3i GetLaraJointPosition(int jointIndex, const Vector3i& offset)
if (jointIndex >= NUM_LARA_MESHES)
jointIndex = LM_HEAD;
// Use matrices done in the renderer to transform the offset vector.
auto pos = offset.ToVector3();
g_Renderer.GetLaraAbsBonePosition(pos, jointIndex);
return Vector3i(pos);
}
Vector3i GetJointAbsPosition(ItemInfo* item, int jointIndex, Vector3i offset)
{
auto pos = offset;
GetJointAbsPosition(item, &pos, jointIndex);
return pos;
}
void GetJointAbsPosition(ItemInfo* item, Vector3i* offset, int jointIndex)
Vector3i GetJointAbsPosition(ItemInfo* item, int jointIndex, const Vector3i& offset)
{
// Get real item number.
short itemNumber = item - g_Level.Items.data();
// Use matrices done in the renderer and transform the input vector.
auto pos = offset->ToVector3();
g_Renderer.GetItemAbsBonePosition(itemNumber, &pos, jointIndex);
// Use matrices done in the renderer to transform the offset vector.
auto pos = offset.ToVector3();
g_Renderer.GetItemAbsBonePosition(itemNumber, pos, jointIndex);
return Vector3i(pos);
}
// Store the result.
// TODO: Adopt above version and remove this one.
void GetJointAbsPosition(ItemInfo* item, Vector3i* offset, int jointIndex)
{
short itemNumber = item - g_Level.Items.data();
auto pos = offset->ToVector3();
g_Renderer.GetItemAbsBonePosition(itemNumber, pos, jointIndex);
*offset = Vector3i(pos);
}

View file

@ -98,5 +98,5 @@ void ClampRotation(PoseData* pose, short angle, short rotation);
void DrawAnimatingItem(ItemInfo* item);
Vector3i GetLaraJointPosition(int jointIndex, const Vector3i& offset = Vector3i::Zero);
Vector3i GetJointAbsPosition(ItemInfo* item, int jointIndex, Vector3i offset = Vector3i::Zero);
Vector3i GetJointAbsPosition(ItemInfo* item, int jointIndex, const Vector3i& offset = Vector3i::Zero);
void GetJointAbsPosition(ItemInfo* item, Vector3i* offset, int jointIndex);

View file

@ -642,7 +642,7 @@ namespace TEN::Renderer
void UpdateLaraAnimations(bool force);
void UpdateItemAnimations(int itemNumber, bool force);
void GetLaraAbsBonePosition(Vector3& pos, int jointIndex);
void GetItemAbsBonePosition(int itemNumber, Vector3* pos, int jointIndex);
void GetItemAbsBonePosition(int itemNumber, Vector3& pos, int jointIndex);
int GetSpheres(short itemNumber, BoundingSphere* ptr, char worldSpace, Matrix local);
void GetBoneMatrix(short itemNumber, int joint, Matrix* outMatrix);
void DrawObjectOn2DPosition(short x, short y, short objectNum, short rotX, short rotY, short rotZ, float scale1);

View file

@ -394,7 +394,7 @@ namespace TEN::Renderer
pos = Vector3::Transform(pos, world);
}
void Renderer11::GetItemAbsBonePosition(int itemNumber, Vector3* pos, int jointIndex)
void Renderer11::GetItemAbsBonePosition(int itemNumber, Vector3& pos, int jointIndex)
{
auto* rendererItem = &m_items[itemNumber];
auto* nativeItem = &g_Level.Items[itemNumber];
@ -416,7 +416,7 @@ namespace TEN::Renderer
jointIndex = 0;
auto world = rendererItem->AnimationTransforms[jointIndex] * rendererItem->World;
*pos = Vector3::Transform(*pos, world);
pos = Vector3::Transform(pos, world);
}
int Renderer11::GetSpheres(short itemNumber, BoundingSphere *spheres, char worldSpace, Matrix local)