1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
/*
* Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved.
*
* NVIDIA CORPORATION and its licensors retain all intellectual property
* and proprietary rights in and to this software, related documentation
* and any modifications thereto. Any use, reproduction, disclosure or
* distribution of this software and related documentation without an express
* license agreement from NVIDIA CORPORATION is strictly prohibited.
*/
#ifndef __BASIC_IOS_SCENE_H__
#define __BASIC_IOS_SCENE_H__
#include "Apex.h"
#include "ModuleBasicIos.h"
#include "ApexSDKIntl.h"
#include "ModuleIntl.h"
#include "ModuleBasicIosImpl.h"
#include "ApexSharedUtils.h"
#include "ApexSDKHelpers.h"
#include "ApexContext.h"
#include "ApexActor.h"
#include "ModulePerfScope.h"
#include "PsTime.h"
#include "DebugRenderParams.h"
#include "BasicIosDebugRenderParams.h"
#include "BasicIosCommon.h"
#include "BasicIosCommonSrc.h"
#include "FieldSamplerQueryIntl.h"
#if APEX_CUDA_SUPPORT
#include "../cuda/include/common.h"
#include "ApexCudaWrapper.h"
#include "CudaModuleScene.h"
#define SCENE_CUDA_OBJ(scene, name) static_cast<BasicIosSceneGPU&>(scene).APEX_CUDA_OBJ_NAME(name)
#endif
namespace nvidia
{
namespace apex
{
class RenderDebugInterface;
class FieldSamplerManagerIntl;
}
namespace basicios
{
class BasicIosInjectorStorage
{
public:
virtual bool growInjectorStorage(uint32_t newSize) = 0;
};
class BasicIosInjectorAllocator
{
public:
BasicIosInjectorAllocator(BasicIosInjectorStorage* storage) : mStorage(storage)
{
mFreeInjectorListStart = NULL_INJECTOR_INDEX;
mReleasedInjectorListStart = NULL_INJECTOR_INDEX;
}
uint32_t allocateInjectorID();
void releaseInjectorID(uint32_t);
void flushReleased();
static const uint32_t NULL_INJECTOR_INDEX = 0xFFFFFFFFu;
static const uint32_t USED_INJECTOR_INDEX = 0xFFFFFFFEu;
private:
BasicIosInjectorStorage* mStorage;
physx::Array<uint32_t> mInjectorList;
uint32_t mFreeInjectorListStart;
uint32_t mReleasedInjectorListStart;
};
class BasicIosScene : public ModuleSceneIntl, public ApexContext, public ApexResourceInterface, public ApexResource, protected BasicIosInjectorStorage
{
public:
BasicIosScene(ModuleBasicIosImpl& module, SceneIntl& scene, RenderDebugInterface* renderDebug, ResourceList& list);
~BasicIosScene();
/* ModuleSceneIntl */
void release()
{
mModule->releaseModuleSceneIntl(*this);
}
PxScene* getModulePhysXScene() const
{
return mPhysXScene;
}
void setModulePhysXScene(PxScene*);
PxScene* mPhysXScene;
void visualize();
virtual Module* getModule()
{
return mModule;
}
virtual SceneStats* getStats()
{
return 0;
}
bool lockRenderResources()
{
renderLockAllActors(); // Lock options not implemented yet
return true;
}
bool unlockRenderResources()
{
renderUnLockAllActors(); // Lock options not implemented yet
return true;
}
/* ApexResourceInterface */
uint32_t getListIndex() const
{
return m_listIndex;
}
void setListIndex(ResourceList& list, uint32_t index)
{
m_listIndex = index;
m_list = &list;
}
virtual BasicIosActorImpl* createIosActor(ResourceList& list, BasicIosAssetImpl& asset, nvidia::apex::IofxAsset& iofxAsset) = 0;
virtual void submitTasks(float elapsedTime, float substepSize, uint32_t numSubSteps);
virtual void setTaskDependencies();
virtual void fetchResults();
FieldSamplerManagerIntl* getInternalFieldSamplerManager();
SceneIntl& getApexScene() const
{
return *mApexScene;
}
PX_INLINE BasicIosInjectorAllocator& getInjectorAllocator()
{
return mInjectorAllocator;
}
virtual void fetchInjectorParams(uint32_t injectorID, InjectorParams& injParams) = 0;
virtual void updateInjectorParams(uint32_t injectorID, const InjectorParams& injParams) = 0;
protected:
virtual void onSimulationStart() {}
virtual void onSimulationFinish()
{
mInjectorAllocator.flushReleased();
}
ModuleBasicIosImpl* mModule;
SceneIntl* mApexScene;
void destroy();
float computeAABBDistanceSquared(const PxBounds3& aabb);
RenderDebugInterface* mDebugRender;
float mSumBenefit;
DebugRenderParams* mDebugRenderParams;
BasicIosDebugRenderParams* mBasicIosDebugRenderParams;
FieldSamplerManagerIntl* mFieldSamplerManager;
BasicIosInjectorAllocator mInjectorAllocator;
friend class BasicIosActorImpl;
friend class BasicIosAssetImpl;
friend class ModuleBasicIosImpl;
};
}
} // namespace nvidia
#endif // __BASIC_IOS_SCENE_H__
|