mirror of https://github.com/zeldaret/botw.git
ksys/phys: Finish LayerContactPointInfo
Clean up the iterator stuff and fix some inaccuracies.
This commit is contained in:
parent
ba2d81b7b8
commit
631a0ab388
|
|
@ -84328,10 +84328,10 @@ Address,Quality,Size,Name
|
|||
0x0000007100fcfadc,O,000004,_ZN4ksys4phys21LayerContactPointInfoD0Ev
|
||||
0x0000007100fcfae0,O,000300,_ZN4ksys4phys21LayerContactPointInfo11allocPointsEPN4sead4HeapEii
|
||||
0x0000007100fcfc0c,O,000168,_ZN4ksys4phys21LayerContactPointInfo10freePointsEv
|
||||
0x0000007100fcfcb4,O,000260,_ZNK4ksys4phys21LayerContactPointInfo8Iterator7getDataEPN4sead7Vector3IfEENS2_4ModeE
|
||||
0x0000007100fcfdb8,O,000048,_ZNK4ksys4phys21LayerContactPointInfo8Iterator7getDataENS2_4ModeE
|
||||
0x0000007100fcfcb4,O,000260,_ZNK4ksys4phys21LayerContactPointInfo8Iterator16getPointPositionEPN4sead7Vector3IfEENS2_5PointE
|
||||
0x0000007100fcfdb8,O,000048,_ZNK4ksys4phys21LayerContactPointInfo8Iterator16getPointPositionENS2_5PointE
|
||||
0x0000007100fcfde8,O,000068,_ZN4ksys4phys21LayerContactPointInfo8IteratorC1ERKN4sead6BufferIPNS0_12ContactPointEEEi
|
||||
0x0000007100fcfe2c,O,000028,_ZN4ksys4phys21LayerContactPointInfo11IteratorEndC1ERKN4sead6BufferIPNS0_12ContactPointEEEi
|
||||
0x0000007100fcfe2c,O,000028,_ZN4ksys4phys21LayerContactPointInfo8IteratorC1ERKN4sead6BufferIPNS0_12ContactPointEEEiNS2_5IsEndE
|
||||
0x0000007100fcfe48,U,000112,
|
||||
0x0000007100fcfeb8,U,000072,
|
||||
0x0000007100fcff00,U,000692,
|
||||
|
|
|
|||
|
Can't render this file because it is too large.
|
|
|
@ -149,8 +149,8 @@ bool ContactMgr::registerContactPoint(ContactPointInfo* info, const ContactPoint
|
|||
auto& point_in_pool = mContactPointPool[pool_index];
|
||||
point_in_pool = point;
|
||||
|
||||
if (info->mContactPointIndex < info->mPoints.size() || info->_2c >= 2) {
|
||||
int index = info->mContactPointIndex.increment();
|
||||
if (info->mNumContactPoints < info->mPoints.size() || info->_2c >= 2) {
|
||||
int index = info->mNumContactPoints.increment();
|
||||
info->mPoints[index] = &point_in_pool;
|
||||
info->mPoints[index]->flags.makeAllZero();
|
||||
info->mPoints[index]->flags.change(ContactPoint::Flag::Penetrating, penetrating);
|
||||
|
|
@ -169,8 +169,8 @@ void ContactMgr::registerContactPoint(LayerContactPointInfo* info, const Contact
|
|||
auto& point_in_pool = mContactPointPool[pool_index];
|
||||
point_in_pool = point;
|
||||
|
||||
if (info->mContactPointIndex < info->mPoints.size()) {
|
||||
int index = info->mContactPointIndex.increment();
|
||||
if (info->mNumContactPoints < info->mPoints.size()) {
|
||||
int index = info->mNumContactPoints.increment();
|
||||
info->mPoints[index] = &point_in_pool;
|
||||
info->mPoints[index]->flags.makeAllZero();
|
||||
info->mPoints[index]->flags.change(ContactPoint::Flag::Penetrating, penetrating);
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ public:
|
|||
protected:
|
||||
friend class ContactMgr;
|
||||
|
||||
sead::Atomic<int> mContactPointIndex;
|
||||
sead::Atomic<int> mNumContactPoints;
|
||||
sead::SafeArray<sead::BitFlag32, 2> mSubscribedLayers;
|
||||
// TODO: rename
|
||||
sead::SafeArray<sead::BitFlag32, 2> mLayerMask2;
|
||||
|
|
|
|||
|
|
@ -60,27 +60,26 @@ void LayerContactPointInfo::freePoints() {
|
|||
mLayerEntries.freeBuffer();
|
||||
}
|
||||
|
||||
void LayerContactPointInfo::Iterator::getData(sead::Vector3f* out,
|
||||
LayerContactPointInfo::Iterator::Mode mode) const {
|
||||
void LayerContactPointInfo::Iterator::getPointPosition(sead::Vector3f* out, Point point) const {
|
||||
const float separating_distance = getPoint()->separating_distance;
|
||||
out->e = getPoint()->position.e;
|
||||
|
||||
switch (mode) {
|
||||
case Mode::_0: {
|
||||
switch (point) {
|
||||
case Point::BodyA: {
|
||||
if (getPoint()->flags.isOn(ContactPoint::Flag::Penetrating))
|
||||
return;
|
||||
*out += getPoint()->separating_normal * -separating_distance;
|
||||
break;
|
||||
}
|
||||
|
||||
case Mode::_1: {
|
||||
case Point::BodyB: {
|
||||
if (!getPoint()->flags.isOn(ContactPoint::Flag::Penetrating))
|
||||
return;
|
||||
*out += getPoint()->separating_normal * separating_distance;
|
||||
break;
|
||||
}
|
||||
|
||||
case Mode::_2:
|
||||
case Point::Midpoint:
|
||||
default: {
|
||||
*out += getPoint()->separating_normal * separating_distance * 0.5f;
|
||||
break;
|
||||
|
|
@ -88,10 +87,9 @@ void LayerContactPointInfo::Iterator::getData(sead::Vector3f* out,
|
|||
}
|
||||
}
|
||||
|
||||
sead::Vector3f
|
||||
LayerContactPointInfo::Iterator::getData(LayerContactPointInfo::Iterator::Mode mode) const {
|
||||
sead::Vector3f LayerContactPointInfo::Iterator::getPointPosition(Point point) const {
|
||||
sead::Vector3f out;
|
||||
getData(&out, mode);
|
||||
getPointPosition(&out, point);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
|
@ -104,8 +102,8 @@ LayerContactPointInfo::Iterator::Iterator(const LayerContactPointInfo::Points& p
|
|||
}
|
||||
}
|
||||
|
||||
LayerContactPointInfo::IteratorEnd::IteratorEnd(const LayerContactPointInfo::Points& points,
|
||||
int count)
|
||||
LayerContactPointInfo::Iterator::Iterator(const LayerContactPointInfo::Points& points, int count,
|
||||
IsEnd is_end)
|
||||
: mIdx(count), mPoints(points.getBufferPtr()), mPointsNum(count),
|
||||
mPointsStart(points.getBufferPtr()) {}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,26 +22,26 @@ public:
|
|||
bool enabled;
|
||||
};
|
||||
|
||||
class IteratorEnd;
|
||||
|
||||
class Iterator {
|
||||
public:
|
||||
enum class Mode {
|
||||
_0,
|
||||
_1,
|
||||
_2,
|
||||
enum class IsEnd : bool { Yes = true };
|
||||
|
||||
enum class Point {
|
||||
BodyA,
|
||||
BodyB,
|
||||
Midpoint,
|
||||
};
|
||||
|
||||
Iterator(const Points& points, int count);
|
||||
Iterator(const Points& points, int count, IsEnd is_end);
|
||||
|
||||
Iterator& operator++() {
|
||||
++mIdx;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// FIXME: rename
|
||||
void getData(sead::Vector3f* out, Mode mode) const;
|
||||
sead::Vector3f getData(Mode mode) const;
|
||||
void getPointPosition(sead::Vector3f* out, Point point) const;
|
||||
sead::Vector3f getPointPosition(Point point) const;
|
||||
|
||||
const ContactPoint* getPoint() const { return mPoints[mIdx]; }
|
||||
const ContactPoint* operator*() const { return getPoint(); }
|
||||
|
|
@ -53,32 +53,6 @@ public:
|
|||
return !operator==(lhs, rhs);
|
||||
}
|
||||
|
||||
private:
|
||||
friend class IteratorEnd;
|
||||
|
||||
int mIdx = 0;
|
||||
const ContactPoint* const* mPoints = nullptr;
|
||||
int mPointsNum = 0;
|
||||
const ContactPoint* const* mPointsStart = nullptr;
|
||||
};
|
||||
|
||||
class IteratorEnd {
|
||||
public:
|
||||
IteratorEnd(const Points& points, int count);
|
||||
|
||||
friend bool operator==(const Iterator& lhs, const IteratorEnd& rhs) {
|
||||
return lhs.mIdx == rhs.mIdx;
|
||||
}
|
||||
friend bool operator==(const IteratorEnd& lhs, const Iterator& rhs) {
|
||||
return lhs.mIdx == rhs.mIdx;
|
||||
}
|
||||
friend bool operator!=(const Iterator& lhs, const IteratorEnd& rhs) {
|
||||
return !operator==(lhs, rhs);
|
||||
}
|
||||
friend bool operator!=(const IteratorEnd& lhs, const Iterator& rhs) {
|
||||
return !operator==(lhs, rhs);
|
||||
}
|
||||
|
||||
private:
|
||||
int mIdx = 0;
|
||||
const ContactPoint* const* mPoints = nullptr;
|
||||
|
|
@ -113,8 +87,8 @@ public:
|
|||
ContactCallback* getCallback() const { return mCallback; }
|
||||
void setCallback(ContactCallback* callback) { mCallback = callback; }
|
||||
|
||||
auto begin() const { return Iterator(mPoints, mContactPointIndex); }
|
||||
auto end() const { return IteratorEnd(mPoints, mContactPointIndex); }
|
||||
auto begin() const { return Iterator(mPoints, mNumContactPoints); }
|
||||
auto end() const { return Iterator(mPoints, mNumContactPoints, Iterator::IsEnd::Yes); }
|
||||
|
||||
sead::ObjArray<LayerEntry>& getLayerEntries() { return mLayerEntries; }
|
||||
const sead::ObjArray<LayerEntry>& getLayerEntries() const { return mLayerEntries; }
|
||||
|
|
|
|||
Loading…
Reference in New Issue