Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Bolsee <benoit.bolsee@online.be>2009-04-14 00:08:33 +0400
committerBenoit Bolsee <benoit.bolsee@online.be>2009-04-14 00:08:33 +0400
commit0b8661ab4da1a7cfbc756640649a2d07bb36cc64 (patch)
tree6d171db30ddcba3d379dea04b2da9449203419a6 /source/blender
parent6f12e584a97f664c654ddfbe5f721d2a7be3d491 (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/blender')
-rw-r--r--source/blender/blenkernel/intern/world.c3
-rw-r--r--source/blender/blenloader/intern/readfile.c3
-rw-r--r--source/blender/makesdna/DNA_actuator_types.h4
-rw-r--r--source/blender/makesdna/DNA_object_types.h2
-rw-r--r--source/blender/makesdna/DNA_world_types.h5
-rw-r--r--source/blender/python/api2_2x/Object.c3
-rw-r--r--source/blender/src/buttons_logic.c26
-rw-r--r--source/blender/src/buttons_shading.c10
8 files changed, 36 insertions, 20 deletions
diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c
index 594d18f1ca7..6635ef29d51 100644
--- a/source/blender/blenkernel/intern/world.c
+++ b/source/blender/blenkernel/intern/world.c
@@ -106,7 +106,8 @@ World *add_world(char *name)
wrld->ao_approx_error= 0.25f;
wrld->physicsEngine= WOPHY_BULLET;//WOPHY_SUMO; Bullet by default
- wrld->mode = WO_DBVT_CAMERA_CULLING; // DBVT culling by default
+ wrld->mode = WO_DBVT_CULLING; // DBVT culling by default
+ wrld->occlusionRes = 128;
wrld->preview = NULL;
return wrld;
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 63dd1e8e6cb..c3a355160e0 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -8057,7 +8057,8 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
}
/* DBVT culling by default */
for(wrld=main->world.first; wrld; wrld= wrld->id.next) {
- wrld->mode |= WO_DBVT_CAMERA_CULLING;
+ wrld->mode |= WO_DBVT_CULLING;
+ wrld->occlusionRes = 128;
}
}
diff --git a/source/blender/makesdna/DNA_actuator_types.h b/source/blender/makesdna/DNA_actuator_types.h
index 2252126b46c..aeabae42adf 100644
--- a/source/blender/makesdna/DNA_actuator_types.h
+++ b/source/blender/makesdna/DNA_actuator_types.h
@@ -195,7 +195,8 @@ typedef struct bGameActuator {
typedef struct bVisibilityActuator {
/** bit 0: Is this object visible?
- ** bit 1: Apply recursively */
+ ** bit 1: Apply recursively
+ ** bit 2: Is this object an occluder? */
int flag;
} bVisibilityActuator;
@@ -458,6 +459,7 @@ typedef struct FreeCamera {
/* Set means the object will become invisible */
#define ACT_VISIBILITY_INVISIBLE (1 << 0)
#define ACT_VISIBILITY_RECURSIVE (1 << 1)
+#define ACT_VISIBILITY_OCCLUSION (1 << 2)
/* twodfilter->type */
#define ACT_2DFILTER_ENABLED -2
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index b17896aec70..3a408404b0b 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -437,6 +437,7 @@ extern Object workob;
#define OB_COLLISION 65536
#define OB_SOFT_BODY 0x20000
+#define OB_OCCLUDER 0x40000
/* ob->gameflag2 */
#define OB_NEVER_DO_ACTIVITY_CULLING 1
@@ -455,6 +456,7 @@ extern Object workob;
#define OB_BODY_TYPE_DYNAMIC 2
#define OB_BODY_TYPE_RIGID 3
#define OB_BODY_TYPE_SOFT 4
+#define OB_BODY_TYPE_OCCLUDER 5
/* ob->scavisflag */
#define OB_VIS_SENS 1
diff --git a/source/blender/makesdna/DNA_world_types.h b/source/blender/makesdna/DNA_world_types.h
index a51e9704be2..f599364ed66 100644
--- a/source/blender/makesdna/DNA_world_types.h
+++ b/source/blender/makesdna/DNA_world_types.h
@@ -88,7 +88,8 @@ typedef struct World {
* bit 5: (gameengine) : enable Bullet DBVT tree for view frustrum culling
*/
short mode;
- int physicsEngine; /* here it's aligned */
+ short occlusionRes; /* resolution of occlusion Z buffer in pixel */
+ short physicsEngine; /* here it's aligned */
float misi, miststa, mistdist, misthi;
@@ -135,7 +136,7 @@ typedef struct World {
#define WO_DOF 4
#define WO_ACTIVITY_CULLING 8
#define WO_AMB_OCC 16
-#define WO_DBVT_CAMERA_CULLING 32
+#define WO_DBVT_CULLING 32
/* aomix */
#define WO_AOADD 0
diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c
index fd2301bfae4..2de2906335f 100644
--- a/source/blender/python/api2_2x/Object.c
+++ b/source/blender/python/api2_2x/Object.c
@@ -3561,7 +3561,7 @@ static int Object_setRBMass( BPy_Object * self, PyObject * args )
/* this is too low level, possible to add helper methods */
-#define GAMEFLAG_MASK ( OB_COLLISION | OB_DYNAMIC | OB_CHILD | OB_ACTOR | OB_DO_FH | \
+#define GAMEFLAG_MASK ( OB_OCCLUDER | OB_COLLISION | OB_DYNAMIC | OB_CHILD | OB_ACTOR | OB_DO_FH | \
OB_ROT_FH | OB_ANISOTROPIC_FRICTION | OB_GHOST | OB_RIGID_BODY | OB_SOFT_BODY | \
OB_BOUNDS | OB_COLLISION_RESPONSE | OB_SECTOR | OB_PROP | \
OB_MAINACTOR )
@@ -5542,6 +5542,7 @@ static PyObject *M_Object_RBFlagsDict( void )
if( M ) {
BPy_constant *d = ( BPy_constant * ) M;
+ PyConstant_Insert( d, "OCCLUDER", PyInt_FromLong( OB_OCCLUDER ) );
PyConstant_Insert( d, "COLLISION", PyInt_FromLong( OB_COLLISION ) );
PyConstant_Insert( d, "DYNAMIC", PyInt_FromLong( OB_DYNAMIC ) );
PyConstant_Insert( d, "CHILD", PyInt_FromLong( OB_CHILD ) );
diff --git a/source/blender/src/buttons_logic.c b/source/blender/src/buttons_logic.c
index 97f07c7553c..2f68720acb0 100644
--- a/source/blender/src/buttons_logic.c
+++ b/source/blender/src/buttons_logic.c
@@ -2455,18 +2455,18 @@ static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, sh
xco + 10, yco - 20, (width - 20)/3, 19, &visAct->flag,
0.0, 0.0, 0, 0,
"Set the objects visible. Initialized from the objects render restriction toggle (access in the outliner)");
- uiDefButBitI(block, TOG, ACT_VISIBILITY_INVISIBLE, B_REDR,
- "Invisible",
+ uiDefButBitI(block, TOG, ACT_VISIBILITY_OCCLUSION, B_REDR,
+ "Occlusion",
xco + 10 + ((width - 20)/3), yco - 20, (width - 20)/3, 19, &visAct->flag,
0.0, 0.0, 0, 0,
- "Set the object invisible. Initialized from the objects render restriction toggle (access in the outliner)");
+ "Set the object to occlude objects behind it. Initialized from the object type in physics button");
uiBlockEndAlign(block);
uiDefButBitI(block, TOG, ACT_VISIBILITY_RECURSIVE, B_NOP,
"Children",
xco + 10 + (((width - 20)/3)*2)+10, yco - 20, ((width - 20)/3)-10, 19, &visAct->flag,
0.0, 0.0, 0, 0,
- "Sets all the children of this object to the same visibility recursively");
+ "Sets all the children of this object to the same visibility/occlusion recursively");
yco-= ysize;
@@ -3033,25 +3033,29 @@ static void check_body_type(void *arg1_but, void *arg2_object)
Object *ob = arg2_object;
switch (ob->body_type) {
+ case OB_BODY_TYPE_OCCLUDER:
+ ob->gameflag |= OB_OCCLUDER;
+ ob->gameflag &= ~(OB_COLLISION|OB_DYNAMIC);
+ break;
case OB_BODY_TYPE_NO_COLLISION:
- ob->gameflag &= ~OB_COLLISION;
+ ob->gameflag &= ~(OB_COLLISION|OB_OCCLUDER|OB_DYNAMIC);
break;
case OB_BODY_TYPE_STATIC:
ob->gameflag |= OB_COLLISION;
- ob->gameflag &= ~(OB_DYNAMIC|OB_RIGID_BODY|OB_SOFT_BODY);
+ ob->gameflag &= ~(OB_DYNAMIC|OB_RIGID_BODY|OB_SOFT_BODY|OB_OCCLUDER);
break;
case OB_BODY_TYPE_DYNAMIC:
ob->gameflag |= OB_COLLISION|OB_DYNAMIC|OB_ACTOR;
- ob->gameflag &= ~(OB_RIGID_BODY|OB_SOFT_BODY);
+ ob->gameflag &= ~(OB_RIGID_BODY|OB_SOFT_BODY|OB_OCCLUDER);
break;
case OB_BODY_TYPE_RIGID:
ob->gameflag |= OB_COLLISION|OB_DYNAMIC|OB_RIGID_BODY|OB_ACTOR;
- ob->gameflag &= ~(OB_SOFT_BODY);
+ ob->gameflag &= ~(OB_SOFT_BODY|OB_OCCLUDER);
break;
default:
case OB_BODY_TYPE_SOFT:
ob->gameflag |= OB_COLLISION|OB_DYNAMIC|OB_SOFT_BODY|OB_ACTOR;
- ob->gameflag &= ~(OB_RIGID_BODY);
+ ob->gameflag &= ~(OB_RIGID_BODY|OB_OCCLUDER);
/* assume triangle mesh, if no bounds chosen for soft body */
if ((ob->gameflag & OB_BOUNDS) && (ob->boundtype<OB_BOUND_POLYH))
@@ -3216,7 +3220,7 @@ static void buttons_bullet(uiBlock *block, Object *ob)
/* determine the body_type setting based on flags */
if (!(ob->gameflag & OB_COLLISION))
- ob->body_type = OB_BODY_TYPE_NO_COLLISION;
+ ob->body_type = (ob->gameflag & OB_OCCLUDER) ? OB_BODY_TYPE_OCCLUDER : OB_BODY_TYPE_NO_COLLISION;
else if (!(ob->gameflag & OB_DYNAMIC))
ob->body_type = OB_BODY_TYPE_STATIC;
else if (!(ob->gameflag & (OB_RIGID_BODY|OB_SOFT_BODY)))
@@ -3234,7 +3238,7 @@ static void buttons_bullet(uiBlock *block, Object *ob)
//only enable game soft body if Blender Soft Body exists
but = uiDefButS(block, MENU, REDRAWVIEW3D,
- "Object type%t|No collision%x0|Static%x1|Dynamic%x2|Rigid body%x3|Soft body%x4",
+ "Object type%t|Occluder%x5|No collision%x0|Static%x1|Dynamic%x2|Rigid body%x3|Soft body%x4",
10, 205, 100, 19, &ob->body_type, 0, 0, 0, 0, "Selects the type of physical representation");
uiButSetFunc(but, check_body_type, but, ob);
diff --git a/source/blender/src/buttons_shading.c b/source/blender/src/buttons_shading.c
index e68c86349ce..a129698cce3 100644
--- a/source/blender/src/buttons_shading.c
+++ b/source/blender/src/buttons_shading.c
@@ -2181,7 +2181,7 @@ static void world_panel_mistaph(World *wrld)
uiSetButLock(wrld->id.lib!=0, ERROR_LIBDATA_MESSAGE);
#if GAMEBLENDER == 1
- uiDefButI(block, MENU, B_REDR,
+ uiDefButS(block, MENU, B_REDR,
#ifdef USE_ODE
"Physics %t|None %x0|Sumo %x2|Ode %x4 |Bullet %x5",
#else
@@ -2198,8 +2198,12 @@ static void world_panel_mistaph(World *wrld)
/* Gravitation for the game worlds */
uiDefButF(block, NUMSLI,0, "Grav ", 150,180,150,19, &(wrld->gravity), 0.0, 25.0, 0, 0, "Sets the gravitation constant of the game world");
- if (wrld->physicsEngine == WOPHY_BULLET)
- uiDefButBitS(block, TOG, WO_DBVT_CAMERA_CULLING, 0, "DBVT culling", 10,160,140,19, &wrld->mode, 0, 0, 0, 0, "Toggles use of optimized Bullet DBVT tree for camera culling");
+ if (wrld->physicsEngine == WOPHY_BULLET) {
+ uiDefButBitS(block, TOG, WO_DBVT_CULLING, B_REDR, "DBVT culling", 10,160,140,19, &wrld->mode, 0, 0, 0, 0, "Toggles use of optimized Bullet DBVT tree for view frustrum and occlusion culling");
+ if (wrld->mode & WO_DBVT_CULLING)
+ uiDefButS(block, NUM, B_REDR, "Occlu Res:",
+ 150, 160, 150, 19, &wrld->occlusionRes, 128.0, 1024.0, 0, 0, "Sets the size of the occlusion buffer in pixel, use higher value for better precsion (slower)");
+ }
#endif
uiBlockSetCol(block, TH_BUT_SETTING1);