Plasma Engine  2.0
Loading...
Searching...
No Matches
SurfaceResource.h
1#pragma once
2
3#include <Core/CoreDLL.h>
4
5#include <Core/Physics/SurfaceResourceDescriptor.h>
6#include <Core/ResourceManager/Resource.h>
7#include <Core/World/Declarations.h>
8#include <Foundation/Containers/DynamicArray.h>
9#include <Foundation/Reflection/Reflection.h>
10
11class plWorld;
12class plUuid;
13
15{
16 enum class Type
17 {
18 Created,
19 Destroyed
20 };
21
22 Type m_Type;
23 plSurfaceResource* m_pSurface;
24};
25
26class PL_CORE_DLL plSurfaceResource : public plResource
27{
28 PL_ADD_DYNAMIC_REFLECTION(plSurfaceResource, plResource);
29 PL_RESOURCE_DECLARE_COMMON_CODE(plSurfaceResource);
30 PL_RESOURCE_DECLARE_CREATEABLE(plSurfaceResource, plSurfaceResourceDescriptor);
31
32public:
35
36 const plSurfaceResourceDescriptor& GetDescriptor() const { return m_Descriptor; }
37
39
40 void* m_pPhysicsMaterialPhysX = nullptr;
41 void* m_pPhysicsMaterialJolt = nullptr;
42
45 bool InteractWithSurface(plWorld* pWorld, plGameObjectHandle hObject, const plVec3& vPosition, const plVec3& vSurfaceNormal, const plVec3& vIncomingDirection, const plTempHashedString& sInteraction, const plUInt16* pOverrideTeamID, float fImpulseSqr = 0.0f) const;
46
47 bool IsBasedOn(const plSurfaceResource* pThisOrBaseSurface) const;
48
49 bool IsBasedOn(const plSurfaceResourceHandle hThisOrBaseSurface) const;
50
51private:
52 virtual plResourceLoadDesc UnloadData(Unload WhatToUnload) override;
53 virtual plResourceLoadDesc UpdateContent(plStreamReader* Stream) override;
54 virtual void UpdateMemoryUsage(MemoryUsage& out_NewMemoryUsage) override;
55
56private:
57 static const plSurfaceInteraction* FindInteraction(const plSurfaceResource* pCurSurf, plUInt64 uiHash, float fImpulseSqr, float& out_fImpulseParamValue);
58
59 plSurfaceResourceDescriptor m_Descriptor;
60
61 struct SurfInt
62 {
63 plUInt64 m_uiInteractionTypeHash = 0;
64 const plSurfaceInteraction* m_pInteraction;
65 };
66
67 plDynamicArray<SurfInt> m_Interactions;
68};
Definition DynamicArray.h:81
Definition Event.h:177
The base class for all resources.
Definition Resource.h:10
virtual plResourceLoadDesc UnloadData(Unload WhatToUnload)=0
Requests the resource to unload another quality level. If bFullUnload is true, the resource should un...
virtual plResourceLoadDesc UpdateContent(plStreamReader *pStream)=0
Called whenever more data for the resource is available. The resource must read the stream to update ...
virtual void UpdateMemoryUsage(MemoryUsage &out_NewMemoryUsage)=0
This function must be overridden by all resource types.
Interface for binary in (read) streams.
Definition Stream.h:22
Definition SurfaceResource.h:27
A class to use together with plHashedString for quick comparisons with temporary strings that need no...
Definition HashedString.h:151
This data type is the abstraction for 128-bit Uuid (also known as GUID) instances.
Definition Uuid.h:11
A world encapsulates a scene graph of game objects and various component managers and their component...
Definition World.h:22
A handle to a game object.
Definition Declarations.h:76
Definition Resource.h:34
Describes in which loading state a resource currently is, and how many different quality levels there...
Definition Declarations.h:102
Definition SurfaceResourceDescriptor.h:37
Definition SurfaceResourceDescriptor.h:60
Definition SurfaceResource.h:15