mirror of
https://github.com/MonsterDruide1/OdysseyDecomp
synced 2026-04-23 09:04:21 +00:00
Project/Gravity: Implement GravityPoint (#769)
This commit is contained in:
parent
d894dc77b8
commit
bd0216bf28
|
|
@ -293124,20 +293124,22 @@ Project/Gravity/GravityHolder.o:
|
|||
size: 424
|
||||
label: _ZNK2al13GravityHolder19tryCalcBlendGravityEPN4sead7Vector3IfEERKS3_
|
||||
status: NotDecompiled
|
||||
Project/Gravity/GravityPoint.o:
|
||||
'.text':
|
||||
- offset: 0xa604ec
|
||||
size: 32
|
||||
label:
|
||||
- _ZN2al12GravityPointC1Ev
|
||||
- _ZN2al12GravityPointC2Ev
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0xa6050c
|
||||
size: 100
|
||||
label: _ZN2al12GravityPoint21initWithPlacementInfoERKNS_13PlacementInfoE
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0xa60570
|
||||
size: 180
|
||||
label: _ZNK2al12GravityPoint14tryCalcGravityEPN4sead7Vector3IfEERKS3_
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
Project/HitSensor/HitSensor.o:
|
||||
'.text':
|
||||
- offset: 0xa60624
|
||||
|
|
|
|||
26
lib/al/Project/Gravity/GravityPoint.cpp
Normal file
26
lib/al/Project/Gravity/GravityPoint.cpp
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#include "Project/Gravity/GravityPoint.h"
|
||||
|
||||
#include "Library/Math/MathUtil.h"
|
||||
#include "Library/Placement/PlacementFunction.h"
|
||||
|
||||
namespace al {
|
||||
|
||||
GravityPoint::GravityPoint() = default;
|
||||
|
||||
void GravityPoint::initWithPlacementInfo(const PlacementInfo& info) {
|
||||
tryGetTrans(&mTrans, info);
|
||||
sead::Vector3f scale = sead::Vector3f::zero;
|
||||
tryGetScale(&scale, info);
|
||||
mRadius = scale.x * 50.0f;
|
||||
}
|
||||
|
||||
bool GravityPoint::tryCalcGravity(sead::Vector3f* gravity, const sead::Vector3f& position) const {
|
||||
if ((mTrans - position).length() <= mRadius) {
|
||||
*gravity = (mTrans - position);
|
||||
tryNormalizeOrDirZ(gravity);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace al
|
||||
22
lib/al/Project/Gravity/GravityPoint.h
Normal file
22
lib/al/Project/Gravity/GravityPoint.h
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#pragma once
|
||||
|
||||
#include <math/seadVector.h>
|
||||
|
||||
namespace al {
|
||||
class PlacementInfo;
|
||||
|
||||
class GravityPoint {
|
||||
public:
|
||||
GravityPoint();
|
||||
|
||||
void initWithPlacementInfo(const PlacementInfo& info);
|
||||
bool tryCalcGravity(sead::Vector3f* gravity, const sead::Vector3f& position) const;
|
||||
|
||||
private:
|
||||
sead::Vector3f mTrans = sead::Vector3f::zero;
|
||||
f32 mRadius = 0.0f;
|
||||
};
|
||||
|
||||
static_assert(sizeof(GravityPoint) == 0x10);
|
||||
|
||||
} // namespace al
|
||||
Loading…
Reference in a new issue