mirror of https://github.com/zeldaret/botw.git
PlacementMap: Add x_0, x_4(); change u16 mStaticCompoundId to s16 mStaticCompundActorId (#85)
This commit is contained in:
parent
4e21ee7613
commit
c804527d7a
|
@ -73767,9 +73767,9 @@ Address,Quality,Size,Name
|
||||||
0x0000007100d43280,O,000588,_ZN4ksys3map12PlacementMap14cleanupPhysicsEv
|
0x0000007100d43280,O,000588,_ZN4ksys3map12PlacementMap14cleanupPhysicsEv
|
||||||
0x0000007100d434cc,O,000424,_ZN4ksys3map12PlacementMap18loadStaticCompoundEibb
|
0x0000007100d434cc,O,000424,_ZN4ksys3map12PlacementMap18loadStaticCompoundEibb
|
||||||
0x0000007100d43674,O,000400,_ZN4ksys3map12PlacementMap3x_2Ei
|
0x0000007100d43674,O,000400,_ZN4ksys3map12PlacementMap3x_2Ei
|
||||||
0x0000007100d43804,U,000552,PlacementMap::x_0
|
0x0000007100d43804,O,000552,_ZN4ksys3map12PlacementMap26updateObjectCollisionAndIdEiPNS0_6ObjectE
|
||||||
0x0000007100d43a2c,O,000028,_ZN4ksys3map12PlacementMap10unloadHkscEi
|
0x0000007100d43a2c,O,000028,_ZN4ksys3map12PlacementMap10unloadHkscEi
|
||||||
0x0000007100d43a48,U,000620,PlacementMap::x_4
|
0x0000007100d43a48,O,000620,_ZN4ksys3map12PlacementMap26clearStaticCompoundActorIdEi
|
||||||
0x0000007100d43cb4,U,000172,PlacementMap::x_1
|
0x0000007100d43cb4,U,000172,PlacementMap::x_1
|
||||||
0x0000007100d43d60,U,000248,PlacementMap::staticCompoundStuff
|
0x0000007100d43d60,U,000248,PlacementMap::staticCompoundStuff
|
||||||
0x0000007100d43e58,O,000192,_ZN4ksys3map12PlacementMap25doSomethingStaticCompoundEi
|
0x0000007100d43e58,O,000192,_ZN4ksys3map12PlacementMap25doSomethingStaticCompoundEi
|
||||||
|
|
Can't render this file because it is too large.
|
|
@ -61,7 +61,7 @@ void Object::initData(MubinIter* iter, u8 idx, u32 actor_data_idx, ActorData* da
|
||||||
mFlags.makeAllZero();
|
mFlags.makeAllZero();
|
||||||
mIdx = 0;
|
mIdx = 0;
|
||||||
mNumLinksPointingToMe = 0;
|
mNumLinksPointingToMe = 0;
|
||||||
mStaticCompoundId = 0xFFFF;
|
mStaticCompoundActorId = -1;
|
||||||
_18 = nullptr;
|
_18 = nullptr;
|
||||||
_20 = nullptr;
|
_20 = nullptr;
|
||||||
_10 = nullptr;
|
_10 = nullptr;
|
||||||
|
@ -88,7 +88,7 @@ void Object::initData(MubinIter* iter, u8 idx, u32 actor_data_idx, ActorData* da
|
||||||
_10 = nullptr;
|
_10 = nullptr;
|
||||||
_18 = nullptr;
|
_18 = nullptr;
|
||||||
_20 = nullptr;
|
_20 = nullptr;
|
||||||
mStaticCompoundId = 0xFFFF;
|
mStaticCompoundActorId = -1;
|
||||||
mActorDataIdx = actor_data_idx;
|
mActorDataIdx = actor_data_idx;
|
||||||
mProc = nullptr;
|
mProc = nullptr;
|
||||||
mLinkData = nullptr;
|
mLinkData = nullptr;
|
||||||
|
|
|
@ -40,6 +40,7 @@ public:
|
||||||
_100 = 0x100,
|
_100 = 0x100,
|
||||||
ActorCreated = 0x200,
|
ActorCreated = 0x200,
|
||||||
_400 = 0x400,
|
_400 = 0x400,
|
||||||
|
_800 = 0x800,
|
||||||
_2000 = 0x2000,
|
_2000 = 0x2000,
|
||||||
_4000 = 0x4000,
|
_4000 = 0x4000,
|
||||||
_8000 = 0x8000,
|
_8000 = 0x8000,
|
||||||
|
@ -187,7 +188,8 @@ public:
|
||||||
auto getActorDataIdx() const { return mActorDataIdx; }
|
auto getActorDataIdx() const { return mActorDataIdx; }
|
||||||
auto getIdx() const { return mIdx; }
|
auto getIdx() const { return mIdx; }
|
||||||
auto getId() const { return mId; }
|
auto getId() const { return mId; }
|
||||||
auto getStaticCompoundId() const { return mStaticCompoundId; }
|
auto getStaticCompoundActorId() const { return mStaticCompoundActorId; }
|
||||||
|
void setStaticCompoundActorId(s16 id) { mStaticCompoundActorId = id; }
|
||||||
|
|
||||||
const ActorData& getActorData() const {
|
const ActorData& getActorData() const {
|
||||||
return PlacementMgr::instance()->mPlacementActors->mActorData[mActorDataIdx];
|
return PlacementMgr::instance()->mPlacementActors->mActorData[mActorDataIdx];
|
||||||
|
@ -215,7 +217,7 @@ private:
|
||||||
sead::TypedBitFlag<ActorFlag8, u8> mActorFlags8;
|
sead::TypedBitFlag<ActorFlag8, u8> mActorFlags8;
|
||||||
u8 _b = 0xff;
|
u8 _b = 0xff;
|
||||||
u16 mId = 0;
|
u16 mId = 0;
|
||||||
u16 mStaticCompoundId = 0xffff;
|
s16 mStaticCompoundActorId = -1;
|
||||||
void* _10 = nullptr;
|
void* _10 = nullptr;
|
||||||
void* _18 = nullptr;
|
void* _18 = nullptr;
|
||||||
void* _20 = nullptr;
|
void* _20 = nullptr;
|
||||||
|
|
|
@ -40,6 +40,73 @@ PlacementMap::~PlacementMap() {
|
||||||
r.cleanup();
|
r.cleanup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
bool PlacementMap::clearStaticCompoundActorId(int idx) {
|
||||||
|
const auto lock = sead::makeScopedLock(mCs);
|
||||||
|
const auto& resource = mRes[idx].mRes.getResource();
|
||||||
|
if (auto* sc = sead::DynamicCast<phys::StaticCompound>(resource)) {
|
||||||
|
if (sc->calledFromMapDtor()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
mRes[idx].mRes.requestUnload();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = mParsedNumStaticObjs; i <= mNumStaticObjs; i++) {
|
||||||
|
auto* obj = mPa->getStaticObj_2(i);
|
||||||
|
if (getStaticCompoundIdFromPosition(*obj) == idx) {
|
||||||
|
obj->setStaticCompoundActorId(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int gid = mDynamicGroupIdx;
|
||||||
|
if (gid >= 0) {
|
||||||
|
int num_objs = mPa->getNumObjs(gid);
|
||||||
|
for (int i = 0; i < num_objs; i++) {
|
||||||
|
auto* obj = mPa->getObj(gid, i);
|
||||||
|
if (getStaticCompoundIdFromPosition(*obj) == idx) {
|
||||||
|
obj->setStaticCompoundActorId(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PlacementMap::updateObjectCollisionAndId(int index, Object* obj) {
|
||||||
|
if (PlacementMgr::instance()->auto17(obj)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (getStaticCompoundIdFromPosition(*obj) != index) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto& rsrc = mRes[index];
|
||||||
|
obj->setStaticCompoundActorId(-1);
|
||||||
|
|
||||||
|
const auto lock = sead::makeScopedLock(mCs);
|
||||||
|
|
||||||
|
auto* sc = sead::DynamicCast<phys::StaticCompound>(rsrc.mRes.getResource());
|
||||||
|
if (!sc) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
u32 hash_id = obj->getHashId();
|
||||||
|
int srt_hash = 0;
|
||||||
|
obj->getMubinIter().tryGetParamIntByKey(&srt_hash, "SRTHash");
|
||||||
|
int idx = sc->setMapObject(hash_id, static_cast<u32>(srt_hash), obj);
|
||||||
|
obj->setStaticCompoundActorId(idx);
|
||||||
|
if (obj->getStaticCompoundActorId() < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
bool disable = false;
|
||||||
|
if (obj->shouldSkipSpawn() ||
|
||||||
|
(obj->checkActorDataFlag(mPa, map::ActorData::Flag::MapConstPassive) &&
|
||||||
|
obj->getFlags0().isOn(Object::Flag0::_800))) {
|
||||||
|
obj->resetFlags0(Object::Flag0::_200000);
|
||||||
|
disable = false;
|
||||||
|
} else {
|
||||||
|
obj->setFlags0(Object::Flag0::_200000);
|
||||||
|
disable = true;
|
||||||
|
}
|
||||||
|
sc->disableCollision(idx, disable);
|
||||||
|
}
|
||||||
|
|
||||||
bool PlacementMap::parseStaticMap_(sead::Heap* heap, u8* data) {
|
bool PlacementMap::parseStaticMap_(sead::Heap* heap, u8* data) {
|
||||||
if (!mMubinPath.isEmpty()) {
|
if (!mMubinPath.isEmpty()) {
|
||||||
if (!mSkipLoadStaticMap) {
|
if (!mSkipLoadStaticMap) {
|
||||||
|
@ -52,14 +119,25 @@ bool PlacementMap::parseStaticMap_(sead::Heap* heap, u8* data) {
|
||||||
mStaticMapLoaded = true;
|
mStaticMapLoaded = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
int PlacementMap::getStaticCompoundIdFromPosition(const Object& object) const {
|
||||||
|
if (mMgr->isShrineOrDivineBeast()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return getStaticCompoundIdFromPosition(object.getTranslate().x, object.getTranslate().z);
|
||||||
|
}
|
||||||
|
int PlacementMap::getStaticCompoundIdFromPosition(float x, float z) const {
|
||||||
|
if (mMgr->isShrineOrDivineBeast()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return getStaticCompoundIdFromPosition(sead::Vector3f(x, 0, z));
|
||||||
|
}
|
||||||
int PlacementMap::getStaticCompoundIdFromPosition(const sead::Vector3f& pos) const {
|
int PlacementMap::getStaticCompoundIdFromPosition(const sead::Vector3f& pos) const {
|
||||||
if (mMgr->isShrineOrDivineBeast()) {
|
if (mMgr->isShrineOrDivineBeast()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
float dx = (pos.x - (1000 * mCol - 5000));
|
float dx = (pos.x - (1000 * mCol - 5000));
|
||||||
float dz = (pos.z - (1000 * mRow - 4000));
|
float dz = (pos.z - (1000 * mRow - 4000));
|
||||||
return (2 * (dz > 500.0)) + (dx > 500.0);
|
return (2 * (dz > 500.0f)) + (dx > 500.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlacementMap::isDynamicLoaded(const sead::Vector3f& pos) {
|
bool PlacementMap::isDynamicLoaded(const sead::Vector3f& pos) {
|
||||||
|
@ -144,20 +222,20 @@ PlacementMap::MapObjStatus PlacementMap::x_2(int hksc_idx) {
|
||||||
|
|
||||||
sc->sub_7100FCAD0C(mMat);
|
sc->sub_7100FCAD0C(mMat);
|
||||||
for (int i = mParsedNumStaticObjs; i <= mNumStaticObjs; i++) {
|
for (int i = mParsedNumStaticObjs; i <= mNumStaticObjs; i++) {
|
||||||
x_0(hksc_idx, mPa->getStaticObj_0(i));
|
updateObjectCollisionAndId(hksc_idx, mPa->getStaticObj_0(i));
|
||||||
}
|
}
|
||||||
const int gid = mDynamicGroupIdx;
|
const int gid = mDynamicGroupIdx;
|
||||||
if (gid >= 0) {
|
if (gid >= 0) {
|
||||||
int n = mPa->getNumObjs(gid);
|
int n = mPa->getNumObjs(gid);
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
x_0(hksc_idx, mPa->getObj(gid, i));
|
updateObjectCollisionAndId(hksc_idx, mPa->getObj(gid, i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return MapObjStatus::Loading;
|
return MapObjStatus::Loading;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlacementMap::doDisableObjStaticCompound(Object* obj, bool disable) {
|
void PlacementMap::doDisableObjStaticCompound(Object* obj, bool disable) {
|
||||||
if ((s16)obj->getStaticCompoundId() < 0) {
|
if ((s16)obj->getStaticCompoundActorId() < 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto lock = sead::makeScopedLock(mCs);
|
const auto lock = sead::makeScopedLock(mCs);
|
||||||
|
@ -175,7 +253,7 @@ void PlacementMap::doDisableObjStaticCompound(Object* obj, bool disable) {
|
||||||
int idx = getStaticCompoundIdFromPosition(obj->getTranslate());
|
int idx = getStaticCompoundIdFromPosition(obj->getTranslate());
|
||||||
auto* resource = mRes[idx].mRes.getResource();
|
auto* resource = mRes[idx].mRes.getResource();
|
||||||
if (auto* sc = sead::DynamicCast<ksys::phys::StaticCompound>(resource)) {
|
if (auto* sc = sead::DynamicCast<ksys::phys::StaticCompound>(resource)) {
|
||||||
s16 sc_id = obj->getStaticCompoundId();
|
s16 sc_id = obj->getStaticCompoundActorId();
|
||||||
sc->disableCollision(sc_id, disable);
|
sc->disableCollision(sc_id, disable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,9 +92,9 @@ private:
|
||||||
void cleanupPhysics();
|
void cleanupPhysics();
|
||||||
bool loadStaticCompound(int hksc_idx, bool is_auto_gen_mu, bool req_arg_8);
|
bool loadStaticCompound(int hksc_idx, bool is_auto_gen_mu, bool req_arg_8);
|
||||||
MapObjStatus x_2(int hksc_idx);
|
MapObjStatus x_2(int hksc_idx);
|
||||||
void x_0(int id, Object* obj);
|
void updateObjectCollisionAndId(int id, Object* obj);
|
||||||
void unloadHksc(int hksc_idx);
|
void unloadHksc(int hksc_idx);
|
||||||
int x_4(int id);
|
bool clearStaticCompoundActorId(int id);
|
||||||
int x_1(int id);
|
int x_1(int id);
|
||||||
bool staticCompoundStuff(int sc_id, bool cleanup);
|
bool staticCompoundStuff(int sc_id, bool cleanup);
|
||||||
int doSomethingStaticCompound(int hksc_idx);
|
int doSomethingStaticCompound(int hksc_idx);
|
||||||
|
@ -106,6 +106,8 @@ private:
|
||||||
const sead::SafeString& folder_and_file, int map_id_maybe, bool skip_load_static_map);
|
const sead::SafeString& folder_and_file, int map_id_maybe, bool skip_load_static_map);
|
||||||
|
|
||||||
int getStaticCompoundIdFromPosition(const sead::Vector3f& pos) const;
|
int getStaticCompoundIdFromPosition(const sead::Vector3f& pos) const;
|
||||||
|
int getStaticCompoundIdFromPosition(float x, float z) const;
|
||||||
|
int getStaticCompoundIdFromPosition(const Object& object) const;
|
||||||
|
|
||||||
u8 _0;
|
u8 _0;
|
||||||
u8 mSkipLoadStaticMap;
|
u8 mSkipLoadStaticMap;
|
||||||
|
|
|
@ -55,6 +55,8 @@ public:
|
||||||
bool someFlagCheck() const;
|
bool someFlagCheck() const;
|
||||||
|
|
||||||
void threadFn(sead::Thread* thread, sead::MessageQueue::Element msg);
|
void threadFn(sead::Thread* thread, sead::MessageQueue::Element msg);
|
||||||
|
// 0x00000071011eb4dc
|
||||||
|
bool auto17(Object* obj);
|
||||||
|
|
||||||
enum class MgrFlag {
|
enum class MgrFlag {
|
||||||
_1 = 0x1,
|
_1 = 0x1,
|
||||||
|
|
|
@ -62,11 +62,11 @@ void StaticCompound::doCreate_(u8* buffer, u32 buffer_size, sead::Heap* parent_h
|
||||||
mHeap->adjust();
|
mHeap->adjust();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StaticCompound::setMapObject(u32 hash_id, u32 srt_hash, map::Object* object) {
|
int StaticCompound::setMapObject(u32 hash_id, u32 srt_hash, map::Object* object) {
|
||||||
int idx = mStaticCompoundInfo->getActorIdx(hash_id, srt_hash);
|
int idx = mStaticCompoundInfo->getActorIdx(hash_id, srt_hash);
|
||||||
if (idx < 0 || idx >= mMapObjects.size())
|
if (idx >= 0 && idx < mMapObjects.size())
|
||||||
return;
|
mMapObjects[idx] = object;
|
||||||
mMapObjects[idx] = object;
|
return idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
map::Object* StaticCompound::getMapObject(int shape_idx) const {
|
map::Object* StaticCompound::getMapObject(int shape_idx) const {
|
||||||
|
|
|
@ -27,7 +27,7 @@ public:
|
||||||
StaticCompound();
|
StaticCompound();
|
||||||
~StaticCompound() override;
|
~StaticCompound() override;
|
||||||
|
|
||||||
void setMapObject(u32 hash_id, u32 srt_hash, map::Object* object);
|
int setMapObject(u32 hash_id, u32 srt_hash, map::Object* object);
|
||||||
map::Object* getMapObject(int shape_idx) const;
|
map::Object* getMapObject(int shape_idx) const;
|
||||||
|
|
||||||
bool disableCollision(int actor_idx, bool x);
|
bool disableCollision(int actor_idx, bool x);
|
||||||
|
|
Loading…
Reference in New Issue