Index: source/blender/python/api2_2x/Object.c =================================================================== --- source/blender/python/api2_2x/Object.c (Revision 14503) +++ source/blender/python/api2_2x/Object.c (Arbeitskopie) @@ -40,6 +40,7 @@ #include "DNA_object_types.h" #include "DNA_view3d_types.h" #include "DNA_object_force.h" +#include "DNA_object_fluidsim.h" #include "DNA_userdef_types.h" #include "DNA_key_types.h" /* for pinShape and activeShape */ @@ -109,6 +110,7 @@ #include "NLA.h" #include "logic.h" #include "Effect.h" +#include "Fluid.h" #include "Group.h" #include "Modifier.h" #include "Constraint.h" @@ -459,6 +461,9 @@ static PyObject *Object_copy(BPy_Object * self); /* __copy__ */ static PyObject *Object_trackAxis(BPy_Object * self); static PyObject *Object_upAxis(BPy_Object * self); +static PyObject *Object_getIsFluidEnabled(BPy_Object * self); +static int Object_setIsFluidEnabled(BPy_Object * self, PyObject * value ); +static PyObject *Object_getFluid(BPy_Object * self); /*****************************************************************************/ /* Python BPy_Object methods table: */ @@ -767,6 +772,8 @@ "() - Return a copy of this object."}, {"copy", ( PyCFunction ) Object_copy, METH_NOARGS, "() - Return a copy of this object."}, + {"getFluid", ( PyCFunction ) Object_getFluid, METH_NOARGS, + "Returns the fluid object"}, {NULL, NULL, 0, NULL} }; @@ -5100,8 +5107,15 @@ (getter)getIntAttr, (setter)setIntAttrClamp, "set the index for the active shape key", (void *)EXPP_OBJ_ATTR_ACT_SHAPE}, + {"isFluidEnabled", + (getter)Object_getIsFluidEnabled, (setter)Object_setIsFluidEnabled, + "State of the fluid simulation for the object", + NULL}, + {"fluid", + (getter)Object_getFluid, (setter)NULL, + "Get the fluid object", + NULL}, - {NULL,NULL,NULL,NULL,NULL} /* Sentinel */ }; @@ -6029,3 +6043,56 @@ return PyString_FromString(cup); } + +static PyObject *Object_getIsFluidEnabled( BPy_Object * self ) +{ +// printf ( "DEBUG: get fluidsimFlag value is [%d]\n", self->object->fluidsimFlag ); +// printf ( "DEBUG: get fluidsimFlag & value is [%d]\n", self->object->fluidsimFlag & OB_FLUIDSIM_ENABLE ); +// printf ( "DEBUG: get fluidsimFlag | value is [%d]\n", self->object->fluidsimFlag | OB_FLUIDSIM_ENABLE ); + + // What if object was not setup yet ? + if ( self->object->fluidsimFlag & OB_FLUIDSIM_ENABLE ) + Py_RETURN_TRUE; + else + Py_RETURN_FALSE; +} + +/* + * Enable the fluid sim for this object. + */ +static int Object_setIsFluidEnabled( BPy_Object * self, PyObject * value ) +{ + int param = PyObject_IsTrue( value ); + if( param == -1 ) + return EXPP_ReturnIntError( PyExc_TypeError, "Object.setIsFluidEnabled: expected True/False or 0/1" ); + +// printf ( "DEBUG: set param value is [%d]\n", param ); +// printf ( "DEBUG: set fluidsimFlag value is [%d]\n", self->object->fluidsimFlag ); +// printf ( "DEBUG: set fluidsimFlag & value is [%d]\n", self->object->fluidsimFlag & OB_FLUIDSIM_ENABLE ); +// printf ( "DEBUG: set fluidsimFlag | value is [%d]\n", self->object->fluidsimFlag | OB_FLUIDSIM_ENABLE ); + + // This value is proper to set the flag directly + self->object->fluidsimFlag = param; + + return 0; +} + +/* + * Get the python Fluid object. + * + */ +static PyObject *Object_getFluid( BPy_Object * self ) +{ + // We need the blender object to build the Fluid object properly, + // since the fluidsim code needs a refrence to an object and not the just + // the FluidsimSettings. + + // TODO: we might be able to keep a refrence to the object so we don't have + // to recrete the instance again. + return Fluid_CreatePyObject( self ); + +} + + + + Index: source/blender/python/api2_2x/Blender.c =================================================================== --- source/blender/python/api2_2x/Blender.c (Revision 14503) +++ source/blender/python/api2_2x/Blender.c (Arbeitskopie) @@ -70,6 +70,7 @@ #include "CurNurb.h" #include "Draw.h" #include "Effect.h" +#include "Fluid.h" #include "Ipo.h" #include "Ipocurve.h" #include "IDProp.h" @@ -1052,6 +1053,7 @@ PyDict_SetItemString(dict, "Camera", Camera_Init()); PyDict_SetItemString(dict, "Draw", Draw_Init()); PyDict_SetItemString(dict, "Effect", Effect_Init()); + PyDict_SetItemString(dict, "Fluid", Fluid_Init()); PyDict_SetItemString(dict, "Ipo", Ipo_Init()); PyDict_SetItemString(dict, "IpoCurve", IpoCurve_Init()); PyDict_SetItemString(dict, "Image", Image_Init()); Index: source/blender/python/SConscript =================================================================== --- source/blender/python/SConscript (Revision 14503) +++ source/blender/python/SConscript (Arbeitskopie) @@ -5,7 +5,9 @@ incs = 'api2_2x ../blenkernel ../nodes ../blenlib ../blenloader' incs += ' ../render/extern/include ../radiosity/extern/include' -incs += ' ../makesdna #intern/guardedalloc #intern/bmfont ../imbuf ../include' +incs += ' ../makesdna #intern/guardedalloc #intern/bmfont ../imbuf' +incs += ' #intern/elbeem/extern' +incs += ' ../include' incs += ' ' + env['BF_PYTHON_INC'] incs += ' ' + env['BF_OPENGL_INC']