License conversion from Flora to Apache 2.0
[platform/core/uifw/dali-core.git] / dali / internal / update / dynamics / scene-graph-dynamics-mesh-shape.h
1 #ifndef __SCENE_GRAPH_DYNAMICS_MESH_SHAPE_H__
2 #define __SCENE_GRAPH_DYNAMICS_MESH_SHAPE_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // BASE CLASS HEADERS
22 #include <dali/internal/update/dynamics/scene-graph-dynamics-shape.h>
23
24 // INTERNAL HEADERS
25 #include <dali/integration-api/resource-declarations.h>
26 #include <dali/internal/common/message.h>
27 #include <dali/internal/common/event-to-update.h>
28 #include <dali/internal/event/dynamics/dynamics-declarations.h>
29 #include <dali/internal/update/modeling/scene-graph-mesh-declarations.h>
30
31 namespace Dali
32 {
33
34 namespace Internal
35 {
36
37 class ResourceManager;
38
39 namespace SceneGraph
40 {
41
42 class DynamicsWorld;
43
44 class DynamicsMeshShape : public DynamicsShape
45 {
46 public:
47   /**
48    * Constructor.
49    * @param[in] world           The dynamics world object
50    * @param[in] resourceManager The resource manager
51    * @param[in] meshId          ID for the mesh resource
52    */
53   DynamicsMeshShape( DynamicsWorld& world, ResourceManager& resourceManager, const Integration::ResourceId meshId );
54
55   /**
56    * Destructor.
57    */
58   virtual ~DynamicsMeshShape();
59
60   /**
61    * Initialize the mesh.
62    */
63   void Initialize();
64
65   Mesh* GetMesh() const;
66
67 private:
68   // unimplemented copy constructor and assignment operator
69   DynamicsMeshShape(const DynamicsMeshShape&);
70   DynamicsMeshShape& operator=(const DynamicsMeshShape&);
71
72 private:
73   ResourceManager& mResourceManager;
74   Integration::ResourceId mMeshId;
75 }; // class DynamicsMeshShape
76
77 inline void InitializeDynamicsMeshShapeMessage( EventToUpdate& eventToUpdate, const DynamicsMeshShape& shape )
78 {
79   typedef Message< DynamicsMeshShape > LocalType;
80
81   // Reserve some memory inside the message queue
82   unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
83
84   // Construct message in the message queue memory; note that delete should not be called on the return value
85   new (slot) LocalType( &shape, &DynamicsMeshShape::Initialize );
86 }
87
88 } // namespace SceneGraph
89
90 } // namespace Internal
91
92 } // namespace Dali
93
94 #endif // __SCENE_GRAPH_DYNAMICS_MESH_SHAPE_H__