Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
SubMesh.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2018 DIVIDE-Studio
3 Copyright (c) 2009 Ionut Cava
4
5 This file is part of DIVIDE Framework.
6
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software
9 and associated documentation files (the "Software"), to deal in the Software
10 without restriction,
11 including without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense,
13 and/or sell copies of the Software, and to permit persons to whom the
14 Software is furnished to do so,
15 subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED,
22 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23 PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY,
26 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27 IN CONNECTION WITH THE SOFTWARE
28 OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 */
31
32#pragma once
33#ifndef DVD_SUB_MESH_H_
34#define DVD_SUB_MESH_H_
35
36#include "Object3D.h"
37
38/*
39DIVIDE-Engine: 21.10.2010 (Ionut Cava)
40
41A SubMesh is a geometry wrapper used to build a mesh. Just like a mesh, it can
42be rendered locally or across
43the server or disabled from rendering alltogheter.
44
45Objects created from this class have theyr position in relative space based on
46the parent mesh position.
47(Same for scale,rotation and so on).
48
49The SubMesh is composed of a VB object that contains vertx,normal and textcoord
50data, a vector of materials,
51and a name.
52*/
53
54#include "Mesh.h"
55
56namespace Divide {
57
58namespace Attorney {
59 class SubMeshMesh;
60 class SubMeshMeshImporter;
61};
62
63class MeshImporter;
64
65class AnimationComponent;
66
68{
69 friend class Attorney::SubMeshMesh;
71
72 enum class BoundingBoxState : U8 {
73 Computing = 0,
74 Computed,
75 COUNT
76 };
77
78 using BoundingBoxPerAnimation = vector<BoundingBox>;
79 using BoundingBoxPerAnimationStatus = vector<BoundingBoxState>;
80
81 public:
82 explicit SubMesh( const ResourceDescriptor<SubMesh>& descriptor );
83
84 void postLoad(SceneGraphNode* sgn) override;
85 bool postLoad() override;
86
87 PROPERTY_R_IW(ResourcePtr<Mesh>, parentMesh, nullptr);
88 PROPERTY_R(U32, id, 0u);
89 PROPERTY_R(U8, boneCount, 0u);
90
91private:
92 void computeBBForAnimation(SceneGraphNode* sgn, U32 animIndex);
93 void buildBoundingBoxesForAnim(const Task& parentTask, U32 animationIndex, const AnimationComponent* const animComp);
94
95 void updateBB(U32 animIndex);
96
97protected:
98 void onAnimationChange(SceneGraphNode* sgn, U32 newIndex) override;
99
100private:
102 mutable SharedMutex _bbStateLock;
103 BoundingBoxPerAnimationStatus _boundingBoxesState;
104
106 mutable SharedMutex _bbLock;
107 BoundingBoxPerAnimation _boundingBoxes;
108};
109
111
112namespace Attorney
113{
114
116{
117 static void setParentMesh(SubMesh& subMesh, ResourcePtr<Mesh> parentMesh)
118 {
119 subMesh.parentMesh(parentMesh);
120 subMesh.geometryBuffer(parentMesh->geometryBuffer());
121 }
122
123 friend class Divide::Mesh;
125};
126
128{
129 static void setBoundingBox(SubMesh& subMesh,
130 const vec3<F32>& min,
131 const vec3<F32>& max,
132 const vec3<F32>& worldOffset) noexcept
133 {
134 subMesh._boundingBox.set(min, max);
135 subMesh._worldOffset.set(worldOffset);
136 }
137
139};
140}; // namespace Attorney
141}; // namespace Divide
142
143#endif //DVD_SUB_MESH_H_
#define PROPERTY_R(...)
Convenience method to add a class member with public read access but protected write access.
#define PROPERTY_R_IW(...)
Convenience method to add a class member with public read access but protected write access including...
#define TYPEDEF_SMART_POINTERS_FOR_TYPE(T)
#define DEFINE_3D_OBJECT_TYPE(Name, Enum)
Definition: SceneNodeFwd.h:128
static void setParentMesh(SubMesh &subMesh, ResourcePtr< Mesh > parentMesh)
Definition: SubMesh.h:117
friend class Divide::Mesh
Definition: SubMesh.h:123
static void setBoundingBox(SubMesh &subMesh, const vec3< F32 > &min, const vec3< F32 > &max, const vec3< F32 > &worldOffset) noexcept
Definition: SubMesh.h:129
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
T * ResourcePtr
Definition: Resource.h:112
uint8_t U8
std::shared_mutex SharedMutex
Definition: SharedMutex.h:43
eastl::vector< Type > vector
Definition: Vector.h:42
uint32_t U32