mirror of
https://github.com/MonsterDruide1/OdysseyDecomp
synced 2026-04-23 09:04:21 +00:00
Area: Implement BirdGatheringSpotArea (#921)
This commit is contained in:
parent
4564f1b396
commit
c305fb1518
|
|
@ -965,41 +965,41 @@ Area/BirdGatheringSpotArea.o:
|
|||
- offset: 0x005130
|
||||
size: 124
|
||||
label: _ZN21BirdGatheringSpotAreaC2EPKc
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x0051ac
|
||||
size: 136
|
||||
label: _ZN21BirdGatheringSpotAreaC1EPKc
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x005234
|
||||
size: 68
|
||||
label: _ZN21BirdGatheringSpotArea4initERKN2al12AreaInitInfoE
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x005278
|
||||
size: 152
|
||||
label: _ZN21BirdGatheringSpotArea14updateClippingEPKN2al13ClippingJudgeERKN4sead7Vector3IfEE
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x005310
|
||||
size: 8
|
||||
label: _ZNK21BirdGatheringSpotArea9isClippedEv
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x005318
|
||||
size: 8
|
||||
label: _ZNK21BirdGatheringSpotArea16getSightDistanceEv
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x005320
|
||||
size: 20
|
||||
label: _ZNK21BirdGatheringSpotArea27isGreaterPriorityNotClippedEPKS_
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x005334
|
||||
size: 232
|
||||
label: _ZNK21BirdGatheringSpotArea21calcRandomGroundTransEPN4sead7Vector3IfEE
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x00541c
|
||||
size: 48
|
||||
label:
|
||||
- _ZN21BirdGatheringSpotArea16AreaClippingInfoC1Ev
|
||||
- _ZN21BirdGatheringSpotArea16AreaClippingInfoC2Ev
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x00544c
|
||||
size: 8
|
||||
label: _ZNK2al7AreaObj7getNameEv
|
||||
|
|
|
|||
51
src/Area/BirdGatheringSpotArea.cpp
Normal file
51
src/Area/BirdGatheringSpotArea.cpp
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
#include "Area/BirdGatheringSpotArea.h"
|
||||
|
||||
#include "Library/Area/AreaInitInfo.h"
|
||||
#include "Library/Area/AreaShape.h"
|
||||
#include "Library/Clipping/ClippingJudge.h"
|
||||
#include "Library/Math/MathUtil.h"
|
||||
#include "Library/Placement/PlacementFunction.h"
|
||||
|
||||
BirdGatheringSpotArea::BirdGatheringSpotArea(const char* name) : al::AreaObj(name) {}
|
||||
|
||||
void BirdGatheringSpotArea::init(const al::AreaInitInfo& info) {
|
||||
al::AreaObj::init(info);
|
||||
al::getArg(&mBirdNumMax, *getPlacementInfo(), "BirdNumMax");
|
||||
getAreaShape()->calcLocalBoundingBox(&mClippingInfo.boundingBox);
|
||||
}
|
||||
|
||||
void BirdGatheringSpotArea::updateClipping(const al::ClippingJudge* judge,
|
||||
const sead::Vector3f& pos) {
|
||||
const sead::Matrix34f& mtx = getAreaMtx();
|
||||
|
||||
mClippingInfo.isClipped =
|
||||
judge->isJudgedToClipFrustumObb(&mtx, mClippingInfo.boundingBox, 300.0f, 1);
|
||||
|
||||
if (!mClippingInfo.isClipped)
|
||||
mClippingInfo.sightDistance = (pos - mtx.getTranslation()).length();
|
||||
}
|
||||
|
||||
void BirdGatheringSpotArea::calcRandomGroundTrans(sead::Vector3f* outTrans) const {
|
||||
f32 rx = al::getRandom(-1.0f, 1.0f);
|
||||
f32 rz = al::getRandom(-1.0f, 1.0f);
|
||||
|
||||
const sead::Vector3f& scale = getAreaShape()->getScale();
|
||||
|
||||
sead::Vector3f offset = {rx * scale.x * 500.0f, 0.0f, rz * scale.z * 500.0f};
|
||||
|
||||
outTrans->setMul(getAreaMtx(), offset);
|
||||
}
|
||||
|
||||
bool BirdGatheringSpotArea::isGreaterPriorityNotClipped(const BirdGatheringSpotArea* other) const {
|
||||
return other->getSightDistance() <= getSightDistance();
|
||||
}
|
||||
|
||||
bool BirdGatheringSpotArea::isClipped() const {
|
||||
return mClippingInfo.isClipped;
|
||||
}
|
||||
|
||||
f32 BirdGatheringSpotArea::getSightDistance() const {
|
||||
return mClippingInfo.sightDistance;
|
||||
}
|
||||
|
||||
BirdGatheringSpotArea::AreaClippingInfo::AreaClippingInfo() = default;
|
||||
|
|
@ -1,12 +1,14 @@
|
|||
#pragma once
|
||||
|
||||
#include <math/seadBoundBox.h>
|
||||
#include <math/seadVector.h>
|
||||
|
||||
#include "Library/Area/AreaObj.h"
|
||||
|
||||
namespace al {
|
||||
class AreaInitInfo;
|
||||
class ClippingJudge;
|
||||
}
|
||||
} // namespace al
|
||||
|
||||
class BirdGatheringSpotArea : public al::AreaObj {
|
||||
public:
|
||||
|
|
@ -15,18 +17,17 @@ public:
|
|||
|
||||
bool isClipped = false;
|
||||
f32 sightDistance = 0.0f;
|
||||
sead::BoundBox3f boundingBox = sead::BoundBox3f(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
sead::BoundBox3f boundingBox = {sead::Vector3f::zero, sead::Vector3f::zero};
|
||||
};
|
||||
|
||||
BirdGatheringSpotArea(const char* name);
|
||||
|
||||
void init(const al::AreaInitInfo& info) override;
|
||||
|
||||
void calcRandomGroundTrans(sead::Vector3f* trans) const;
|
||||
f32 getSightDistance() const;
|
||||
void updateClipping(const al::ClippingJudge* judge, const sead::Vector3f& pos);
|
||||
bool isClipped() const;
|
||||
f32 getSightDistance() const;
|
||||
bool isGreaterPriorityNotClipped(const BirdGatheringSpotArea* other) const;
|
||||
void updateClipping(const al::ClippingJudge*, const sead::Vector3f&);
|
||||
void calcRandomGroundTrans(sead::Vector3f* outTrans) const;
|
||||
|
||||
private:
|
||||
s32 mBirdNumMax = 0;
|
||||
|
|
|
|||
Loading…
Reference in a new issue