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
diff options
context:
space:
mode:
authorDalai Felinto <dfelinto@gmail.com>2012-01-11 11:27:39 +0400
committerDalai Felinto <dfelinto@gmail.com>2012-01-11 11:27:39 +0400
commit782f0b63829a2c257a6e2942c49882f7fe04c33c (patch)
treeb7d421c7d4560167b8f71b4fb2d2fd2ad2d59daf /source/blender
parent0effb45d58b75d96f8bc1be74affc43e99fe2a92 (diff)
bge camera actuator: -X and -Y axis
The camera actuator only allows to look the object from its front face. Given that Blender takes -Y as the default forward orientation, the current functionality doesn't let a camera to track an actor from behind. This patch allows for -X and -Y axis tracking. This way a camera over the shoulders of a character is possible (without resorting to rotate the mesh/armature original orientation. - patch reviewed by Campbell Barton, thanks
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/intern/sca.c2
-rw-r--r--source/blender/blenloader/intern/readfile.c18
-rw-r--r--source/blender/makesdna/DNA_actuator_types.h4
-rw-r--r--source/blender/makesrna/intern/rna_actuator.c8
4 files changed, 23 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c
index f7eda6bd9b3..92dfe90eec1 100644
--- a/source/blender/blenkernel/intern/sca.c
+++ b/source/blender/blenkernel/intern/sca.c
@@ -428,7 +428,7 @@ void init_actuator(bActuator *act)
case ACT_CAMERA:
act->data= MEM_callocN(sizeof(bCameraActuator), "camact");
ca = act->data;
- ca->axis = ACT_CAMERA_X;
+ ca->axis = OB_POSX;
ca->damping = 1.0/32.0;
break;
case ACT_EDIT_OBJECT:
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index bb5682f4ebd..1f45be6848d 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -12941,7 +12941,23 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
/* put compatibility code here until next subversion bump */
{
-
+ {
+ /* convert Camera Actuator values to defines */
+ Object *ob;
+ bActuator *act;
+ for(ob = main->object.first; ob; ob= ob->id.next) {
+ for(act= ob->actuators.first; act; act= act->next) {
+ if (act->type == ACT_CAMERA) {
+ bCameraActuator *ba= act->data;
+
+ if(ba->axis==(float) 'x') ba->axis=OB_POSX;
+ else if (ba->axis==(float)'y') ba->axis=OB_POSY;
+ /* don't do an if/else to avoid imediate subversion bump*/
+// ba->axis=((ba->axis == (float) 'x')?OB_POSX_X:OB_POSY);
+ }
+ }
+ }
+ }
}
/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
diff --git a/source/blender/makesdna/DNA_actuator_types.h b/source/blender/makesdna/DNA_actuator_types.h
index a4280a6e463..076910ade1f 100644
--- a/source/blender/makesdna/DNA_actuator_types.h
+++ b/source/blender/makesdna/DNA_actuator_types.h
@@ -520,10 +520,6 @@ typedef struct bActuator {
#define ACT_STATE_REMOVE 2
#define ACT_STATE_CHANGE 3
-/* cameraactuator->axis */
-#define ACT_CAMERA_X (float)'x'
-#define ACT_CAMERA_Y (float)'y'
-
/* steeringactuator->type */
#define ACT_STEERING_SEEK 0
#define ACT_STEERING_FLEE 1
diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c
index 612c34d1c92..6098e885df5 100644
--- a/source/blender/makesrna/intern/rna_actuator.c
+++ b/source/blender/makesrna/intern/rna_actuator.c
@@ -867,8 +867,10 @@ static void rna_def_camera_actuator(BlenderRNA *brna)
PropertyRNA *prop;
static EnumPropertyItem prop_axis_items[] ={
- {ACT_CAMERA_X, "X", 0, "X", "Camera tries to get behind the X axis"},
- {ACT_CAMERA_Y, "Y", 0, "Y", "Camera tries to get behind the Y axis"},
+ {OB_POSX, "POS_X", 0, "+X", "Camera tries to get behind the X axis"},
+ {OB_POSY, "POS_Y", 0, "+Y", "Camera tries to get behind the Y axis"},
+ {OB_NEGX, "NEG_X", 0, "-X", "Camera tries to get behind the -X axis"},
+ {OB_NEGY, "NEG_Y", 0, "-Y", "Camera tries to get behind the -Y axis"},
{0, NULL, 0, NULL, NULL}};
srna= RNA_def_struct(brna, "CameraActuator", "Actuator");
@@ -905,7 +907,7 @@ static void rna_def_camera_actuator(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Damping", "Strength of the constraint that drives the camera behind the target");
RNA_def_property_update(prop, NC_LOGIC, NULL);
- /* x/y */
+ /* +x/+y/-x/-y */
prop= RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "axis");
RNA_def_property_enum_items(prop, prop_axis_items);