Merge of first part of changes from the apricot branch, especially

the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:

* GLSL support in the viewport and game engine, enable in the game
  menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
  gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
  storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.

* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
  An extra texture slot shows up once the last slot is used.

* Memory limit for undo, not enabled by default yet because it
  needs the .B.blend to be changed.
* Multiple undo for image painting.

* An offset for dupligroups, so not all objects in a group have to
  be at the origin.
This commit is contained in:
2008-09-04 20:51:28 +00:00
parent 2167e5c341
commit cb89decfdc
258 changed files with 13813 additions and 5271 deletions

View File

@@ -34,7 +34,7 @@ SET(INC
api2_2x ../blenkernel ../blenlib ../blenloader
../render/extern/include ../radiosity/extern/include
../makesdna ../../../intern/guardedalloc ../../../intern/bmfont ../imbuf ../include
${PYTHON_INC}
${PYTHON_INC} ../../../extern/glew/include ../gpu
)
IF(WITH_QUICKTIME)
@@ -50,5 +50,9 @@ IF(WITH_FFMPEG)
ADD_DEFINITIONS(-DWITH_FFMPEG)
ENDIF(WITH_FFMPEG)
IF(BF_BUILDINFO)
ADD_DEFINITIONS(-DNAN_BUILDINFO)
ENDIF(BF_BUILDINFO)
BLENDERLIB_NOLIST(blender_python "${SRC}" "${INC}")
#env.BlenderLib ( libname='blender_python', sources = Split(sources), includes = Split(incs), defines = defs, libtype=['core','game2'], priority = [60,115] )

View File

@@ -6,6 +6,7 @@ sources = Split('BPY_interface.c BPY_menus.c') + env.Glob('api2_2x/*.c')
incs = 'api2_2x ../blenkernel ../nodes ../blenlib ../blenloader'
incs += ' ../render/extern/include ../radiosity/extern/include'
incs += ' ../makesdna #intern/guardedalloc #intern/bmfont ../imbuf ../include'
incs += ' #extern/glew/include ../gpu'
incs += ' ' + env['BF_PYTHON_INC']
incs += ' ' + env['BF_OPENGL_INC']
@@ -23,4 +24,7 @@ if env['WITH_BF_OPENEXR'] == 1:
if env['WITH_BF_FFMPEG'] == 1:
defs.append('WITH_FFMPEG')
if env['BF_BUILDINFO'] == 1:
defs.append('NAN_BUILDINFO')
env.BlenderLib ( libname='blender_python', sources = Split(sources), includes = Split(incs), defines = defs, libtype=['core','game2'], priority = [60,115] )

View File

@@ -34,7 +34,7 @@ struct ID; /*keep me up here */
/* for open, close in Blender_Load */
#include <fcntl.h>
#include "BDR_editobject.h" /* exit_editmode() */
#include "BDR_drawmesh.h" /* set_mipmap() */
#include "GPU_draw.h" /* GPU_set_mipmap() */
#include "BIF_usiblender.h"
#include "BLI_blenlib.h"
#include "BLI_bpath.h"
@@ -314,8 +314,8 @@ static PyObject *Blender_Set( PyObject * self, PyObject * args )
else
U.gameflags |= USER_DISABLE_MIPMAP;
set_mipmap(!(U.gameflags & USER_DISABLE_MIPMAP));
}else
GPU_set_mipmap(!(U.gameflags & USER_DISABLE_MIPMAP));
} else
return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
"value given is not a blender setting" ) );
Py_RETURN_NONE;
@@ -543,7 +543,21 @@ static PyObject *Blender_Get( PyObject * self, PyObject * value )
} /* End 'quick hack' part. */
else if(StringEqual( str, "version" ))
ret = PyInt_FromLong( G.version );
else if(StringEqual( str, "buildinfo" )) {
#ifdef NAN_BUILDINFO
char buffer[1024];
extern char * build_date;
extern char * build_time;
extern char * build_rev;
extern char * build_platform;
extern char * build_type;
sprintf(buffer, "Built on %s %s, Rev-%s Version %s %s", build_date, build_time, build_rev, build_platform, build_type);
ret = PyString_FromString( buffer );
#else
ret = PyString_FromString( "No Build Info" );
#endif
}
else if(StringEqual( str, "compressfile" ))
ret = PyInt_FromLong( (U.flag & USER_FILECOMPRESS) >> 15 );
else if(StringEqual( str, "mipmap" ))

View File

