diff options
author | Benoit Bolsee <benoit.bolsee@online.be> | 2009-04-14 00:08:33 +0400 |
---|---|---|
committer | Benoit Bolsee <benoit.bolsee@online.be> | 2009-04-14 00:08:33 +0400 |
commit | 0b8661ab4da1a7cfbc756640649a2d07bb36cc64 (patch) | |
tree | 6d171db30ddcba3d379dea04b2da9449203419a6 /source/gameengine/Converter | |
parent | 6f12e584a97f664c654ddfbe5f721d2a7be3d491 (diff) |
BGE: Occlusion culling and other performance improvements.
Added occlusion culling capability in the BGE.
More info: http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.49/Game_Engine#BGE_Scenegraph_improvement
MSVC, scons, cmake, Makefile updated.
Other minor performance improvements:
- The rasterizer was computing the openGL model matrix of the objects too many times
- DBVT view frustrum culling was not properly culling behind the near plane:
Large objects behind the camera were sent to the GPU
- Remove all references to mesh split/join feature as it is not yet functional
Diffstat (limited to 'source/gameengine/Converter')
-rw-r--r-- | source/gameengine/Converter/BL_BlenderDataConversion.cpp | 20 | ||||
-rw-r--r-- | source/gameengine/Converter/KX_BlenderSceneConverter.cpp | 2 | ||||
-rw-r--r-- | source/gameengine/Converter/KX_ConvertActuators.cpp | 3 |
3 files changed, 19 insertions, 6 deletions
diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 50a660e77c9..5de2c4a2fe7 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -843,6 +843,7 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools* { bool visible = true; + bool twoside = false; RAS_IPolyMaterial* polymat = NULL; BL_Material *bl_mat = NULL; @@ -859,6 +860,7 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools* visible = ((bl_mat->ras_mode & POLY_VIS)!=0); collider = ((bl_mat->ras_mode & COLLIDER)!=0); + twoside = ((bl_mat->mode & TF_TWOSIDE)!=0); /* vertex colors and uv's were stored in bl_mat temporarily */ bl_mat->GetConversionRGB(rgb); @@ -899,6 +901,7 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools* mode = tface->mode; visible = !((mface->flag & ME_HIDE)||(tface->mode & TF_INVISIBLE)); + twoside = ((tface->mode & TF_TWOSIDE)!=0); uv0.setValue(tface->uv[0]); uv1.setValue(tface->uv[1]); @@ -999,6 +1002,7 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools* poly->SetVisible(visible); poly->SetCollider(collider); + poly->SetTwoside(twoside); //poly->SetEdgeCode(mface->edcode); meshobj->AddVertex(poly,0,pt0,uv0,uv20,tan0,rgb0,no0,flat,mface->v1); @@ -1677,6 +1681,7 @@ static KX_GameObject *gameobject_from_blenderobject( bool ignoreActivityCulling = ((ob->gameflag2 & OB_NEVER_DO_ACTIVITY_CULLING)!=0); gameobj->SetIgnoreActivityCulling(ignoreActivityCulling); + gameobj->SetOccluder((ob->gameflag & OB_OCCLUDER) != 0, false); // two options exists for deform: shape keys and armature // only support relative shape key @@ -1894,12 +1899,14 @@ void BL_ConvertBlenderObjects(struct Main* maggie, if (blenderscene->world) { kxscene->SetActivityCulling( (blenderscene->world->mode & WO_ACTIVITY_CULLING) != 0); kxscene->SetActivityCullingRadius(blenderscene->world->activityBoxRadius); - kxscene->SetDbvtCameraCulling((blenderscene->world->mode & WO_DBVT_CAMERA_CULLING) != 0); + kxscene->SetDbvtCulling((blenderscene->world->mode & WO_DBVT_CULLING) != 0); } else { kxscene->SetActivityCulling(false); - kxscene->SetDbvtCameraCulling(false); + kxscene->SetDbvtCulling(false); } - + // no occlusion culling by default + kxscene->SetDbvtOcclusionRes(0); + int activeLayerBitInfo = blenderscene->lay; // templist to find Root Parents (object with no parents) @@ -2452,8 +2459,9 @@ void BL_ConvertBlenderObjects(struct Main* maggie, } // create graphic controller for culling - if (kxscene->GetDbvtCameraCulling()) + if (kxscene->GetDbvtCulling()) { + bool occlusion = false; for (i=0; i<sumolist->GetCount();i++) { KX_GameObject* gameobj = (KX_GameObject*) sumolist->GetValue(i); @@ -2464,8 +2472,12 @@ void BL_ConvertBlenderObjects(struct Main* maggie, // box[0] is the min, box[1] is the max bool isactive = objectlist->SearchValue(gameobj); BL_CreateGraphicObjectNew(gameobj,box[0],box[1],kxscene,isactive,physics_engine); + if (gameobj->GetOccluder()) + occlusion = true; } } + if (occlusion) + kxscene->SetDbvtOcclusionRes(blenderscene->world->occlusionRes); } //set ini linearVel and int angularVel //rcruiz diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index b0c676a410d..190f9dbb472 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -283,7 +283,7 @@ void KX_BlenderSceneConverter::ConvertScene(const STR_String& scenename, case WOPHY_BULLET: { physics_engine = UseBullet; - useDbvtCulling = (blenderscene->world->mode & WO_DBVT_CAMERA_CULLING) != 0; + useDbvtCulling = (blenderscene->world->mode & WO_DBVT_CULLING) != 0; break; } diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index f7635856ad9..eb2d0a1c4b1 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -1008,9 +1008,10 @@ void BL_ConvertActuators(char* maggiename, bVisibilityActuator *vis_act = (bVisibilityActuator *) bact->data; KX_VisibilityActuator * tmp_vis_act = NULL; bool v = ((vis_act->flag & ACT_VISIBILITY_INVISIBLE) != 0); + bool o = ((vis_act->flag & ACT_VISIBILITY_OCCLUSION) != 0); bool recursive = ((vis_act->flag & ACT_VISIBILITY_RECURSIVE) != 0); - tmp_vis_act = new KX_VisibilityActuator(gameobj, !v, recursive); + tmp_vis_act = new KX_VisibilityActuator(gameobj, !v, o, recursive); baseact = tmp_vis_act; } |