• R/O
  • SSH

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisionbeb9f2c3c8688193ba1823c342ceec30f5542e1a (tree)
Time2024-07-08 03:08:23
Authorsebastian_bugiu
Commitersebastian_bugiu

Log Message

WIP adding NodeMemoryManager and ObjectMemoryManager per zone.

Change Summary

Incremental Difference

diff -r 9acd6c13646b -r beb9f2c3c868 OgreMain/include/OgreMovableObject.h
--- a/OgreMain/include/OgreMovableObject.h Fri Jul 05 14:36:49 2024 +0200
+++ b/OgreMain/include/OgreMovableObject.h Sun Jul 07 20:08:23 2024 +0200
@@ -218,6 +218,8 @@
218218 /// Called by SceneManager when it is telling we're a static MovableObject being dirty
219219 /// Don't call this directly. @see SceneManager::notifyStaticDirty
220220 virtual void _notifyStaticDirty(void) const {}
221+
222+ void migrateTo( ObjectMemoryManager *objMemManager );
221223
222224 /** Internal method by which the movable object must add Renderable subclass instances to the rendering queue.
223225 @remarks
diff -r 9acd6c13646b -r beb9f2c3c868 OgreMain/include/OgreSceneManager.h
--- a/OgreMain/include/OgreSceneManager.h Fri Jul 05 14:36:49 2024 +0200
+++ b/OgreMain/include/OgreSceneManager.h Sun Jul 07 20:08:23 2024 +0200
@@ -1976,8 +1976,9 @@
19761976 virtual void updateSceneGraph();
19771977
19781978 typedef FastArray<MovableObject*> MovableObjectArray;
1979- virtual void _findVisibleObjects ( Camera * cam, Camera * lodCamera,
1980- const size_t numNodes, ObjectData t, MovableObjectArray &outCulledObjects, bool onlyShadowCasters ) {}
1979+ virtual void _findVisibleObjects( NodeMemoryManagerVec &nodeMemoryManagers,
1980+ ObjectMemoryManagerVec &entitiesMemoryManagerCulledList,
1981+ bool onlyShadowCasters ) {}
19811982
19821983 /** Internal method for applying animations to scene nodes.
19831984 @remarks
diff -r 9acd6c13646b -r beb9f2c3c868 OgreMain/src/OgreMovableObject.cpp
--- a/OgreMain/src/OgreMovableObject.cpp Fri Jul 05 14:36:49 2024 +0200
+++ b/OgreMain/src/OgreMovableObject.cpp Sun Jul 07 20:08:23 2024 +0200
@@ -52,9 +52,9 @@
5252 const uint32 VisibilityFlags::LAYER_SHADOW_CASTER = 1 << 31;
5353 const uint32 VisibilityFlags::LAYER_VISIBILITY = 1 << 30;
5454 const uint32 VisibilityFlags::LAYER_PCZ_VISIBILITY = 1 << 29;
55- const uint32 VisibilityFlags::RESERVED_VISIBILITY_FLAGS = ~(LAYER_SHADOW_CASTER|LAYER_VISIBILITY|LAYER_PCZ_VISIBILITY);
55+ const uint32 VisibilityFlags::RESERVED_VISIBILITY_FLAGS = ~(LAYER_SHADOW_CASTER|LAYER_VISIBILITY);
5656 uint32 MovableObject::msDefaultQueryFlags = 0xFFFFFFFF;
57- uint32 MovableObject::msDefaultVisibilityFlags = 0xFFFFFFFF & (~(LAYER_VISIBILITY|LAYER_PCZ_VISIBILITY));
57+ uint32 MovableObject::msDefaultVisibilityFlags = 0xFFFFFFFF & (~(LAYER_VISIBILITY));
5858 //-----------------------------------------------------------------------
5959 MovableObject::MovableObject( IdType id, ObjectMemoryManager *objectMemoryManager,
6060 SceneManager *manager, uint8 renderQueueId )
@@ -191,6 +191,17 @@
191191 return retVal;
192192 }
193193 //-----------------------------------------------------------------------
194+ void MovableObject::migrateTo( ObjectMemoryManager *objMemManager )
195+ {
196+ mObjectMemoryManager->migrateTo( mObjectData, mRenderQueueID,
197+ objMemManager );
198+ mObjectMemoryManager = objMemManager;
199+ if( mParentNode )
200+ {
201+
202+ }
203+ }
204+ //-----------------------------------------------------------------------
194205 bool MovableObject::isVisible(void) const
195206 {
196207 if( !getVisible() )
@@ -560,10 +571,18 @@
560571 //Decompose the result for analyzing each MovableObject's
561572 //There's no need to check objData.mOwner[j] is null because
562573 //we set mVisibilityFlags to 0 on slot removals
574+ int vis = 0;
563575 if( IS_BIT_SET( j, scalarMask ) )
564576 {
565577 culledObjects.push_back( objData.mOwner[j] );
578+ vis = 1;
566579 }
580+// if ( vis == 1 )
581+// {
582+ std::stringstream str;
583+ str << "visibility for object: " << objData.mOwner[j]->getName() << " final visibility: " << vis;
584+ LogManager::getSingleton().logMessage( LML_NORMAL, str.str() );
585+// }
567586 }
568587
569588 objData.advanceFrustumPack();
diff -r 9acd6c13646b -r beb9f2c3c868 OgreMain/src/OgreSceneManager.cpp
--- a/OgreMain/src/OgreSceneManager.cpp Fri Jul 05 14:36:49 2024 +0200
+++ b/OgreMain/src/OgreSceneManager.cpp Sun Jul 07 20:08:23 2024 +0200
@@ -1087,10 +1087,10 @@
10871087
10881088 camera->_setRenderedRqs( realFirstRq, realLastRq );
10891089 #ifdef USE_PCZ
1090- PCZCullFrustumRequest cullRequest( realFirstRq, realLastRq,
1090+ CullFrustumRequest cullRequest( realFirstRq, realLastRq,
10911091 mIlluminationStage == IRS_RENDER_TO_TEXTURE, true, false,
10921092 &mEntitiesMemoryManagerCulledList, camera, lodCamera );
1093- firePCZCullFrustumThreads( cullRequest );
1093+ fireCullFrustumThreads( cullRequest );
10941094 #else
10951095 CullFrustumRequest cullRequest( realFirstRq, realLastRq,
10961096 mIlluminationStage == IRS_RENDER_TO_TEXTURE, true, false,
@@ -2489,9 +2489,6 @@
24892489 //when there are less entities than ARRAY_PACKED_REALS
24902490 numObjs = std::min( numObjs, totalObjs - toAdvance );
24912491 objData.advancePack( toAdvance / ARRAY_PACKED_REALS );
2492-
2493- // First go through the portals to remove everything that isn't visible.
2494- _findVisibleObjects( const_cast<Camera*>(camera), const_cast<Camera*>(lodCamera), numObjs, objData, outVisibleObjects, false );
24952492
24962493 MovableObject::pczCullFrustum( numObjs, objData, camera, visibilityMask,
24972494 outVisibleObjects, lodCamera );
@@ -2895,7 +2892,7 @@
28952892 _applySceneAnimations();
28962893 updateAllTransforms();
28972894 #ifdef USE_PCZ
2898- resetAllUpdateFlags();
2895+// resetAllUpdateFlags();
28992896 #endif
29002897 updateAllAnimations();
29012898 updateAllTagPoints();
diff -r 9acd6c13646b -r beb9f2c3c868 PlugIns/PCZSceneManager/include/OgreDefaultZone.h
--- a/PlugIns/PCZSceneManager/include/OgreDefaultZone.h Fri Jul 05 14:36:49 2024 +0200
+++ b/PlugIns/PCZSceneManager/include/OgreDefaultZone.h Sun Jul 07 20:08:23 2024 +0200
@@ -97,16 +97,12 @@
9797 Starts with objects in the zone and proceeds through visible portals
9898 This is a recursive call (the main call should be to _findVisibleObjects)
9999 */
100- void findVisibleNodes(PCZCamera * cam, PCZCamera * lodCamera,
101- const size_t numNodes,
102- ObjectData objData,
103- MovableObject::MovableObjectArray &outCulledObjects,
104-// NodeList & visibleNodeList,
105-// RenderQueue * queue,
106-// VisibleObjectsBoundsInfo* visibleBounds,
107- bool onlyShadowCasters,
108- bool displayNodes,
109- bool showBoundingBoxes);
100+ void findVisibleNodes( PCZCamera *camera,
101+ NodeMemoryManagerVec &nodeMemoryManagers,
102+ ObjectMemoryManagerVec &entitiesMemoryManagerCulledList,
103+ bool onlyShadowCasters,
104+ bool displayNodes,
105+ bool showBoundingBoxes );
110106
111107 /* Functions for finding Nodes that intersect various shapes */
112108 void _findNodes( const AxisAlignedBox &t,
diff -r 9acd6c13646b -r beb9f2c3c868 PlugIns/PCZSceneManager/include/OgrePCZSceneManager.h
--- a/PlugIns/PCZSceneManager/include/OgrePCZSceneManager.h Fri Jul 05 14:36:49 2024 +0200
+++ b/PlugIns/PCZSceneManager/include/OgrePCZSceneManager.h Sun Jul 07 20:08:23 2024 +0200
@@ -141,10 +141,13 @@
141141
142142 /** Update Scene Graph (does several things now) */
143143 void updateSceneGraph( /*Camera * cam*/ );
144+
145+ virtual void highLevelCull();
144146
145147 /** Recurses through the PCZTree determining which nodes are visible. */
146- virtual void _findVisibleObjects ( Camera * cam, Camera * lodCamera,
147- const size_t numNodes, ObjectData objData, MovableObject::MovableObjectArray &outCulledObjects, bool onlyShadowCasters );
148+ virtual void _findVisibleObjects( NodeMemoryManagerVec &nodeMemoryManagers,
149+ ObjectMemoryManagerVec &entitiesMemoryManagerCulledList,
150+ bool onlyShadowCasters );
148151
149152 /** Alerts each unculled object, notifying it that it will be drawn.
150153 * Useful for doing calculations only on nodes that will be drawn, prior
@@ -328,6 +331,9 @@
328331
329332 /// @see SceneManager::prepareShadowTextures.
330333 // virtual void prepareShadowTextures(Camera* cam, Viewport* vp, const LightList* lightList = 0);
334+
335+ void setCurrentCamera( Camera *camera ) { mCurrentCamera = camera; }
336+ Camera *getCurrentCamera() { return mCurrentCamera; }
331337
332338 protected:
333339 /// Type of default zone to be used
@@ -367,21 +373,11 @@
367373 /// The zone of the active camera (for shadow texture casting use);
368374 PCZone* mActiveCameraZone;
369375
370-// NodeMemoryManager mNodeMemoryManager[NUM_SCENE_MEMORY_MANAGER_TYPES];
371-// ObjectMemoryManager mEntityMemoryManager[NUM_SCENE_MEMORY_MANAGER_TYPES];
372-// ObjectMemoryManager mLightMemoryManager;
376+ Camera *mCurrentCamera;
377+
373378 ObjectMemoryManager mPortalMemoryManager;
374379 ObjectMemoryManager mAntiPortalMemoryManager;
375380 ObjectMemoryManager mZoneMemoryManager;
376-// SkeletonAnimManager mSkeletonAnimationManager;
377-// NodeMemoryManager mTagPointNodeMemoryManager;
378- /// Filled and cleared every frame in HighLevelCull()
379- NodeMemoryManagerVec mNodeMemoryManagerUpdateList;
380-// NodeMemoryManagerVec mTagPointNodeMemoryManagerUpdateList;
381- ObjectMemoryManagerVec mEntitiesMemoryManagerCulledList;
382- ObjectMemoryManagerVec mEntitiesMemoryManagerUpdateList;
383- ObjectMemoryManagerVec mLightsMemoryManagerCulledList;
384-// SkeletonAnimManagerVec mSkeletonAnimManagerCulledList;
385381
386382 /** Internal method for locating a list of lights which could be affecting the frustum.
387383 @remarks
diff -r 9acd6c13646b -r beb9f2c3c868 PlugIns/PCZSceneManager/include/OgrePCZone.h
--- a/PlugIns/PCZSceneManager/include/OgrePCZone.h Fri Jul 05 14:36:49 2024 +0200
+++ b/PlugIns/PCZSceneManager/include/OgrePCZone.h Sun Jul 07 20:08:23 2024 +0200
@@ -53,6 +53,8 @@
5353
5454 #include "OgrePCZPrerequisites.h"
5555 #include "OgrePortalBase.h"
56+#include "Math/Array/OgreNodeMemoryManager.h"
57+#include "Math/Array/OgreObjectMemoryManager.h"
5658
5759 namespace Ogre
5860 {
@@ -192,16 +194,14 @@
192194 Starts with objects in the zone and proceeds through visible portals
193195 This is a recursive call (the main call should be to _findVisibleObjects)
194196 */
195- virtual void findVisibleNodes(PCZCamera * cam, PCZCamera * lodCamera,
196- const size_t numNodes,
197- ObjectData objData,
198- MovableObject::MovableObjectArray &outCulledObjects,
199-// NodeList & visibleNodeList,
200- // RenderQueue * queue,
201- // VisibleObjectsBoundsInfo* visibleBounds,
202- bool onlyShadowCasters,
203- bool displayNodes = false,
204- bool showBoundingBoxes = false) = 0;
197+ typedef vector<NodeMemoryManager*>::type NodeMemoryManagerVec;
198+ typedef vector<ObjectMemoryManager*>::type ObjectMemoryManagerVec;
199+ virtual void findVisibleNodes( PCZCamera *camera,
200+ NodeMemoryManagerVec &nodeMemoryManagers,
201+ ObjectMemoryManagerVec &ntitiesMemoryManagerCulledList,
202+ bool onlyShadowCasters,
203+ bool displayNodes = false,
204+ bool showBoundingBoxes = false) = 0;
205205
206206 /* Functions for finding Nodes that intersect various shapes */
207207 virtual void _findNodes( const AxisAlignedBox &t,
@@ -254,6 +254,9 @@
254254 AntiPortalList mAntiPortals;
255255 /// Pointer to the pcz scene manager that created this zone
256256 PCZSceneManager * mPCZSM;
257+
258+ NodeMemoryManager mNodeMemoryManager;
259+ ObjectMemoryManager mEntitiesMemoryManager;
257260
258261 protected:
259262 /** Binary predicate for portal <-> camera distance sorting. */
diff -r 9acd6c13646b -r beb9f2c3c868 PlugIns/PCZSceneManager/src/OgreDefaultZone.cpp
--- a/PlugIns/PCZSceneManager/src/OgreDefaultZone.cpp Fri Jul 05 14:36:49 2024 +0200
+++ b/PlugIns/PCZSceneManager/src/OgreDefaultZone.cpp Sun Jul 07 20:08:23 2024 +0200
@@ -45,6 +45,7 @@
4545 #include "OgrePCZCamera.h"
4646 #include "OgreMovableObject.h"
4747 #include "OgreLogManager.h"
48+#include "Math/Array/OgreNodeMemoryManager.h"
4849
4950 namespace Ogre
5051 {
@@ -78,6 +79,11 @@
7879 {
7980 // add a reference to this node in the "nodes at home in this zone" list
8081 mHomeNodeList.insert( n );
82+// n->migrateTo( &mNodeMemoryManager );
83+ for( size_t i = 0; i < n->numAttachedObjects(); ++i )
84+ {
85+ n->getAttachedObject( i )->migrateTo( &mEntitiesMemoryManager );
86+ }
8187 }
8288 else
8389 {
@@ -516,17 +522,12 @@
516522 /*
517523 // Recursively walk the zones, adding all visible SceneNodes to the list of visible nodes.
518524 */
519- void DefaultZone::findVisibleNodes(PCZCamera * camera,
520- PCZCamera * lodCamera,
521- const size_t numNodes,
522- ObjectData objData,
523- MovableObject::MovableObjectArray &outCulledObjects,
524- // NodeList & visibleNodeList,
525- // RenderQueue * queue,
526- // VisibleObjectsBoundsInfo* visibleBounds,
525+ void DefaultZone::findVisibleNodes( PCZCamera *camera,
526+ NodeMemoryManagerVec &nodeMemoryManagers,
527+ ObjectMemoryManagerVec &entitiesMemoryManagerCulledList,
527528 bool onlyShadowCasters,
528529 bool displayNodes,
529- bool showBoundingBoxes)
530+ bool showBoundingBoxes )
530531 {
531532
532533 //return immediately if nothing is in the zone.
@@ -546,9 +547,12 @@
546547 // TODO use modern way to render sky.
547548 //mPCZSM->enableSky(true);
548549 }
550+
551+ nodeMemoryManagers.push_back( &mNodeMemoryManager );
552+ entitiesMemoryManagerCulledList.push_back( &mEntitiesMemoryManager );
549553
550554 // find visible nodes at home in the zone
551- bool vis;
555+ /*bool vis;
552556 PCZSceneNodeList::iterator it = mHomeNodeList.begin();
553557 while ( it != mHomeNodeList.end() )
554558 {
@@ -686,7 +690,7 @@
686690 }
687691 }
688692 ++it;
689- }
693+ }*/
690694
691695 // Here we merge both portal and antiportal visible to the camera into one list.
692696 // Then we sort them in the order from nearest to furthest from camera.
@@ -737,16 +741,12 @@
737741 portal->getTargetZone()->setLastVisibleFrame(mLastVisibleFrame);
738742 portal->getTargetZone()->setLastVisibleFromCamera(camera);
739743 // recurse into the connected zone
740- portal->getTargetZone()->findVisibleNodes(camera, lodCamera,
741- numNodes,
742- objData,
743- outCulledObjects,
744- // visibleNodeList,
745- // RenderQueue * queue,
746- // VisibleObjectsBoundsInfo* visibleBounds,
747- onlyShadowCasters,
748- displayNodes,
749- showBoundingBoxes);
744+ portal->getTargetZone()->findVisibleNodes( camera,
745+ nodeMemoryManagers,
746+ entitiesMemoryManagerCulledList,
747+ onlyShadowCasters,
748+ displayNodes,
749+ showBoundingBoxes );
750750 if (planes_added > 0)
751751 {
752752 // Then remove the extra culling planes added before going to the next portal in the list.
diff -r 9acd6c13646b -r beb9f2c3c868 PlugIns/PCZSceneManager/src/OgrePCZSceneManager.cpp
--- a/PlugIns/PCZSceneManager/src/OgrePCZSceneManager.cpp Fri Jul 05 14:36:49 2024 +0200
+++ b/PlugIns/PCZSceneManager/src/OgrePCZSceneManager.cpp Sun Jul 07 20:08:23 2024 +0200
@@ -55,7 +55,8 @@
5555 mDefaultZone(0),
5656 mShowPortals(false),
5757 mZoneFactoryManager(0),
58- mActiveCameraZone(0)
58+ mActiveCameraZone(0),
59+ mCurrentCamera( 0 )
5960 { }
6061
6162 PCZSceneManager::~PCZSceneManager()
@@ -369,15 +370,6 @@
369370 return retVal;
370371 }
371372
372- /*SceneNode* PCZSceneManager::createSceneNodeImpl(const String& name)
373- {
374- SceneNode *retVal = OGRE_NEW PCZSceneNode( Id::generateNewId<Node>(), this,
375- nodeMemoryManager, parent );
376- if( nodeMemoryManager->getMemoryManagerType() == SCENE_STATIC )
377- notifyStaticDirty( retVal );
378- return retVal;
379- }*/
380-
381373 SceneNode * PCZSceneManager::createSceneNode( SceneMemoryMgrTypes sceneType )
382374 {
383375 SceneNode * sn = SceneManager::createSceneNode(sceneType);
@@ -421,6 +413,9 @@
421413 zone->notifyCameraCreated( c );
422414 }
423415
416+ // TODO HACK for setting current camera for findVisibleNodes(). This should be an explicit call from game.
417+ setCurrentCamera( c );
418+
424419 return c;
425420 }
426421
@@ -1279,12 +1274,9 @@
12791274 // main visibility determination & render queue filling routine
12801275 // over-ridden from base/default scene manager. This is *the*
12811276 // main call.
1282- void PCZSceneManager::_findVisibleObjects( Camera * camera,
1283- Camera * lodCamera,
1284- const size_t numNodes,
1285- ObjectData objData,
1286- MovableObject::MovableObjectArray &outCulledObjects,
1287- bool onlyShadowCasters )
1277+ void PCZSceneManager::_findVisibleObjects( NodeMemoryManagerVec &nodeMemoryManagers,
1278+ ObjectMemoryManagerVec &entitiesMemoryManagerCulledList,
1279+ bool onlyShadowCasters )
12881280 {
12891281 // clear the render queue
12901282 // getRenderQueue()->clear();
@@ -1303,10 +1295,12 @@
13031295 }
13041296 return;
13051297 }*/
1298+
1299+ PCZCamera *camera = (PCZCamera*) getCurrentCamera();
13061300
13071301 // increment the visibility frame counter
13081302 mFrameCount = frameCount;
1309- mLastActiveCamera = camera;
1303+// mLastActiveCamera = camera;
13101304
13111305 // clear the list of visible nodes
13121306 mVisible.clear();
@@ -1316,27 +1310,33 @@
13161310 //enableSky(false);
13171311
13181312 // remove all extra culling planes
1319- ((PCZCamera*)camera)->removeAllExtraCullingPlanes();
1313+ camera->removeAllExtraCullingPlanes();
13201314
13211315 // update the camera
1322- ((PCZCamera*)camera)->update();
1316+ camera->update();
13231317
13241318 // get the home zone of the camera
13251319 PCZone* cameraHomeZone = ((PCZSceneNode*)(camera->getParentSceneNode()))->getHomeZone();
1326-
1327- // walk the zones, starting from the camera home zone,
1328- // adding all visible scene nodes to the mVisibles list
1329- cameraHomeZone->setLastVisibleFrame(mFrameCount);
1330- cameraHomeZone->findVisibleNodes( (PCZCamera*)camera, (PCZCamera*)lodCamera,
1331- numNodes,
1332- objData,
1333- outCulledObjects,
1334- // visibleNodeList,
1335- // RenderQueue * queue,
1336- // VisibleObjectsBoundsInfo* visibleBounds,
1337- onlyShadowCasters,
1338- false,
1339- false);
1320+
1321+ if( cameraHomeZone )
1322+ {
1323+ // walk the zones, starting from the camera home zone,
1324+ // adding all visible scene nodes to the mVisibles list
1325+ cameraHomeZone->setLastVisibleFrame(mFrameCount);
1326+ cameraHomeZone->findVisibleNodes( camera,
1327+ nodeMemoryManagers,
1328+ entitiesMemoryManagerCulledList,
1329+ onlyShadowCasters,
1330+ false,
1331+ false);
1332+ }
1333+ }
1334+
1335+ void PCZSceneManager::highLevelCull()
1336+ {
1337+ SceneManager::highLevelCull();
1338+
1339+ _findVisibleObjects( mNodeMemoryManagerUpdateList, mEntitiesMemoryManagerCulledList, false );
13401340 }
13411341
13421342 void PCZSceneManager::findNodesIn( const AxisAlignedBox &box,