@@ -46,6 +46,8 @@
#include "gen_utils.h"
#include "gen_library.h"
#include "vector.h"
/* checks for the group being removed */
#define GROUP_DEL_CHECK_PY(bpy_group) if (!(bpy_group->group)) return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, "Group has been removed" ) )
#define GROUP_DEL_CHECK_INT(bpy_group) if (!(bpy_group->group)) return ( EXPP_ReturnIntError( PyExc_RuntimeError, "Group has been removed" ) )
@@ -200,6 +202,31 @@ static int Group_setObjects( BPy_Group * self, PyObject * args )
return 0;
}
static PyObject *Group_getDupliOfs( BPy_Group * self )
{
GROUP_DEL_CHECK_PY(self);
return newVectorObject( self->group->dupli_ofs, 3, Py_WRAP );
}
static int Group_setDupliOfs( BPy_Group * self, PyObject * value )
{
VectorObject *bpy_vec;
GROUP_DEL_CHECK_INT(self);
if (!VectorObject_Check(value))
return ( EXPP_ReturnIntError( PyExc_TypeError,
"expected a vector" ) );
bpy_vec = (VectorObject *)value;
if (bpy_vec->size != 3)
return ( EXPP_ReturnIntError( PyExc_ValueError,
"can only assign a 3D vector" ) );
self->group->dupli_ofs[0] = bpy_vec->vec[0];
self->group->dupli_ofs[1] = bpy_vec->vec[1];
self->group->dupli_ofs[2] = bpy_vec->vec[2];
return 0;
}
/*****************************************************************************/
@@ -251,6 +278,10 @@ static PyGetSetDef BPy_Group_getseters[] = {
(getter)Group_getObjects, (setter)Group_setObjects,
"objects in this group",
NULL},
{"dupliOffset",
(getter)Group_getDupliOfs, (setter)Group_setDupliOfs,
"offset to use when instancing this group as a DupliGroup",
NULL},
{NULL,NULL,NULL,NULL,NULL} /* Sentinel */
};

View File

@@ -29,7 +29,6 @@
*/
#include "Image.h" /*This must come first */
#include "BDR_drawmesh.h" /* free_realtime_image */
#include "BKE_main.h"
#include "BKE_global.h"
#include "BKE_library.h"
@@ -48,6 +47,7 @@
#include "BKE_icons.h"
#include "IMB_imbuf.h"
#include "IDProp.h"
#include "GPU_draw.h"
/* used so we can get G.scene->r.cfra for getting the
current image frame, some images change frame if they are a sequence */
@@ -1003,7 +1003,7 @@ static PyObject *Image_glFree( BPy_Image * self )
{
Image *image = self->image;
free_realtime_image( image );
GPU_free_image( image );
/* remove the nocollect flag, image is available for garbage collection again */
image->flag &= ~IMA_NOCOLLECT;
Py_RETURN_NONE;

View File

@@ -84,6 +84,8 @@
#define EXPP_LAMP_MODE_NODIFFUSE 2048
#define EXPP_LAMP_MODE_NOSPECULAR 4096
#define EXPP_LAMP_MODE_SHAD_RAY 8192
#define EXPP_LAMP_MODE_LAYER_SHADOW 32768
/* Lamp MIN, MAX values */
#define EXPP_LAMP_SAMPLES_MIN 1
@@ -780,6 +782,8 @@ static PyObject *Lamp_ModesDict( void )
PyInt_FromLong( EXPP_LAMP_MODE_NOSPECULAR ) );
PyConstant_Insert( c, "RayShadow",
PyInt_FromLong( EXPP_LAMP_MODE_SHAD_RAY ) );
PyConstant_Insert( c, "LayerShadow",
PyInt_FromLong( EXPP_LAMP_MODE_LAYER_SHADOW ) );
}
return Modes;
@@ -1011,8 +1015,8 @@ static int Lamp_setType( BPy_Lamp * self, PyObject * value )
static int Lamp_setMode( BPy_Lamp * self, PyObject * value )
{
short param;
static short bitmask = EXPP_LAMP_MODE_SHADOWS
int param;
static int bitmask = EXPP_LAMP_MODE_SHADOWS
| EXPP_LAMP_MODE_HALO
| EXPP_LAMP_MODE_LAYER
| EXPP_LAMP_MODE_QUAD
@@ -1022,14 +1026,15 @@ static int Lamp_setMode( BPy_Lamp * self, PyObject * value )
| EXPP_LAMP_MODE_SQUARE
| EXPP_LAMP_MODE_NODIFFUSE
| EXPP_LAMP_MODE_NOSPECULAR
| EXPP_LAMP_MODE_SHAD_RAY;
| EXPP_LAMP_MODE_SHAD_RAY
| EXPP_LAMP_MODE_LAYER_SHADOW;
if( !PyInt_Check ( value ) ) {
char errstr[128];
sprintf ( errstr , "expected int bitmask of 0x%04x", bitmask );
return EXPP_ReturnIntError( PyExc_TypeError, errstr );
}
param = (short)PyInt_AS_LONG ( value );
param = PyInt_AS_LONG ( value );
if ( ( param & bitmask ) != param )
return EXPP_ReturnIntError( PyExc_ValueError,
@@ -1373,7 +1378,8 @@ static PyObject *Lamp_getModesConst( void )
EXPP_LAMP_MODE_SQUARE, "NoDiffuse",
EXPP_LAMP_MODE_NODIFFUSE, "NoSpecular",
EXPP_LAMP_MODE_NOSPECULAR, "RayShadow",
EXPP_LAMP_MODE_SHAD_RAY);
EXPP_LAMP_MODE_SHAD_RAY, "LayerShadow",
EXPP_LAMP_MODE_LAYER_SHADOW);
}
static PyObject *Lamp_getTypesConst( void )
@@ -1597,6 +1603,8 @@ static PyObject *Lamp_oldsetMode( BPy_Lamp * self, PyObject * args )
flag |= ( short ) EXPP_LAMP_MODE_NOSPECULAR;
else if( !strcmp( name, "RayShadow" ) )
flag |= ( short ) EXPP_LAMP_MODE_SHAD_RAY;
else if( !strcmp( name, "LayerShadow" ) )
flag |= ( short ) EXPP_LAMP_MODE_LAYER_SHADOW;
else
return EXPP_ReturnPyObjError( PyExc_AttributeError,
"unknown lamp flag argument" );

