mirror of https://github.com/AxioDL/metaforce.git
Various CActorContraption fixes
This commit is contained in:
parent
6679f6de72
commit
37307e1cf6
|
@ -136,7 +136,7 @@ else()
|
||||||
-Wno-unused-function -Wno-sign-compare -Wno-unknown-pragmas -fno-exceptions -Werror)
|
-Wno-unused-function -Wno-sign-compare -Wno-unknown-pragmas -fno-exceptions -Werror)
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=deprecated-declarations")
|
add_compile_options(-Wno-error=deprecated-declarations)
|
||||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -flto=thin")
|
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -flto=thin")
|
||||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -flto=thin")
|
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -flto=thin")
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto=thin")
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto=thin")
|
||||||
|
@ -160,8 +160,9 @@ if(USE_LD_GOLD AND ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_
|
||||||
execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
|
execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
|
||||||
if("${LD_VERSION}" MATCHES "GNU gold")
|
if("${LD_VERSION}" MATCHES "GNU gold")
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold -Wl,--disable-new-dtags")
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold -Wl,--disable-new-dtags")
|
||||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold -Wl,--disable-new-dtags")
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=gold -Wl,--disable-new-dtags")
|
||||||
add_compile_options(-flto=thin)
|
add_compile_options(-flto=thin)
|
||||||
|
add_link_options(-flto=thin)
|
||||||
message(STATUS "GNU gold linker enabled.")
|
message(STATUS "GNU gold linker enabled.")
|
||||||
else()
|
else()
|
||||||
message(WARNING "GNU gold linker isn't available, using the default system linker.")
|
message(WARNING "GNU gold linker isn't available, using the default system linker.")
|
||||||
|
@ -289,7 +290,7 @@ unset(GIT_EXECUTABLE CACHE)
|
||||||
find_package(Git)
|
find_package(Git)
|
||||||
if(GIT_FOUND)
|
if(GIT_FOUND)
|
||||||
# Get the current working branch
|
# Get the current working branch
|
||||||
execute_process(COMMAND "${GIT_EXECUTABLE}" regiv-parse --abbrev-ref HEAD WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
execute_process(COMMAND "${GIT_EXECUTABLE}" rev-parse --abbrev-ref HEAD WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||||
OUTPUT_VARIABLE GIT_BRANCH OUTPUT_STRIP_TRAILING_WHITESPACE )
|
OUTPUT_VARIABLE GIT_BRANCH OUTPUT_STRIP_TRAILING_WHITESPACE )
|
||||||
|
|
||||||
# Get the latest abbreviated commit hash of the working branch
|
# Get the latest abbreviated commit hash of the working branch
|
||||||
|
|
|
@ -37,6 +37,9 @@ size_t ComputeBitstreamSize(size_t keyFrameCount, const std::vector<Channel>& ch
|
||||||
static inline QuantizedRot QuantizeRotation(const Value& quat, atUint32 div) {
|
static inline QuantizedRot QuantizeRotation(const Value& quat, atUint32 div) {
|
||||||
float q = M_PIF / 2.0f / float(div);
|
float q = M_PIF / 2.0f / float(div);
|
||||||
zeus::simd_floats f(quat.simd);
|
zeus::simd_floats f(quat.simd);
|
||||||
|
assert(std::abs(f[1]) <= 1.f && "Out of range quat X component");
|
||||||
|
assert(std::abs(f[2]) <= 1.f && "Out of range quat Y component");
|
||||||
|
assert(std::abs(f[3]) <= 1.f && "Out of range quat Z component");
|
||||||
return {{
|
return {{
|
||||||
atInt32(std::asin(f[1]) / q),
|
atInt32(std::asin(f[1]) / q),
|
||||||
atInt32(std::asin(f[2]) / q),
|
atInt32(std::asin(f[2]) / q),
|
||||||
|
|
|
@ -23,7 +23,9 @@ struct QuantizedValue {
|
||||||
atInt32 delta = std::abs(v[idx] - other.v[idx]);
|
atInt32 delta = std::abs(v[idx] - other.v[idx]);
|
||||||
if (delta == 0)
|
if (delta == 0)
|
||||||
return 1;
|
return 1;
|
||||||
return int(std::ceil(std::log2(delta))) + 1;
|
int ret = int(std::ceil(std::log2(delta))) + 1;
|
||||||
|
assert(ret <= 24 && "Bad q value");
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
struct QuantizedRot {
|
struct QuantizedRot {
|
||||||
|
|
|
@ -597,6 +597,7 @@ ANIM::ANIM(const BlenderAction& act, const std::unordered_map<std::string, atInt
|
||||||
if (sign == 0.f)
|
if (sign == 0.f)
|
||||||
sign = q.w() < 0.f ? -1.f : 1.f;
|
sign = q.w() < 0.f ? -1.f : 1.f;
|
||||||
q *= sign;
|
q *= sign;
|
||||||
|
q.normalize();
|
||||||
rotVals.emplace_back(q.mSimd);
|
rotVals.emplace_back(q.mSimd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,8 +122,8 @@ std::unique_ptr<atUint8[]> PAK::Entry::getBuffer(const nod::Node& pak, atUint64&
|
||||||
strm->read(&chunkSz, 2);
|
strm->read(&chunkSz, 2);
|
||||||
chunkSz = hecl::SBig(chunkSz);
|
chunkSz = hecl::SBig(chunkSz);
|
||||||
strm->read(compBuf, chunkSz);
|
strm->read(compBuf, chunkSz);
|
||||||
size_t dsz = rem;
|
size_t dsz;
|
||||||
lzokay::decompress(compBuf, chunkSz, bufCur, dsz);
|
lzokay::decompress(compBuf, chunkSz, bufCur, rem, dsz);
|
||||||
bufCur += dsz;
|
bufCur += dsz;
|
||||||
rem -= dsz;
|
rem -= dsz;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,8 @@ struct CameraHintTrigger : IScriptObject {
|
||||||
Value<atVec3f> location;
|
Value<atVec3f> location;
|
||||||
Value<atVec3f> orientation;
|
Value<atVec3f> orientation;
|
||||||
Value<atVec3f> volume;
|
Value<atVec3f> volume;
|
||||||
Value<bool> unknown1;
|
Value<bool> active;
|
||||||
Value<bool> unknown2;
|
Value<bool> deactivateOnEntered;
|
||||||
Value<bool> unknown3;
|
Value<bool> deactivateOnExited;
|
||||||
};
|
};
|
||||||
} // namespace DataSpec::DNAMP1
|
} // namespace DataSpec::DNAMP1
|
||||||
|
|
|
@ -47,8 +47,8 @@ void MREA::StreamReader::nextBlock() {
|
||||||
rem -= chunkSz;
|
rem -= chunkSz;
|
||||||
} else {
|
} else {
|
||||||
m_source.readUBytesToBuf(m_compBuf.get(), chunkSz);
|
m_source.readUBytesToBuf(m_compBuf.get(), chunkSz);
|
||||||
size_t dsz = rem;
|
size_t dsz;
|
||||||
lzokay::decompress(m_compBuf.get(), chunkSz, bufCur, dsz);
|
lzokay::decompress(m_compBuf.get(), chunkSz, bufCur, rem, dsz);
|
||||||
bufCur += dsz;
|
bufCur += dsz;
|
||||||
rem -= dsz;
|
rem -= dsz;
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,8 +179,8 @@ std::unique_ptr<atUint8[]> PAK::Entry::getBuffer(const nod::Node& pak, atUint64&
|
||||||
while (rem) {
|
while (rem) {
|
||||||
atUint16 chunkSz = hecl::SBig(*(atUint16*)compBufCur);
|
atUint16 chunkSz = hecl::SBig(*(atUint16*)compBufCur);
|
||||||
compBufCur += 2;
|
compBufCur += 2;
|
||||||
size_t dsz = rem;
|
size_t dsz;
|
||||||
lzokay::decompress(compBufCur, chunkSz, bufCur, dsz);
|
lzokay::decompress(compBufCur, chunkSz, bufCur, rem, dsz);
|
||||||
compBufCur += chunkSz;
|
compBufCur += chunkSz;
|
||||||
bufCur += dsz;
|
bufCur += dsz;
|
||||||
rem -= dsz;
|
rem -= dsz;
|
||||||
|
|
|
@ -400,8 +400,8 @@ zeus::CVector3f CPatterned::GetAimPosition(const urde::CStateManager& mgr, float
|
||||||
if (segId != 0xFF) {
|
if (segId != 0xFF) {
|
||||||
zeus::CTransform xf = GetModelData()->GetAnimationData()->GetLocatorTransform(segId, nullptr);
|
zeus::CTransform xf = GetModelData()->GetAnimationData()->GetLocatorTransform(segId, nullptr);
|
||||||
zeus::CVector3f scaledOrigin = GetModelData()->GetScale() * xf.origin;
|
zeus::CVector3f scaledOrigin = GetModelData()->GetScale() * xf.origin;
|
||||||
if (GetTouchBounds())
|
if (auto tb = GetTouchBounds())
|
||||||
return offset + GetTouchBounds()->clampToBox(x34_transform * scaledOrigin);
|
return offset + tb->clampToBox(x34_transform * scaledOrigin);
|
||||||
|
|
||||||
zeus::CAABox aabox = GetBaseBoundingBox();
|
zeus::CAABox aabox = GetBaseBoundingBox();
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,6 @@ void CScriptActorKeyframe::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId u
|
||||||
}
|
}
|
||||||
|
|
||||||
x44_28_playing = true;
|
x44_28_playing = true;
|
||||||
printf("%s\n", x10_name.c_str());
|
|
||||||
SendScriptMsgs(EScriptObjectState::Play, mgr, EScriptObjectMessage::None);
|
SendScriptMsgs(EScriptObjectState::Play, mgr, EScriptObjectMessage::None);
|
||||||
}
|
}
|
||||||
} else if (msg == EScriptObjectMessage::InitializedInArea) {
|
} else if (msg == EScriptObjectMessage::InitializedInArea) {
|
||||||
|
|
|
@ -1,20 +1,57 @@
|
||||||
#include "CScriptCameraHintTrigger.hpp"
|
#include "CScriptCameraHintTrigger.hpp"
|
||||||
#include "CActorParameters.hpp"
|
#include "CActorParameters.hpp"
|
||||||
|
#include "CStateManager.hpp"
|
||||||
#include "TCastTo.hpp"
|
#include "TCastTo.hpp"
|
||||||
|
|
||||||
namespace urde {
|
namespace urde {
|
||||||
|
|
||||||
CScriptCameraHintTrigger::CScriptCameraHintTrigger(TUniqueId uid, bool active, std::string_view name,
|
CScriptCameraHintTrigger::CScriptCameraHintTrigger(TUniqueId uid, bool active, std::string_view name,
|
||||||
const CEntityInfo& info, const zeus::CVector3f& scale,
|
const CEntityInfo& info, const zeus::CVector3f& scale,
|
||||||
const zeus::CTransform& xf, bool b2, bool b3)
|
const zeus::CTransform& xf, bool deactivateOnEnter,
|
||||||
|
bool deactivateOnExit)
|
||||||
: CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(EMaterialTypes::Trigger),
|
: CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(EMaterialTypes::Trigger),
|
||||||
CActorParameters::None(), kInvalidUniqueId)
|
CActorParameters::None(), kInvalidUniqueId)
|
||||||
, xe8_obb(xf, scale)
|
, xe8_obb(xf, scale)
|
||||||
, x124_scale(scale) {
|
, x124_scale(scale) {
|
||||||
x130_24_ = b2;
|
x130_24_deactivateOnEnter = deactivateOnEnter;
|
||||||
x130_25_ = b3;
|
x130_25_deactivateOnExit = deactivateOnExit;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScriptCameraHintTrigger::Accept(IVisitor& visitor) { visitor.Visit(this); }
|
void CScriptCameraHintTrigger::Accept(IVisitor& visitor) { visitor.Visit(this); }
|
||||||
|
|
||||||
|
void CScriptCameraHintTrigger::Think(float dt, CStateManager& mgr) {
|
||||||
|
if (!GetActive())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (x130_26_playerInside && !x130_27_playerWasInside) {
|
||||||
|
x130_27_playerWasInside = true;
|
||||||
|
SendScriptMsgs(EScriptObjectState::Entered, mgr, EScriptObjectMessage::None);
|
||||||
|
if (x130_24_deactivateOnEnter)
|
||||||
|
mgr.SendScriptMsg(this, kInvalidUniqueId, EScriptObjectMessage::Deactivate);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!x130_26_playerInside && x130_27_playerWasInside) {
|
||||||
|
x130_27_playerWasInside = false;
|
||||||
|
SendScriptMsgs(EScriptObjectState::Exited, mgr, EScriptObjectMessage::None);
|
||||||
|
if (x130_25_deactivateOnExit)
|
||||||
|
mgr.SendScriptMsg(this, kInvalidUniqueId, EScriptObjectMessage::Deactivate);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x130_26_playerInside)
|
||||||
|
SendScriptMsgs(EScriptObjectState::Inside, mgr, EScriptObjectMessage::None);
|
||||||
|
|
||||||
|
x130_26_playerInside = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CScriptCameraHintTrigger::Touch(CActor& other, CStateManager& mgr) {
|
||||||
|
if (TCastToPtr<CPlayer>(other)) {
|
||||||
|
if (auto tb = other.GetTouchBounds())
|
||||||
|
x130_26_playerInside = xe8_obb.OBBIntersectsBox(zeus::COBBox::FromAABox(*tb, {}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<zeus::CAABox> CScriptCameraHintTrigger::GetTouchBounds() const {
|
||||||
|
return {xe8_obb.calculateAABox()};
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace urde
|
} // namespace urde
|
||||||
|
|
|
@ -9,18 +9,23 @@ class CScriptCameraHintTrigger : public CActor {
|
||||||
zeus::CVector3f x124_scale;
|
zeus::CVector3f x124_scale;
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
bool x130_24_ : 1;
|
bool x130_24_deactivateOnEnter : 1;
|
||||||
bool x130_25_ : 1;
|
bool x130_25_deactivateOnExit : 1;
|
||||||
bool x130_26_ : 1;
|
bool x130_26_playerInside : 1;
|
||||||
bool x130_27_ : 1;
|
bool x130_27_playerWasInside : 1;
|
||||||
};
|
};
|
||||||
u8 _dummy = 0;
|
u32 _dummy = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CScriptCameraHintTrigger(TUniqueId, bool, std::string_view name, const CEntityInfo&, const zeus::CVector3f&,
|
CScriptCameraHintTrigger(TUniqueId uid, bool active, std::string_view name,
|
||||||
const zeus::CTransform&, bool, bool);
|
const CEntityInfo& info, const zeus::CVector3f& scale,
|
||||||
|
const zeus::CTransform& xf, bool deactivateOnEnter,
|
||||||
|
bool deactivateOnExit);
|
||||||
|
|
||||||
void Accept(IVisitor& visitor);
|
void Accept(IVisitor& visitor);
|
||||||
|
void Think(float dt, CStateManager& mgr);
|
||||||
|
void Touch(CActor& other, CStateManager& mgr);
|
||||||
|
std::optional<zeus::CAABox> GetTouchBounds() const;
|
||||||
};
|
};
|
||||||
} // namespace urde
|
} // namespace urde
|
||||||
|
|
|
@ -99,7 +99,7 @@ void CScriptPickup::Think(float dt, CStateManager& mgr) {
|
||||||
x28c_25_inTractor = false;
|
x28c_25_inTractor = false;
|
||||||
posDelta.zeroOut();
|
posDelta.zeroOut();
|
||||||
}
|
}
|
||||||
SetVelocityOR(posDelta);
|
SetVelocityWR(posDelta);
|
||||||
} else if (x28c_24_generated) {
|
} else if (x28c_24_generated) {
|
||||||
float chargeFactor =
|
float chargeFactor =
|
||||||
mgr.GetPlayer().GetPlayerGun()->IsCharging() ? mgr.GetPlayer().GetPlayerGun()->GetChargeBeamFactor() : 0.f;
|
mgr.GetPlayer().GetPlayerGun()->IsCharging() ? mgr.GetPlayer().GetPlayerGun()->GetChargeBeamFactor() : 0.f;
|
||||||
|
|
|
@ -3095,17 +3095,17 @@ CEntity* ScriptLoader::LoadCameraHintTrigger(CStateManager& mgr, CInputStream& i
|
||||||
SActorHead aHead = LoadActorHead(in, mgr);
|
SActorHead aHead = LoadActorHead(in, mgr);
|
||||||
zeus::CVector3f scale = 0.5f * zeus::CVector3f::ReadBig(in);
|
zeus::CVector3f scale = 0.5f * zeus::CVector3f::ReadBig(in);
|
||||||
bool active = in.readBool();
|
bool active = in.readBool();
|
||||||
bool b2 = in.readBool();
|
bool deactivateOnEnter = in.readBool();
|
||||||
bool b3 = in.readBool();
|
bool deactivateOnExit = in.readBool();
|
||||||
|
|
||||||
zeus::CTransform xfRot = aHead.x10_transform.getRotation();
|
zeus::CTransform xfRot = aHead.x10_transform.getRotation();
|
||||||
if (xfRot == zeus::CTransform())
|
if (xfRot == zeus::CTransform())
|
||||||
return new CScriptTrigger(mgr.AllocateUniqueId(), aHead.x0_name, info, aHead.x10_transform.origin,
|
return new CScriptTrigger(mgr.AllocateUniqueId(), aHead.x0_name, info, aHead.x10_transform.origin,
|
||||||
zeus::CAABox(-scale, scale), CDamageInfo(), zeus::skZero3f,
|
zeus::CAABox(-scale, scale), CDamageInfo(), zeus::skZero3f,
|
||||||
ETriggerFlags::DetectPlayer, active, b2, b3);
|
ETriggerFlags::DetectPlayer, active, deactivateOnEnter, deactivateOnExit);
|
||||||
|
|
||||||
return new CScriptCameraHintTrigger(mgr.AllocateUniqueId(), active, aHead.x0_name, info, scale, aHead.x10_transform,
|
return new CScriptCameraHintTrigger(mgr.AllocateUniqueId(), active, aHead.x0_name, info, scale, aHead.x10_transform,
|
||||||
b2, b3);
|
deactivateOnEnter, deactivateOnExit);
|
||||||
}
|
}
|
||||||
|
|
||||||
CEntity* ScriptLoader::LoadRumbleEffect(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) {
|
CEntity* ScriptLoader::LoadRumbleEffect(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) {
|
||||||
|
|
2
amuse
2
amuse
|
@ -1 +1 @@
|
||||||
Subproject commit 2a3444400e3b2d6310901c8e7b7cf1952720079d
|
Subproject commit a74caa5fb0f0502bc712aa04f8d6a8a0af7fc754
|
2
hecl
2
hecl
|
@ -1 +1 @@
|
||||||
Subproject commit 31aa28f5674a5d728a3c37d4c0e703ffe76fab64
|
Subproject commit 6caf187e3204ff5e92b40b6f50b015ef785c69d7
|
2
specter
2
specter
|
@ -1 +1 @@
|
||||||
Subproject commit 3b51992b9ac66d2eedc98aba9f9eff85d3c0afde
|
Subproject commit d4a4c425371077cf7ebb2088086755b7d28c7342
|
Loading…
Reference in New Issue