BGE patch: add advanced parameters for SoftBody. Add Rasterizer.drawLine() Python function.
This commit is contained in:
		@@ -964,6 +964,10 @@ Object *add_only_object(int type, char *name)
 | 
				
			|||||||
	ob->anisotropicFriction[2] = 1.0f;
 | 
						ob->anisotropicFriction[2] = 1.0f;
 | 
				
			||||||
	ob->gameflag= OB_PROP|OB_COLLISION;
 | 
						ob->gameflag= OB_PROP|OB_COLLISION;
 | 
				
			||||||
	ob->margin = 0.0;
 | 
						ob->margin = 0.0;
 | 
				
			||||||
 | 
						ob->linearStiffness = 1.0f;
 | 
				
			||||||
 | 
						ob->angularStiffness = 1.0f;
 | 
				
			||||||
 | 
						ob->volumePreservation = 1.0f;
 | 
				
			||||||
 | 
						ob->gamesoftFlag = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* NT fluid sim defaults */
 | 
						/* NT fluid sim defaults */
 | 
				
			||||||
	ob->fluidsimFlag = 0;
 | 
						ob->fluidsimFlag = 0;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7849,6 +7849,10 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
 | 
				
			|||||||
			// Before it was conditioning all the other dynamic flags
 | 
								// Before it was conditioning all the other dynamic flags
 | 
				
			||||||
			if (!(ob->gameflag & OB_ACTOR))
 | 
								if (!(ob->gameflag & OB_ACTOR))
 | 
				
			||||||
				ob->gameflag &= ~(OB_GHOST|OB_DYNAMIC|OB_RIGID_BODY|OB_SOFT_BODY|OB_COLLISION_RESPONSE);
 | 
									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;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -156,7 +156,14 @@ typedef struct Object {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	float formfactor;
 | 
						float formfactor;
 | 
				
			||||||
	float rdamping, sizefac;
 | 
						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 dt, dtx;
 | 
				
			||||||
@@ -411,6 +418,9 @@ extern Object workob;
 | 
				
			|||||||
#define OB_RECALC_TIME		4
 | 
					#define OB_RECALC_TIME		4
 | 
				
			||||||
#define OB_RECALC			7
 | 
					#define OB_RECALC			7
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ob->gamesoftFlag */
 | 
				
			||||||
 | 
					#define OB_SOFT_SHAPE_MATCHING	1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* ob->gameflag */
 | 
					/* ob->gameflag */
 | 
				
			||||||
#define OB_DYNAMIC		1
 | 
					#define OB_DYNAMIC		1
 | 
				
			||||||
#define OB_CHILD		2
 | 
					#define OB_CHILD		2
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2979,11 +2979,11 @@ static uiBlock *advanced_bullet_menu(void *arg_ob)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	uiBlock *block;
 | 
						uiBlock *block;
 | 
				
			||||||
	Object *ob = arg_ob;
 | 
						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);
 | 
						block= uiNewBlock(&curarea->uiblocks, "advanced_bullet_options", UI_EMBOSS, UI_HELV, curarea->win);
 | 
				
			||||||
	/* use this for a fake extra empy space around the buttons */
 | 
						/* 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",
 | 
						uiDefButBitI(block, TOG, OB_ACTOR, 0, "Sensor actor",
 | 
				
			||||||
				xco, yco, 118, 19, &ob->gameflag, 0, 0, 0, 0,
 | 
									xco, yco, 118, 19, &ob->gameflag, 0, 0, 0, 0,
 | 
				
			||||||
@@ -3008,6 +3008,25 @@ static uiBlock *advanced_bullet_menu(void *arg_ob)
 | 
				
			|||||||
				xco, yco, 118, 19, &ob->margin, 0.0, 1.0, 1, 0, 
 | 
									xco, yco, 118, 19, &ob->margin, 0.0, 1.0, 1, 0, 
 | 
				
			||||||
				"Collision margin");
 | 
									"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);
 | 
						uiBlockSetDirection(block, UI_TOP);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3529,6 +3529,10 @@ void copy_attr(short event)
 | 
				
			|||||||
						base->object->boundtype = ob->boundtype;
 | 
											base->object->boundtype = ob->boundtype;
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
					base->object->margin= ob->margin;
 | 
										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 */
 | 
									else if(event==17) {	/* tex space */
 | 
				
			||||||
					copy_texture_space(base->object, ob);
 | 
										copy_texture_space(base->object, ob);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -797,6 +797,36 @@ static PyObject* gPyGetMaterialType(PyObject*)
 | 
				
			|||||||
	return PyInt_FromLong(flag);
 | 
						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	gPyGetWindowHeight__doc__="getWindowHeight doc";
 | 
				
			||||||
STR_String	gPyGetWindowWidth__doc__="getWindowWidth doc";
 | 
					STR_String	gPyGetWindowWidth__doc__="getWindowWidth doc";
 | 
				
			||||||
STR_String	gPyEnableVisibility__doc__="enableVisibility doc";
 | 
					STR_String	gPyEnableVisibility__doc__="enableVisibility doc";
 | 
				
			||||||
@@ -838,6 +868,8 @@ static struct PyMethodDef rasterizer_methods[] = {
 | 
				
			|||||||
   METH_VARARGS, "set the state of a GLSL material setting"},
 | 
					   METH_VARARGS, "set the state of a GLSL material setting"},
 | 
				
			||||||
  {"getGLSLMaterialSetting",(PyCFunction) gPyGetGLSLMaterialSetting,
 | 
					  {"getGLSLMaterialSetting",(PyCFunction) gPyGetGLSLMaterialSetting,
 | 
				
			||||||
   METH_VARARGS, "get the state of a GLSL material setting"},
 | 
					   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 }
 | 
					  { NULL, (PyCFunction) NULL, 0, NULL }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -181,4 +181,15 @@ def getGLSLMaterialSetting(setting, enable):
 | 
				
			|||||||
	@type setting: string (lights, shaders, shadows, ramps, nodes, extra_textures)
 | 
						@type setting: string (lights, shaders, shadows, ramps, nodes, extra_textures)
 | 
				
			||||||
	@rtype: boolean
 | 
						@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]
 | 
				
			||||||
 | 
						"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user