Implement/match LegoEntity::SetLocation (#629)

* Implement/match LegoEntity::SetLocation

* Remove comment
This commit is contained in:
Christian Semmler 2024-03-05 14:31:57 -05:00 committed by GitHub
parent 3b2bd0e9d4
commit a93e2ae0d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 57 additions and 23 deletions

View file

@ -57,7 +57,7 @@ class LegoEntity : public MxEntity {
void FUN_10010c30();
void FUN_100114e0(MxU8 p_unk0x59);
void SetLocation(const Vector3& p_location, const Vector3& p_direction, const Vector3& p_up, MxBool);
void SetLocation(const Vector3& p_location, const Vector3& p_direction, const Vector3& p_up, MxBool p_und);
inline LegoROI* GetROI() { return m_roi; }
inline MxU8 GetFlags() { return m_flags; }

View file

@ -205,14 +205,14 @@ MxU32 Helicopter::VTable0xd4(LegoControlManagerEvent& p_param)
}
if (m_world && m_world->GetCamera()) {
Mx3DPointFloat loc, dir, lookat;
loc.CopyFrom(m_world->GetCamera()->GetWorldLocation());
dir.CopyFrom(m_world->GetCamera()->GetWorldDirection());
loc = m_world->GetCamera()->GetWorldLocation();
dir = m_world->GetCamera()->GetWorldDirection();
lookat = dir;
float scale = 3;
lookat.Mul(scale);
lookat.Add(&loc);
Mx3DPointFloat v68, v7c, v90(0, 1, 0), va4;
v68.CopyFrom(m_world->GetCamera()->GetWorldUp());
v68 = m_world->GetCamera()->GetWorldUp();
va4.EqualsCross(v68, dir);
v7c.EqualsCross(va4, v90);
if (ret) {

View file

@ -85,9 +85,9 @@ void LegoEntity::SetROI(LegoROI* p_roi, MxBool p_bool1, MxBool p_bool2)
if (p_bool2) {
MxMatrix mat;
CalcLocalTransform(
Mx3DPointFloat(m_worldLocation.GetX(), m_worldLocation.GetY(), m_worldLocation.GetZ()),
Mx3DPointFloat(m_worldDirection.GetX(), m_worldDirection.GetY(), m_worldDirection.GetZ()),
Mx3DPointFloat(m_worldUp.GetX(), m_worldUp.GetY(), m_worldUp.GetZ()),
Mx3DPointFloat(m_worldLocation[0], m_worldLocation[1], m_worldLocation[2]),
Mx3DPointFloat(m_worldDirection[0], m_worldDirection[1], m_worldDirection[2]),
Mx3DPointFloat(m_worldUp[0], m_worldUp[1], m_worldUp[2]),
mat
);
@ -106,10 +106,38 @@ void LegoEntity::SetROI(LegoROI* p_roi, MxBool p_bool1, MxBool p_bool2)
}
}
// STUB: LEGO1 0x100109b0
void LegoEntity::SetLocation(const Vector3& p_location, const Vector3& p_direction, const Vector3& p_up, MxBool)
// FUNCTION: LEGO1 0x100109b0
void LegoEntity::SetLocation(const Vector3& p_location, const Vector3& p_direction, const Vector3& p_up, MxBool p_und)
{
// TODO
Mx3DPointFloat direction;
Mx3DPointFloat up;
direction = p_direction;
direction.Unitize();
up = p_up;
up.Unitize();
m_worldLocation = p_location;
m_worldDirection = direction;
m_worldUp = up;
if (m_roi != NULL) {
MxMatrix mat;
CalcLocalTransform(
Mx3DPointFloat(p_location[0], p_location[1], p_location[2]),
Mx3DPointFloat(direction[0], direction[1], direction[2]),
Mx3DPointFloat(up[0], up[1], up[2]),
mat
);
m_roi->FUN_100a46b0(mat);
VideoManager()->Get3DManager()->GetLego3DView()->Moved(*m_roi);
if (p_und) {
FUN_10010c30();
}
}
}
// FUNCTION: LEGO1 0x10010c30

View file

@ -31,16 +31,16 @@ class Mx3DPointFloat : public Vector3 {
// FUNCTION: LEGO1 0x10003c10
virtual void operator=(const Vector3& p_impl) { EqualsImpl(p_impl.m_data); } // vtable+0x88
inline void CopyFrom(const Mx3DPointFloat& p_other)
// FUNCTION: LEGO1 0x10010c00
inline Mx3DPointFloat& operator=(const Mx3DPointFloat& p_other)
{
// ALPHA: 0x10010860, multiple indirections to this call
EqualsImpl(p_other.m_data);
((Vector3&) *this).operator=(p_other);
float* dest = m_elements;
const float* src = p_other.m_elements;
for (size_t i = sizeof(m_elements) / sizeof(float); i > 0; --i) {
*dest++ = *src++;
for (size_t i = 0; i < sizeof(m_elements) / sizeof(float); i++) {
m_elements[i] = p_other.m_elements[i];
}
return *this;
}
inline void EqualsCross(Mx3DPointFloat& p_a, Mx3DPointFloat& p_b) { EqualsCrossImpl(p_a.m_data, p_b.m_data); }

View file

@ -76,11 +76,9 @@ void MxDSAction::CopyFrom(MxDSAction& p_dsAction)
this->m_startTime = p_dsAction.m_startTime;
this->m_duration = p_dsAction.m_duration;
this->m_loopCount = p_dsAction.m_loopCount;
this->m_location.CopyFrom(p_dsAction.m_location);
this->m_direction.CopyFrom(p_dsAction.m_direction);
this->m_up.CopyFrom(p_dsAction.m_up);
this->m_location = p_dsAction.m_location;
this->m_direction = p_dsAction.m_direction;
this->m_up = p_dsAction.m_up;
AppendData(p_dsAction.m_extraLength, p_dsAction.m_extraData);
this->m_unk0x84 = p_dsAction.m_unk0x84;
this->m_unk0x88 = p_dsAction.m_unk0x88;

View file

@ -139,8 +139,16 @@ class Vector2 {
virtual void SetVector(float* p_other) { EqualsImpl(p_other); } // vtable+0x70
// FUNCTION: LEGO1 0x10002260
virtual void SetVector(Vector2* p_other) { EqualsImpl(p_other->m_data); } // vtable+0x6c
virtual void SetVector(const Vector2* p_other) { EqualsImpl(p_other->m_data); } // vtable+0x6c
// SYNTHETIC: LEGO1 0x10010be0
// Vector3::operator=
inline Vector2& operator=(const Vector2& p_other)
{
Vector2::SetVector(&p_other);
return *this;
}
inline float& operator[](size_t idx) { return m_data[idx]; }
inline const float& operator[](size_t idx) const { return m_data[idx]; }