diff --git a/CMakeLists.txt b/CMakeLists.txt index d57e81b07..0591aab3a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -136,7 +136,7 @@ else() -Wno-unused-function -Wno-sign-compare -Wno-unknown-pragmas -fno-exceptions -Werror) 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_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -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) if("${LD_VERSION}" MATCHES "GNU gold") 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_link_options(-flto=thin) message(STATUS "GNU gold linker enabled.") else() message(WARNING "GNU gold linker isn't available, using the default system linker.") @@ -289,7 +290,7 @@ unset(GIT_EXECUTABLE CACHE) find_package(Git) if(GIT_FOUND) # 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 ) # Get the latest abbreviated commit hash of the working branch diff --git a/DataSpec/DNACommon/ANIM.cpp b/DataSpec/DNACommon/ANIM.cpp index e41dda999..091953dab 100644 --- a/DataSpec/DNACommon/ANIM.cpp +++ b/DataSpec/DNACommon/ANIM.cpp @@ -37,6 +37,9 @@ size_t ComputeBitstreamSize(size_t keyFrameCount, const std::vector& ch static inline QuantizedRot QuantizeRotation(const Value& quat, atUint32 div) { float q = M_PIF / 2.0f / float(div); 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 {{ atInt32(std::asin(f[1]) / q), atInt32(std::asin(f[2]) / q), diff --git a/DataSpec/DNACommon/ANIM.hpp b/DataSpec/DNACommon/ANIM.hpp index 268971bb2..575ceab2d 100644 --- a/DataSpec/DNACommon/ANIM.hpp +++ b/DataSpec/DNACommon/ANIM.hpp @@ -23,7 +23,9 @@ struct QuantizedValue { atInt32 delta = std::abs(v[idx] - other.v[idx]); if (delta == 0) 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 { diff --git a/DataSpec/DNAMP1/ANIM.cpp b/DataSpec/DNAMP1/ANIM.cpp index ab75260fc..95e9e7091 100644 --- a/DataSpec/DNAMP1/ANIM.cpp +++ b/DataSpec/DNAMP1/ANIM.cpp @@ -597,6 +597,7 @@ ANIM::ANIM(const BlenderAction& act, const std::unordered_map PAK::Entry::getBuffer(const nod::Node& pak, atUint64& strm->read(&chunkSz, 2); chunkSz = hecl::SBig(chunkSz); strm->read(compBuf, chunkSz); - size_t dsz = rem; - lzokay::decompress(compBuf, chunkSz, bufCur, dsz); + size_t dsz; + lzokay::decompress(compBuf, chunkSz, bufCur, rem, dsz); bufCur += dsz; rem -= dsz; } diff --git a/DataSpec/DNAMP1/ScriptObjects/CameraHintTrigger.hpp b/DataSpec/DNAMP1/ScriptObjects/CameraHintTrigger.hpp index f971444d5..f6730a8ae 100644 --- a/DataSpec/DNAMP1/ScriptObjects/CameraHintTrigger.hpp +++ b/DataSpec/DNAMP1/ScriptObjects/CameraHintTrigger.hpp @@ -12,8 +12,8 @@ struct CameraHintTrigger : IScriptObject { Value location; Value orientation; Value volume; - Value unknown1; - Value unknown2; - Value unknown3; + Value active; + Value deactivateOnEntered; + Value deactivateOnExited; }; } // namespace DataSpec::DNAMP1 diff --git a/DataSpec/DNAMP2/MREA.cpp b/DataSpec/DNAMP2/MREA.cpp index 850efd9ec..086ea757a 100644 --- a/DataSpec/DNAMP2/MREA.cpp +++ b/DataSpec/DNAMP2/MREA.cpp @@ -47,8 +47,8 @@ void MREA::StreamReader::nextBlock() { rem -= chunkSz; } else { m_source.readUBytesToBuf(m_compBuf.get(), chunkSz); - size_t dsz = rem; - lzokay::decompress(m_compBuf.get(), chunkSz, bufCur, dsz); + size_t dsz; + lzokay::decompress(m_compBuf.get(), chunkSz, bufCur, rem, dsz); bufCur += dsz; rem -= dsz; } diff --git a/DataSpec/DNAMP3/PAK.cpp b/DataSpec/DNAMP3/PAK.cpp index fd55153e7..4c6e078e7 100644 --- a/DataSpec/DNAMP3/PAK.cpp +++ b/DataSpec/DNAMP3/PAK.cpp @@ -179,8 +179,8 @@ std::unique_ptr PAK::Entry::getBuffer(const nod::Node& pak, atUint64& while (rem) { atUint16 chunkSz = hecl::SBig(*(atUint16*)compBufCur); compBufCur += 2; - size_t dsz = rem; - lzokay::decompress(compBufCur, chunkSz, bufCur, dsz); + size_t dsz; + lzokay::decompress(compBufCur, chunkSz, bufCur, rem, dsz); compBufCur += chunkSz; bufCur += dsz; rem -= dsz; diff --git a/Runtime/World/CPatterned.cpp b/Runtime/World/CPatterned.cpp index f516fd731..a78ec3528 100644 --- a/Runtime/World/CPatterned.cpp +++ b/Runtime/World/CPatterned.cpp @@ -400,8 +400,8 @@ zeus::CVector3f CPatterned::GetAimPosition(const urde::CStateManager& mgr, float if (segId != 0xFF) { zeus::CTransform xf = GetModelData()->GetAnimationData()->GetLocatorTransform(segId, nullptr); zeus::CVector3f scaledOrigin = GetModelData()->GetScale() * xf.origin; - if (GetTouchBounds()) - return offset + GetTouchBounds()->clampToBox(x34_transform * scaledOrigin); + if (auto tb = GetTouchBounds()) + return offset + tb->clampToBox(x34_transform * scaledOrigin); zeus::CAABox aabox = GetBaseBoundingBox(); diff --git a/Runtime/World/CScriptActorKeyframe.cpp b/Runtime/World/CScriptActorKeyframe.cpp index 0f03b2de9..4f1b1fc2d 100644 --- a/Runtime/World/CScriptActorKeyframe.cpp +++ b/Runtime/World/CScriptActorKeyframe.cpp @@ -39,7 +39,6 @@ void CScriptActorKeyframe::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId u } x44_28_playing = true; - printf("%s\n", x10_name.c_str()); SendScriptMsgs(EScriptObjectState::Play, mgr, EScriptObjectMessage::None); } } else if (msg == EScriptObjectMessage::InitializedInArea) { diff --git a/Runtime/World/CScriptCameraHintTrigger.cpp b/Runtime/World/CScriptCameraHintTrigger.cpp index d4099eeb0..ab4fbd3b3 100644 --- a/Runtime/World/CScriptCameraHintTrigger.cpp +++ b/Runtime/World/CScriptCameraHintTrigger.cpp @@ -1,20 +1,57 @@ #include "CScriptCameraHintTrigger.hpp" #include "CActorParameters.hpp" +#include "CStateManager.hpp" #include "TCastTo.hpp" namespace urde { CScriptCameraHintTrigger::CScriptCameraHintTrigger(TUniqueId uid, bool active, std::string_view name, 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), CActorParameters::None(), kInvalidUniqueId) , xe8_obb(xf, scale) , x124_scale(scale) { - x130_24_ = b2; - x130_25_ = b3; + x130_24_deactivateOnEnter = deactivateOnEnter; + x130_25_deactivateOnExit = deactivateOnExit; } 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(other)) { + if (auto tb = other.GetTouchBounds()) + x130_26_playerInside = xe8_obb.OBBIntersectsBox(zeus::COBBox::FromAABox(*tb, {})); + } +} + +std::optional CScriptCameraHintTrigger::GetTouchBounds() const { + return {xe8_obb.calculateAABox()}; +} + } // namespace urde diff --git a/Runtime/World/CScriptCameraHintTrigger.hpp b/Runtime/World/CScriptCameraHintTrigger.hpp index 383908561..a807214e0 100644 --- a/Runtime/World/CScriptCameraHintTrigger.hpp +++ b/Runtime/World/CScriptCameraHintTrigger.hpp @@ -9,18 +9,23 @@ class CScriptCameraHintTrigger : public CActor { zeus::CVector3f x124_scale; union { struct { - bool x130_24_ : 1; - bool x130_25_ : 1; - bool x130_26_ : 1; - bool x130_27_ : 1; + bool x130_24_deactivateOnEnter : 1; + bool x130_25_deactivateOnExit : 1; + bool x130_26_playerInside : 1; + bool x130_27_playerWasInside : 1; }; - u8 _dummy = 0; + u32 _dummy = 0; }; public: - CScriptCameraHintTrigger(TUniqueId, bool, std::string_view name, const CEntityInfo&, const zeus::CVector3f&, - const zeus::CTransform&, bool, bool); + CScriptCameraHintTrigger(TUniqueId uid, bool active, std::string_view name, + const CEntityInfo& info, const zeus::CVector3f& scale, + const zeus::CTransform& xf, bool deactivateOnEnter, + bool deactivateOnExit); void Accept(IVisitor& visitor); + void Think(float dt, CStateManager& mgr); + void Touch(CActor& other, CStateManager& mgr); + std::optional GetTouchBounds() const; }; } // namespace urde diff --git a/Runtime/World/CScriptPickup.cpp b/Runtime/World/CScriptPickup.cpp index 4d8bd1e95..8b5a21b7b 100644 --- a/Runtime/World/CScriptPickup.cpp +++ b/Runtime/World/CScriptPickup.cpp @@ -99,7 +99,7 @@ void CScriptPickup::Think(float dt, CStateManager& mgr) { x28c_25_inTractor = false; posDelta.zeroOut(); } - SetVelocityOR(posDelta); + SetVelocityWR(posDelta); } else if (x28c_24_generated) { float chargeFactor = mgr.GetPlayer().GetPlayerGun()->IsCharging() ? mgr.GetPlayer().GetPlayerGun()->GetChargeBeamFactor() : 0.f; diff --git a/Runtime/World/ScriptLoader.cpp b/Runtime/World/ScriptLoader.cpp index ae0427cd6..9754e38ca 100644 --- a/Runtime/World/ScriptLoader.cpp +++ b/Runtime/World/ScriptLoader.cpp @@ -3095,17 +3095,17 @@ CEntity* ScriptLoader::LoadCameraHintTrigger(CStateManager& mgr, CInputStream& i SActorHead aHead = LoadActorHead(in, mgr); zeus::CVector3f scale = 0.5f * zeus::CVector3f::ReadBig(in); bool active = in.readBool(); - bool b2 = in.readBool(); - bool b3 = in.readBool(); + bool deactivateOnEnter = in.readBool(); + bool deactivateOnExit = in.readBool(); zeus::CTransform xfRot = aHead.x10_transform.getRotation(); if (xfRot == zeus::CTransform()) return new CScriptTrigger(mgr.AllocateUniqueId(), aHead.x0_name, info, aHead.x10_transform.origin, 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, - b2, b3); + deactivateOnEnter, deactivateOnExit); } CEntity* ScriptLoader::LoadRumbleEffect(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) { diff --git a/amuse b/amuse index 2a3444400..a74caa5fb 160000 --- a/amuse +++ b/amuse @@ -1 +1 @@ -Subproject commit 2a3444400e3b2d6310901c8e7b7cf1952720079d +Subproject commit a74caa5fb0f0502bc712aa04f8d6a8a0af7fc754 diff --git a/hecl b/hecl index 31aa28f56..6caf187e3 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit 31aa28f5674a5d728a3c37d4c0e703ffe76fab64 +Subproject commit 6caf187e3204ff5e92b40b6f50b015ef785c69d7 diff --git a/specter b/specter index 3b51992b9..d4a4c4253 160000 --- a/specter +++ b/specter @@ -1 +1 @@ -Subproject commit 3b51992b9ac66d2eedc98aba9f9eff85d3c0afde +Subproject commit d4a4c425371077cf7ebb2088086755b7d28c7342