[Bf-committers] SVN commit: /data/svn/bf-blender [16716] trunk/blender/source: BGE patch: add advanced parameters for SoftBody.

blender at erwincoumans.com blender at erwincoumans.com
Thu Sep 25 23:15:03 CEST 2008


It has been fixed now. 

Bullet soft bodies re-use some of the existing Blender soft bodies.
Thanks,
Erwin 


Ton Roosendaal writes: 

> Hi Benoit, 
> 
> Just adding options for this in Object struct is not correct.
> First off it's an experimental function only available in GE, secondly  
> it will make future improvements in Blender for proper Bullet physics  
> very confused. 
> 
> You're safer with adding a pointer to a new struct BulletSoftbody or  
> so, and allocate this struct on first usage (like how  
> DNA_object_force.h now). 
> 
> I'd also recommend to re-use existing softbody settings, where or if  
> possible? An integrated approach where Blender softbody works in GE  
> would also be preferable. 
> 
> -Ton- 
> 
> ------------------------------------------------------------------------
> Ton Roosendaal  Blender Foundation   ton at blender.org    www.blender.org
> Blender Institute BV  Entrepotdok 57A  1018AD Amsterdam The Netherlands 
> 
> On 25 Sep, 2008, at 0:58, Benoit Bolsee wrote: 
> 
>> Revision: 16716
>>            
>> http://projects.blender.org/plugins/scmsvn/viewcvs.php? 
>> view=rev&root=bf-blender&revision=16716
>> Author:   ben2610
>> Date:     2008-09-25 00:58:49 +0200 (Thu, 25 Sep 2008) 
>>
>> Log Message:
>> -----------
>> BGE patch: add advanced parameters for SoftBody. Add  
>> Rasterizer.drawLine() Python function. 
>>
>> Modified Paths:
>> --------------
>>     trunk/blender/source/blender/blenkernel/intern/object.c
>>     trunk/blender/source/blender/blenloader/intern/readfile.c
>>     trunk/blender/source/blender/makesdna/DNA_object_types.h
>>     trunk/blender/source/blender/src/buttons_logic.c
>>     trunk/blender/source/blender/src/editobject.c
>>     trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp
>>     trunk/blender/source/gameengine/PyDoc/Rasterizer.py 
>>
>> Modified: trunk/blender/source/blender/blenkernel/intern/object.c
>> ===================================================================
>> --- trunk/blender/source/blender/blenkernel/intern/object.c	2008-09-24  
>> 11:52:31 UTC (rev 16715)
>> +++ trunk/blender/source/blender/blenkernel/intern/object.c	2008-09-24  
>> 22:58:49 UTC (rev 16716)
>> @@ -964,6 +964,10 @@
>>  	ob->anisotropicFriction[2] = 1.0f;
>>  	ob->gameflag= OB_PROP|OB_COLLISION;
>>  	ob->margin = 0.0;
>> +	ob->linearStiffness = 1.0f;
>> +	ob->angularStiffness = 1.0f;
>> +	ob->volumePreservation = 1.0f;
>> +	ob->gamesoftFlag = 0; 
>>
>>  	/* NT fluid sim defaults */
>>  	ob->fluidsimFlag = 0; 
>>
>> Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
>> ===================================================================
>> ---  
>> trunk/blender/source/blender/blenloader/intern/readfile.c	2008-09-24  
>> 11:52:31 UTC (rev 16715)
>> +++  
>> trunk/blender/source/blender/blenloader/intern/readfile.c	2008-09-24  
>> 22:58:49 UTC (rev 16716)
>> @@ -7849,6 +7849,10 @@
>>  			// Before it was conditioning all the other dynamic flags
>>  			if (!(ob->gameflag & OB_ACTOR))
>>  				ob->gameflag &=  
>> ~(OB_GHOST|OB_DYNAMIC|OB_RIGID_BODY|OB_SOFT_BODY|OB_COLLISION_RESPONSE) 
>> ;
>> +			/* suitable default for older files */
>> +			ob->linearStiffness = 1.0f;
>> +			ob->angularStiffness = 1.0f;
>> +			ob->volumePreservation = 1.0f;
>>  		}
>>  	} 
>>
>>
>> Modified: trunk/blender/source/blender/makesdna/DNA_object_types.h
>> ===================================================================
>> ---  
>> trunk/blender/source/blender/makesdna/DNA_object_types.h	2008-09-24  
>> 11:52:31 UTC (rev 16715)
>> +++  
>> trunk/blender/source/blender/makesdna/DNA_object_types.h	2008-09-24  
>> 22:58:49 UTC (rev 16716)
>> @@ -156,9 +156,16 @@ 
>>
>>  	float formfactor;
>>  	float rdamping, sizefac;
>> -	float margin, pad3;
>> +	float margin;
>> +	/* for game engine soft body */
>> +	float linearStiffness;
>> +	float angularStiffness;
>> +	float volumePreservation;
>> +	int   gamesoftFlag;
>> +	int   pad3; 
>>
>>
>> +
>>  	char dt, dtx;
>>  	char totcol;	/* copy of mesh or curve or meta */
>>  	char actcol;	/* currently selected material in the user interface */
>> @@ -411,6 +418,9 @@
>>  #define OB_RECALC_TIME		4
>>  #define OB_RECALC			7 
>>
>> +/* ob->gamesoftFlag */
>> +#define OB_SOFT_SHAPE_MATCHING	1
>> +
>>  /* ob->gameflag */
>>  #define OB_DYNAMIC		1
>>  #define OB_CHILD		2 
>>
>> Modified: trunk/blender/source/blender/src/buttons_logic.c
>> ===================================================================
>> --- trunk/blender/source/blender/src/buttons_logic.c	2008-09-24  
>> 11:52:31 UTC (rev 16715)
>> +++ trunk/blender/source/blender/src/buttons_logic.c	2008-09-24  
>> 22:58:49 UTC (rev 16716)
>> @@ -2979,11 +2979,11 @@
>>  {
>>  	uiBlock *block;
>>  	Object *ob = arg_ob;
>> -	short yco = 65, xco = 0;
>> +	short yco = 105, xco = 0; 
>>
>>  	block= uiNewBlock(&curarea->uiblocks, "advanced_bullet_options",  
>> UI_EMBOSS, UI_HELV, curarea->win);
>>  	/* use this for a fake extra empy space around the buttons */
>> -	uiDefBut(block, LABEL, 0, "", -5, -10, 255, 100, NULL, 0, 0, 0, 0,  
>> "");
>> +	uiDefBut(block, LABEL, 0, "", -5, -10, 255, 140, NULL, 0, 0, 0, 0,  
>> ""); 
>>
>>  	uiDefButBitI(block, TOG, OB_ACTOR, 0, "Sensor actor",
>>  				xco, yco, 118, 19, &ob->gameflag, 0, 0, 0, 0,
>> @@ -3008,6 +3008,25 @@
>>  				xco, yco, 118, 19, &ob->margin, 0.0, 1.0, 1, 0,
>>  				"Collision margin");
>>  	}
>> +	if (ob->gameflag & OB_SOFT_BODY) {
>> +		uiDefButBitI(block, TOG, OB_SOFT_SHAPE_MATCHING, 0, "Shape  
>> matching",
>> +					xco+=120, yco, 118, 19, &ob->gamesoftFlag, 0, 0, 0, 0,
>> +					"Enable soft body shape matching");
>> +		yco -= 25;
>> +		xco = 0;
>> +		uiDefButF(block, NUMSLI, 0, "LinStiff ", xco, yco, 238, 19,
>> +				&ob->linearStiffness, 0.0, 1.0, 1, 0,
>> +				"Linear stiffness of the soft body vertex spring");
>> +		yco -= 25;
>> +		uiDefButF(block, NUMSLI, 0, "AngStiff ", xco, yco, 238, 19,
>> +				&ob->angularStiffness, 0.0, 1.0, 1, 0,
>> +				"Angular stiffness of the soft body vertex spring");
>> +		yco -= 25;
>> +		uiDefButF(block, NUMSLI, 0, "Volume ", xco, yco, 238, 19,
>> +				&ob->volumePreservation, 0.0, 1.0, 1, 0,
>> +				"Factor of soft body volume preservation");
>> +	}
>> +
>>  			
>>  	uiBlockSetDirection(block, UI_TOP); 
>>
>>
>> Modified: trunk/blender/source/blender/src/editobject.c
>> ===================================================================
>> --- trunk/blender/source/blender/src/editobject.c	2008-09-24 11:52:31  
>> UTC (rev 16715)
>> +++ trunk/blender/source/blender/src/editobject.c	2008-09-24 22:58:49  
>> UTC (rev 16716)
>> @@ -3529,6 +3529,10 @@
>>  						base->object->boundtype = ob->boundtype;
>>  					}
>>  					base->object->margin= ob->margin;
>> +					base->object->linearStiffness= ob->linearStiffness;
>> +					base->object->angularStiffness= ob->angularStiffness;
>> +					base->object->volumePreservation= ob->volumePreservation;
>> +					base->object->gamesoftFlag= ob->gamesoftFlag;
>>  				}
>>  				else if(event==17) {	/* tex space */
>>  					copy_texture_space(base->object, ob); 
>>
>> Modified: trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp
>> ===================================================================
>> ---  
>> trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp	2008-09-24  
>> 11:52:31 UTC (rev 16715)
>> +++  
>> trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp	2008-09-24  
>> 22:58:49 UTC (rev 16716)
>> @@ -797,6 +797,36 @@
>>  	return PyInt_FromLong(flag);
>>  } 
>>
>> +static PyObject* gPyDrawLine(PyObject*, PyObject* args)
>> +{
>> +	PyObject* ob_from;
>> +	PyObject* ob_to;
>> +	PyObject* ob_color;
>> +
>> +	if (!gp_Rasterizer) {
>> +		PyErr_SetString(PyExc_RuntimeError, "Rasterizer not available");
>> +		return NULL;
>> +	}
>> +
>> +	if (!PyArg_ParseTuple(args,"OOO",&ob_from,&ob_to,&ob_color))
>> +		return NULL;
>> +
>> +	MT_Vector3 from(0., 0., 0.);
>> +	MT_Vector3 to(0., 0., 0.);
>> +	MT_Vector3 color(0., 0., 0.);
>> +	if (!PyVecTo(ob_from, from))
>> +		return NULL;
>> +	if (!PyVecTo(ob_to, to))
>> +		return NULL;
>> +	if (!PyVecTo(ob_color, color))
>> +		return NULL;
>> +
>> +	gp_Rasterizer->DrawDebugLine(from,to,color);
>> +	
>> +	Py_RETURN_NONE;
>> +}
>> +
>> +
>>  STR_String	gPyGetWindowHeight__doc__="getWindowHeight doc";
>>  STR_String	gPyGetWindowWidth__doc__="getWindowWidth doc";
>>  STR_String	gPyEnableVisibility__doc__="enableVisibility doc";
>> @@ -838,6 +868,8 @@
>>     METH_VARARGS, "set the state of a GLSL material setting"},
>>    {"getGLSLMaterialSetting",(PyCFunction) gPyGetGLSLMaterialSetting,
>>     METH_VARARGS, "get the state of a GLSL material setting"},
>> +  {"drawLine", (PyCFunction) gPyDrawLine,
>> +   METH_VARARGS, "draw a line on the screen"},
>>    { NULL, (PyCFunction) NULL, 0, NULL }
>>  }; 
>>
>>
>> Modified: trunk/blender/source/gameengine/PyDoc/Rasterizer.py
>> ===================================================================
>> --- trunk/blender/source/gameengine/PyDoc/Rasterizer.py	2008-09-24  
>> 11:52:31 UTC (rev 16715)
>> +++ trunk/blender/source/gameengine/PyDoc/Rasterizer.py	2008-09-24  
>> 22:58:49 UTC (rev 16716)
>> @@ -181,4 +181,15 @@
>>  	@type setting: string (lights, shaders, shadows, ramps, nodes,  
>> extra_textures)
>>  	@rtype: boolean
>>  	"""
>> +def drawLine(from,to,color):
>> +	"""
>> +	Draw a line in the 3D scene.
>> +	
>> +	@param from: the origin of the line
>> +	@type from: list [x, y, z]
>> +	@param to: the end of the line
>> +	@type to: list [x, y, z]
>> +	@param color: the color of the line
>> +	@type color: list [r, g, b]
>> +	""" 
>>
>> 
>>
>> _______________________________________________
>> Bf-blender-cvs mailing list
>> Bf-blender-cvs at blender.org
>> http://lists.blender.org/mailman/listinfo/bf-blender-cvs 
>>
> 
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers
 



More information about the Bf-committers mailing list