7#include "game/nodes/SpatialNode.h"
8#include "math/GLMath.hpp"
9#include "render/general/resource/GpuResource.h"
10#include "shader/general/resource/binding/ShaderResourceBinding.h"
11#include "shader/general/resource/binding/cpuwrite/ShaderCpuWriteResourceBindingUniquePtr.h"
12#include "shader/general/resource/binding/texture/ShaderTextureResourceBindingUniquePtr.h"
13#include "shader/VulkanAlignmentConstants.hpp"
14#include "misc/shapes/AABB.h"
15#include "material/Material.h"
16#include "render/general/resource/MeshData.h"
18#include "MeshNode.generated.h"
20namespace ne RNAMESPACE() {
42 alignas(iVkMat4Alignment) glm::mat4x4 worldMatrix = glm::identity<glm::mat4x4>();
49 alignas(iVkMat4Alignment) glm::mat4x4 normalMatrix = glm::identity<glm::mat4x4>();
72 std::unordered_map<std::string, ShaderCpuWriteResourceBindingUniquePtr>
100 MeshNode(
const std::string& sNodeName);
116 void setMaterial(std::unique_ptr<Material> pMaterial,
size_t iMaterialSlot = 0);
125 void setMeshData(
const MeshData& meshData);
134 void setMeshData(
MeshData&& meshData);
137 void onMeshDataChanged();
144 void setIsVisible(
bool bVisible);
156 Material* getMaterial(
size_t iMaterialSlot = 0);
164 size_t getAvailableMaterialSlotCount();
181 inline std::pair<std::recursive_mutex*, MeshData*>
getMeshData() {
182 return std::make_pair(&mtxMeshData, &meshData);
191 return &mtxGpuResources;
203 return &mtxShaderMeshDataConstants;
218 bool isVisible()
const;
228 virtual void onAfterDeserialized()
override;
240 virtual void onSpawning()
override;
251 virtual void onDespawning()
override;
259 virtual void onWorldLocationRotationScaleChanged()
override;
288 void setShaderCpuWriteResourceBinding(
289 const std::string& sShaderResourceName,
290 size_t iResourceSizeInBytes,
291 const std::function<
void*()>& onStartedUpdatingResource,
292 const std::function<
void()>& onFinishedUpdatingResource);
305 void setShaderTextureResourceBinding(
306 const std::string& sShaderResourceName,
const std::string& sPathToTextureResourceRelativeRes);
327 void markShaderCpuWriteResourceToBeCopiedToGpu(
const std::string& sShaderResourceName);
335 static std::unique_ptr<Material> getDefaultMaterial();
342 void allocateShaderResources();
345 void allocateGeometryBuffers();
348 void deallocateShaderResources();
351 void deallocateGeometryBuffers();
358 void* onStartedUpdatingShaderMeshConstants();
361 void onFinishedUpdatingShaderMeshConstants();
373 void updateShaderResourcesToUseChangedMaterialPipelines();
385 std::pair<GpuResource*, unsigned int> getIndexBufferInfoForMaterialSlot(
size_t iMaterialSlot);
401 RPROPERTY(
Serialize(FST_AS_EXTERNAL_BINARY_FILE))
408 std::recursive_mutex mtxMeshData;
417 bool bIsVisible = true;
420 static inline const auto sMeshShaderConstantBufferName = "meshData";
422 ne_MeshNode_GENERATED
426File_MeshNode_GENERATED
Definition: GuidProperty.h:30
Definition: Material.h:63
Definition: MeshData.h:93
Definition: MeshNode.h:28
std::pair< std::recursive_mutex *, MeshData * > getMeshData()
Definition: MeshNode.h:181
std::pair< std::recursive_mutex, GpuResources > * getMeshGpuResources()
Definition: MeshNode.h:190
AABB * getAABB()
Definition: MeshNode.h:211
std::pair< std::recursive_mutex, MeshShaderConstants > * getMeshShaderConstants()
Definition: MeshNode.h:202
static const char * getMeshShaderConstantBufferName()
Definition: MeshNode.h:91
Definition: SerializeProperty.h:42
Definition: SpatialNode.h:12
Definition: MeshNode.h:57
std::unique_ptr< GpuResource > pVertexBuffer
Definition: MeshNode.h:61
std::vector< std::unique_ptr< GpuResource > > vIndexBuffers
Definition: MeshNode.h:64
Definition: MeshNode.h:68
std::unordered_map< std::string, ShaderTextureResourceBindingUniquePtr > shaderTextureResources
Definition: MeshNode.h:76
std::unordered_map< std::string, ShaderCpuWriteResourceBindingUniquePtr > shaderCpuWriteResourceBindings
Definition: MeshNode.h:73
Definition: MeshNode.h:53
Mesh mesh
Definition: MeshNode.h:80
ShaderResources shaderResources
Definition: MeshNode.h:83
Definition: MeshNode.h:38