[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16716] trunk/blender/source: BGE patch: add advanced parameters for SoftBody.
Benoit Bolsee
benoit.bolsee at online.be
Thu Sep 25 00:58:49 CEST 2008
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]
+ """
More information about the Bf-blender-cvs
mailing list