View File

@@ -677,7 +677,7 @@ static int MTex_setMapping( BPy_MTex *self, PyObject *value, void *closure)
static PyObject *MTex_getFlag( BPy_MTex *self, void *closure )
{
return PyBool_FromLong( self->mtex->texflag & ((int) closure) );
return PyBool_FromLong( self->mtex->texflag & (GET_INT_FROM_POINTER(closure)) );
}
static int MTex_setFlag( BPy_MTex *self, PyObject *value, void *closure)
@@ -687,9 +687,9 @@ static int MTex_setFlag( BPy_MTex *self, PyObject *value, void *closure)
"expected a bool");
if ( value == Py_True )
self->mtex->texflag |= (int)closure;
self->mtex->texflag |= GET_INT_FROM_POINTER(closure);
else
self->mtex->texflag &= ~((int) closure);
self->mtex->texflag &= ~(GET_INT_FROM_POINTER(closure));
return 0;
}
@@ -774,7 +774,7 @@ static int MTex_setProjZ( BPy_MTex *self, PyObject *value, void *closure)
static PyObject *MTex_getMapToFlag( BPy_MTex *self, void *closure )
{
int flag = (int) closure;
int flag = GET_INT_FROM_POINTER(closure);
if ( self->mtex->mapto & flag )
{
@@ -786,7 +786,7 @@ static PyObject *MTex_getMapToFlag( BPy_MTex *self, void *closure )
static int MTex_setMapToFlag( BPy_MTex *self, PyObject *value, void *closure)
{
int flag = (int) closure;
int flag = GET_INT_FROM_POINTER(closure);
int intVal;
if ( !PyInt_Check( value ) )

View File

@@ -37,6 +37,10 @@ include nan_compile.mk
CFLAGS += $(LEVEL_1_C_WARNINGS)
ifdef NAN_BUILDINFO
CPPFLAGS += -DNAN_BUILDINFO
endif
ifeq ($(WITH_FFMPEG), true)
CPPFLAGS += -DWITH_FFMPEG
endif
@@ -45,6 +49,7 @@ ifeq ($(WITH_OPENEXR),true)
CPPFLAGS += -DWITH_OPENEXR
endif
CPPFLAGS += -I$(NAN_GLEW)/include
CPPFLAGS += -I$(OPENGL_HEADERS)
CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
CPPFLAGS += -I../../makesdna
@@ -52,6 +57,7 @@ CPPFLAGS += -I../../blenkernel
CPPFLAGS += -I../../blenlib
CPPFLAGS += -I../../blenloader
CPPFLAGS += -I../../include
CPPFLAGS += -I../../gpu
CPPFLAGS += -I../../render/extern/include
CPPFLAGS += -I../../radiosity/extern/include
CPPFLAGS += -I$(NAN_BMFONT)/include

View File

@@ -1754,8 +1754,7 @@ static PyObject *Material_getTextures( BPy_Material * self )
}
/* turn the array into a tuple */
tuple = Py_BuildValue( "NNNNNNNNNN", t[0], t[1], t[2], t[3],
t[4], t[5], t[6], t[7], t[8], t[9] );
tuple = Py_BuildValue( "NNNNNNNNNNNNNNNNNN", t[0], t[1], t[2], t[3], t[4], t[5], t[6], t[7], t[8], t[9], t[10], t[11], t[12], t[13], t[14], t[15], t[16], t[17] );
if( !tuple )
return EXPP_ReturnPyObjError( PyExc_MemoryError,
"Material_getTextures: couldn't create PyTuple" );

View File

@@ -105,6 +105,8 @@ class Group:
This object gives access to Groups in Blender.
@ivar layers: Layer bitmask for this group.
@type layers: int
@ivar dupliOffset: Object offset when instanced as a dupligroup
@type dupliOffset: vector
@ivar objects: Objects that this group uses.
This is a sequence with-list like access so use list(grp.objects) if you need to use a list (where grp is a group).
The groups objects can be set by assigning a list or iterator of objects to the groups objects.