Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2008-08-29 03:12:29 +0400
committerCampbell Barton <ideasman42@gmail.com>2008-08-29 03:12:29 +0400
commit7e4eb371fe4333799b9ad763170679d4e56b242a (patch)
tree4f6b7355ed04afd770fe277257a57e0aa05ebafa /source
parent2b1c7fe4f92243b6a5dd671950952854635923aa (diff)
svn merge -r 16287:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender still getting errors compiling blenderplayer
Diffstat (limited to 'source')
-rw-r--r--source/blender/include/BIF_editarmature.h1
-rw-r--r--source/blender/makesdna/DNA_sensor_types.h3
-rw-r--r--source/blender/src/buttons_logic.c9
-rw-r--r--source/blender/src/editarmature.c84
-rw-r--r--source/blender/src/editobject.c23
-rw-r--r--source/blender/src/space.c2
-rw-r--r--source/gameengine/Converter/KX_ConvertSensors.cpp2
-rw-r--r--source/gameengine/Ketsji/KX_RaySensor.cpp18
-rw-r--r--source/gameengine/Ketsji/KX_RaySensor.h4
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp1
10 files changed, 136 insertions, 11 deletions
diff --git a/source/blender/include/BIF_editarmature.h b/source/blender/include/BIF_editarmature.h
index 07fc8f08b4a..b2bdb2dad73 100644
--- a/source/blender/include/BIF_editarmature.h
+++ b/source/blender/include/BIF_editarmature.h
@@ -91,6 +91,7 @@ void free_editArmature(void);
int join_armature(void);
void separate_armature(void);
+void apply_armature_pose2bones(void);
void load_editArmature(void);
void make_bone_parent(void);
diff --git a/source/blender/makesdna/DNA_sensor_types.h b/source/blender/makesdna/DNA_sensor_types.h
index b5d8511c698..d508ff3a552 100644
--- a/source/blender/makesdna/DNA_sensor_types.h
+++ b/source/blender/makesdna/DNA_sensor_types.h
@@ -237,6 +237,9 @@ typedef struct bJoystickSensor {
* */
/* #define SENS_COLLISION_PROPERTY 0 */
#define SENS_COLLISION_MATERIAL 1
+/* ray specific mode */
+/* X-Ray means that the ray will traverse objects that don't have the property/material */
+#define SENS_RAY_XRAY 2
/* Some stuff for the mouse sensor Type: */
#define BL_SENS_MOUSE_LEFT_BUTTON 1
diff --git a/source/blender/src/buttons_logic.c b/source/blender/src/buttons_logic.c
index b7ce16f50a6..9b41b646bc8 100644
--- a/source/blender/src/buttons_logic.c
+++ b/source/blender/src/buttons_logic.c
@@ -1390,9 +1390,14 @@ static short draw_sensorbuttons(bSensor *sens, uiBlock *block, short xco, short
&raySens->propname, 0, 31, 0, 0,
"Only look for Objects with this property");
}
-
+
+ /* X-Ray option */
+ uiDefButBitS(block, TOG, SENS_RAY_XRAY, 1, "X",
+ xco + 10,yco - 68, 0.10 * (width-20), 19,
+ &raySens->mode, 0.0, 0.0, 0, 0,
+ "Toggle X-Ray option (see through objects that don't have the property)");
/* 2. sensing range */
- uiDefButF(block, NUM, 1, "Range", xco+10, yco-68, 0.6 * (width-20), 19,
+ uiDefButF(block, NUM, 1, "Range", xco+10 + 0.10 * (width-20), yco-68, 0.5 * (width-20), 19,
&raySens->range, 0.01, 10000.0, 100, 0,
"Sense objects no farther than this distance");
diff --git a/source/blender/src/editarmature.c b/source/blender/src/editarmature.c
index 35986fcff4a..01a0c330b47 100644
--- a/source/blender/src/editarmature.c
+++ b/source/blender/src/editarmature.c
@@ -439,6 +439,90 @@ void docenter_armature (Object *ob, int centermode)
}
}
+/* helper for apply_armature_pose2bones - fixes parenting of objects that are bone-parented to armature */
+static void applyarmature_fix_boneparents (Object *ob)
+{
+
+}
+
+/* set the current pose as the restpose */
+void apply_armature_pose2bones(void)
+{
+ Object *ob;
+ bArmature *arm;
+ bPose *pose;
+ bPoseChannel *pchan;
+ EditBone *curbone;
+
+ /* don't check if editmode (should be done by caller) */
+ ob= OBACT;
+ if (ob->type!=OB_ARMATURE) return;
+ if (object_data_is_libdata(ob)) {
+ error_libdata();
+ return;
+ }
+ arm= get_armature(ob);
+
+ /* Get editbones of active armature to alter */
+ if (G.edbo.first) BLI_freelistN(&G.edbo);
+ make_boneList(&G.edbo, &arm->bonebase, NULL);
+
+ /* get pose of active object and move it out of posemode */
+ pose= ob->pose;
+
+ for (pchan=pose->chanbase.first; pchan; pchan=pchan->next) {
+ curbone= editbone_name_exists(&G.edbo, pchan->name);
+
+ /* simply copy the head/tail values from pchan over to curbone */
+ VECCOPY(curbone->head, pchan->pose_head);
+ VECCOPY(curbone->tail, pchan->pose_tail);
+
+ /* fix roll:
+ * 1. find auto-calculated roll value for this bone now
+ * 2. remove this from the 'visual' y-rotation
+ */
+ {
+ float premat[3][3], imat[3][3],pmat[3][3], tmat[3][3];
+ float delta[3], eul[3];
+
+ /* obtain new auto-yrotation */
+ VecSubf(delta, curbone->tail, curbone->head);
+ vec_roll_to_mat3(delta, curbone->roll, premat);
+ Mat3Inv(imat, premat);
+
+ /* get pchan 'visual' matrix */
+ Mat3CpyMat4(pmat, pchan->pose_mat);
+
+ /* remove auto from visual and get euler rotation */
+ Mat3MulMat3(tmat, imat, pmat);
+ Mat3ToEul(tmat, eul);
+
+ /* just use this euler-y as new roll value */
+ curbone->roll= eul[1];
+ }
+
+ /* clear transform values for pchan */
+ pchan->loc[0]= pchan->loc[1]= pchan->loc[2]= 0;
+ pchan->size[0]= pchan->size[1]= pchan->size[2]= 1;
+ pchan->quat[1]= pchan->quat[2]= pchan->quat[3]= 0;
+ pchan->quat[0]= 1;
+ }
+
+ /* convert editbones back to bones */
+ editbones_to_armature(&G.edbo, ob);
+ if (G.edbo.first) BLI_freelistN(&G.edbo);
+
+ /* flush positions of posebones */
+ where_is_pose(ob);
+
+ /* fix parenting of objects which are bone-parented */
+ applyarmature_fix_boneparents(ob);
+
+ BIF_undo_push("Apply new restpose");
+ allqueue(REDRAWVIEW3D, 0);
+}
+
+
/* Helper function for armature joining - link fixing */
static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChannel *pchan, EditBone *curbone)
{
diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c
index 1ba7bce6dab..dded38a00e8 100644
--- a/source/blender/src/editobject.c
+++ b/source/blender/src/editobject.c
@@ -4130,15 +4130,26 @@ void apply_object( void )
}
allqueue(REDRAWVIEW3D, 0);
- } else {
+ }
+ else {
+ ob= OBACT;
- evt = pupmenu("Apply Object%t|Scale and Rotation to ObData|Visual Transform to Objects Loc/Scale/Rot");
+ if ((ob->pose) && (ob->flag & OB_POSEMODE))
+ evt = pupmenu("Apply Object%t|Current Pose as RestPose%x3");
+ else
+ evt = pupmenu("Apply Object%t|Scale and Rotation to ObData%x1|Visual Transform to Objects Loc/Scale/Rot%x2");
if (evt==-1) return;
- if (evt==1) {
- apply_objects_locrot();
- } else if (evt==2) {
- apply_objects_visual_tx();
+ switch (evt) {
+ case 1:
+ apply_objects_locrot();
+ break;
+ case 2:
+ apply_objects_visual_tx();
+ break;
+ case 3:
+ apply_armature_pose2bones();
+ break;
}
}
}
diff --git a/source/blender/src/space.c b/source/blender/src/space.c
index 066c1c750ee..12c67ea4c07 100644
--- a/source/blender/src/space.c
+++ b/source/blender/src/space.c
@@ -1976,7 +1976,7 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
G.vd->drawtype= pupval;
doredraw= 1;
}
- }
+ }
break;
case EKEY:
diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp
index 98e078ccf8d..db47dc2dd3d 100644
--- a/source/gameengine/Converter/KX_ConvertSensors.cpp
+++ b/source/gameengine/Converter/KX_ConvertSensors.cpp
@@ -633,6 +633,7 @@ void BL_ConvertSensors(struct Object* blenderobject,
if (eventmgr)
{
bool bFindMaterial = (blenderraysensor->mode & SENS_COLLISION_MATERIAL);
+ bool bXRay = (blenderraysensor->mode & SENS_RAY_XRAY);
STR_String checkname = (bFindMaterial? blenderraysensor->matname : blenderraysensor->propname);
@@ -645,6 +646,7 @@ void BL_ConvertSensors(struct Object* blenderobject,
gameobj,
checkname,
bFindMaterial,
+ bXRay,
distance,
axis,
kxscene);
diff --git a/source/gameengine/Ketsji/KX_RaySensor.cpp b/source/gameengine/Ketsji/KX_RaySensor.cpp
index 57101b769ea..8dc22fe13c1 100644
--- a/source/gameengine/Ketsji/KX_RaySensor.cpp
+++ b/source/gameengine/Ketsji/KX_RaySensor.cpp
@@ -51,6 +51,7 @@ KX_RaySensor::KX_RaySensor(class SCA_EventManager* eventmgr,
SCA_IObject* gameobj,
const STR_String& propname,
bool bFindMaterial,
+ bool bXRay,
double distance,
int axis,
KX_Scene* ketsjiScene,
@@ -58,6 +59,7 @@ KX_RaySensor::KX_RaySensor(class SCA_EventManager* eventmgr,
: SCA_ISensor(gameobj,eventmgr, T),
m_propertyname(propname),
m_bFindMaterial(bFindMaterial),
+ m_bXRay(bXRay),
m_distance(distance),
m_scene(ketsjiScene),
m_axis(axis)
@@ -153,7 +155,21 @@ bool KX_RaySensor::NeedRayCast(KX_ClientObjectInfo* client)
printf("Invalid client type %d found ray casting\n", client->m_type);
return false;
}
- // no X-Ray function yet
+ if (m_bXRay && m_propertyname.Length() != 0)
+ {
+ if (m_bFindMaterial)
+ {
+ // not quite correct: an object may have multiple material
+ // should check all the material and not only the first one
+ if (!client->m_auxilary_info || (m_propertyname != ((char*)client->m_auxilary_info)))
+ return false;
+ }
+ else
+ {
+ if (client->m_gameobject->GetProperty(m_propertyname) == NULL)
+ return false;
+ }
+ }
return true;
}
diff --git a/source/gameengine/Ketsji/KX_RaySensor.h b/source/gameengine/Ketsji/KX_RaySensor.h
index 9e53f80b69c..02a755fedc1 100644
--- a/source/gameengine/Ketsji/KX_RaySensor.h
+++ b/source/gameengine/Ketsji/KX_RaySensor.h
@@ -43,6 +43,7 @@ class KX_RaySensor : public SCA_ISensor
Py_Header;
STR_String m_propertyname;
bool m_bFindMaterial;
+ bool m_bXRay;
double m_distance;
class KX_Scene* m_scene;
bool m_bTriggered;
@@ -57,7 +58,8 @@ public:
KX_RaySensor(class SCA_EventManager* eventmgr,
SCA_IObject* gameobj,
const STR_String& propname,
- bool fFindMaterial,
+ bool bFindMaterial,
+ bool bXRay,
double distance,
int axis,
class KX_Scene* ketsjiScene,
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
index a34c70143e5..d14ddf8f65c 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
@@ -53,6 +53,7 @@ void DrawRasterizerLine(const float* from,const float* to,int color);
#include <stdio.h>
+#include <string.h> // for memset
#ifdef NEW_BULLET_VEHICLE_SUPPORT
class WrapperVehicle : public PHY_IVehicle