2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-11 13:47:43 +00:00

CSegId: Add member functions for querying validity

Allows querying validity of segment IDs without hardcoding the magic
value that signifies an invalid ID.
This commit is contained in:
Lioncash
2019-10-26 21:53:11 -04:00
parent 30af6f0bfb
commit 660d092cad
14 changed files with 112 additions and 78 deletions

View File

@@ -393,19 +393,21 @@ bool CPatterned::CanRenderUnsorted(const urde::CStateManager& mgr) const {
zeus::CVector3f CPatterned::GetAimPosition(const urde::CStateManager& mgr, float dt) const {
zeus::CVector3f offset;
if (dt > 0.f)
if (dt > 0.f) {
offset = PredictMotion(dt).x0_translation;
}
CSegId segId = GetModelData()->GetAnimationData()->GetLocatorSegId("lockon_target_LCTR"sv);
if (segId != 0xFF) {
zeus::CTransform xf = GetModelData()->GetAnimationData()->GetLocatorTransform(segId, nullptr);
zeus::CVector3f scaledOrigin = GetModelData()->GetScale() * xf.origin;
if (auto tb = GetTouchBounds())
const CSegId segId = GetModelData()->GetAnimationData()->GetLocatorSegId("lockon_target_LCTR"sv);
if (segId.IsValid()) {
const zeus::CTransform xf = GetModelData()->GetAnimationData()->GetLocatorTransform(segId, nullptr);
const zeus::CVector3f scaledOrigin = GetModelData()->GetScale() * xf.origin;
if (const auto tb = GetTouchBounds()) {
return offset + tb->clampToBox(x34_transform * scaledOrigin);
}
zeus::CAABox aabox = GetBaseBoundingBox();
zeus::CAABox primBox(aabox.min + GetPrimitiveOffset(), aabox.max + GetPrimitiveOffset());
const zeus::CAABox aabox = GetBaseBoundingBox();
const zeus::CAABox primBox(aabox.min + GetPrimitiveOffset(), aabox.max + GetPrimitiveOffset());
return offset + (x34_transform * primBox.clampToBox(scaledOrigin));
}