mirror of
https://github.com/MonsterDruide1/OdysseyDecomp
synced 2026-04-23 09:04:21 +00:00
Library/Light: Implement DirectionParam (#854)
This commit is contained in:
parent
cf81af3458
commit
9346090dc8
|
|
@ -215963,12 +215963,12 @@ Util/YoshiUtil.o:
|
|||
- offset: 0x7c05b4
|
||||
size: 20
|
||||
label: _ZN3agl3utl12ParameterObjD2Ev
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
lazy: true
|
||||
- offset: 0x7c05c8
|
||||
size: 4
|
||||
label: _ZN3agl3utl12ParameterObjD0Ev
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
lazy: true
|
||||
- offset: 0x7c05cc
|
||||
size: 20
|
||||
|
|
@ -240543,37 +240543,37 @@ Library/Fluid/RippleTextureController.o:
|
|||
- offset: 0x8a1560
|
||||
size: 8
|
||||
label: _ZNK2al12ParameterV2f15getParamTypeStrEv
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
lazy: true
|
||||
- offset: 0x8a1568
|
||||
size: 8
|
||||
label: _ZNK2al12ParameterV2f12getParamTypeEv
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
lazy: true
|
||||
- offset: 0x8a1570
|
||||
size: 8
|
||||
label: _ZNK2al9ParameterIN4sead7Vector2IfEEE3ptrEv
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
lazy: true
|
||||
- offset: 0x8a1578
|
||||
size: 8
|
||||
label: _ZN2al9ParameterIN4sead7Vector2IfEEE3ptrEv
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
lazy: true
|
||||
- offset: 0x8a1580
|
||||
size: 8
|
||||
label: _ZNK2al9ParameterIN4sead7Vector2IfEEE4sizeEv
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
lazy: true
|
||||
- offset: 0x8a1588
|
||||
size: 8
|
||||
label: _ZNK2al9ParameterIN4sead7Vector2IfEEE15getParamTypeStrEv
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
lazy: true
|
||||
- offset: 0x8a1590
|
||||
size: 8
|
||||
label: _ZNK2al9ParameterIN4sead7Vector2IfEEE12getParamTypeEv
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
lazy: true
|
||||
Library/Fluid/RippleTextureKeeper.o:
|
||||
'.text':
|
||||
|
|
@ -244139,67 +244139,67 @@ Library/Light/DirectionParam.o:
|
|||
- offset: 0x8bd58c
|
||||
size: 452
|
||||
label: _ZN2al14DirectionParam9initByArgERKNS_13ActorInitInfoE
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x8bd750
|
||||
size: 224
|
||||
label: _ZN2al14DirectionParam15syncToDirectionEv
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x8bd830
|
||||
size: 360
|
||||
label: _ZN2al14DirectionParam13initializeDirEPN3agl3utl12ParameterObjEPKcS6_
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x8bd998
|
||||
size: 212
|
||||
label: _ZN2al14DirectionParam13initializeDirERKN4sead7Vector3IfEEPN3agl3utl12ParameterObjEPKcSB_
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x8bda6c
|
||||
size: 20
|
||||
label: _ZN2al14DirectionParam17syncFromDirectionERKN4sead7Vector3IfEE
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x8bda80
|
||||
size: 508
|
||||
label: _ZN2al14DirectionParam13initializeDirEPNS_12ParameterObjEPKcS4_
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x8bdc7c
|
||||
size: 380
|
||||
label: _ZN2al14DirectionParam13initializeDirERKN4sead7Vector3IfEEPNS_12ParameterObjEPKcS9_
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x8bddf8
|
||||
size: 40
|
||||
label: _ZNK2al14DirectionParam18getLongitudeRadianEv
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x8bde20
|
||||
size: 40
|
||||
label: _ZNK2al14DirectionParam17getLatitudeRadianEv
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x8bde48
|
||||
size: 36
|
||||
label: _ZN2al14DirectionParam21getLongitudeRadianPtrEv
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x8bde6c
|
||||
size: 36
|
||||
label: _ZN2al14DirectionParam20getLatitudeRadianPtrEv
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x8bde90
|
||||
size: 32
|
||||
label: _ZN2al14DirectionParam18setLongitudeRadianEf
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x8bdeb0
|
||||
size: 32
|
||||
label: _ZN2al14DirectionParam17setLatitudeRadianEf
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x8bded0
|
||||
size: 284
|
||||
label: _ZN2al14DirectionParam17syncFromDirectionEv
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x8bdfec
|
||||
size: 296
|
||||
label: _ZN2al14DirectionParam17syncFromRPYDegreeERKN4sead7Vector3IfEE
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x8be114
|
||||
size: 92
|
||||
label: _ZN2al14DirectionParam4lerpERKS0_S2_f
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x8be170
|
||||
size: 696
|
||||
label: _ZN2al10PlaneParam10initializeERKN4sead7Vector3IfEEPNS_12ParameterObjEPKc
|
||||
|
|
|
|||
148
lib/al/Library/Light/DirectionParam.cpp
Normal file
148
lib/al/Library/Light/DirectionParam.cpp
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
#include "Library/Light/DirectionParam.h"
|
||||
|
||||
#include <math/seadQuat.h>
|
||||
#include <utility/aglParameter.h>
|
||||
#include <utility/aglParameterObj.h>
|
||||
|
||||
#include "Library/Math/MathUtil.h"
|
||||
#include "Library/Placement/PlacementFunction.h"
|
||||
#include "Library/Yaml/ParameterBase.h"
|
||||
#include "Library/Yaml/ParameterObj.h"
|
||||
|
||||
namespace al {
|
||||
|
||||
void DirectionParam::initByArg(const ActorInitInfo& initInfo) {
|
||||
f32 longitudeDegree = 0.0f;
|
||||
f32 latitudeDegree = 0.0f;
|
||||
tryGetArg(&longitudeDegree, initInfo, "DirectionParamLongitudeDegree");
|
||||
tryGetArg(&latitudeDegree, initInfo, "DirectionParamLatitudeDegree");
|
||||
|
||||
sead::Vector2f coordinate = {sead::Mathf::deg2rad(longitudeDegree),
|
||||
sead::Mathf::deg2rad(latitudeDegree)};
|
||||
mAglCoordinate = new agl::utl::Parameter<sead::Vector2f>(
|
||||
coordinate, "PlacementArg", "配置情報からのパラメータ", new agl::utl::ParameterObj);
|
||||
syncToDirection();
|
||||
}
|
||||
|
||||
void DirectionParam::syncToDirection() {
|
||||
mDirection.y = -sead::Mathf::sin(getLatitudeRadian());
|
||||
f32 rho = -sead::Mathf::cos(getLatitudeRadian());
|
||||
|
||||
mDirection.x = sead::Mathf::sin(getLongitudeRadian()) * rho;
|
||||
mDirection.z = sead::Mathf::cos(getLongitudeRadian()) * rho;
|
||||
}
|
||||
|
||||
void DirectionParam::initializeDir(agl::utl::ParameterObj* parameterObj, const char* name,
|
||||
const char* label) {
|
||||
mAglCoordinate =
|
||||
new agl::utl::Parameter<sead::Vector2f>(sead::Vector2f::zero, name, label, parameterObj);
|
||||
syncToDirection();
|
||||
}
|
||||
|
||||
void DirectionParam::initializeDir(const sead::Vector3f& direction,
|
||||
agl::utl::ParameterObj* parameterObj, const char* name,
|
||||
const char* label) {
|
||||
mAglCoordinate =
|
||||
new agl::utl::Parameter<sead::Vector2f>(sead::Vector2f::zero, name, label, parameterObj);
|
||||
syncFromDirection(direction);
|
||||
}
|
||||
|
||||
void DirectionParam::syncFromDirection(const sead::Vector3f& direction) {
|
||||
mDirection.set(direction);
|
||||
syncFromDirection();
|
||||
}
|
||||
|
||||
void DirectionParam::initializeDir(ParameterObj* parameterObj, const char* name,
|
||||
const char* label) {
|
||||
mAlCoordinate = new ParameterV2f(sead::Vector2f::zero, name, label, "", parameterObj, true);
|
||||
syncToDirection();
|
||||
}
|
||||
|
||||
void DirectionParam::initializeDir(const sead::Vector3f& direction, ParameterObj* parameterObj,
|
||||
const char* name, const char* label) {
|
||||
mAlCoordinate = new ParameterV2f(sead::Vector2f::zero, name, label, "", parameterObj, true);
|
||||
syncFromDirection(direction);
|
||||
}
|
||||
|
||||
f32 DirectionParam::getLongitudeRadian() const {
|
||||
if (mAlCoordinate)
|
||||
return (*mAlCoordinate)->x;
|
||||
if (mAglCoordinate)
|
||||
return (*mAglCoordinate)->x;
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
f32 DirectionParam::getLatitudeRadian() const {
|
||||
if (mAlCoordinate)
|
||||
return (*mAlCoordinate)->y;
|
||||
if (mAglCoordinate)
|
||||
return (*mAglCoordinate)->y;
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
f32* DirectionParam::getLongitudeRadianPtr() {
|
||||
if (mAlCoordinate)
|
||||
return &(*mAlCoordinate)->x;
|
||||
if (mAglCoordinate)
|
||||
return &(*mAglCoordinate)->x;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
f32* DirectionParam::getLatitudeRadianPtr() {
|
||||
if (mAlCoordinate)
|
||||
return &(*mAlCoordinate)->y;
|
||||
if (mAglCoordinate)
|
||||
return &(*mAglCoordinate)->y;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void DirectionParam::setLongitudeRadian(f32 radian) {
|
||||
if (mAlCoordinate)
|
||||
(*mAlCoordinate)->x = radian;
|
||||
else if (mAglCoordinate)
|
||||
(*mAglCoordinate)->x = radian;
|
||||
}
|
||||
|
||||
void DirectionParam::setLatitudeRadian(f32 radian) {
|
||||
if (mAlCoordinate)
|
||||
(*mAlCoordinate)->y = radian;
|
||||
else if (mAglCoordinate)
|
||||
(*mAglCoordinate)->y = radian;
|
||||
}
|
||||
|
||||
void DirectionParam::syncFromDirection() {
|
||||
sead::Vector3f direction = mDirection;
|
||||
if (!(direction.normalize() > 0.0f))
|
||||
return;
|
||||
|
||||
f32 length = sead::Mathf::sqrt(direction.z * direction.z + direction.x * direction.x);
|
||||
|
||||
if (length > 0.0f) {
|
||||
f32 inv = 1.0f / length;
|
||||
f32 x = -direction.z * inv;
|
||||
f32 y = -direction.x * inv;
|
||||
setLongitudeRadian(sead::Mathf::atan2(y, x));
|
||||
}
|
||||
|
||||
setLatitudeRadian(sead::Mathf::asin(sead::Mathf::clamp(-direction.y, -1.0f, 1.0f)));
|
||||
}
|
||||
|
||||
void DirectionParam::syncFromRPYDegree(const sead::Vector3f& degreeRPY) {
|
||||
sead::Quatf quat;
|
||||
quat.setRPY(sead::Mathf::deg2rad(degreeRPY.x), sead::Mathf::deg2rad(degreeRPY.y),
|
||||
sead::Mathf::deg2rad(degreeRPY.z));
|
||||
|
||||
sead::Vector3f direction;
|
||||
calcQuatUp(&direction, quat);
|
||||
syncFromDirection(-direction);
|
||||
}
|
||||
|
||||
void DirectionParam::lerp(const DirectionParam& startDirection, const DirectionParam& endDirection,
|
||||
f32 rate) {
|
||||
lerpVec(&mDirection, startDirection.getDirection(), endDirection.getDirection(), rate);
|
||||
if (!tryNormalizeOrZero(&mDirection))
|
||||
mDirection.set(endDirection.getDirection());
|
||||
syncFromDirection();
|
||||
}
|
||||
|
||||
} // namespace al
|
||||
50
lib/al/Library/Light/DirectionParam.h
Normal file
50
lib/al/Library/Light/DirectionParam.h
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
#pragma once
|
||||
|
||||
#include <basis/seadTypes.h>
|
||||
#include <math/seadVector.h>
|
||||
|
||||
namespace agl::utl {
|
||||
template <typename T>
|
||||
class Parameter;
|
||||
class ParameterObj;
|
||||
} // namespace agl::utl
|
||||
|
||||
namespace al {
|
||||
class ActorInitInfo;
|
||||
class ParameterObj;
|
||||
class ParameterV2f;
|
||||
|
||||
class DirectionParam {
|
||||
public:
|
||||
DirectionParam() = default;
|
||||
|
||||
void initByArg(const ActorInitInfo& initInfo);
|
||||
void syncToDirection();
|
||||
void initializeDir(agl::utl::ParameterObj* parameterObj, const char* name, const char* label);
|
||||
void initializeDir(const sead::Vector3f& direction, agl::utl::ParameterObj* parameterObj,
|
||||
const char* name, const char* label);
|
||||
void syncFromDirection(const sead::Vector3f& direction);
|
||||
void initializeDir(ParameterObj* parameterObj, const char* name, const char* label);
|
||||
void initializeDir(const sead::Vector3f& direction, ParameterObj* parameterObj,
|
||||
const char* name, const char* label);
|
||||
f32 getLongitudeRadian() const;
|
||||
f32 getLatitudeRadian() const;
|
||||
f32* getLongitudeRadianPtr();
|
||||
f32* getLatitudeRadianPtr();
|
||||
void setLongitudeRadian(f32 radian);
|
||||
void setLatitudeRadian(f32 radian);
|
||||
void syncFromDirection();
|
||||
void syncFromRPYDegree(const sead::Vector3f& degreeRPY);
|
||||
void lerp(const DirectionParam& startDirection, const DirectionParam& endDirection, f32 rate);
|
||||
|
||||
const sead::Vector3f& getDirection() const { return mDirection; }
|
||||
|
||||
private:
|
||||
agl::utl::Parameter<sead::Vector2f>* mAglCoordinate = nullptr;
|
||||
ParameterV2f* mAlCoordinate = nullptr;
|
||||
sead::Vector3f mDirection = -sead::Vector3f::ey;
|
||||
};
|
||||
|
||||
static_assert(sizeof(DirectionParam) == 0x20);
|
||||
|
||||
} // namespace al
|
||||
|
|
@ -42,10 +42,20 @@ SEAD_ENUM(YamlParamType,
|
|||
const sead::SafeString& meta, ParameterObj* obj, bool e) \
|
||||
: Parameter(name, label, meta, obj, e) {} \
|
||||
\
|
||||
Parameter##Name(const Type& value, const sead::SafeString& name, \
|
||||
const sead::SafeString& label, const sead::SafeString& meta, \
|
||||
ParameterObj* obj, bool e) \
|
||||
: Parameter(value, name, label, meta, obj, e) {} \
|
||||
\
|
||||
Parameter##Name(const sead::SafeString& name, const sead::SafeString& label, \
|
||||
const sead::SafeString& meta, ParameterList* list, bool e) \
|
||||
: Parameter(name, label, meta, list, e) {} \
|
||||
\
|
||||
Parameter##Name(const Type& value, const sead::SafeString& name, \
|
||||
const sead::SafeString& label, const sead::SafeString& meta, \
|
||||
ParameterList* list, bool e) \
|
||||
: Parameter(value, name, label, meta, list, e) {} \
|
||||
\
|
||||
const char* getParamTypeStr() const override { \
|
||||
return YamlParamType::text(YamlParamType::Name); \
|
||||
} \
|
||||
|
|
@ -117,6 +127,13 @@ public:
|
|||
mValue = T();
|
||||
}
|
||||
|
||||
Parameter(const T& value, const sead::SafeString& name, const sead::SafeString& label,
|
||||
const sead::SafeString& meta, ParameterObj* obj, bool e)
|
||||
: ParameterBase(e) {
|
||||
initializeListNode(name, label, meta, obj, e);
|
||||
mValue = value;
|
||||
}
|
||||
|
||||
Parameter(const sead::SafeString& name, const sead::SafeString& label,
|
||||
const sead::SafeString& meta, ParameterList* list, bool e)
|
||||
: ParameterBase(e) {
|
||||
|
|
@ -124,6 +141,13 @@ public:
|
|||
mValue = T();
|
||||
}
|
||||
|
||||
Parameter(const T& value, const sead::SafeString& name, const sead::SafeString& label,
|
||||
const sead::SafeString& meta, ParameterList* list, bool e)
|
||||
: ParameterBase(e) {
|
||||
initializeListNode(name, label, meta, list, e);
|
||||
mValue = value;
|
||||
}
|
||||
|
||||
const void* ptr() const override { return &mValue; };
|
||||
|
||||
void* ptr() override { return &mValue; };
|
||||
|
|
@ -140,6 +164,10 @@ public:
|
|||
|
||||
void setValue(const T& value) { mValue = value; }
|
||||
|
||||
T* operator->() { return &mValue; }
|
||||
|
||||
const T* operator->() const { return &mValue; }
|
||||
|
||||
private:
|
||||
T mValue = T();
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue