Fix CScriptActorRotate

This commit is contained in:
Phillip Stephens 2021-04-18 20:11:18 -07:00
parent f795332d89
commit 83fc649023
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
4 changed files with 19 additions and 15 deletions

View File

@ -194,5 +194,6 @@ public:
CSimpleShadow* Shadow() { return x94_simpleShadow.get(); } CSimpleShadow* Shadow() { return x94_simpleShadow.get(); }
void MoveScannableObjectInfoToActor(CActor*, CStateManager&); void MoveScannableObjectInfoToActor(CActor*, CStateManager&);
const zeus::CAABox& GetRenderBounds() const { return x9c_renderBounds; } const zeus::CAABox& GetRenderBounds() const { return x9c_renderBounds; }
void SetNotInSortedLists(bool notIn) { xe4_27_notInSortedLists = notIn; }
}; };
} // namespace metaforce } // namespace metaforce

View File

@ -44,11 +44,11 @@ void CScriptActorRotate::Think(float dt, CStateManager& mgr) {
for (const auto& actorPair : x48_actors) { for (const auto& actorPair : x48_actors) {
if (const TCastToPtr<CActor> act = mgr.ObjectById(actorPair.first)) { if (const TCastToPtr<CActor> act = mgr.ObjectById(actorPair.first)) {
const zeus::CTransform xf = zeus::CTransform::RotateZ(zeus::degToRad(timeOffset * x34_rotation.z())) * const zeus::CTransform xf = zeus::CTransform::RotateX(zeus::degToRad(timeOffset * x34_rotation.x())) *
zeus::CTransform::RotateY(zeus::degToRad(timeOffset * x34_rotation.y())) * zeus::CTransform::RotateY(zeus::degToRad(timeOffset * x34_rotation.y())) *
zeus::CTransform::RotateX(zeus::degToRad(timeOffset * x34_rotation.x())); zeus::CTransform::RotateZ(zeus::degToRad(timeOffset * x34_rotation.z()));
zeus::CTransform localRot = actorPair.second * xf; zeus::CTransform localRot = actorPair.second * xf;
localRot.origin = act->GetTranslation(); localRot.origin += act->GetTranslation();
act->SetTransform(localRot); act->SetTransform(localRot);
if (const TCastToPtr<CScriptPlatform> plat = mgr.ObjectById(actorPair.first)) { if (const TCastToPtr<CScriptPlatform> plat = mgr.ObjectById(actorPair.first)) {
@ -57,8 +57,8 @@ void CScriptActorRotate::Think(float dt, CStateManager& mgr) {
} }
} }
if (x58_24_updateRotation) { if (!x58_24_updateRotation) {
if (!x58_25_skipSpiderBallWaypoints) { if (x58_25_updateSpiderBallWaypoints) {
UpdateSpiderBallWaypoints(mgr); UpdateSpiderBallWaypoints(mgr);
} }
@ -82,11 +82,11 @@ void CScriptActorRotate::UpdatePlatformRiders(std::vector<SRiders>& riders, CScr
act->SetTransform(rider.x8_transform); act->SetTransform(rider.x8_transform);
act->SetTranslation(act->GetTranslation() + plat.GetTranslation()); act->SetTranslation(act->GetTranslation() + plat.GetTranslation());
if (x58_24_updateRotation) { if (!x58_24_updateRotation) {
riderXf = {act->GetTransform().basis, act->GetTranslation() - plat.GetTranslation()}; riderXf = {act->GetTransform().basis, act->GetTranslation() - plat.GetTranslation()};
if (TCastToConstPtr<CScriptSpiderBallWaypoint>(act.GetPtr())) { if (TCastToConstPtr<CScriptSpiderBallWaypoint>(act.GetPtr())) {
x58_25_skipSpiderBallWaypoints = true; x58_25_updateSpiderBallWaypoints = true;
} }
} }
@ -128,22 +128,21 @@ void CScriptActorRotate::UpdateActors(bool next, CStateManager& mgr) {
void CScriptActorRotate::UpdateSpiderBallWaypoints(CStateManager& mgr) { void CScriptActorRotate::UpdateSpiderBallWaypoints(CStateManager& mgr) {
rstl::reserved_vector<TUniqueId, 1024> waypointIds; rstl::reserved_vector<TUniqueId, 1024> waypointIds;
CObjectList& objectList = mgr.GetAllObjectList(); CObjectList& objectList = mgr.GetAllObjectList();
for (const CEntity* ent : objectList) { for (CEntity* ent : objectList) {
if (const TCastToConstPtr<CScriptSpiderBallWaypoint> wp = ent) { if (const TCastToPtr<CScriptSpiderBallWaypoint> wp = ent) {
waypointIds.push_back(wp->GetUniqueId()); waypointIds.push_back(wp->GetUniqueId());
wp->ClearWaypoints();
} }
} }
for (const TUniqueId& uid : waypointIds) { for (const TUniqueId& uid : waypointIds) {
auto* wp = static_cast<CScriptSpiderBallWaypoint*>(mgr.ObjectById(uid)); auto* wp = static_cast<CScriptSpiderBallWaypoint*>(mgr.ObjectById(uid));
if (wp) { if (wp) {
#if 0 wp->BuildWaypointListAndBounds(mgr);
wp->sub_801187B4(mgr); wp->SetNotInSortedLists(false);
wp->xe4_27_ = true;
#endif
} }
} }
x58_25_skipSpiderBallWaypoints = false; x58_25_updateSpiderBallWaypoints = false;
} }
} // namespace metaforce } // namespace metaforce

View File

@ -19,7 +19,7 @@ class CScriptActorRotate : public CEntity {
float x44_currentTime = 0.f; float x44_currentTime = 0.f;
std::map<TUniqueId, zeus::CTransform> x48_actors; std::map<TUniqueId, zeus::CTransform> x48_actors;
bool x58_24_updateRotation : 1 = false; bool x58_24_updateRotation : 1 = false;
bool x58_25_skipSpiderBallWaypoints : 1 = false; bool x58_25_updateSpiderBallWaypoints : 1 = false;
bool x58_26_updateActors : 1; bool x58_26_updateActors : 1;
bool x58_27_updateOnCreation : 1; bool x58_27_updateOnCreation : 1;

View File

@ -31,5 +31,9 @@ public:
const CScriptSpiderBallWaypoint*& closestWaypoint, zeus::CVector3f& closestPoint, const CScriptSpiderBallWaypoint*& closestWaypoint, zeus::CVector3f& closestPoint,
zeus::CVector3f& deltaBetweenPoints, float deltaBetweenInterpDist, zeus::CVector3f& deltaBetweenPoints, float deltaBetweenInterpDist,
zeus::CVector3f& interpDeltaBetweenPoints) const; zeus::CVector3f& interpDeltaBetweenPoints) const;
void ClearWaypoints() {
xfc_aabox.reset();
xec_waypoints.clear();
}
}; };
} // namespace metaforce } // namespace metaforce