From 46c70ecf11c3695d1c772751564b45d89193eda9 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Sat, 10 Jun 2017 22:49:27 -0700 Subject: [PATCH] Initial CScriptPlatform imps, minor cleanup, and RandomStatic GLSL fixes --- Runtime/Audio/CSfxManager.hpp | 11 +++++ Runtime/Character/CHierarchyPoseBuilder.cpp | 6 +-- Runtime/Collision/CMaterialList.hpp | 1 + .../Shaders/CRandomStaticFilterGLSL.cpp | 12 ++--- Runtime/World/CScriptPlatform.cpp | 30 +++++++++--- Runtime/World/CScriptPlatform.hpp | 49 ++++++++++++++++++- Runtime/World/ScriptLoader.cpp | 2 +- 7 files changed, 92 insertions(+), 19 deletions(-) diff --git a/Runtime/Audio/CSfxManager.hpp b/Runtime/Audio/CSfxManager.hpp index cc478d272..512d98894 100644 --- a/Runtime/Audio/CSfxManager.hpp +++ b/Runtime/Audio/CSfxManager.hpp @@ -42,6 +42,17 @@ public: class CBaseSfxWrapper; using CSfxHandle = std::shared_ptr; + /* Original imp, kept for reference + class CSfxHandle + { + static u32 mRefCount; + u32 x0_idx; + public: + CSfxHandle(u32 id) + : x0_idx(++mRefCount << 14 | (id & 0xFFFF)) {} + }; + */ + class CSfxChannel { friend class CSfxManager; diff --git a/Runtime/Character/CHierarchyPoseBuilder.cpp b/Runtime/Character/CHierarchyPoseBuilder.cpp index 27a4ae22b..b7d566a6f 100644 --- a/Runtime/Character/CHierarchyPoseBuilder.cpp +++ b/Runtime/Character/CHierarchyPoseBuilder.cpp @@ -15,9 +15,9 @@ void CHierarchyPoseBuilder::BuildIntoHierarchy(const CCharLayoutInfo& layout, { xcec_rootId = boneId; xcf0_hasRoot = true; - //zeus::CVector3f origin = layout.GetFromParentUnrotated(boneId); - //CTreeNode& node = x38_treeMap[boneId]; - //node.x14_offset = origin; + zeus::CVector3f origin = layout.GetFromParentUnrotated(boneId); + CTreeNode& node = x38_treeMap[boneId]; + node.x14_offset = origin; } else { diff --git a/Runtime/Collision/CMaterialList.hpp b/Runtime/Collision/CMaterialList.hpp index b0e670149..71860e6e9 100644 --- a/Runtime/Collision/CMaterialList.hpp +++ b/Runtime/Collision/CMaterialList.hpp @@ -27,6 +27,7 @@ enum class EMaterialTypes Sand = 17, ProjectilePassthrough = 18, Solid = 19, + Twenty = 20, CameraPassthrough = 21, Wood = 22, Organic = 23, diff --git a/Runtime/Graphics/Shaders/CRandomStaticFilterGLSL.cpp b/Runtime/Graphics/Shaders/CRandomStaticFilterGLSL.cpp index c7e7b0c65..9705ee9e1 100644 --- a/Runtime/Graphics/Shaders/CRandomStaticFilterGLSL.cpp +++ b/Runtime/Graphics/Shaders/CRandomStaticFilterGLSL.cpp @@ -48,7 +48,7 @@ BOO_GLSL_BINDING_HEAD " float discardThres;\n" "};\n" "\n" -"vec2i Lookup8BPP(in vec2 uv, in float randOff)\n" +"ivec2 Lookup8BPP(in vec2 uv, in float randOff)\n" "{\n" " float bx;\n" " float rx = modf(uv.x / 8.0, bx) * 8.0;\n" @@ -58,7 +58,7 @@ BOO_GLSL_BINDING_HEAD " float addr = bidx * 32.0 + ry * 8.0 + rx + randOff;\n" " float y;\n" " float x = modf(addr / 1024.0, y) * 1024.0;\n" -" return vec2i(x, y);\n" +" return ivec2(x, y);\n" "}\n" "\n" "SBINDING(0) in VertToFrag vtf;\n" @@ -66,7 +66,7 @@ BOO_GLSL_BINDING_HEAD "TBINDING0 uniform sampler2D tex;\n" "void main()\n" "{\n" -" colorOut = texelFetch(tex, Lookup8BPP(vtf.uv, vtf.randOff)) * vtf.color;\n" +" colorOut = texelFetch(tex, Lookup8BPP(vtf.uv, vtf.randOff), 0) * vtf.color;\n" " colorOut.a = vtf.color.a;\n" "}\n"; @@ -81,7 +81,7 @@ BOO_GLSL_BINDING_HEAD " float discardThres;\n" "};\n" "\n" -"vec2i Lookup8BPP(in vec2 uv, in float randOff)\n" +"ivec2 Lookup8BPP(in vec2 uv, in float randOff)\n" "{\n" " float bx;\n" " float rx = modf(uv.x / 8.0, bx) * 8.0;\n" @@ -91,7 +91,7 @@ BOO_GLSL_BINDING_HEAD " float addr = bidx * 32.0 + ry * 8.0 + rx + randOff;\n" " float y;\n" " float x = modf(addr / 1024.0, y) * 1024.0;\n" -" return vec2i(x, y);\n" +" return ivec2(x, y);\n" "}\n" "\n" "SBINDING(0) in VertToFrag vtf;\n" @@ -99,7 +99,7 @@ BOO_GLSL_BINDING_HEAD "TBINDING0 uniform sampler2D tex;\n" "void main()\n" "{\n" -" colorOut = texelFetch(tex, Lookup8BPP(vtf.uv, vtf.randOff)) * vtf.color;\n" +" colorOut = texelFetch(tex, Lookup8BPP(vtf.uv, vtf.randOff), 0) * vtf.color;\n" " if (colorOut.a < vtf.discardThres)\n" " discard;\n" "}\n"; diff --git a/Runtime/World/CScriptPlatform.cpp b/Runtime/World/CScriptPlatform.cpp index bbd87a3e4..f41abfb3d 100644 --- a/Runtime/World/CScriptPlatform.cpp +++ b/Runtime/World/CScriptPlatform.cpp @@ -1,5 +1,6 @@ #include "CScriptPlatform.hpp" #include "Collision/CMaterialList.hpp" +#include "Collision/CCollidableOBBTreeGroup.hpp" #include "TCastTo.hpp" namespace urde @@ -17,18 +18,31 @@ static CMaterialList MakePlatformMaterialList() CScriptPlatform::CScriptPlatform(TUniqueId uid, const std::string& name, const CEntityInfo& info, const zeus::CTransform& xf, CModelData&& mData, const CActorParameters& actParms, - const zeus::CAABox& aabb, float, bool, float, bool active, const CHealthInfo& hInfo, - const CDamageVulnerability& dInfo, - const rstl::optional_object>& dcln, bool, u32, - u32) + const zeus::CAABox& aabb, float f1, bool, float f2, bool active, + const CHealthInfo& hInfo, const CDamageVulnerability& dVuln, + const rstl::optional_object>& dcln, + bool, u32, u32) : CPhysicsActor(uid, active, name, info, xf, std::move(mData), MakePlatformMaterialList(), aabb, SMoverData(15000.f), actParms, 0.3f, 0.1f) +, x28c_(hInfo) +, x294_(hInfo) +, x29c_(dVuln) +, x304_treeGroupContainer(dcln) { + CActor::SetMaterialFilter(CMaterialFilter::MakeIncludeExclude( + CMaterialList(EMaterialTypes::Solid), + CMaterialList(EMaterialTypes::ThirtyEight, EMaterialTypes::Twenty, EMaterialTypes::Platform))); + if (x304_treeGroupContainer) + x314_treeGroup = std::make_unique(x304_treeGroupContainer->GetObj(), x68_material); } -void CScriptPlatform::Accept(IVisitor& visitor) -{ - visitor.Visit(this); -} +void CScriptPlatform::Accept(IVisitor& visitor) { visitor.Visit(this); } +rstl::optional_object CScriptPlatform::GetTouchBounds() const +{ + if (x314_treeGroup) + return {x314_treeGroup->CalculateAABox(GetTransform())}; + + return {CPhysicsActor::GetBoundingBox()}; +} } diff --git a/Runtime/World/CScriptPlatform.hpp b/Runtime/World/CScriptPlatform.hpp index 6217655b3..984cf3ff8 100644 --- a/Runtime/World/CScriptPlatform.hpp +++ b/Runtime/World/CScriptPlatform.hpp @@ -4,20 +4,67 @@ #include "CPhysicsActor.hpp" #include "optional.hpp" #include "CToken.hpp" +#include "CHealthInfo.hpp" +#include "CDamageVulnerability.hpp" namespace urde { class CCollidableOBBTreeGroup; +class CCollidableOBBTreeGroupContainer; + +struct SRiders +{ + TUniqueId x0_uid; + u32 x4_; + zeus::CTransform x8_transform; +}; class CScriptPlatform : public CPhysicsActor { + u32 x254_; + TUniqueId x258_ = kInvalidUniqueId; + TUniqueId x25a_ = kInvalidUniqueId; + float x25c_; + float x260_; + float x264_; + float x268_; + float x26c_; + zeus::CVector3f x270_; + zeus::CQuaternion x27c_; + CHealthInfo x28c_; + CHealthInfo x294_; + CDamageVulnerability x29c_; + rstl::optional_object> x304_treeGroupContainer; + std::unique_ptr x314_treeGroup; + std::vector x318_riders; + float x348_; + u32 x34c_; + u32 x350_; + TUniqueId x354_; + union + { + struct + { + bool x356_24_ : 1; + bool x356_25_ : 1; + bool x356_26_ : 1; + bool x356_27_ : 1; + bool x356_28_ : 1; + bool x356_29_ : 1; + bool x356_30_ : 1; + bool x356_31_ : 1; + }; + u32 x356_dummy = 0; + }; + public: CScriptPlatform(TUniqueId, const std::string& name, const CEntityInfo& info, const zeus::CTransform& xf, CModelData&& mData, const CActorParameters& actParms, const zeus::CAABox& aabb, float, bool, float, bool, const CHealthInfo& hInfo, const CDamageVulnerability& dInfo, - const rstl::optional_object>& dcln, bool, u32, u32); + const rstl::optional_object>& dcln, bool, u32, u32); void Accept(IVisitor& visitor); + rstl::optional_object GetTouchBounds() const; }; } diff --git a/Runtime/World/ScriptLoader.cpp b/Runtime/World/ScriptLoader.cpp index 6cab33324..de443dc2e 100644 --- a/Runtime/World/ScriptLoader.cpp +++ b/Runtime/World/ScriptLoader.cpp @@ -644,7 +644,7 @@ CEntity* ScriptLoader::LoadPlatform(CStateManager& mgr, CInputStream& in, int pr zeus::CAABox aabb = GetCollisionBox(mgr, info.GetAreaId(), extent, centroid); FourCC dclnType = g_ResFactory->GetResourceTypeById(dclnId); - rstl::optional_object> dclnToken; + rstl::optional_object> dclnToken; if (dclnType) { dclnToken.emplace(g_SimplePool->GetObj({SBIG('DCLN'), dclnId}));