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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-01-26 11:34:40 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-01-26 11:34:40 +0300
commit87627374000b7de7445736a7239a3f2b168ce7eb (patch)
tree2f0fe5d42d0938fc1b684af702d8613099bea1bd /source
parent784d8ee37a52f3ef689aa6d02e75e50566efe93f (diff)
parentba8ea9ec63c25b1ce134a846176f7bf252f4d487 (diff)
2.50: svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r17853:HEAD
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_global.h1
-rw-r--r--source/blender/blenkernel/SConscript6
-rw-r--r--source/blender/blenkernel/intern/collision.c2
-rw-r--r--source/blender/blenkernel/intern/constraint.c14
-rw-r--r--source/blender/blenkernel/intern/effect.c2
-rw-r--r--source/blender/blenkernel/intern/image.c36
-rw-r--r--source/blender/blenkernel/intern/particle_system.c8
-rw-r--r--source/blender/blenlib/BLI_arithb.h1
-rw-r--r--source/blender/blenlib/intern/arithb.c11
-rw-r--r--source/blender/blenlib/intern/graph.c6
-rw-r--r--source/blender/blenloader/intern/readfile.c2
-rw-r--r--source/blender/blenpluginapi/iff.h5
-rw-r--r--source/blender/editors/animation/anim_markers.c22
-rw-r--r--source/blender/editors/space_file/SConscript7
-rw-r--r--source/blender/editors/space_file/filelist.c7
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c3
-rw-r--r--source/blender/editors/transform/transform_snap.c18
-rw-r--r--source/blender/gpu/intern/gpu_material.c2
-rw-r--r--source/blender/imbuf/IMB_imbuf_types.h10
-rw-r--r--source/blender/imbuf/intern/IMB_jp2.h49
-rw-r--r--source/blender/imbuf/intern/jp2.c736
-rw-r--r--source/blender/imbuf/intern/openexr/CMakeLists.txt4
-rw-r--r--source/blender/imbuf/intern/readimage.c11
-rw-r--r--source/blender/imbuf/intern/util.c20
-rw-r--r--source/blender/imbuf/intern/writeimage.c8
-rw-r--r--source/blender/makesdna/DNA_action_types.h20
-rw-r--r--source/blender/makesdna/DNA_actuator_types.h2
-rw-r--r--source/blender/makesdna/DNA_scene_types.h12
-rw-r--r--source/blender/nodes/CMakeLists.txt6
-rw-r--r--source/blender/nodes/SConscript2
-rw-r--r--source/blender/nodes/intern/CMP_nodes/CMP_filter.c1
-rw-r--r--source/blender/radiosity/intern/source/radfactors.c4
-rw-r--r--source/blender/radiosity/intern/source/radrender.c4
-rw-r--r--source/blender/readblenfile/intern/BLO_readblenfile.c2
-rw-r--r--source/blender/render/intern/source/occlusion.c10
-rw-r--r--source/blender/render/intern/source/pipeline.c32
-rw-r--r--source/blender/render/intern/source/rendercore.c4
-rw-r--r--source/blender/render/intern/source/shadeinput.c2
-rw-r--r--source/creator/creator.c13
-rw-r--r--source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp12
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h1
-rw-r--r--source/gameengine/Converter/BL_ActionActuator.cpp339
-rw-r--r--source/gameengine/Converter/BL_ActionActuator.h54
-rw-r--r--source/gameengine/Converter/BL_ShapeActionActuator.cpp80
-rw-r--r--source/gameengine/Converter/BL_ShapeActionActuator.h40
-rw-r--r--source/gameengine/Converter/KX_ConvertActuators.cpp3
-rw-r--r--source/gameengine/Converter/KX_ConvertSensors.cpp1
-rw-r--r--source/gameengine/Expressions/PyObjectPlus.cpp531
-rw-r--r--source/gameengine/Expressions/PyObjectPlus.h130
-rw-r--r--source/gameengine/Expressions/Value.cpp12
-rw-r--r--source/gameengine/Expressions/Value.h5
-rw-r--r--source/gameengine/GameLogic/SCA_2DFilterActuator.cpp3
-rw-r--r--source/gameengine/GameLogic/SCA_ActuatorSensor.cpp31
-rw-r--r--source/gameengine/GameLogic/SCA_ActuatorSensor.h2
-rw-r--r--source/gameengine/GameLogic/SCA_DelaySensor.cpp26
-rw-r--r--source/gameengine/GameLogic/SCA_DelaySensor.h1
-rw-r--r--source/gameengine/GameLogic/SCA_IInputDevice.h1
-rw-r--r--source/gameengine/GameLogic/SCA_ILogicBrick.cpp37
-rw-r--r--source/gameengine/GameLogic/SCA_ILogicBrick.h4
-rw-r--r--source/gameengine/GameLogic/SCA_ISensor.cpp187
-rw-r--r--source/gameengine/GameLogic/SCA_ISensor.h12
-rw-r--r--source/gameengine/GameLogic/SCA_JoystickSensor.cpp93
-rw-r--r--source/gameengine/GameLogic/SCA_JoystickSensor.h31
-rw-r--r--source/gameengine/GameLogic/SCA_KeyboardSensor.cpp132
-rw-r--r--source/gameengine/GameLogic/SCA_KeyboardSensor.h16
-rw-r--r--source/gameengine/GameLogic/SCA_MouseSensor.cpp233
-rw-r--r--source/gameengine/GameLogic/SCA_MouseSensor.h12
-rw-r--r--source/gameengine/GameLogic/SCA_PropertyActuator.cpp22
-rw-r--r--source/gameengine/GameLogic/SCA_PropertyActuator.h1
-rw-r--r--source/gameengine/GameLogic/SCA_PropertySensor.cpp37
-rw-r--r--source/gameengine/GameLogic/SCA_PropertySensor.h10
-rw-r--r--source/gameengine/GameLogic/SCA_PythonController.cpp24
-rw-r--r--source/gameengine/GameLogic/SCA_PythonController.h1
-rw-r--r--source/gameengine/GameLogic/SCA_RandomActuator.cpp45
-rw-r--r--source/gameengine/GameLogic/SCA_RandomActuator.h2
-rw-r--r--source/gameengine/GameLogic/SCA_RandomSensor.cpp32
-rw-r--r--source/gameengine/GameLogic/SCA_RandomSensor.h1
-rw-r--r--source/gameengine/GamePlayer/ghost/CMakeLists.txt4
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_Application.cpp6
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_ghost.cpp24
-rw-r--r--source/gameengine/GamePlayer/ghost/Makefile3
-rw-r--r--source/gameengine/GamePlayer/ghost/SConscript5
-rw-r--r--source/gameengine/Ketsji/KX_BulletPhysicsController.cpp156
-rw-r--r--source/gameengine/Ketsji/KX_BulletPhysicsController.h6
-rw-r--r--source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp2
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.cpp35
-rw-r--r--source/gameengine/Ketsji/KX_IPhysicsController.cpp3
-rw-r--r--source/gameengine/Ketsji/KX_IPhysicsController.h11
-rw-r--r--source/gameengine/Ketsji/KX_KetsjiEngine.cpp20
-rw-r--r--source/gameengine/Ketsji/KX_OdePhysicsController.cpp2
-rw-r--r--source/gameengine/Ketsji/KX_OdePhysicsController.h2
-rw-r--r--source/gameengine/Ketsji/KX_PolyProxy.cpp32
-rw-r--r--source/gameengine/Ketsji/KX_PythonInit.cpp10
-rw-r--r--source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp7
-rw-r--r--source/gameengine/Ketsji/KX_SCA_DynamicActuator.h2
-rw-r--r--source/gameengine/Ketsji/KX_SumoPhysicsController.cpp4
-rw-r--r--source/gameengine/Ketsji/KX_SumoPhysicsController.h6
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsController.cpp26
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsController.h44
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp14
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h2
-rw-r--r--source/gameengine/Physics/common/PHY_DynamicTypes.h3
-rw-r--r--source/gameengine/PyDoc/BL_ActionActuator.py73
-rw-r--r--source/gameengine/PyDoc/BL_ShapeActionActuator.py63
-rw-r--r--source/gameengine/PyDoc/KX_ActuatorSensor.py7
-rw-r--r--source/gameengine/PyDoc/SCA_DelaySensor.py17
-rw-r--r--source/gameengine/PyDoc/SCA_ILogicBrick.py9
-rw-r--r--source/gameengine/PyDoc/SCA_ISensor.py34
-rw-r--r--source/gameengine/PyDoc/SCA_JoystickSensor.py59
-rw-r--r--source/gameengine/PyDoc/SCA_KeyboardSensor.py65
-rw-r--r--source/gameengine/PyDoc/SCA_MouseSensor.py11
-rw-r--r--source/gameengine/PyDoc/SCA_PropertyActuator.py11
-rw-r--r--source/gameengine/PyDoc/SCA_PropertySensor.py17
-rw-r--r--source/gameengine/PyDoc/SCA_PythonController.py10
-rw-r--r--source/gameengine/PyDoc/SCA_RandomActuator.py32
-rw-r--r--source/nan_definitions.mk14
116 files changed, 3597 insertions, 563 deletions
diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h
index 07ade7cb208..0d5208ed90d 100644
--- a/source/blender/blenkernel/BKE_global.h
+++ b/source/blender/blenkernel/BKE_global.h
@@ -178,6 +178,7 @@ typedef struct Global {
#define G_FILE_GLSL_NO_RAMPS (1 << 19)
#define G_FILE_GLSL_NO_NODES (1 << 20)
#define G_FILE_GLSL_NO_EXTRA_TEX (1 << 21)
+#define G_FILE_IGNORE_DEPRECATION_WARNINGS (1 << 22)
/* G.windowstate */
#define G_WINDOWSTATE_USERDEF 0
diff --git a/source/blender/blenkernel/SConscript b/source/blender/blenkernel/SConscript
index bf09b2aac03..cb0c60fb1f1 100644
--- a/source/blender/blenkernel/SConscript
+++ b/source/blender/blenkernel/SConscript
@@ -35,6 +35,9 @@ if env['WITH_BF_INTERNATIONAL']:
if env['WITH_BF_OPENEXR']:
defs += ' WITH_OPENEXR'
+if env['WITH_BF_OPENJPEG']:
+ defs += ' WITH_OPENJPEG'
+
if env['WITH_BF_DDS']:
defs += ' WITH_DDS'
@@ -46,6 +49,9 @@ if env['WITH_BF_QUICKTIME']:
defs += ' WITH_QUICKTIME'
incs += ' ' + env['BF_QUICKTIME_INC']
+if env['WITH_BF_BULLET']:
+ defs += ' WITH_BULLET'
+
if env['BF_NO_ELBEEM']:
defs += ' DISABLE_ELBEEM'
diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c
index 9e57fef41f7..c122145c98f 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -1237,7 +1237,7 @@ int cloth_collision_moving_edges ( ClothModifierData *clmd, CollisionModifierDat
if(out_normalVelocity < 0.0)
{
out_normalVelocity*= -1.0;
- VecMulf(out_normal, -1.0);
+ VecNegf(out_normal);
}
*/
/* Inelastic repulsion impulse. */
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index f5613a34700..912bc7ab3bd 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -898,7 +898,7 @@ static void vectomat (float *vec, float *target_up, short axis, short upflag, sh
n[2] = 1.0;
}
if (axis > 2) axis -= 3;
- else VecMulf(n,-1);
+ else VecNegf(n);
/* n specifies the transformation of the track axis */
if (flags & TARGET_Z_UP) {
@@ -2039,7 +2039,7 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *
Projf(vec2, vec, cob->matrix[0]);
VecSubf(totmat[1], vec, vec2);
Normalize(totmat[1]);
- VecMulf(totmat[1],-1);
+ VecNegf(totmat[1]);
/* the x axis is fixed */
totmat[0][0] = cob->matrix[0][0];
@@ -2057,7 +2057,7 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *
Projf(vec2, vec, cob->matrix[0]);
VecSubf(totmat[2], vec, vec2);
Normalize(totmat[2]);
- VecMulf(totmat[2],-1);
+ VecNegf(totmat[2]);
/* the x axis is fixed */
totmat[0][0] = cob->matrix[0][0];
@@ -2122,7 +2122,7 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *
Projf(vec2, vec, cob->matrix[1]);
VecSubf(totmat[0], vec, vec2);
Normalize(totmat[0]);
- VecMulf(totmat[0],-1);
+ VecNegf(totmat[0]);
/* the y axis is fixed */
totmat[1][0] = cob->matrix[1][0];
@@ -2140,7 +2140,7 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *
Projf(vec2, vec, cob->matrix[1]);
VecSubf(totmat[2], vec, vec2);
Normalize(totmat[2]);
- VecMulf(totmat[2],-1);
+ VecNegf(totmat[2]);
/* the y axis is fixed */
totmat[1][0] = cob->matrix[1][0];
@@ -2205,7 +2205,7 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *
Projf(vec2, vec, cob->matrix[2]);
VecSubf(totmat[0], vec, vec2);
Normalize(totmat[0]);
- VecMulf(totmat[0],-1);
+ VecNegf(totmat[0]);
/* the z axis is fixed */
totmat[2][0] = cob->matrix[2][0];
@@ -2223,7 +2223,7 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *
Projf(vec2, vec, cob->matrix[2]);
VecSubf(totmat[1], vec, vec2);
Normalize(totmat[1]);
- VecMulf(totmat[1],-1);
+ VecNegf(totmat[1]);
/* the z axis is fixed */
totmat[2][0] = cob->matrix[2][0];
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index d28d4206768..5217464c2c9 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -252,7 +252,7 @@ static float eff_calc_visibility(Scene *scene, Object *ob, float *co, float *dir
return 0;
VECCOPY(norm, dir);
- VecMulf(norm, -1.0);
+ VecNegf(norm);
len = Normalize(norm);
// check all collision objects
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 7890b72f6e2..1b851444e04 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -766,6 +766,10 @@ int BKE_imtype_to_ftype(int imtype)
return RAWTGA;
else if(imtype==R_HAMX)
return AN_hamx;
+#ifdef WITH_OPENJPEG
+ else if(imtype==R_JP2)
+ return JP2;
+#endif
else
return JPG|90;
}
@@ -800,6 +804,10 @@ int BKE_ftype_to_imtype(int ftype)
return R_RAWTGA;
else if(ftype == AN_hamx)
return R_HAMX;
+#ifdef WITH_OPENJPEG
+ else if(ftype & JP2)
+ return R_JP2;
+#endif
else
return R_JPEG90;
}
@@ -876,6 +884,12 @@ void BKE_add_image_extension(Scene *scene, char *string, int imtype)
if(!BLI_testextensie(string, ".tga"))
extension= ".tga";
}
+#ifdef WITH_OPENJPEG
+ else if(imtype==R_JP2) {
+ if(!BLI_testextensie(string, ".jp2"))
+ extension= ".jp2";
+ }
+#endif
else { // R_MOVIE, R_AVICODEC, R_AVIRAW, R_AVIJPEG, R_JPEG90, R_QUICKTIME etc
if(!( BLI_testextensie(string, ".jpg") || BLI_testextensie(string, ".jpeg")))
extension= ".jpg";
@@ -1219,6 +1233,28 @@ int BKE_write_ibuf(Scene *scene, ImBuf *ibuf, char *name, int imtype, int subimt
else if(imtype==R_HAMX) {
ibuf->ftype= AN_hamx;
}
+#ifdef WITH_OPENJPEG
+ else if(imtype==R_JP2) {
+ if(quality < 10) quality= 90;
+ ibuf->ftype= JP2|quality;
+
+ if (subimtype & R_JPEG2K_16BIT) {
+ ibuf->ftype |= JP2_16BIT;
+ } else if (subimtype & R_JPEG2K_12BIT) {
+ ibuf->ftype |= JP2_12BIT;
+ }
+
+ if (subimtype & R_JPEG2K_YCC) {
+ ibuf->ftype |= JP2_YCC;
+ }
+
+ if (subimtype & R_JPEG2K_CINE_PRESET) {
+ ibuf->ftype |= JP2_CINE;
+ if (subimtype & R_JPEG2K_CINE_48FPS)
+ ibuf->ftype |= JP2_CINE_48FPS;
+ }
+ }
+#endif
else {
/* R_JPEG90, R_MOVIE, etc. default we save jpegs */
if(quality < 10) quality= 90;
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 4a4a8b2e5b7..516cdc76125 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -824,7 +824,7 @@ void psys_thread_distribute_particle(ParticleThread *thread, ParticleData *pa, C
VecCopyf(tan,seam->tan);
VecSubf(temp2,co1,temp);
if(Inpf(tan,temp2)<0.0f)
- VecMulf(tan,-1.0f);
+ VecNegf(tan);
}
for(w=0; w<maxw; w++){
VecSubf(temp2,ptn[w].co,temp);
@@ -1878,7 +1878,7 @@ void reset_particle(Scene *scene, ParticleData *pa, ParticleSystem *psys, Partic
}
/* create rotation quat */
- VecMulf(rot_vec,-1.0);
+ VecNegf(rot_vec);
vectoquat(rot_vec, OB_POSX, OB_POSZ, q2);
/* randomize rotation quat */
@@ -3025,7 +3025,7 @@ static void particle_intersect_face(void *userdata, int index, const BVHTreeRay
CalcNormFloat(t0, t1, t2, col->nor);
VECSUB(temp, co2, co1);
if(Inpf(col->nor, temp) > 0.0f)
- VecMulf(col->nor, -1.0f);
+ VecNegf(col->nor);
VECCOPY(col->vel,vel);
@@ -3805,7 +3805,7 @@ static void boid_body(Scene *scene, BoidVecFunc *bvf, ParticleData *pa, Particle
VecRotToQuat(pa->state.vel,bank,q);
VECCOPY(dvec,pa->state.vel);
- VecMulf(dvec,-1.0f);
+ VecNegf(dvec);
vectoquat(dvec, OB_POSX, OB_POSZ, q2);
QuatMul(pa->state.rot,q,q2);
diff --git a/source/blender/blenlib/BLI_arithb.h b/source/blender/blenlib/BLI_arithb.h
index 8c55a83785b..5acee360872 100644
--- a/source/blender/blenlib/BLI_arithb.h
+++ b/source/blender/blenlib/BLI_arithb.h
@@ -242,6 +242,7 @@ int VecLen(int *v1, int *v2);
float VecLenf(float *v1, float *v2);
float VecLength(float *v);
void VecMulf(float *v1, float f);
+void VecNegf(float *v1);
int VecLenCompare(float *v1, float *v2, float limit);
int VecCompare(float *v1, float *v2, float limit);
diff --git a/source/blender/blenlib/intern/arithb.c b/source/blender/blenlib/intern/arithb.c
index a9e1e80a403..0d65e615039 100644
--- a/source/blender/blenlib/intern/arithb.c
+++ b/source/blender/blenlib/intern/arithb.c
@@ -2188,6 +2188,13 @@ void VecMulf(float *v1, float f)
v1[2]*= f;
}
+void VecNegf(float *v1)
+{
+ v1[0] = -v1[0];
+ v1[1] = -v1[1];
+ v1[2] = -v1[2];
+}
+
void VecOrthoBasisf(float *v, float *v1, float *v2)
{
float f = sqrt(v[0]*v[0] + v[1]*v[1]);
@@ -3950,7 +3957,7 @@ int SweepingSphereIntersectsTriangleUV(float p1[3], float p2[3], float radius, f
Normalize(nor);
/* flip normal */
- if(Inpf(nor,vel)>0.0f) VecMulf(nor,-1.0f);
+ if(Inpf(nor,vel)>0.0f) VecNegf(nor);
a=Inpf(p1,nor)-Inpf(v0,nor);
nordotv=Inpf(nor,vel);
@@ -4682,7 +4689,7 @@ void tangent_from_uv(float *uv1, float *uv2, float *uv3, float *co1, float *co2,
/* check flip */
if ((ct[0]*n[0] + ct[1]*n[1] + ct[2]*n[2]) < 0.0f)
- VecMulf(tang, -1.0f);
+ VecNegf(tang);
}
/* used for zoom values*/
diff --git a/source/blender/blenlib/intern/graph.c b/source/blender/blenlib/intern/graph.c
index de9c8860c6a..11bb8ea8964 100644
--- a/source/blender/blenlib/intern/graph.c
+++ b/source/blender/blenlib/intern/graph.c
@@ -807,15 +807,15 @@ static void testAxialSymmetry(BGraph *graph, BNode* root_node, BNode* node1, BNo
if (abs(nor[0]) > abs(nor[1]) && abs(nor[0]) > abs(nor[2]) && nor[0] < 0)
{
- VecMulf(nor, -1);
+ VecNegf(nor);
}
else if (abs(nor[1]) > abs(nor[0]) && abs(nor[1]) > abs(nor[2]) && nor[1] < 0)
{
- VecMulf(nor, -1);
+ VecNegf(nor);
}
else if (abs(nor[2]) > abs(nor[1]) && abs(nor[2]) > abs(nor[0]) && nor[2] < 0)
{
- VecMulf(nor, -1);
+ VecNegf(nor);
}
/* mirror node2 along axis */
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 256ef7cb8aa..3600c64d352 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -3396,6 +3396,7 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
FluidsimModifierData *fluidmd = (FluidsimModifierData*) md;
fluidmd->fss= newdataadr(fd, fluidmd->fss);
+ fluidmd->fss->meshSurfNormals = 0;
}
else if (md->type==eModifierType_Collision) {
@@ -8517,6 +8518,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
fluidmd->fss->lastgoodframe = INT_MAX;
fluidmd->fss->flag = 0;
+ fluidmd->fss->meshSurfNormals = 0;
}
}
}
diff --git a/source/blender/blenpluginapi/iff.h b/source/blender/blenpluginapi/iff.h
index 92cbd7dd093..e7f328d870f 100644
--- a/source/blender/blenpluginapi/iff.h
+++ b/source/blender/blenpluginapi/iff.h
@@ -56,6 +56,10 @@
#endif
#define RADHDR (1<<24)
+#ifdef WITH_OPENJPEG
+#define JP2 (1 << 18)
+#endif
+
#define RAWTGA (TGA | 1)
#define JPG_STD (JPG | (0 << 8))
@@ -113,6 +117,7 @@
#define IS_tim(x) (x->ftype & TIM)
#define IS_tiff(x) (x->ftype & TIFF)
#define IS_openexr(x) (x->ftype & OPENEXR)
+#define IS_jp2(x) (x->ftype & JP2)
#define IMAGIC 0732
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index 2bd91ec9e6a..947b3bad9e7 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -163,6 +163,9 @@ void draw_markers_time(const bContext *C, int flag)
View2D *v2d= UI_view2d_fromcontext(C);
TimeMarker *marker;
+ if(markers == NULL)
+ return;
+
/* unselected markers are drawn at the first time */
for (marker= markers->first; marker; marker= marker->next) {
if (!(marker->flag & SELECT)) draw_marker(v2d, marker, CTX_data_scene(C)->r.cfra, flag);
@@ -185,6 +188,9 @@ static int ed_marker_add(bContext *C, wmOperator *op)
TimeMarker *marker;
int frame= CTX_data_scene(C)->r.cfra;
+ if(markers == NULL)
+ return OPERATOR_CANCELLED;
+
/* two markers can't be at the same place */
for(marker= markers->first; marker; marker= marker->next)
if(marker->frame == frame)
@@ -260,6 +266,8 @@ static int ed_marker_move_init(bContext *C, wmOperator *op)
TimeMarker *marker;
int totmark=0;
int a;
+
+ if(markers == NULL) return 0;
for (marker= markers->first; marker; marker= marker->next)
if (marker->flag & SELECT) totmark++;
@@ -496,6 +504,8 @@ static void ed_marker_duplicate_apply(bContext *C, wmOperator *op)
ListBase *markers= context_get_markers(C);
TimeMarker *marker, *newmarker;
+ if(markers == NULL) return;
+
/* go through the list of markers, duplicate selected markers and add duplicated copies
* to the begining of the list (unselect original markers) */
for(marker= markers->first; marker; marker= marker->next) {
@@ -591,6 +601,9 @@ static int ed_marker_select(bContext *C, wmEvent *evt, int extend)
float viewx;
int x, y, cfra;
+ if(markers == NULL)
+ return OPERATOR_PASS_THROUGH;
+
x= evt->x - CTX_wm_region(C)->winrct.xmin;
y= evt->y - CTX_wm_region(C)->winrct.ymin;
@@ -681,6 +694,9 @@ static int ed_marker_border_select_exec(bContext *C, wmOperator *op)
if(yminf > 30.0f || ymaxf < 0.0f)
return 0;
+ if(markers == NULL)
+ return 0;
+
/* XXX marker context */
for(marker= markers->first; marker; marker= marker->next) {
if ((marker->frame > xminf) && (marker->frame <= xmaxf)) {
@@ -730,6 +746,9 @@ static int ed_marker_select_all_exec(bContext *C, wmOperator *op)
ListBase *markers= context_get_markers(C);
TimeMarker *marker;
int select= RNA_int_get(op->ptr, "select_type");
+
+ if(markers == NULL)
+ return OPERATOR_CANCELLED;
if(RNA_boolean_get(op->ptr, "select_swap")) {
for(marker= markers->first; marker; marker= marker->next) {
@@ -786,6 +805,9 @@ static int ed_marker_delete_exec(bContext *C, wmOperator *op)
TimeMarker *marker, *nmarker;
short changed= 0;
+ if(markers == NULL)
+ return OPERATOR_CANCELLED;
+
for(marker= markers->first; marker; marker= nmarker) {
nmarker= marker->next;
if(marker->flag & SELECT) {
diff --git a/source/blender/editors/space_file/SConscript b/source/blender/editors/space_file/SConscript
index dab30676171..8302d6eecef 100644
--- a/source/blender/editors/space_file/SConscript
+++ b/source/blender/editors/space_file/SConscript
@@ -8,4 +8,9 @@ incs += ' ../../blenloader #intern/bmfont ../../makesrna'
incs += ' ../../render/extern/include '
incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include'
-env.BlenderLib ( 'bf_editors_space_file', sources, Split(incs), [], libtype=['core'], priority=[115] )
+defs = []
+
+if env['WITH_BF_OPENJPEG']:
+ defs.append('WITH_OPENJPEG')
+
+env.BlenderLib ( 'bf_editors_space_file', sources, Split(incs), defs, libtype=['core'], priority=[115] )
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index e3551510df1..384fb2141c3 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -769,6 +769,9 @@ void filelist_setfiletypes(struct FileList* filelist, short has_quicktime)
if( BLI_testextensie(file->relname, ".int")
|| BLI_testextensie(file->relname, ".inta")
|| BLI_testextensie(file->relname, ".jpg")
+#ifdef WITH_OPENJPEG
+ || BLI_testextensie(file->relname, ".jp2")
+#endif
|| BLI_testextensie(file->relname, ".jpeg")
|| BLI_testextensie(file->relname, ".tga")
|| BLI_testextensie(file->relname, ".rgb")
@@ -812,6 +815,10 @@ void filelist_setfiletypes(struct FileList* filelist, short has_quicktime)
if(BLI_testextensie(file->relname, ".int")
|| BLI_testextensie(file->relname, ".inta")
|| BLI_testextensie(file->relname, ".jpg")
+ || BLI_testextensie(file->relname, ".jpeg")
+#ifdef WITH_OPENJPEG
+ || BLI_testextensie(file->relname, ".jp2")
+#endif
|| BLI_testextensie(file->relname, ".tga")
|| BLI_testextensie(file->relname, ".rgb")
|| BLI_testextensie(file->relname, ".rgba")
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index c10cadb2332..a96cd5a817c 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -1080,7 +1080,8 @@ void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d)
int m;
#endif
- if(G.f & G_VERTEXPAINT || G.f & G_WEIGHTPAINT || G.f & G_TEXTUREPAINT);
+ if(G.f & G_VERTEXPAINT || G.f & G_WEIGHTPAINT);
+ else if((G.f & G_TEXTUREPAINT) && scene->toolsettings && (scene->toolsettings->imapaint.flag & IMAGEPAINT_PROJECT_DISABLE)==0);
else if(scene->obedit && v3d->drawtype>OB_WIRE && (v3d->flag & V3D_ZBUF_SELECT));
else {
v3d->flag &= ~V3D_NEEDBACKBUFDRAW;
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index 023b97058d3..7663f3418fb 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -1212,10 +1212,22 @@ int snapObjects(TransInfo *t, int *dist, float *loc, float *no, int mode) {
Object *ob = dupli_ob->ob;
if (ob->type == OB_MESH) {
- DerivedMesh *dm = mesh_get_derived_final(t->scene, ob, CD_MASK_BAREMESH);
+ DerivedMesh *dm;
+ EditMesh *em;
int val;
-
- val = snapDerivedMesh(t, ob, dm, NULL, dupli_ob->mat, ray_start, ray_normal, t->mval, loc, no, dist, &depth);
+
+ if(ob == t->obedit)
+ {
+ em = ((Mesh *)ob->data)->edit_mesh;
+ dm = editmesh_get_derived_cage(t->scene, t->obedit, em, CD_MASK_BAREMESH);
+ }
+ else
+ {
+ em = NULL;
+ dm = mesh_get_derived_final(t->scene, ob, CD_MASK_BAREMESH);
+ }
+
+ val = snapDerivedMesh(t, ob, dm, em, dupli_ob->mat, ray_start, ray_normal, t->mval, loc, no, dist, &depth);
retval = retval || val;
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c
index 46df003cbbc..87703bc73bf 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -306,7 +306,7 @@ void GPU_material_bind_uniforms(GPUMaterial *material, float obmat[][4], float v
if(material->dynproperty & DYN_LAMP_VEC) {
VECCOPY(lamp->dynvec, lamp->vec);
Normalize(lamp->dynvec);
- VecMulf(lamp->dynvec, -1.0f);
+ VecNegf(lamp->dynvec);
Mat4Mul3Vecfl(viewmat, lamp->dynvec);
}
diff --git a/source/blender/imbuf/IMB_imbuf_types.h b/source/blender/imbuf/IMB_imbuf_types.h
index 73ef83393b0..eadd7affe6a 100644
--- a/source/blender/imbuf/IMB_imbuf_types.h
+++ b/source/blender/imbuf/IMB_imbuf_types.h
@@ -181,6 +181,15 @@ typedef enum {
#define DDS (1 << 19)
#endif
+#ifdef WITH_OPENJPEG
+#define JP2 (1 << 18)
+#define JP2_12BIT (1 << 17)
+#define JP2_16BIT (1 << 16)
+#define JP2_YCC (1 << 15)
+#define JP2_CINE (1 << 14)
+#define JP2_CINE_48FPS (1 << 13)
+#endif
+
#define RAWTGA (TGA | 1)
#define JPG_STD (JPG | (0 << 8))
@@ -217,6 +226,7 @@ typedef enum {
#define IS_tga(x) (x->ftype & TGA)
#define IS_png(x) (x->ftype & PNG)
#define IS_openexr(x) (x->ftype & OPENEXR)
+#define IS_jp2(x) (x->ftype & JP2)
#define IS_cineon(x) (x->ftype & CINEON)
#define IS_dpx(x) (x->ftype & DPX)
#define IS_bmp(x) (x->ftype & BMP)
diff --git a/source/blender/imbuf/intern/IMB_jp2.h b/source/blender/imbuf/intern/IMB_jp2.h
new file mode 100644
index 00000000000..fcdd4589fca
--- /dev/null
+++ b/source/blender/imbuf/intern/IMB_jp2.h
@@ -0,0 +1,49 @@
+/*
+ * IMB_jp2.h
+ *
+ * $Id: IMB_bmp.h 14444 2008-04-16 22:40:48Z hos $
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+/**
+ * \file IMB_jp2.h
+ * \ingroup imbuf
+ * \brief Function declarations for jp2.c
+ */
+
+#ifndef IMB_JP2_H
+#define IMB_JP2_H
+
+#ifdef WITH_OPENJPEG
+struct ImBuf;
+
+int imb_is_a_jp2(void *buf);
+struct ImBuf *imb_jp2_decode(unsigned char *mem, int size, int flags);
+short imb_savejp2(struct ImBuf *ibuf, char *name, int flags);
+#endif /* WITH_OPENJPEG */
+
+#endif
+
diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c
new file mode 100644
index 00000000000..6217cd6bea2
--- /dev/null
+++ b/source/blender/imbuf/intern/jp2.c
@@ -0,0 +1,736 @@
+/**
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Contributor(s): Campbell Barton
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifdef WITH_OPENJPEG
+
+#include "BLI_blenlib.h"
+
+#include "imbuf.h"
+#include "imbuf_patch.h"
+
+#include "IMB_imbuf_types.h"
+#include "IMB_imbuf.h"
+#include "IMB_allocimbuf.h"
+#include "IMB_jp2.h"
+
+#include "openjpeg.h"
+
+#define JP2_FILEHEADER_SIZE 14
+
+static char JP2_HEAD[]= {0x0, 0x0, 0x0, 0x0C, 0x6A, 0x50, 0x20, 0x20, 0x0D, 0x0A, 0x87, 0x0A};
+
+/* We only need this because of how the presets are set */
+typedef struct img_folder{
+ /** The directory path of the folder containing input images*/
+ char *imgdirpath;
+ /** Output format*/
+ char *out_format;
+ /** Enable option*/
+ char set_imgdir;
+ /** Enable Cod Format for output*/
+ char set_out_format;
+ /** User specified rate stored in case of cinema option*/
+ float *rates;
+}img_fol_t;
+
+static int checkj2p(unsigned char *mem) /* J2K_CFMT */
+{
+ return memcmp(JP2_HEAD, mem, 12) ? 0 : 1;
+}
+
+int imb_is_a_jp2(void *buf)
+{
+ return checkj2p(buf);
+}
+
+
+/**
+sample error callback expecting a FILE* client object
+*/
+void error_callback(const char *msg, void *client_data) {
+ FILE *stream = (FILE*)client_data;
+ fprintf(stream, "[ERROR] %s", msg);
+}
+/**
+sample warning callback expecting a FILE* client object
+*/
+void warning_callback(const char *msg, void *client_data) {
+ FILE *stream = (FILE*)client_data;
+ fprintf(stream, "[WARNING] %s", msg);
+}
+/**
+sample debug callback expecting no client object
+*/
+void info_callback(const char *msg, void *client_data) {
+ (void)client_data;
+ fprintf(stdout, "[INFO] %s", msg);
+}
+
+
+
+struct ImBuf *imb_jp2_decode(unsigned char *mem, int size, int flags)
+{
+ struct ImBuf *ibuf = 0;
+ int use_float = 0; /* for precissions higher then 8 use float */
+ unsigned char *rect= NULL;
+ float *rect_float= NULL;
+
+ long signed_offsets[4] = {0,0,0,0};
+ int float_divs[4];
+
+ int index;
+
+ int w, h, depth;
+
+ opj_dparameters_t parameters; /* decompression parameters */
+
+ opj_event_mgr_t event_mgr; /* event manager */
+ opj_image_t *image = NULL;
+
+ int i;
+
+ opj_dinfo_t* dinfo = NULL; /* handle to a decompressor */
+ opj_cio_t *cio = NULL;
+
+ if (checkj2p(mem) == 0) return(0);
+
+ /* configure the event callbacks (not required) */
+ memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
+ event_mgr.error_handler = error_callback;
+ event_mgr.warning_handler = warning_callback;
+ event_mgr.info_handler = info_callback;
+
+
+ /* set decoding parameters to default values */
+ opj_set_default_decoder_parameters(&parameters);
+
+
+ /* JPEG 2000 compressed image data */
+
+ /* get a decoder handle */
+ dinfo = opj_create_decompress(CODEC_JP2);
+
+ /* catch events using our callbacks and give a local context */
+ opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
+
+ /* setup the decoder decoding parameters using the current image and user parameters */
+ opj_setup_decoder(dinfo, &parameters);
+
+ /* open a byte stream */
+ cio = opj_cio_open((opj_common_ptr)dinfo, mem, size);
+
+ /* decode the stream and fill the image structure */
+ image = opj_decode(dinfo, cio);
+
+ if(!image) {
+ fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
+ opj_destroy_decompress(dinfo);
+ opj_cio_close(cio);
+ return NULL;
+ }
+
+ /* close the byte stream */
+ opj_cio_close(cio);
+
+
+ if((image->numcomps * image->x1 * image->y1) == 0)
+ {
+ fprintf(stderr,"\nError: invalid raw image parameters\n");
+ return NULL;
+ }
+
+ w = image->comps[0].w;
+ h = image->comps[0].h;
+
+ switch (image->numcomps) {
+ case 1: /* Greyscale */
+ case 3: /* Color */
+ depth= 24;
+ break;
+ default: /* 2 or 4 - Greyscale or Color + alpha */
+ depth= 32; /* greyscale + alpha */
+ break;
+ }
+
+
+ i = image->numcomps;
+ if (i>4) i= 4;
+
+ while (i) {
+ i--;
+
+ if (image->comps[i].prec > 8)
+ use_float = 1;
+
+ if (image->comps[i].sgnd)
+ signed_offsets[i]= 1 << (image->comps[i].prec - 1);
+
+ /* only needed for float images but dosnt hurt to calc this */
+ float_divs[i]= (1<<image->comps[i].prec)-1;
+ }
+
+ if (use_float) {
+ ibuf= IMB_allocImBuf(w, h, depth, IB_rectfloat, 0);
+ rect_float = ibuf->rect_float;
+ } else {
+ ibuf= IMB_allocImBuf(w, h, depth, IB_rect, 0);
+ rect = (unsigned char *) ibuf->rect;
+ }
+
+ if (ibuf==NULL) {
+ if(dinfo)
+ opj_destroy_decompress(dinfo);
+ return NULL;
+ }
+
+ ibuf->ftype = JP2;
+
+ if (use_float) {
+ rect_float = ibuf->rect_float;
+
+ if (image->numcomps < 3) {
+ /* greyscale 12bits+ */
+ for (i = 0; i < w * h; i++, rect_float+=4) {
+ index = w * h - ((i) / (w) + 1) * w + (i) % (w);
+
+ rect_float[0]= rect_float[1]= rect_float[2]= (float)(image->comps[0].data[index] + signed_offsets[0]) / float_divs[0];
+
+ if (image->numcomps == 2)
+ rect_float[3]= (image->comps[1].data[index] + signed_offsets[1]) / float_divs[1];
+ else
+ rect_float[3]= 1.0f;
+ }
+ } else {
+ /* rgb or rgba 12bits+ */
+ for (i = 0; i < w * h; i++, rect_float+=4) {
+ index = w * h - ((i) / (w) + 1) * w + (i) % (w);
+
+ rect_float[0]= (float)(image->comps[0].data[index] + signed_offsets[0]) / float_divs[0];
+ rect_float[1]= (float)(image->comps[1].data[index] + signed_offsets[1]) / float_divs[1];
+ rect_float[2]= (float)(image->comps[2].data[index] + signed_offsets[2]) / float_divs[2];
+
+ if (image->numcomps >= 4)
+ rect_float[3]= (float)(image->comps[2].data[index] + signed_offsets[3]) / float_divs[3];
+ else
+ rect_float[3]= 1.0f;
+ }
+ }
+
+ } else {
+
+ if (image->numcomps < 3) {
+ /* greyscale */
+ for (i = 0; i < w * h; i++, rect+=4) {
+ index = w * h - ((i) / (w) + 1) * w + (i) % (w);
+
+ rect_float[0]= rect_float[1]= rect_float[2]= (image->comps[0].data[index] + signed_offsets[0]);
+
+ if (image->numcomps == 2)
+ rect[3]= image->comps[1].data[index] + signed_offsets[1];
+ else
+ rect[3]= 255;
+ }
+ } else {
+ /* 8bit rgb or rgba */
+ for (i = 0; i < w * h; i++, rect+=4) {
+ int index = w * h - ((i) / (w) + 1) * w + (i) % (w);
+
+ rect[0]= image->comps[0].data[index] + signed_offsets[0];
+ rect[1]= image->comps[1].data[index] + signed_offsets[1];
+ rect[2]= image->comps[2].data[index] + signed_offsets[2];
+
+ if (image->numcomps >= 4)
+ rect[3]= image->comps[2].data[index] + signed_offsets[3];
+ else
+ rect[3]= 255;
+ }
+ }
+ }
+
+ /* free remaining structures */
+ if(dinfo) {
+ opj_destroy_decompress(dinfo);
+ }
+
+ /* free image data structure */
+ opj_image_destroy(image);
+
+ if (flags & IB_rect) {
+ IMB_rect_from_float(ibuf);
+ }
+
+ return(ibuf);
+}
+
+//static opj_image_t* rawtoimage(const char *filename, opj_cparameters_t *parameters, raw_cparameters_t *raw_cp) {
+/* prec can be 8, 12, 16 */
+
+#define UPSAMPLE_8_TO_12(_val) ((_val<<4) | (_val & ((1<<4)-1)))
+#define UPSAMPLE_8_TO_16(_val) ((_val<<8)+_val)
+
+#define DOWNSAMPLE_FLOAT_TO_8BIT(_val) (_val)<=0.0f?0: ((_val)>=1.0f?255: (int)(255.0f*(_val)))
+#define DOWNSAMPLE_FLOAT_TO_12BIT(_val) (_val)<=0.0f?0: ((_val)>=1.0f?4095: (int)(4095.0f*(_val)))
+#define DOWNSAMPLE_FLOAT_TO_16BIT(_val) (_val)<=0.0f?0: ((_val)>=1.0f?65535: (int)(65535.0f*(_val)))
+
+
+/*
+2048x1080 (2K) at 24 fps or 48 fps, or 4096x2160 (4K) at 24 fps; 3×12 bits per pixel, XYZ color space
+
+ * In 2K, for Scope (2.39:1) presentation 2048x858 pixels of the imager is used
+ * In 2K, for Flat (1.85:1) presentation 1998x1080 pixels of the imager is used
+*/
+
+/* ****************************** COPIED FROM image_to_j2k.c */
+
+/* ----------------------------------------------------------------------- */
+#define CINEMA_24_CS 1302083 /*Codestream length for 24fps*/
+#define CINEMA_48_CS 651041 /*Codestream length for 48fps*/
+#define COMP_24_CS 1041666 /*Maximum size per color component for 2K & 4K @ 24fps*/
+#define COMP_48_CS 520833 /*Maximum size per color component for 2K @ 48fps*/
+
+
+static int initialise_4K_poc(opj_poc_t *POC, int numres){
+ POC[0].tile = 1;
+ POC[0].resno0 = 0;
+ POC[0].compno0 = 0;
+ POC[0].layno1 = 1;
+ POC[0].resno1 = numres-1;
+ POC[0].compno1 = 3;
+ POC[0].prg1 = CPRL;
+ POC[1].tile = 1;
+ POC[1].resno0 = numres-1;
+ POC[1].compno0 = 0;
+ POC[1].layno1 = 1;
+ POC[1].resno1 = numres;
+ POC[1].compno1 = 3;
+ POC[1].prg1 = CPRL;
+ return 2;
+}
+
+void cinema_parameters(opj_cparameters_t *parameters){
+ parameters->tile_size_on = false;
+ parameters->cp_tdx=1;
+ parameters->cp_tdy=1;
+
+ /*Tile part*/
+ parameters->tp_flag = 'C';
+ parameters->tp_on = 1;
+
+ /*Tile and Image shall be at (0,0)*/
+ parameters->cp_tx0 = 0;
+ parameters->cp_ty0 = 0;
+ parameters->image_offset_x0 = 0;
+ parameters->image_offset_y0 = 0;
+
+ /*Codeblock size= 32*32*/
+ parameters->cblockw_init = 32;
+ parameters->cblockh_init = 32;
+ parameters->csty |= 0x01;
+
+ /*The progression order shall be CPRL*/
+ parameters->prog_order = CPRL;
+
+ /* No ROI */
+ parameters->roi_compno = -1;
+
+ parameters->subsampling_dx = 1; parameters->subsampling_dy = 1;
+
+ /* 9-7 transform */
+ parameters->irreversible = 1;
+
+}
+
+void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *image, img_fol_t *img_fol){
+ int i;
+ float temp_rate;
+
+ switch (parameters->cp_cinema){
+ case CINEMA2K_24:
+ case CINEMA2K_48:
+ if(parameters->numresolution > 6){
+ parameters->numresolution = 6;
+ }
+ if (!((image->comps[0].w == 2048) || (image->comps[0].h == 1080))){
+ fprintf(stdout,"Image coordinates %d x %d is not 2K compliant.\nJPEG Digital Cinema Profile-3 "
+ "(2K profile) compliance requires that at least one of coordinates match 2048 x 1080\n",
+ image->comps[0].w,image->comps[0].h);
+ parameters->cp_rsiz = STD_RSIZ;
+ }
+ break;
+
+ case CINEMA4K_24:
+ if(parameters->numresolution < 1){
+ parameters->numresolution = 1;
+ }else if(parameters->numresolution > 7){
+ parameters->numresolution = 7;
+ }
+ if (!((image->comps[0].w == 4096) || (image->comps[0].h == 2160))){
+ fprintf(stdout,"Image coordinates %d x %d is not 4K compliant.\nJPEG Digital Cinema Profile-4"
+ "(4K profile) compliance requires that at least one of coordinates match 4096 x 2160\n",
+ image->comps[0].w,image->comps[0].h);
+ parameters->cp_rsiz = STD_RSIZ;
+ }
+ parameters->numpocs = initialise_4K_poc(parameters->POC,parameters->numresolution);
+ break;
+ case OFF:
+ /* do nothing */
+ break;
+ }
+
+ switch (parameters->cp_cinema){
+ case CINEMA2K_24:
+ case CINEMA4K_24:
+ for(i=0 ; i<parameters->tcp_numlayers ; i++){
+ temp_rate = 0 ;
+ if (img_fol->rates[i]== 0){
+ parameters->tcp_rates[0]= ((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
+ (CINEMA_24_CS * 8 * image->comps[0].dx * image->comps[0].dy);
+ }else{
+ temp_rate =((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
+ (img_fol->rates[i] * 8 * image->comps[0].dx * image->comps[0].dy);
+ if (temp_rate > CINEMA_24_CS ){
+ parameters->tcp_rates[i]= ((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
+ (CINEMA_24_CS * 8 * image->comps[0].dx * image->comps[0].dy);
+ }else{
+ parameters->tcp_rates[i]= img_fol->rates[i];
+ }
+ }
+ }
+ parameters->max_comp_size = COMP_24_CS;
+ break;
+
+ case CINEMA2K_48:
+ for(i=0 ; i<parameters->tcp_numlayers ; i++){
+ temp_rate = 0 ;
+ if (img_fol->rates[i]== 0){
+ parameters->tcp_rates[0]= ((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
+ (CINEMA_48_CS * 8 * image->comps[0].dx * image->comps[0].dy);
+ }else{
+ temp_rate =((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
+ (img_fol->rates[i] * 8 * image->comps[0].dx * image->comps[0].dy);
+ if (temp_rate > CINEMA_48_CS ){
+ parameters->tcp_rates[0]= ((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
+ (CINEMA_48_CS * 8 * image->comps[0].dx * image->comps[0].dy);
+ }else{
+ parameters->tcp_rates[i]= img_fol->rates[i];
+ }
+ }
+ }
+ parameters->max_comp_size = COMP_48_CS;
+ break;
+ case OFF:
+ /* do nothing */
+ break;
+ }
+ parameters->cp_disto_alloc = 1;
+}
+
+
+static opj_image_t* ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters) {
+
+ unsigned char *rect;
+ float *rect_float;
+
+ int subsampling_dx = parameters->subsampling_dx;
+ int subsampling_dy = parameters->subsampling_dy;
+
+
+ int i, numcomps, w, h, prec;
+ int x,y, y_row;
+ OPJ_COLOR_SPACE color_space;
+ opj_image_cmptparm_t cmptparm[4]; /* maximum of 4 components */
+ opj_image_t * image = NULL;
+
+ img_fol_t img_fol; /* only needed for cinema presets */
+ memset(&img_fol,0,sizeof(img_fol_t));
+
+ if (ibuf->ftype & JP2_CINE) {
+
+ if (ibuf->x==4096 || ibuf->y==2160)
+ parameters->cp_cinema= CINEMA4K_24;
+ else {
+ if (ibuf->ftype & JP2_CINE_48FPS) {
+ parameters->cp_cinema= CINEMA2K_48;
+ }
+ else {
+ parameters->cp_cinema= CINEMA2K_24;
+ }
+ }
+ if (parameters->cp_cinema){
+ img_fol.rates = (float*)MEM_mallocN(parameters->tcp_numlayers * sizeof(float), "jp2_rates");
+ for(i=0; i< parameters->tcp_numlayers; i++){
+ img_fol.rates[i] = parameters->tcp_rates[i];
+ }
+ cinema_parameters(parameters);
+ }
+
+ color_space= CLRSPC_SYCC;
+ prec= 12;
+ numcomps= 3;
+ }
+ else {
+ /* Get settings from the imbuf */
+ color_space = (ibuf->ftype & JP2_YCC) ? CLRSPC_SYCC : CLRSPC_SRGB;
+
+ if (ibuf->ftype & JP2_16BIT) prec= 16;
+ else if (ibuf->ftype & JP2_12BIT) prec= 12;
+ else prec= 8;
+
+ /* 32bit images == alpha channel */
+ /* grayscale not supported yet */
+ numcomps= (ibuf->depth==32) ? 4 : 3;
+ }
+
+ w= ibuf->x;
+ h= ibuf->y;
+
+
+ /* initialize image components */
+ memset(&cmptparm[0], 0, 4 * sizeof(opj_image_cmptparm_t));
+ for(i = 0; i < numcomps; i++) {
+ cmptparm[i].prec = prec;
+ cmptparm[i].bpp = prec;
+ cmptparm[i].sgnd = 0;
+ cmptparm[i].dx = subsampling_dx;
+ cmptparm[i].dy = subsampling_dy;
+ cmptparm[i].w = w;
+ cmptparm[i].h = h;
+ }
+ /* create the image */
+ image = opj_image_create(numcomps, &cmptparm[0], color_space);
+ if(!image) {
+ printf("Error: opj_image_create() failed\n");
+ return NULL;
+ }
+
+ /* set image offset and reference grid */
+ image->x0 = parameters->image_offset_x0;
+ image->y0 = parameters->image_offset_y0;
+ image->x1 = parameters->image_offset_x0 + (w - 1) * subsampling_dx + 1;
+ image->y1 = parameters->image_offset_y0 + (h - 1) * subsampling_dy + 1;
+
+ /* set image data */
+ rect = (unsigned char*) ibuf->rect;
+ rect_float= ibuf->rect_float;
+
+ if (rect_float && rect && prec==8) {
+ /* No need to use the floating point buffer, just write the 8 bits from the char buffer */
+ rect_float= NULL;
+ }
+
+
+ if (rect_float) {
+ switch (prec) {
+ case 8: /* Convert blenders float color channels to 8,12 or 16bit ints */
+ for(y=h-1; y>=0; y--) {
+ y_row = y*w;
+ for(x=0; x<w; x++, rect_float+=4) {
+ i = y_row + x;
+
+ image->comps[0].data[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rect_float[0]);
+ image->comps[1].data[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rect_float[1]);
+ image->comps[2].data[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rect_float[2]);
+ if (numcomps>3)
+ image->comps[3].data[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rect_float[3]);
+ }
+ }
+ break;
+
+ case 12:
+ for(y=h-1; y>=0; y--) {
+ y_row = y*w;
+ for(x=0; x<w; x++, rect_float+=4) {
+ i = y_row + x;
+
+ image->comps[0].data[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rect_float[0]);
+ image->comps[1].data[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rect_float[1]);
+ image->comps[2].data[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rect_float[2]);
+ if (numcomps>3)
+ image->comps[3].data[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rect_float[3]);
+ }
+ }
+ break;
+ case 16:
+ for(y=h-1; y>=0; y--) {
+ y_row = y*w;
+ for(x=0; x<w; x++, rect_float+=4) {
+ i = y_row + x;
+
+ image->comps[0].data[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rect_float[0]);
+ image->comps[1].data[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rect_float[1]);
+ image->comps[2].data[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rect_float[2]);
+ if (numcomps>3)
+ image->comps[3].data[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rect_float[3]);
+ }
+ }
+ break;
+ }
+ } else {
+ /* just use rect*/
+ switch (prec) {
+ case 8:
+ for(y=h-1; y>=0; y--) {
+ y_row = y*w;
+ for(x=0; x<w; x++, rect+=4) {
+ i = y_row + x;
+
+ image->comps[0].data[i] = rect[0];
+ image->comps[1].data[i] = rect[1];
+ image->comps[2].data[i] = rect[2];
+ if (numcomps>3)
+ image->comps[3].data[i] = rect[3];
+ }
+ }
+ break;
+
+ case 12: /* Up Sampling, a bit pointless but best write the bit depth requested */
+ for(y=h-1; y>=0; y--) {
+ y_row = y*w;
+ for(x=0; x<w; x++, rect+=4) {
+ i = y_row + x;
+
+ image->comps[0].data[i]= UPSAMPLE_8_TO_12(rect[0]);
+ image->comps[1].data[i]= UPSAMPLE_8_TO_12(rect[1]);
+ image->comps[2].data[i]= UPSAMPLE_8_TO_12(rect[2]);
+ if (numcomps>3)
+ image->comps[3].data[i]= UPSAMPLE_8_TO_12(rect[3]);
+ }
+ }
+ break;
+ case 16:
+ for(y=h-1; y>=0; y--) {
+ y_row = y*w;
+ for(x=0; x<w; x++, rect+=4) {
+ i = y_row + x;
+
+ image->comps[0].data[i]= UPSAMPLE_8_TO_16(rect[0]);
+ image->comps[1].data[i]= UPSAMPLE_8_TO_16(rect[1]);
+ image->comps[2].data[i]= UPSAMPLE_8_TO_16(rect[2]);
+ if (numcomps>3)
+ image->comps[3].data[i]= UPSAMPLE_8_TO_16(rect[3]);
+ }
+ }
+ break;
+ }
+ }
+
+ /* Decide if MCT should be used */
+ parameters->tcp_mct = image->numcomps == 3 ? 1 : 0;
+
+ if(parameters->cp_cinema){
+ cinema_setup_encoder(parameters,image,&img_fol);
+ }
+
+ if (img_fol.rates)
+ MEM_freeN(img_fol.rates);
+
+ return image;
+}
+
+
+/* Found write info at http://users.ece.gatech.edu/~slabaugh/personal/c/bitmapUnix.c */
+short imb_savejp2(struct ImBuf *ibuf, char *name, int flags) {
+
+ int quality = ibuf->ftype & 0xff;
+
+ int bSuccess;
+ opj_cparameters_t parameters; /* compression parameters */
+ opj_event_mgr_t event_mgr; /* event manager */
+ opj_image_t *image = NULL;
+
+ /*
+ configure the event callbacks (not required)
+ setting of each callback is optionnal
+ */
+ memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
+ event_mgr.error_handler = error_callback;
+ event_mgr.warning_handler = warning_callback;
+ event_mgr.info_handler = info_callback;
+
+ /* set encoding parameters to default values */
+ opj_set_default_encoder_parameters(&parameters);
+
+ /* compression ratio */
+ /* invert range, from 10-100, 100-1
+ * where jpeg see's 1 and highest quality (lossless) and 100 is very low quality*/
+ parameters.tcp_rates[0]= ((100-quality)/90.0f*99.0f) + 1;
+
+
+ parameters.tcp_numlayers = 1; // only one resolution
+ parameters.cp_disto_alloc = 1;
+
+ image= ibuftoimage(ibuf, &parameters);
+
+
+ { /* JP2 format output */
+ int codestream_length;
+ opj_cio_t *cio = NULL;
+ FILE *f = NULL;
+
+ /* get a JP2 compressor handle */
+ opj_cinfo_t* cinfo = opj_create_compress(CODEC_JP2);
+
+ /* catch events using our callbacks and give a local context */
+ opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, stderr);
+
+ /* setup the encoder parameters using the current image and using user parameters */
+ opj_setup_encoder(cinfo, &parameters, image);
+
+ /* open a byte stream for writing */
+ /* allocate memory for all tiles */
+ cio = opj_cio_open((opj_common_ptr)cinfo, NULL, 0);
+
+ /* encode the image */
+ bSuccess = opj_encode(cinfo, cio, image, NULL); /* last arg used to be parameters.index but this deprecated */
+
+ if (!bSuccess) {
+ opj_cio_close(cio);
+ fprintf(stderr, "failed to encode image\n");
+ return 0;
+ }
+ codestream_length = cio_tell(cio);
+
+ /* write the buffer to disk */
+ f = fopen(name, "wb");
+
+ if (!f) {
+ fprintf(stderr, "failed to open %s for writing\n", name);
+ return 1;
+ }
+ fwrite(cio->buffer, 1, codestream_length, f);
+ fclose(f);
+ fprintf(stderr,"Generated outfile %s\n",name);
+ /* close and free the byte stream */
+ opj_cio_close(cio);
+
+ /* free remaining compression structures */
+ opj_destroy_compress(cinfo);
+ }
+
+ /* free image data */
+ opj_image_destroy(image);
+
+ return 1;
+}
+
+#endif /* WITH_OPENJPEG */
diff --git a/source/blender/imbuf/intern/openexr/CMakeLists.txt b/source/blender/imbuf/intern/openexr/CMakeLists.txt
index bb1dad087f3..21792086774 100644
--- a/source/blender/imbuf/intern/openexr/CMakeLists.txt
+++ b/source/blender/imbuf/intern/openexr/CMakeLists.txt
@@ -38,5 +38,9 @@ SET(INC
${OPENEXR_INC}
)
+IF(WITH_OPENEXR)
+ ADD_DEFINITIONS(-DWITH_OPENEXR)
+ENDIF(WITH_OPENEXR)
+
BLENDERLIB(bf_openexr "${SRC}" "${INC}")
#env.BlenderLib ('bf_openexr', source_files, incs, defs, libtype=['core','player'], priority = [90, 200])
diff --git a/source/blender/imbuf/intern/readimage.c b/source/blender/imbuf/intern/readimage.c
index 05e7921665b..6df92f69fff 100644
--- a/source/blender/imbuf/intern/readimage.c
+++ b/source/blender/imbuf/intern/readimage.c
@@ -58,6 +58,10 @@
#include "IMB_dpxcineon.h"
#include "BKE_global.h"
+#ifdef WITH_OPENJPEG
+#include "IMB_jp2.h"
+#endif
+
#ifdef WITH_OPENEXR
#include "openexr/openexr_api.h"
#endif
@@ -161,11 +165,16 @@ ImBuf *IMB_ibImageFromMemory(int *mem, int size, int flags) {
if (ibuf) return (ibuf);
#endif
+#ifdef WITH_OPENJPEG
+ ibuf = imb_jp2_decode((uchar *)mem, size, flags);
+ if (ibuf) return (ibuf);
+#endif
+
#ifdef WITH_DDS
ibuf = imb_load_dds((uchar *)mem, size, flags);
if (ibuf) return (ibuf);
#endif
-
+
#ifdef WITH_QUICKTIME
#if defined(_WIN32) || defined (__APPLE__)
if(G.have_quicktime) {
diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c
index c86f9b017bf..15d1d031dbd 100644
--- a/source/blender/imbuf/intern/util.c
+++ b/source/blender/imbuf/intern/util.c
@@ -68,10 +68,14 @@
#include "quicktime_import.h"
#endif
+#ifdef WITH_OPENJPEG
+#include "IMB_jp2.h"
+#endif
+
#ifdef WITH_FFMPEG
#include <ffmpeg/avcodec.h>
#include <ffmpeg/avformat.h>
-//#include <ffmpeg/avdevice.h>
+#include <ffmpeg/avdevice.h>
#include <ffmpeg/log.h>
#if LIBAVFORMAT_VERSION_INT < (49 << 16)
@@ -140,7 +144,11 @@ static int IMB_ispic_name(char *name)
/*
if (imb_is_a_bmp(buf)) return(BMP);
*/
-
+
+#ifdef WITH_OPENJPEG
+ if (imb_is_a_jp2(buf)) return(JP2);
+#endif
+
#ifdef WITH_QUICKTIME
#if defined(_WIN32) || defined(__APPLE__)
if(G.have_quicktime) {
@@ -191,6 +199,9 @@ int IMB_ispic(char *filename)
#ifdef WITH_BF_OPENEXR
|| BLI_testextensie(filename, ".exr")
#endif
+#ifdef WITH_BF_OPENJPEG
+ || BLI_testextensie(filename, ".jp2")
+#endif
|| BLI_testextensie(filename, ".sgi")) {
return IMB_ispic_name(filename);
} else {
@@ -211,6 +222,9 @@ int IMB_ispic(char *filename)
#ifdef WITH_BF_OPENEXR
|| BLI_testextensie(filename, ".exr")
#endif
+#ifdef WITH_BF_OPENJPEG
+ || BLI_testextensie(filename, ".jp2")
+#endif
|| BLI_testextensie(filename, ".iff")
|| BLI_testextensie(filename, ".lbm")
|| BLI_testextensie(filename, ".sgi")) {
@@ -258,7 +272,7 @@ void do_init_ffmpeg()
if (!ffmpeg_init) {
ffmpeg_init = 1;
av_register_all();
- //avdevice_register_all();
+ avdevice_register_all();
if ((G.f & G_DEBUG) == 0)
{
diff --git a/source/blender/imbuf/intern/writeimage.c b/source/blender/imbuf/intern/writeimage.c
index 11cb1ed039a..7e1120bf3e4 100644
--- a/source/blender/imbuf/intern/writeimage.c
+++ b/source/blender/imbuf/intern/writeimage.c
@@ -57,6 +57,9 @@
#include "IMB_bmp.h"
#include "IMB_tiff.h"
#include "IMB_radiance_hdr.h"
+#ifdef WITH_OPENJPEG
+#include "IMB_jp2.h"
+#endif
#ifdef WITH_OPENEXR
#include "openexr/openexr_api.h"
#endif
@@ -131,6 +134,11 @@ short IMB_saveiff(struct ImBuf *ibuf, char *name, int flags)
if (IS_dpx(ibuf)) {
return imb_save_dpx(ibuf, name, flags);
}
+#ifdef WITH_OPENJPEG
+ if (IS_jp2(ibuf)) {
+ return imb_savejp2(ibuf, name, flags);
+ }
+#endif
file = open(name, O_BINARY | O_RDWR | O_CREAT | O_TRUNC, 0666);
if (file < 0) return (FALSE);
diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h
index 1c49489c3c5..37995145ff8 100644
--- a/source/blender/makesdna/DNA_action_types.h
+++ b/source/blender/makesdna/DNA_action_types.h
@@ -102,7 +102,7 @@ typedef struct bPoseChannel {
/* PoseChannel (transform) flags */
-enum {
+typedef enum ePchan_Flag {
POSE_LOC = 0x0001,
POSE_ROT = 0x0002,
POSE_SIZE = 0x0004,
@@ -119,7 +119,7 @@ enum {
} ePchan_Flag;
/* PoseChannel constflag (constraint detection) */
-enum {
+typedef enum ePchan_ConstFlag {
PCHAN_HAS_IK = (1<<0),
PCHAN_HAS_CONST = (1<<1),
/* only used for drawing Posemode, not stored in channel */
@@ -130,7 +130,7 @@ enum {
} ePchan_ConstFlag;
/* PoseChannel->ikflag */
-enum {
+typedef enum ePchan_IkFlag {
BONE_IK_NO_XDOF = (1<<0),
BONE_IK_NO_YDOF = (1<<1),
BONE_IK_NO_ZDOF = (1<<2),
@@ -145,7 +145,7 @@ enum {
} ePchan_IkFlag;
/* PoseChannel->rotmode */
-enum {
+typedef enum ePchan_RotMode {
/* quaternion rotations (default, and for older Blender versions) */
PCHAN_ROT_QUAT = 0,
/* euler rotations (xyz only) */
@@ -177,7 +177,7 @@ typedef struct bPose {
/* Pose->flag */
-enum {
+typedef enum ePose_Flags {
/* results in armature_rebuild_pose being called */
POSE_RECALC = (1<<0),
/* prevents any channel from getting overridden by anim from IPO */
@@ -221,7 +221,7 @@ typedef struct bActionGroup {
} bActionGroup;
/* Action Group flags */
-enum {
+typedef enum eActionGroup_Flag {
AGRP_SELECTED = (1<<0),
AGRP_ACTIVE = (1<<1),
AGRP_PROTECTED = (1<<2),
@@ -259,7 +259,7 @@ typedef struct bAction {
/* Flags for the action */
-enum {
+typedef enum eAction_Flags {
/* flags for displaying in UI */
ACT_EXPANDED = (1<<0),
ACT_SELECTED = (1<<1),
@@ -331,7 +331,7 @@ typedef struct SpaceAction {
} SpaceAction;
/* SpaceAction flag */
-enum {
+typedef enum eSAction_Flag {
/* during transform (only set for TimeSlide) */
SACTION_MOVING = (1<<0),
/* show sliders (if relevant) */
@@ -354,7 +354,7 @@ enum {
/* SpaceAction Mode Settings */
// XXX should this be used by other editors too?
-enum {
+typedef enum eAnimEdit_Context {
/* action (default) */
SACTCONT_ACTION = 0,
/* editing of shapekey's IPO block */
@@ -366,7 +366,7 @@ enum {
} eAnimEdit_Context;
/* SpaceAction AutoSnap Settings (also used by other Animation Editors) */
-enum {
+typedef enum eAnimEdit_AutoSnap {
/* no auto-snap */
SACTSNAP_OFF = 0,
/* snap to 1.0 frame/second intervals */
diff --git a/source/blender/makesdna/DNA_actuator_types.h b/source/blender/makesdna/DNA_actuator_types.h
index 43dada97d0e..48432b8c6e2 100644
--- a/source/blender/makesdna/DNA_actuator_types.h
+++ b/source/blender/makesdna/DNA_actuator_types.h
@@ -82,7 +82,7 @@ typedef struct bEditObjectActuator {
char name[32];
float linVelocity[3]; /* initial lin. velocity on creation */
float angVelocity[3]; /* initial ang. velocity on creation */
- float pad;
+ float mass;
short localflag; /* flag for the lin & ang. vel: apply locally */
short dyn_operation;
} bEditObjectActuator;
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index aeb5fe01533..9194e4d2632 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -312,6 +312,10 @@ typedef struct RenderData {
/* cineon */
short cineonwhite, cineonblack;
float cineongamma;
+
+ /* jpeg2000 */
+ short jp2_preset, jp2_depth;
+ int rpad3;
} RenderData;
/* control render convert and shading engine */
@@ -693,6 +697,7 @@ typedef struct Scene {
#define R_DPX 27
#define R_MULTILAYER 28
#define R_DDS 29
+#define R_JP2 30
/* subimtype, flag options for imtype */
#define R_OPENEXR_HALF 1
@@ -701,6 +706,13 @@ typedef struct Scene {
#define R_CINEON_LOG 8
#define R_TIFF_16BIT 16
+#define R_JPEG2K_12BIT 32 /* Jpeg2000 */
+#define R_JPEG2K_16BIT 64
+#define R_JPEG2K_YCC 128 /* when disabled use RGB */
+#define R_JPEG2K_CINE_PRESET 256
+#define R_JPEG2K_CINE_48FPS 512
+
+
/* bake_mode: same as RE_BAKE_xxx defines */
/* bake_flag: */
#define R_BAKE_CLEAR 1
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt
index 0b2bd9b4bfd..1f76cd0b424 100644
--- a/source/blender/nodes/CMakeLists.txt
+++ b/source/blender/nodes/CMakeLists.txt
@@ -55,11 +55,9 @@ ELSE(WITH_PYTHON)
ADD_DEFINITIONS(-DDISABLE_PYTHON)
ENDIF(WITH_PYTHON)
-ADD_DEFINITIONS(-DWITH_CCGSUBSURF)
-
-BLENDERLIB(bf_nodes "${SRC}" "${INC}")
-
IF(WITH_INTERNATIONAL)
ADD_DEFINITIONS(-DWITH_FREETYPE2)
ENDIF(WITH_INTERNATIONAL)
+BLENDERLIB(bf_nodes "${SRC}" "${INC}")
+
diff --git a/source/blender/nodes/SConscript b/source/blender/nodes/SConscript
index b1ce78c717e..4859bbb550f 100644
--- a/source/blender/nodes/SConscript
+++ b/source/blender/nodes/SConscript
@@ -39,8 +39,6 @@ if env['WITH_BF_QUICKTIME']:
defs += ' WITH_QUICKTIME'
incs += ' ' + env['BF_QUICKTIME_INC']
-defs += ' WITH_CCGSUBSURF '
-
env.BlenderLib ( libname = 'bf_nodes', sources = sources, includes = Split(incs), defines = Split(defs), libtype=['core'], priority = [190] )
env.BlenderLib ( libname = 'bf_cmpnodes', sources = cmpsources, includes = Split(incs), defines = Split(defs), libtype=['core'], priority = [175] )
env.BlenderLib ( libname = 'bf_shdnodes', sources = shdsources, includes = Split(incs), defines = Split(defs), libtype=['core'], priority = [175] )
diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_filter.c b/source/blender/nodes/intern/CMP_nodes/CMP_filter.c
index 46a9d747ac1..6011ac3b58a 100644
--- a/source/blender/nodes/intern/CMP_nodes/CMP_filter.c
+++ b/source/blender/nodes/intern/CMP_nodes/CMP_filter.c
@@ -78,6 +78,7 @@ static void do_filter_edge(CompBuf *out, CompBuf *in, float *filter, float fac)
QUATCOPY(fp, row2+4);
}
else if(pix==CB_VAL) {
+ fp+= pix;
for(x=2; x<rowlen; x++) {
f1= filter[0]*row1[0] + filter[1]*row1[1] + filter[2]*row1[2] + filter[3]*row2[0] + filter[4]*row2[1] + filter[5]*row2[2] + filter[6]*row3[0] + filter[7]*row3[1] + filter[8]*row3[2];
f2= filter[0]*row1[0] + filter[3]*row1[1] + filter[6]*row1[2] + filter[1]*row2[0] + filter[4]*row2[1] + filter[7]*row2[2] + filter[2]*row3[0] + filter[5]*row3[1] + filter[8]*row3[2];
diff --git a/source/blender/radiosity/intern/source/radfactors.c b/source/blender/radiosity/intern/source/radfactors.c
index 1a400ff57a8..b87473dd811 100644
--- a/source/blender/radiosity/intern/source/radfactors.c
+++ b/source/blender/radiosity/intern/source/radfactors.c
@@ -533,10 +533,10 @@ void progressiverad()
if(shoot->first->f & RAD_TWOSIDED) {
VECCOPY(unshot, shoot->unshot);
- VecMulf(shoot->norm, -1.0);
+ VecNegf(shoot->norm);
if(makeformfactors(shoot))
applyformfactors(shoot);
- VecMulf(shoot->norm, -1.0);
+ VecNegf(shoot->norm);
VECCOPY(shoot->unshot, unshot);
}
diff --git a/source/blender/radiosity/intern/source/radrender.c b/source/blender/radiosity/intern/source/radrender.c
index 57726518f76..d33bbc90ee3 100644
--- a/source/blender/radiosity/intern/source/radrender.c
+++ b/source/blender/radiosity/intern/source/radrender.c
@@ -294,10 +294,10 @@ static void progressiverad_rr(Render *re)
/* ...unless it's two sided */
if(shootrf->flag & RAD_TWOSIDED) {
VECCOPY(unshot, shootrf->unshot);
- VecMulf(shootrf->norm, -1.0);
+ VecNegf(shootrf->norm);
makeformfactors_rr(re, shoot, shootrf);
applyformfactors_rr(re, shoot, shootrf);
- VecMulf(shootrf->norm, -1.0);
+ VecNegf(shootrf->norm);
VECCOPY(shootrf->unshot, unshot);
}
diff --git a/source/blender/readblenfile/intern/BLO_readblenfile.c b/source/blender/readblenfile/intern/BLO_readblenfile.c
index a988b269725..40a991ad702 100644
--- a/source/blender/readblenfile/intern/BLO_readblenfile.c
+++ b/source/blender/readblenfile/intern/BLO_readblenfile.c
@@ -68,7 +68,7 @@ char *headerMagic = "BLENDFI";
*/
void BLO_setversionnumber(char array[4], int version)
{
- memset(array, 0, sizeof(array));
+ memset(array, 0, sizeof(char)*4);
array[1] = version / 100;
array[2] = version % 100;
diff --git a/source/blender/render/intern/source/occlusion.c b/source/blender/render/intern/source/occlusion.c
index 5a2a58ca919..174a9db4398 100644
--- a/source/blender/render/intern/source/occlusion.c
+++ b/source/blender/render/intern/source/occlusion.c
@@ -181,8 +181,8 @@ static void occ_shade(ShadeSample *ssamp, ObjectInstanceRen *obi, VlakRen *vlr,
/* not a pretty solution, but fixes common cases */
if(shi->obr->ob && shi->obr->ob->transflag & OB_NEG_SCALE) {
- VecMulf(shi->vn, -1.0f);
- VecMulf(shi->vno, -1.0f);
+ VecNegf(shi->vn);
+ VecNegf(shi->vno);
}
/* init material vars */
@@ -1288,7 +1288,7 @@ static void occ_compute_passes(Render *re, OcclusionTree *tree, int totpass)
for(pass=0; pass<totpass; pass++) {
for(i=0; i<tree->totface; i++) {
occ_face(&tree->face[i], co, n, NULL);
- VecMulf(n, -1.0f);
+ VecNegf(n);
VECADDFAC(co, co, n, 1e-8f);
occ_lookup(tree, 0, &tree->face[i], co, n, &occ[i], NULL);
@@ -1321,7 +1321,7 @@ static void sample_occ_tree(Render *re, OcclusionTree *tree, OccFace *exclude, f
aocolor= WO_AOPLAIN;
VECCOPY(nn, n);
- VecMulf(nn, -1.0f);
+ VecNegf(nn);
occ_lookup(tree, thread, exclude, co, nn, &occ, (aocolor)? bn: NULL);
@@ -1525,7 +1525,7 @@ static void *exec_strandsurface_sample(void *data)
CalcCent3f(co, co1, co2, co3);
CalcNormFloat(co1, co2, co3, n);
}
- VecMulf(n, -1.0f);
+ VecNegf(n);
sample_occ_tree(re, re->occlusiontree, NULL, co, n, othread->thread, 0, col);
VECCOPY(othread->facecol[a], col);
diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c
index 12f904f8f5c..70f03fa8947 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/source/pipeline.c
@@ -2622,17 +2622,19 @@ void RE_BlenderAnim(Render *re, Scene *scene, int sfra, int efra, int tfra)
else
nfra+= tfra;
- if (scene->r.mode & (R_NO_OVERWRITE | R_TOUCH) ) {
- BKE_makepicstring(scene, name, scene->r.pic, scene->r.cfra, scene->r.imtype);
- }
-
- if (scene->r.mode & R_NO_OVERWRITE && BLI_exist(name)) {
- printf("skipping existing frame \"%s\"\n", name);
- continue;
- }
- if (scene->r.mode & R_TOUCH && !BLI_exist(name)) {
- BLI_make_existing_file(name); /* makes the dir if its not there */
- BLI_touch(name);
+ /* Touch/NoOverwrite options are only valid for image's */
+ if(BKE_imtype_is_movie(scene->r.imtype) == 0) {
+ if(scene->r.mode & (R_NO_OVERWRITE | R_TOUCH))
+ BKE_makepicstring(scene, name, scene->r.pic, scene->r.cfra, scene->r.imtype);
+
+ if(scene->r.mode & R_NO_OVERWRITE && BLI_exist(name)) {
+ printf("skipping existing frame \"%s\"\n", name);
+ continue;
+ }
+ if(scene->r.mode & R_TOUCH && !BLI_exist(name)) {
+ BLI_make_existing_file(name); /* makes the dir if its not there */
+ BLI_touch(name);
+ }
}
re->r.cfra= scene->r.cfra; /* weak.... */
@@ -2645,8 +2647,10 @@ void RE_BlenderAnim(Render *re, Scene *scene, int sfra, int efra, int tfra)
if(G.afbreek==1) {
/* remove touched file */
- if (scene->r.mode & R_TOUCH && BLI_exist(name) && BLI_filepathsize(name) == 0) {
- BLI_delete(name, 0, 0);
+ if(BKE_imtype_is_movie(scene->r.imtype) == 0) {
+ if (scene->r.mode & R_TOUCH && BLI_exist(name) && BLI_filepathsize(name) == 0) {
+ BLI_delete(name, 0, 0);
+ }
}
break;
@@ -2711,7 +2715,7 @@ void RE_set_max_threads(int threads)
} else if(threads>=1 && threads<=BLENDER_MAX_THREADS) {
commandline_threads= threads;
} else {
- printf("Error, threads has to be in range 1-%d\n", BLENDER_MAX_THREADS);
+ printf("Error, threads has to be in range 0-%d\n", BLENDER_MAX_THREADS);
}
}
diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c
index ebefbad6e21..deb6f0db743 100644
--- a/source/blender/render/intern/source/rendercore.c
+++ b/source/blender/render/intern/source/rendercore.c
@@ -1505,8 +1505,8 @@ static void shade_sample_sss(ShadeSample *ssamp, Material *mat, ObjectInstanceRe
/* not a pretty solution, but fixes common cases */
if(shi->obr->ob && shi->obr->ob->transflag & OB_NEG_SCALE) {
- VecMulf(shi->vn, -1.0f);
- VecMulf(shi->vno, -1.0f);
+ VecNegf(shi->vn);
+ VecNegf(shi->vno);
}
/* if nodetree, use the material that we are currently preprocessing
diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c
index 476330152ec..1cd8ec110f9 100644
--- a/source/blender/render/intern/source/shadeinput.c
+++ b/source/blender/render/intern/source/shadeinput.c
@@ -354,7 +354,7 @@ void shade_input_set_strand(ShadeInput *shi, StrandRen *strand, StrandPoint *spo
Normalize(shi->vn);
if(INPR(shi->vn, shi->view) < 0.0f)
- VecMulf(shi->vn, -1.0f);
+ VecNegf(shi->vn);
}
VECCOPY(shi->vno, shi->vn);
diff --git a/source/creator/creator.c b/source/creator/creator.c
index 5a70b033f84..0160ac7acb2 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -750,6 +750,9 @@ int main(int argc, char **argv)
else if (!strcmp(argv[a],"FRAMESERVER")) scene->r.imtype = R_FRAMESERVER;
else if (!strcmp(argv[a],"CINEON")) scene->r.imtype = R_CINEON;
else if (!strcmp(argv[a],"DPX")) scene->r.imtype = R_DPX;
+#if WITH_OPENJPEG
+ else if (!strcmp(argv[a],"JP2")) G.scene->r.imtype = R_JP2;
+#endif
else printf("\nError: Format from '-F' not known or not compiled in this release.\n");
}
} else {
@@ -759,10 +762,14 @@ int main(int argc, char **argv)
case 't':
a++;
- if(G.background) {
- RE_set_max_threads(atoi(argv[a]));
+ if (a < argc) {
+ if(G.background) {
+ RE_set_max_threads(atoi(argv[a]));
+ } else {
+ printf("Warning: threads can only be set in background mode\n");
+ }
} else {
- printf("Warning: threads can only be set in background mode\n");
+ printf("\nError: you must specify a number of threads between 0 and 8 '-t '.\n");
}
break;
case 'x': /* extension */
diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
index 7f9165b0cfb..8d443b9b386 100644
--- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
+++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
@@ -82,6 +82,7 @@
/***/
#include "GPU_extensions.h"
+#include "Value.h"
#ifdef __cplusplus
extern "C" {
@@ -141,7 +142,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
do
{
View3D *v3d= (View3D*) area->spacedata.first;
- RegionView3D *rv3d= ar->regiondata;
+ RegionView3D *rv3d= (RegionView3D*) ar->regiondata;
// get some preferences
SYS_SystemHandle syshandle = SYS_GetSystem();
@@ -151,6 +152,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
bool frameRate = (SYS_GetCommandLineInt(syshandle, "show_framerate", 0) != 0);
bool game2ipo = (SYS_GetCommandLineInt(syshandle, "game2ipo", 0) != 0);
bool displaylists = (SYS_GetCommandLineInt(syshandle, "displaylists", 0) != 0);
+ bool nodepwarnings = (SYS_GetCommandLineInt(syshandle, "ignore_deprecation_warnings", 0) != 0);
// create the canvas, rasterizer and rendertools
RAS_ICanvas* canvas = new KX_BlenderCanvas(area);
@@ -207,6 +209,8 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
ketsjiengine->SetUseFixedTime(usefixed);
ketsjiengine->SetTimingDisplay(frameRate, profile, properties);
+ CValue::SetDeprecationWarnings(nodepwarnings);
+
//lock frame and camera enabled - storing global values
int tmp_lay= scene->lay;
@@ -376,7 +380,9 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
initGameKeys();
initPythonConstraintBinding();
initMathutils();
+#ifdef WITH_FFMPEG
initVideoTexture();
+#endif
if (sceneconverter)
{
@@ -669,7 +675,9 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area,
initGameKeys();
initPythonConstraintBinding();
initMathutils();
- initVideoTexture();
+#ifdef WITH_FFMPEG
+ initVideoTexture();
+#endif
if (sceneconverter)
{
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h b/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h
index 7d1861a9448..ba3095d4f38 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h
+++ b/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h
@@ -64,7 +64,6 @@ public:
m_reverseKeyTranslateTable[TIMER0 ] = KX_TIMER0 ;
m_reverseKeyTranslateTable[TIMER1 ] = KX_TIMER1 ;
m_reverseKeyTranslateTable[TIMER2 ] = KX_TIMER2 ;
- m_reverseKeyTranslateTable[TIMER3 ] = KX_TIMER3 ;
// SYSTEM
diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp
index 4d748948c27..273dbd2c3f0 100644
--- a/source/gameengine/Converter/BL_ActionActuator.cpp
+++ b/source/gameengine/Converter/BL_ActionActuator.cpp
@@ -39,11 +39,11 @@
#include "BL_SkinDeformer.h"
#include "KX_GameObject.h"
#include "STR_HashedString.h"
-#include "DNA_action_types.h"
#include "DNA_nla_types.h"
-#include "DNA_actuator_types.h"
#include "BKE_action.h"
+#include "DNA_action_types.h"
#include "DNA_armature_types.h"
+#include "DNA_scene_types.h"
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
@@ -418,67 +418,6 @@ bool BL_ActionActuator::Update(double curtime, bool frame)
/* Python functions */
/* ------------------------------------------------------------------------- */
-/* Integration hooks ------------------------------------------------------- */
-
-PyTypeObject BL_ActionActuator::Type = {
- PyObject_HEAD_INIT(&PyType_Type)
- 0,
- "BL_ActionActuator",
- sizeof(BL_ActionActuator),
- 0,
- PyDestructor,
- 0,
- __getattr,
- __setattr,
- 0, //&MyPyCompare,
- __repr,
- 0, //&cvalue_as_number,
- 0,
- 0,
- 0,
- 0
-};
-
-PyParentObject BL_ActionActuator::Parents[] = {
- &BL_ActionActuator::Type,
- &SCA_IActuator::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
-};
-
-PyMethodDef BL_ActionActuator::Methods[] = {
- {"setAction", (PyCFunction) BL_ActionActuator::sPySetAction, METH_VARARGS, (PY_METHODCHAR)SetAction_doc},
- {"setStart", (PyCFunction) BL_ActionActuator::sPySetStart, METH_VARARGS, (PY_METHODCHAR)SetStart_doc},
- {"setEnd", (PyCFunction) BL_ActionActuator::sPySetEnd, METH_VARARGS, (PY_METHODCHAR)SetEnd_doc},
- {"setBlendin", (PyCFunction) BL_ActionActuator::sPySetBlendin, METH_VARARGS, (PY_METHODCHAR)SetBlendin_doc},
- {"setPriority", (PyCFunction) BL_ActionActuator::sPySetPriority, METH_VARARGS, (PY_METHODCHAR)SetPriority_doc},
- {"setFrame", (PyCFunction) BL_ActionActuator::sPySetFrame, METH_VARARGS, (PY_METHODCHAR)SetFrame_doc},
- {"setProperty", (PyCFunction) BL_ActionActuator::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc},
- {"setFrameProperty", (PyCFunction) BL_ActionActuator::sPySetFrameProperty, METH_VARARGS, (PY_METHODCHAR)SetFrameProperty_doc},
- {"setBlendtime", (PyCFunction) BL_ActionActuator::sPySetBlendtime, METH_VARARGS, (PY_METHODCHAR)SetBlendtime_doc},
-
- {"getAction", (PyCFunction) BL_ActionActuator::sPyGetAction, METH_VARARGS, (PY_METHODCHAR)GetAction_doc},
- {"getStart", (PyCFunction) BL_ActionActuator::sPyGetStart, METH_VARARGS, (PY_METHODCHAR)GetStart_doc},
- {"getEnd", (PyCFunction) BL_ActionActuator::sPyGetEnd, METH_VARARGS, (PY_METHODCHAR)GetEnd_doc},
- {"getBlendin", (PyCFunction) BL_ActionActuator::sPyGetBlendin, METH_VARARGS, (PY_METHODCHAR)GetBlendin_doc},
- {"getPriority", (PyCFunction) BL_ActionActuator::sPyGetPriority, METH_VARARGS, (PY_METHODCHAR)GetPriority_doc},
- {"getFrame", (PyCFunction) BL_ActionActuator::sPyGetFrame, METH_VARARGS, (PY_METHODCHAR)GetFrame_doc},
- {"getProperty", (PyCFunction) BL_ActionActuator::sPyGetProperty, METH_VARARGS, (PY_METHODCHAR)GetProperty_doc},
- {"getFrameProperty", (PyCFunction) BL_ActionActuator::sPyGetFrameProperty, METH_VARARGS, (PY_METHODCHAR)GetFrameProperty_doc},
- {"setChannel", (PyCFunction) BL_ActionActuator::sPySetChannel, METH_VARARGS, (PY_METHODCHAR)SetChannel_doc},
-// {"getChannel", (PyCFunction) BL_ActionActuator::sPyGetChannel, METH_VARARGS},
- {"getType", (PyCFunction) BL_ActionActuator::sPyGetType, METH_VARARGS, (PY_METHODCHAR)GetType_doc},
- {"setType", (PyCFunction) BL_ActionActuator::sPySetType, METH_VARARGS, (PY_METHODCHAR)SetType_doc},
- {"getContinue", (PyCFunction) BL_ActionActuator::sPyGetContinue, METH_NOARGS, 0},
- {"setContinue", (PyCFunction) BL_ActionActuator::sPySetContinue, METH_O, 0},
- {NULL,NULL} //Sentinel
-};
-
-PyObject* BL_ActionActuator::_getattr(const STR_String& attr) {
- _getattr_up(SCA_IActuator);
-}
-
/* setStart */
const char BL_ActionActuator::GetAction_doc[] =
"getAction()\n"
@@ -487,6 +426,8 @@ const char BL_ActionActuator::GetAction_doc[] =
PyObject* BL_ActionActuator::PyGetAction(PyObject* self,
PyObject* args,
PyObject* kwds) {
+ ShowDeprecationWarning("getAction()", "the action property");
+
if (m_action){
return PyString_FromString(m_action->id.name+2);
}
@@ -501,6 +442,8 @@ const char BL_ActionActuator::GetProperty_doc[] =
PyObject* BL_ActionActuator::PyGetProperty(PyObject* self,
PyObject* args,
PyObject* kwds) {
+ ShowDeprecationWarning("getProperty()", "the property property");
+
PyObject *result;
result = Py_BuildValue("s", (const char *)m_propname);
@@ -516,6 +459,8 @@ const char BL_ActionActuator::GetFrameProperty_doc[] =
PyObject* BL_ActionActuator::PyGetFrameProperty(PyObject* self,
PyObject* args,
PyObject* kwds) {
+ ShowDeprecationWarning("getFrameProperty()", "the frameProperty property");
+
PyObject *result;
result = Py_BuildValue("s", (const char *)m_framepropname);
@@ -531,6 +476,8 @@ const char BL_ActionActuator::GetFrame_doc[] =
PyObject* BL_ActionActuator::PyGetFrame(PyObject* self,
PyObject* args,
PyObject* kwds) {
+ ShowDeprecationWarning("getFrame()", "the frame property");
+
PyObject *result;
result = Py_BuildValue("f", m_localtime);
@@ -546,6 +493,8 @@ const char BL_ActionActuator::GetEnd_doc[] =
PyObject* BL_ActionActuator::PyGetEnd(PyObject* self,
PyObject* args,
PyObject* kwds) {
+ ShowDeprecationWarning("getEnd()", "the end property");
+
PyObject *result;
result = Py_BuildValue("f", m_endframe);
@@ -561,6 +510,8 @@ const char BL_ActionActuator::GetStart_doc[] =
PyObject* BL_ActionActuator::PyGetStart(PyObject* self,
PyObject* args,
PyObject* kwds) {
+ ShowDeprecationWarning("getStart()", "the start property");
+
PyObject *result;
result = Py_BuildValue("f", m_startframe);
@@ -577,6 +528,8 @@ const char BL_ActionActuator::GetBlendin_doc[] =
PyObject* BL_ActionActuator::PyGetBlendin(PyObject* self,
PyObject* args,
PyObject* kwds) {
+ ShowDeprecationWarning("getBlendin()", "the blendin property");
+
PyObject *result;
result = Py_BuildValue("f", m_blendin);
@@ -593,6 +546,8 @@ const char BL_ActionActuator::GetPriority_doc[] =
PyObject* BL_ActionActuator::PyGetPriority(PyObject* self,
PyObject* args,
PyObject* kwds) {
+ ShowDeprecationWarning("getPriority()", "the priority property");
+
PyObject *result;
result = Py_BuildValue("i", m_priority);
@@ -613,6 +568,8 @@ const char BL_ActionActuator::SetAction_doc[] =
PyObject* BL_ActionActuator::PySetAction(PyObject* self,
PyObject* args,
PyObject* kwds) {
+ ShowDeprecationWarning("setAction()", "the action property");
+
char *string;
int reset = 1;
@@ -647,6 +604,8 @@ const char BL_ActionActuator::SetStart_doc[] =
PyObject* BL_ActionActuator::PySetStart(PyObject* self,
PyObject* args,
PyObject* kwds) {
+ ShowDeprecationWarning("setStart()", "the start property");
+
float start;
if (PyArg_ParseTuple(args,"f",&start))
@@ -668,6 +627,8 @@ const char BL_ActionActuator::SetEnd_doc[] =
PyObject* BL_ActionActuator::PySetEnd(PyObject* self,
PyObject* args,
PyObject* kwds) {
+ ShowDeprecationWarning("setEnd()", "the end property");
+
float end;
if (PyArg_ParseTuple(args,"f",&end))
@@ -690,6 +651,8 @@ const char BL_ActionActuator::SetBlendin_doc[] =
PyObject* BL_ActionActuator::PySetBlendin(PyObject* self,
PyObject* args,
PyObject* kwds) {
+ ShowDeprecationWarning("setBlendin()", "the blendin property");
+
float blendin;
if (PyArg_ParseTuple(args,"f",&blendin))
@@ -713,6 +676,8 @@ const char BL_ActionActuator::SetBlendtime_doc[] =
PyObject* BL_ActionActuator::PySetBlendtime(PyObject* self,
PyObject* args,
PyObject* kwds) {
+ ShowDeprecationWarning("setBlendtime()", "the blendtime property");
+
float blendframe;
if (PyArg_ParseTuple(args,"f",&blendframe))
@@ -740,6 +705,8 @@ const char BL_ActionActuator::SetPriority_doc[] =
PyObject* BL_ActionActuator::PySetPriority(PyObject* self,
PyObject* args,
PyObject* kwds) {
+ ShowDeprecationWarning("setPriority()", "the priority property");
+
int priority;
if (PyArg_ParseTuple(args,"i",&priority))
@@ -761,6 +728,8 @@ const char BL_ActionActuator::SetFrame_doc[] =
PyObject* BL_ActionActuator::PySetFrame(PyObject* self,
PyObject* args,
PyObject* kwds) {
+ ShowDeprecationWarning("setFrame()", "the frame property");
+
float frame;
if (PyArg_ParseTuple(args,"f",&frame))
@@ -787,6 +756,8 @@ const char BL_ActionActuator::SetProperty_doc[] =
PyObject* BL_ActionActuator::PySetProperty(PyObject* self,
PyObject* args,
PyObject* kwds) {
+ ShowDeprecationWarning("setProperty()", "the property property");
+
char *string;
if (PyArg_ParseTuple(args,"s",&string))
@@ -808,6 +779,8 @@ const char BL_ActionActuator::SetFrameProperty_doc[] =
PyObject* BL_ActionActuator::PySetFrameProperty(PyObject* self,
PyObject* args,
PyObject* kwds) {
+ ShowDeprecationWarning("setFrameProperty()", "the frameProperty property");
+
char *string;
if (PyArg_ParseTuple(args,"s",&string))
@@ -839,16 +812,80 @@ PyObject* BL_ActionActuator::PyGetChannel(PyObject* self,
}
*/
-/* setChannel */
-const char BL_ActionActuator::SetChannel_doc[] =
+/* getType */
+const char BL_ActionActuator::GetType_doc[] =
+"getType()\n"
+"\tReturns the operation mode of the actuator.\n";
+PyObject* BL_ActionActuator::PyGetType(PyObject* self,
+ PyObject* args,
+ PyObject* kwds) {
+ ShowDeprecationWarning("getType()", "the type property");
+
+ return Py_BuildValue("h", m_playtype);
+}
+
+/* setType */
+const char BL_ActionActuator::SetType_doc[] =
+"setType(mode)\n"
+"\t - mode: Play (0), Flipper (2), LoopStop (3), LoopEnd (4) or Property (6)\n"
+"\tSet the operation mode of the actuator.\n";
+PyObject* BL_ActionActuator::PySetType(PyObject* self,
+ PyObject* args,
+ PyObject* kwds) {
+ ShowDeprecationWarning("setType()", "the type property");
+
+ short typeArg;
+
+ if (!PyArg_ParseTuple(args, "h", &typeArg)) {
+ return NULL;
+ }
+
+ switch (typeArg) {
+ case ACT_ACTION_PLAY:
+ case ACT_ACTION_FLIPPER:
+ case ACT_ACTION_LOOP_STOP:
+ case ACT_ACTION_LOOP_END:
+ case ACT_ACTION_FROM_PROP:
+ m_playtype = typeArg;
+ break;
+ default:
+ printf("Invalid type for action actuator: %d\n", typeArg); /* error */
+ }
+ Py_RETURN_NONE;
+}
+
+PyObject* BL_ActionActuator::PyGetContinue(PyObject* self) {
+ ShowDeprecationWarning("getContinue()", "the continue property");
+
+ return PyInt_FromLong((long)(m_end_reset==0));
+}
+
+PyObject* BL_ActionActuator::PySetContinue(PyObject* self, PyObject* value) {
+ ShowDeprecationWarning("setContinue()", "the continue property");
+
+ int param = PyObject_IsTrue( value );
+
+ if( param == -1 ) {
+ PyErr_SetString( PyExc_TypeError, "expected True/False or 0/1" );
+ return NULL;
+ }
+
+ if (param) {
+ m_end_reset = 0;
+ } else {
+ m_end_reset = 1;
+ }
+ Py_RETURN_NONE;
+}
+
+//<-----Deprecated
+
+/* setChannel */
+KX_PYMETHODDEF_DOC(BL_ActionActuator, setChannel,
"setChannel(channel, matrix)\n"
"\t - channel : A string specifying the name of the bone channel.\n"
"\t - matrix : A 4x4 matrix specifying the overriding transformation\n"
-"\t as an offset from the bone's rest position.\n";
-
-PyObject* BL_ActionActuator::PySetChannel(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+"\t as an offset from the bone's rest position.\n")
{
float matrix[4][4];
char *string;
@@ -923,61 +960,123 @@ PyObject* BL_ActionActuator::PySetChannel(PyObject* self,
Py_RETURN_NONE;
}
-/* getType */
-const char BL_ActionActuator::GetType_doc[] =
-"getType()\n"
-"\tReturns the operation mode of the actuator.\n";
-PyObject* BL_ActionActuator::PyGetType(PyObject* self,
- PyObject* args,
- PyObject* kwds) {
- return Py_BuildValue("h", m_playtype);
-}
+/* ------------------------------------------------------------------------- */
+/* Python Integration Hooks */
+/* ------------------------------------------------------------------------- */
-/* setType */
-const char BL_ActionActuator::SetType_doc[] =
-"setType(mode)\n"
-"\t - mode: Play (0), Flipper (2), LoopStop (3), LoopEnd (4) or Property (6)\n"
-"\tSet the operation mode of the actuator.\n";
-PyObject* BL_ActionActuator::PySetType(PyObject* self,
- PyObject* args,
- PyObject* kwds) {
- short typeArg;
-
- if (!PyArg_ParseTuple(args, "h", &typeArg)) {
- return NULL;
- }
+PyTypeObject BL_ActionActuator::Type = {
+ PyObject_HEAD_INIT(&PyType_Type)
+ 0,
+ "BL_ActionActuator",
+ sizeof(BL_ActionActuator),
+ 0,
+ PyDestructor,
+ 0,
+ __getattr,
+ __setattr,
+ 0, //&MyPyCompare,
+ __repr,
+ 0, //&cvalue_as_number,
+ 0,
+ 0,
+ 0,
+ 0
+};
- switch (typeArg) {
- case KX_ACT_ACTION_PLAY:
- case KX_ACT_ACTION_FLIPPER:
- case KX_ACT_ACTION_LOOPSTOP:
- case KX_ACT_ACTION_LOOPEND:
- case KX_ACT_ACTION_PROPERTY:
- m_playtype = typeArg;
- break;
- default:
- printf("Invalid type for action actuator: %d\n", typeArg); /* error */
- }
- Py_RETURN_NONE;
-}
+PyParentObject BL_ActionActuator::Parents[] = {
+ &BL_ActionActuator::Type,
+ &SCA_IActuator::Type,
+ &SCA_ILogicBrick::Type,
+ &CValue::Type,
+ NULL
+};
-PyObject* BL_ActionActuator::PyGetContinue(PyObject* self) {
- return PyInt_FromLong((long)(m_end_reset==0));
+PyMethodDef BL_ActionActuator::Methods[] = {
+ //Deprecated ----->
+ {"setAction", (PyCFunction) BL_ActionActuator::sPySetAction, METH_VARARGS, (PY_METHODCHAR)SetAction_doc},
+ {"setStart", (PyCFunction) BL_ActionActuator::sPySetStart, METH_VARARGS, (PY_METHODCHAR)SetStart_doc},
+ {"setEnd", (PyCFunction) BL_ActionActuator::sPySetEnd, METH_VARARGS, (PY_METHODCHAR)SetEnd_doc},
+ {"setBlendin", (PyCFunction) BL_ActionActuator::sPySetBlendin, METH_VARARGS, (PY_METHODCHAR)SetBlendin_doc},
+ {"setPriority", (PyCFunction) BL_ActionActuator::sPySetPriority, METH_VARARGS, (PY_METHODCHAR)SetPriority_doc},
+ {"setFrame", (PyCFunction) BL_ActionActuator::sPySetFrame, METH_VARARGS, (PY_METHODCHAR)SetFrame_doc},
+ {"setProperty", (PyCFunction) BL_ActionActuator::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc},
+ {"setFrameProperty", (PyCFunction) BL_ActionActuator::sPySetFrameProperty, METH_VARARGS, (PY_METHODCHAR)SetFrameProperty_doc},
+ {"setBlendtime", (PyCFunction) BL_ActionActuator::sPySetBlendtime, METH_VARARGS, (PY_METHODCHAR)SetBlendtime_doc},
+
+ {"getAction", (PyCFunction) BL_ActionActuator::sPyGetAction, METH_VARARGS, (PY_METHODCHAR)GetAction_doc},
+ {"getStart", (PyCFunction) BL_ActionActuator::sPyGetStart, METH_VARARGS, (PY_METHODCHAR)GetStart_doc},
+ {"getEnd", (PyCFunction) BL_ActionActuator::sPyGetEnd, METH_VARARGS, (PY_METHODCHAR)GetEnd_doc},
+ {"getBlendin", (PyCFunction) BL_ActionActuator::sPyGetBlendin, METH_VARARGS, (PY_METHODCHAR)GetBlendin_doc},
+ {"getPriority", (PyCFunction) BL_ActionActuator::sPyGetPriority, METH_VARARGS, (PY_METHODCHAR)GetPriority_doc},
+ {"getFrame", (PyCFunction) BL_ActionActuator::sPyGetFrame, METH_VARARGS, (PY_METHODCHAR)GetFrame_doc},
+ {"getProperty", (PyCFunction) BL_ActionActuator::sPyGetProperty, METH_VARARGS, (PY_METHODCHAR)GetProperty_doc},
+ {"getFrameProperty", (PyCFunction) BL_ActionActuator::sPyGetFrameProperty, METH_VARARGS, (PY_METHODCHAR)GetFrameProperty_doc},
+// {"getChannel", (PyCFunction) BL_ActionActuator::sPyGetChannel, METH_VARARGS},
+ {"getType", (PyCFunction) BL_ActionActuator::sPyGetType, METH_VARARGS, (PY_METHODCHAR)GetType_doc},
+ {"setType", (PyCFunction) BL_ActionActuator::sPySetType, METH_VARARGS, (PY_METHODCHAR)SetType_doc},
+ {"getContinue", (PyCFunction) BL_ActionActuator::sPyGetContinue, METH_NOARGS, 0},
+ {"setContinue", (PyCFunction) BL_ActionActuator::sPySetContinue, METH_O, 0},
+ //<------
+ KX_PYMETHODTABLE(BL_ActionActuator, setChannel),
+ {NULL,NULL} //Sentinel
+};
+
+PyAttributeDef BL_ActionActuator::Attributes[] = {
+ KX_PYATTRIBUTE_FLOAT_RW("start", 0, MAXFRAMEF, BL_ActionActuator, m_startframe),
+ KX_PYATTRIBUTE_FLOAT_RW("end", 0, MAXFRAMEF, BL_ActionActuator, m_endframe),
+ KX_PYATTRIBUTE_FLOAT_RW("blendin", 0, MAXFRAMEF, BL_ActionActuator, m_blendin),
+ KX_PYATTRIBUTE_SHORT_RW("priority", 0, 100, false, BL_ActionActuator, m_priority),
+ KX_PYATTRIBUTE_FLOAT_RW_CHECK("frame", 0, MAXFRAMEF, BL_ActionActuator, m_localtime, CheckFrame),
+ KX_PYATTRIBUTE_STRING_RW("property", 0, 31, false, BL_ActionActuator, m_propname),
+ KX_PYATTRIBUTE_STRING_RW("frameProperty", 0, 31, false, BL_ActionActuator, m_framepropname),
+ KX_PYATTRIBUTE_BOOL_RW("continue", BL_ActionActuator, m_end_reset),
+ KX_PYATTRIBUTE_FLOAT_RW_CHECK("blendTime", 0, MAXFRAMEF, BL_ActionActuator, m_blendframe, CheckBlendTime),
+ KX_PYATTRIBUTE_SHORT_RW_CHECK("type",0,100,false,BL_ActionActuator,m_playtype,CheckType),
+ { NULL } //Sentinel
+};
+
+PyObject* BL_ActionActuator::_getattr(const STR_String& attr) {
+ if (attr == "action")
+ return PyString_FromString(m_action->id.name+2);
+ PyObject* object = _getattr_self(Attributes, this, attr);
+ if (object != NULL)
+ return object;
+ _getattr_up(SCA_IActuator);
}
-PyObject* BL_ActionActuator::PySetContinue(PyObject* self, PyObject* value) {
- int param = PyObject_IsTrue( value );
-
- if( param == -1 ) {
- PyErr_SetString( PyExc_TypeError, "expected True/False or 0/1" );
- return NULL;
- }
+int BL_ActionActuator::_setattr(const STR_String& attr, PyObject* value) {
+ if (attr == "action")
+ {
+ if (!PyString_Check(value))
+ {
+ PyErr_SetString(PyExc_ValueError, "expected a string");
+ return 1;
+ }
- if (param) {
- m_end_reset = 0;
- } else {
- m_end_reset = 1;
+ STR_String val = PyString_AsString(value);
+
+ if (val == "")
+ {
+ m_action = NULL;
+ return 0;
+ }
+
+ bAction *action;
+
+ action = (bAction*)SCA_ILogicBrick::m_sCurrentLogicManager->GetActionByName(val);
+
+
+ if (!action)
+ {
+ PyErr_SetString(PyExc_ValueError, "action not found!");
+ return 1;
+ }
+
+ m_action = action;
+ return 0;
}
- Py_RETURN_NONE;
+ int ret = _setattr_self(Attributes, this, attr, value);
+ if (ret >= 0)
+ return ret;
+ return SCA_IActuator::_setattr(attr, value);
}
-
diff --git a/source/gameengine/Converter/BL_ActionActuator.h b/source/gameengine/Converter/BL_ActionActuator.h
index a67b6d29b74..6e291106553 100644
--- a/source/gameengine/Converter/BL_ActionActuator.h
+++ b/source/gameengine/Converter/BL_ActionActuator.h
@@ -32,6 +32,7 @@
#include "GEN_HashedPtr.h"
#include "SCA_IActuator.h"
+#include "DNA_actuator_types.h"
#include "MT_Point3.h"
class BL_ActionActuator : public SCA_IActuator
@@ -81,6 +82,7 @@ public:
void SetBlendTime (float newtime);
+ //Deprecated ----->
KX_PYMETHOD_DOC(BL_ActionActuator,SetAction);
KX_PYMETHOD_DOC(BL_ActionActuator,SetBlendin);
KX_PYMETHOD_DOC(BL_ActionActuator,SetPriority);
@@ -90,7 +92,6 @@ public:
KX_PYMETHOD_DOC(BL_ActionActuator,SetProperty);
KX_PYMETHOD_DOC(BL_ActionActuator,SetFrameProperty);
KX_PYMETHOD_DOC(BL_ActionActuator,SetBlendtime);
- KX_PYMETHOD_DOC(BL_ActionActuator,SetChannel);
KX_PYMETHOD_DOC(BL_ActionActuator,GetAction);
KX_PYMETHOD_DOC(BL_ActionActuator,GetBlendin);
@@ -105,18 +106,53 @@ public:
KX_PYMETHOD_DOC(BL_ActionActuator,SetType);
KX_PYMETHOD_NOARGS(BL_ActionActuator,GetContinue);
KX_PYMETHOD_O(BL_ActionActuator,SetContinue);
+ //<-----
+
+ KX_PYMETHOD_DOC(BL_ActionActuator,setChannel);
virtual PyObject* _getattr(const STR_String& attr);
+ virtual int _setattr(const STR_String& attr, PyObject* value);
- enum ActionActType
+ /* attribute check */
+ static int CheckFrame(void *self, const PyAttributeDef*)
{
- KX_ACT_ACTION_PLAY = 0,
- KX_ACT_ACTION_FLIPPER = 2,
- KX_ACT_ACTION_LOOPSTOP,
- KX_ACT_ACTION_LOOPEND,
- KX_ACT_ACTION_PROPERTY = 6
- };
+ BL_ActionActuator* act = reinterpret_cast<BL_ActionActuator*>(self);
+
+ if (act->m_localtime < act->m_startframe)
+ act->m_localtime = act->m_startframe;
+ else if (act->m_localtime > act->m_endframe)
+ act->m_localtime = act->m_endframe;
+
+ return 0;
+ }
+
+ static int CheckBlendTime(void *self, const PyAttributeDef*)
+ {
+ BL_ActionActuator* act = reinterpret_cast<BL_ActionActuator*>(self);
+
+ if (act->m_blendframe > act->m_blendin)
+ act->m_blendframe = act->m_blendin;
+
+ return 0;
+ }
+
+ static int CheckType(void *self, const PyAttributeDef*)
+ {
+ BL_ActionActuator* act = reinterpret_cast<BL_ActionActuator*>(self);
+
+ switch (act->m_playtype) {
+ case ACT_ACTION_PLAY:
+ case ACT_ACTION_FLIPPER:
+ case ACT_ACTION_LOOP_STOP:
+ case ACT_ACTION_LOOP_END:
+ case ACT_ACTION_FROM_PROP:
+ return 0;
+ default:
+ PyErr_SetString(PyExc_ValueError, "invalid type supplied");
+ return 1;
+ }
+ }
protected:
void SetStartTime(float curtime);
@@ -141,7 +177,7 @@ protected:
float m_stridelength;
short m_playtype;
short m_priority;
- short m_end_reset;
+ bool m_end_reset;
struct bPose* m_pose;
struct bPose* m_blendpose;
struct bPose* m_userpose;
diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.cpp b/source/gameengine/Converter/BL_ShapeActionActuator.cpp
index 09cc9120e6a..df1aed38ceb 100644
--- a/source/gameengine/Converter/BL_ShapeActionActuator.cpp
+++ b/source/gameengine/Converter/BL_ShapeActionActuator.cpp
@@ -35,13 +35,12 @@
#include "SCA_LogicManager.h"
#include "BL_ShapeActionActuator.h"
-#include "BL_ActionActuator.h"
#include "BL_ShapeDeformer.h"
#include "KX_GameObject.h"
#include "STR_HashedString.h"
-#include "DNA_action_types.h"
#include "DNA_nla_types.h"
-#include "DNA_actuator_types.h"
+#include "DNA_action_types.h"
+#include "DNA_scene_types.h"
#include "BKE_action.h"
#include "DNA_armature_types.h"
#include "MEM_guardedalloc.h"
@@ -471,16 +470,73 @@ PyMethodDef BL_ShapeActionActuator::Methods[] = {
{NULL,NULL} //Sentinel
};
+PyAttributeDef BL_ShapeActionActuator::Attributes[] = {
+ KX_PYATTRIBUTE_FLOAT_RW("start", 0, MAXFRAMEF, BL_ShapeActionActuator, m_startframe),
+ KX_PYATTRIBUTE_FLOAT_RW("end", 0, MAXFRAMEF, BL_ShapeActionActuator, m_endframe),
+ KX_PYATTRIBUTE_FLOAT_RW("blendin", 0, MAXFRAMEF, BL_ShapeActionActuator, m_blendin),
+ KX_PYATTRIBUTE_SHORT_RW("priority", 0, 100, false, BL_ShapeActionActuator, m_priority),
+ KX_PYATTRIBUTE_FLOAT_RW_CHECK("frame", 0, MAXFRAMEF, BL_ShapeActionActuator, m_localtime, CheckFrame),
+ KX_PYATTRIBUTE_STRING_RW("property", 0, 31, false, BL_ShapeActionActuator, m_propname),
+ KX_PYATTRIBUTE_STRING_RW("frameProperty", 0, 31, false, BL_ShapeActionActuator, m_framepropname),
+ KX_PYATTRIBUTE_FLOAT_RW_CHECK("blendTime", 0, MAXFRAMEF, BL_ShapeActionActuator, m_blendframe, CheckBlendTime),
+ KX_PYATTRIBUTE_SHORT_RW_CHECK("type",0,100,false,BL_ShapeActionActuator,m_playtype,CheckType),
+ { NULL } //Sentinel
+};
+
+
PyObject* BL_ShapeActionActuator::_getattr(const STR_String& attr) {
+ if (attr == "action")
+ return PyString_FromString(m_action->id.name+2);
+ PyObject* object = _getattr_self(Attributes, this, attr);
+ if (object != NULL)
+ return object;
_getattr_up(SCA_IActuator);
}
+int BL_ShapeActionActuator::_setattr(const STR_String& attr, PyObject* value) {
+ if (attr == "action")
+ {
+ if (!PyString_Check(value))
+ {
+ PyErr_SetString(PyExc_ValueError, "expected a string");
+ return 1;
+ }
+
+ STR_String val = PyString_AsString(value);
+
+ if (val == "")
+ {
+ m_action = NULL;
+ return 0;
+ }
+
+ bAction *action;
+
+ action = (bAction*)SCA_ILogicBrick::m_sCurrentLogicManager->GetActionByName(val);
+
+
+ if (!action)
+ {
+ PyErr_SetString(PyExc_ValueError, "action not found!");
+ return 1;
+ }
+
+ m_action = action;
+ return 0;
+ }
+ int ret = _setattr_self(Attributes, this, attr, value);
+ if (ret >= 0)
+ return ret;
+ return SCA_IActuator::_setattr(attr, value);
+}
+
/* setStart */
const char BL_ShapeActionActuator::GetAction_doc[] =
"getAction()\n"
"\tReturns a string containing the name of the current action.\n";
PyObject* BL_ShapeActionActuator::PyGetAction(PyObject* self) {
+ ShowDeprecationWarning("getAction()", "the action property");
if (m_action){
return PyString_FromString(m_action->id.name+2);
}
@@ -493,6 +549,7 @@ const char BL_ShapeActionActuator::GetProperty_doc[] =
"\tReturns the name of the property to be used in FromProp mode.\n";
PyObject* BL_ShapeActionActuator::PyGetProperty(PyObject* self) {
+ ShowDeprecationWarning("getProperty()", "the property property");
PyObject *result;
result = Py_BuildValue("s", (const char *)m_propname);
@@ -506,6 +563,7 @@ const char BL_ShapeActionActuator::GetFrame_doc[] =
"\tReturns the current frame number.\n";
PyObject* BL_ShapeActionActuator::PyGetFrame(PyObject* self) {
+ ShowDeprecationWarning("getFrame()", "the frame property");
PyObject *result;
result = Py_BuildValue("f", m_localtime);
@@ -519,6 +577,7 @@ const char BL_ShapeActionActuator::GetEnd_doc[] =
"\tReturns the last frame of the action.\n";
PyObject* BL_ShapeActionActuator::PyGetEnd(PyObject* self) {
+ ShowDeprecationWarning("getEnd()", "the end property");
PyObject *result;
result = Py_BuildValue("f", m_endframe);
@@ -532,6 +591,7 @@ const char BL_ShapeActionActuator::GetStart_doc[] =
"\tReturns the starting frame of the action.\n";
PyObject* BL_ShapeActionActuator::PyGetStart(PyObject* self) {
+ ShowDeprecationWarning("getStart()", "the start property");
PyObject *result;
result = Py_BuildValue("f", m_startframe);
@@ -546,6 +606,7 @@ const char BL_ShapeActionActuator::GetBlendin_doc[] =
"\tgenerated when this actuator is triggered.\n";
PyObject* BL_ShapeActionActuator::PyGetBlendin(PyObject* self) {
+ ShowDeprecationWarning("getBlendin()", "the blendin property");
PyObject *result;
result = Py_BuildValue("f", m_blendin);
@@ -560,6 +621,7 @@ const char BL_ShapeActionActuator::GetPriority_doc[] =
"\tPriority numbers will override actuators with higher numbers.\n";
PyObject* BL_ShapeActionActuator::PyGetPriority(PyObject* self) {
+ ShowDeprecationWarning("getPriority()", "the priority property");
PyObject *result;
result = Py_BuildValue("i", m_priority);
@@ -581,6 +643,7 @@ const char BL_ShapeActionActuator::SetAction_doc[] =
PyObject* BL_ShapeActionActuator::PySetAction(PyObject* self,
PyObject* args,
PyObject* kwds) {
+ ShowDeprecationWarning("setAction()", "the action property");
char *string;
int reset = 1;
@@ -615,6 +678,7 @@ const char BL_ShapeActionActuator::SetStart_doc[] =
PyObject* BL_ShapeActionActuator::PySetStart(PyObject* self,
PyObject* args,
PyObject* kwds) {
+ ShowDeprecationWarning("setStart()", "the start property");
float start;
if (PyArg_ParseTuple(args,"f",&start))
@@ -636,6 +700,7 @@ const char BL_ShapeActionActuator::SetEnd_doc[] =
PyObject* BL_ShapeActionActuator::PySetEnd(PyObject* self,
PyObject* args,
PyObject* kwds) {
+ ShowDeprecationWarning("setEnd()", "the end property");
float end;
if (PyArg_ParseTuple(args,"f",&end))
@@ -658,6 +723,7 @@ const char BL_ShapeActionActuator::SetBlendin_doc[] =
PyObject* BL_ShapeActionActuator::PySetBlendin(PyObject* self,
PyObject* args,
PyObject* kwds) {
+ ShowDeprecationWarning("setBlendin()", "the blendin property");
float blendin;
if (PyArg_ParseTuple(args,"f",&blendin))
@@ -681,6 +747,7 @@ const char BL_ShapeActionActuator::SetBlendtime_doc[] =
PyObject* BL_ShapeActionActuator::PySetBlendtime(PyObject* self,
PyObject* args,
PyObject* kwds) {
+ ShowDeprecationWarning("setBlendtime()", "the blendTime property");
float blendframe;
if (PyArg_ParseTuple(args,"f",&blendframe))
@@ -708,6 +775,7 @@ const char BL_ShapeActionActuator::SetPriority_doc[] =
PyObject* BL_ShapeActionActuator::PySetPriority(PyObject* self,
PyObject* args,
PyObject* kwds) {
+ ShowDeprecationWarning("setPriority()", "the priority property");
int priority;
if (PyArg_ParseTuple(args,"i",&priority))
@@ -727,6 +795,7 @@ const char BL_ShapeActionActuator::GetFrameProperty_doc[] =
"\tReturns the name of the property, that is set to the current frame number.\n";
PyObject* BL_ShapeActionActuator::PyGetFrameProperty(PyObject* self) {
+ ShowDeprecationWarning("getFrameProperty()", "the frameProperty property");
PyObject *result;
result = Py_BuildValue("s", (const char *)m_framepropname);
@@ -743,6 +812,7 @@ const char BL_ShapeActionActuator::SetFrame_doc[] =
PyObject* BL_ShapeActionActuator::PySetFrame(PyObject* self,
PyObject* args,
PyObject* kwds) {
+ ShowDeprecationWarning("setFrame()", "the frame property");
float frame;
if (PyArg_ParseTuple(args,"f",&frame))
@@ -769,6 +839,7 @@ const char BL_ShapeActionActuator::SetProperty_doc[] =
PyObject* BL_ShapeActionActuator::PySetProperty(PyObject* self,
PyObject* args,
PyObject* kwds) {
+ ShowDeprecationWarning("setProperty()", "the property property");
char *string;
if (PyArg_ParseTuple(args,"s",&string))
@@ -790,6 +861,7 @@ const char BL_ShapeActionActuator::SetFrameProperty_doc[] =
PyObject* BL_ShapeActionActuator::PySetFrameProperty(PyObject* self,
PyObject* args,
PyObject* kwds) {
+ ShowDeprecationWarning("setFrameProperty()", "the frameProperty property");
char *string;
if (PyArg_ParseTuple(args,"s",&string))
@@ -808,6 +880,7 @@ const char BL_ShapeActionActuator::GetType_doc[] =
"getType()\n"
"\tReturns the operation mode of the actuator.\n";
PyObject* BL_ShapeActionActuator::PyGetType(PyObject* self) {
+ ShowDeprecationWarning("getType()", "the type property");
return Py_BuildValue("h", m_playtype);
}
@@ -819,6 +892,7 @@ const char BL_ShapeActionActuator::SetType_doc[] =
PyObject* BL_ShapeActionActuator::PySetType(PyObject* self,
PyObject* args,
PyObject* kwds) {
+ ShowDeprecationWarning("setType()", "the type property");
short typeArg;
if (!PyArg_ParseTuple(args, "h", &typeArg)) {
diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.h b/source/gameengine/Converter/BL_ShapeActionActuator.h
index 30b2d41fc67..b521c0d98a6 100644
--- a/source/gameengine/Converter/BL_ShapeActionActuator.h
+++ b/source/gameengine/Converter/BL_ShapeActionActuator.h
@@ -32,6 +32,7 @@
#include "GEN_HashedPtr.h"
#include "SCA_IActuator.h"
+#include "BL_ActionActuator.h"
#include "MT_Point3.h"
#include <vector>
@@ -103,6 +104,45 @@ public:
KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetType);
virtual PyObject* _getattr(const STR_String& attr);
+ virtual int _setattr(const STR_String& attr, PyObject* value);
+
+ static int CheckBlendTime(void *self, const PyAttributeDef*)
+ {
+ BL_ShapeActionActuator* act = reinterpret_cast<BL_ShapeActionActuator*>(self);
+
+ if (act->m_blendframe > act->m_blendin)
+ act->m_blendframe = act->m_blendin;
+
+ return 0;
+ }
+ static int CheckFrame(void *self, const PyAttributeDef*)
+ {
+ BL_ShapeActionActuator* act = reinterpret_cast<BL_ShapeActionActuator*>(self);
+
+ if (act->m_localtime < act->m_startframe)
+ act->m_localtime = act->m_startframe;
+ else if (act->m_localtime > act->m_endframe)
+ act->m_localtime = act->m_endframe;
+
+ return 0;
+ }
+ static int CheckType(void *self, const PyAttributeDef*)
+ {
+ BL_ShapeActionActuator* act = reinterpret_cast<BL_ShapeActionActuator*>(self);
+
+ switch (act->m_playtype) {
+ case ACT_ACTION_PLAY:
+ case ACT_ACTION_FLIPPER:
+ case ACT_ACTION_LOOP_STOP:
+ case ACT_ACTION_LOOP_END:
+ case ACT_ACTION_FROM_PROP:
+ return 0;
+ default:
+ PyErr_SetString(PyExc_ValueError, "invalid type supplied");
+ return 1;
+ }
+
+ }
protected:
diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp
index 4f152acc918..3a6122e6608 100644
--- a/source/gameengine/Converter/KX_ConvertActuators.cpp
+++ b/source/gameengine/Converter/KX_ConvertActuators.cpp
@@ -661,7 +661,8 @@ void BL_ConvertActuators(char* maggiename,
{
KX_SCA_DynamicActuator* tmpdynact
= new KX_SCA_DynamicActuator(gameobj,
- editobact->dyn_operation
+ editobact->dyn_operation,
+ editobact->mass
);
baseact = tmpdynact;
}
diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp
index 4cf302b1f64..ae2842076a6 100644
--- a/source/gameengine/Converter/KX_ConvertSensors.cpp
+++ b/source/gameengine/Converter/KX_ConvertSensors.cpp
@@ -120,7 +120,6 @@ void BL_ConvertSensors(struct Object* blenderobject,
gReverseKeyTranslateTable[TIMER0 ] = SCA_IInputDevice::KX_TIMER0;
gReverseKeyTranslateTable[TIMER1 ] = SCA_IInputDevice::KX_TIMER1;
gReverseKeyTranslateTable[TIMER2 ] = SCA_IInputDevice::KX_TIMER2;
- gReverseKeyTranslateTable[TIMER3 ] = SCA_IInputDevice::KX_TIMER3;
// SYSTEM
diff --git a/source/gameengine/Expressions/PyObjectPlus.cpp b/source/gameengine/Expressions/PyObjectPlus.cpp
index 1eca527151a..8fd99c8d267 100644
--- a/source/gameengine/Expressions/PyObjectPlus.cpp
+++ b/source/gameengine/Expressions/PyObjectPlus.cpp
@@ -131,6 +131,537 @@ int PyObjectPlus::_setattr(const STR_String& attr, PyObject *value)
return 1;
}
+PyObject *PyObjectPlus::_getattr_self(const PyAttributeDef attrlist[], void *self, const STR_String &attr)
+{
+ const PyAttributeDef *attrdef;
+ for (attrdef=attrlist; attrdef->m_name != NULL; attrdef++)
+ {
+ if (attr == attrdef->m_name)
+ {
+ if (attrdef->m_type == KX_PYATTRIBUTE_TYPE_DUMMY)
+ {
+ // fake attribute, ignore
+ return NULL;
+ }
+ char *ptr = reinterpret_cast<char*>(self)+attrdef->m_offset;
+ if (attrdef->m_length > 1)
+ {
+ PyObject* resultlist = PyList_New(attrdef->m_length);
+ for (int i=0; i<attrdef->m_length; i++)
+ {
+ switch (attrdef->m_type) {
+ case KX_PYATTRIBUTE_TYPE_BOOL:
+ {
+ bool *val = reinterpret_cast<bool*>(ptr);
+ ptr += sizeof(bool);
+ PyList_SetItem(resultlist,i,PyInt_FromLong(*val));
+ break;
+ }
+ case KX_PYATTRIBUTE_TYPE_SHORT:
+ {
+ short int *val = reinterpret_cast<short int*>(ptr);
+ ptr += sizeof(short int);
+ PyList_SetItem(resultlist,i,PyInt_FromLong(*val));
+ break;
+ }
+ case KX_PYATTRIBUTE_TYPE_ENUM:
+ // enum are like int, just make sure the field size is the same
+ if (sizeof(int) != attrdef->m_size)
+ {
+ Py_DECREF(resultlist);
+ return NULL;
+ }
+ // walkthrough
+ case KX_PYATTRIBUTE_TYPE_INT:
+ {
+ int *val = reinterpret_cast<int*>(ptr);
+ ptr += sizeof(int);
+ PyList_SetItem(resultlist,i,PyInt_FromLong(*val));
+ break;
+ }
+ case KX_PYATTRIBUTE_TYPE_FLOAT:
+ {
+ float *val = reinterpret_cast<float*>(ptr);
+ ptr += sizeof(float);
+ PyList_SetItem(resultlist,i,PyFloat_FromDouble(*val));
+ break;
+ }
+ default:
+ // no support for array of complex data
+ Py_DECREF(resultlist);
+ return NULL;
+ }
+ }
+ return resultlist;
+ }
+ else
+ {
+ switch (attrdef->m_type) {
+ case KX_PYATTRIBUTE_TYPE_BOOL:
+ {
+ bool *val = reinterpret_cast<bool*>(ptr);
+ return PyInt_FromLong(*val);
+ }
+ case KX_PYATTRIBUTE_TYPE_SHORT:
+ {
+ short int *val = reinterpret_cast<short int*>(ptr);
+ return PyInt_FromLong(*val);
+ }
+ case KX_PYATTRIBUTE_TYPE_ENUM:
+ // enum are like int, just make sure the field size is the same
+ if (sizeof(int) != attrdef->m_size)
+ {
+ return NULL;
+ }
+ // walkthrough
+ case KX_PYATTRIBUTE_TYPE_INT:
+ {
+ int *val = reinterpret_cast<int*>(ptr);
+ return PyInt_FromLong(*val);
+ }
+ case KX_PYATTRIBUTE_TYPE_FLOAT:
+ {
+ float *val = reinterpret_cast<float*>(ptr);
+ return PyFloat_FromDouble(*val);
+ }
+ case KX_PYATTRIBUTE_TYPE_STRING:
+ {
+ STR_String *val = reinterpret_cast<STR_String*>(ptr);
+ return PyString_FromString(*val);
+ }
+ default:
+ return NULL;
+ }
+ }
+ }
+ }
+ return NULL;
+}
+
+int PyObjectPlus::_setattr_self(const PyAttributeDef attrlist[], void *self, const STR_String &attr, PyObject *value)
+{
+ const PyAttributeDef *attrdef;
+ void *undoBuffer = NULL;
+ void *sourceBuffer = NULL;
+ size_t bufferSize = 0;
+
+ for (attrdef=attrlist; attrdef->m_name != NULL; attrdef++)
+ {
+ if (attr == attrdef->m_name)
+ {
+ if (attrdef->m_access == KX_PYATTRIBUTE_RO ||
+ attrdef->m_type == KX_PYATTRIBUTE_TYPE_DUMMY)
+ {
+ PyErr_SetString(PyExc_AttributeError, "property is read-only");
+ return 1;
+ }
+ char *ptr = reinterpret_cast<char*>(self)+attrdef->m_offset;
+ if (attrdef->m_length > 1)
+ {
+ if (!PySequence_Check(value))
+ {
+ PyErr_SetString(PyExc_TypeError, "expected a sequence");
+ return 1;
+ }
+ if (PySequence_Size(value) != attrdef->m_length)
+ {
+ PyErr_SetString(PyExc_TypeError, "incorrect number of elements in sequence");
+ return 1;
+ }
+ switch (attrdef->m_type)
+ {
+ case KX_PYATTRIBUTE_TYPE_BOOL:
+ bufferSize = sizeof(bool);
+ break;
+ case KX_PYATTRIBUTE_TYPE_SHORT:
+ bufferSize = sizeof(short int);
+ break;
+ case KX_PYATTRIBUTE_TYPE_ENUM:
+ case KX_PYATTRIBUTE_TYPE_INT:
+ bufferSize = sizeof(int);
+ break;
+ case KX_PYATTRIBUTE_TYPE_FLOAT:
+ bufferSize = sizeof(float);
+ break;
+ default:
+ // should not happen
+ PyErr_SetString(PyExc_AttributeError, "Unsupported attribute type, report to blender.org");
+ return 1;
+ }
+ // let's implement a smart undo method
+ bufferSize *= attrdef->m_length;
+ undoBuffer = malloc(bufferSize);
+ sourceBuffer = ptr;
+ if (undoBuffer)
+ {
+ memcpy(undoBuffer, sourceBuffer, bufferSize);
+ }
+ for (int i=0; i<attrdef->m_length; i++)
+ {
+ PyObject *item = PySequence_GetItem(value, i); /* new ref */
+ // we can decrement the reference immediately, the reference count
+ // is at least 1 because the item is part of an array
+ Py_DECREF(item);
+ switch (attrdef->m_type)
+ {
+ case KX_PYATTRIBUTE_TYPE_BOOL:
+ {
+ bool *var = reinterpret_cast<bool*>(ptr);
+ ptr += sizeof(bool);
+ if (PyInt_Check(item))
+ {
+ *var = (PyInt_AsLong(item) != 0);
+ }
+ else if (PyBool_Check(item))
+ {
+ *var = (item == Py_True);
+ }
+ else
+ {
+ PyErr_SetString(PyExc_TypeError, "expected an integer or a bool");
+ goto UNDO_AND_ERROR;
+ }
+ break;
+ }
+ case KX_PYATTRIBUTE_TYPE_SHORT:
+ {
+ short int *var = reinterpret_cast<short int*>(ptr);
+ ptr += sizeof(short int);
+ if (PyInt_Check(item))
+ {
+ long val = PyInt_AsLong(item);
+ if (attrdef->m_clamp)
+ {
+ if (val < attrdef->m_imin)
+ val = attrdef->m_imin;
+ else if (val > attrdef->m_imax)
+ val = attrdef->m_imax;
+ }
+ else if (val < attrdef->m_imin || val > attrdef->m_imax)
+ {
+ PyErr_SetString(PyExc_ValueError, "item value out of range");
+ goto UNDO_AND_ERROR;
+ }
+ *var = (short int)val;
+ }
+ else
+ {
+ PyErr_SetString(PyExc_TypeError, "expected an integer");
+ goto UNDO_AND_ERROR;
+ }
+ break;
+ }
+ case KX_PYATTRIBUTE_TYPE_ENUM:
+ // enum are equivalent to int, just make sure that the field size matches:
+ if (sizeof(int) != attrdef->m_size)
+ {
+ PyErr_SetString(PyExc_AttributeError, "attribute size check error, report to blender.org");
+ goto UNDO_AND_ERROR;
+ }
+ // walkthrough
+ case KX_PYATTRIBUTE_TYPE_INT:
+ {
+ int *var = reinterpret_cast<int*>(ptr);
+ ptr += sizeof(int);
+ if (PyInt_Check(item))
+ {
+ long val = PyInt_AsLong(item);
+ if (attrdef->m_clamp)
+ {
+ if (val < attrdef->m_imin)
+ val = attrdef->m_imin;
+ else if (val > attrdef->m_imax)
+ val = attrdef->m_imax;
+ }
+ else if (val < attrdef->m_imin || val > attrdef->m_imax)
+ {
+ PyErr_SetString(PyExc_ValueError, "item value out of range");
+ goto UNDO_AND_ERROR;
+ }
+ *var = (int)val;
+ }
+ else
+ {
+ PyErr_SetString(PyExc_TypeError, "expected an integer");
+ goto UNDO_AND_ERROR;
+ }
+ break;
+ }
+ case KX_PYATTRIBUTE_TYPE_FLOAT:
+ {
+ float *var = reinterpret_cast<float*>(ptr);
+ ptr += sizeof(float);
+ double val = PyFloat_AsDouble(item);
+ if (val == -1.0 && PyErr_Occurred())
+ {
+ PyErr_SetString(PyExc_TypeError, "expected a float");
+ goto UNDO_AND_ERROR;
+ }
+ else if (attrdef->m_clamp)
+ {
+ if (val < attrdef->m_fmin)
+ val = attrdef->m_fmin;
+ else if (val > attrdef->m_fmax)
+ val = attrdef->m_fmax;
+ }
+ else if (val < attrdef->m_fmin || val > attrdef->m_fmax)
+ {
+ PyErr_SetString(PyExc_ValueError, "item value out of range");
+ goto UNDO_AND_ERROR;
+ }
+ *var = (float)val;
+ break;
+ }
+ default:
+ // should not happen
+ PyErr_SetString(PyExc_AttributeError, "attribute type check error, report to blender.org");
+ goto UNDO_AND_ERROR;
+ }
+ }
+ // no error, call check function if any
+ if (attrdef->m_function != NULL)
+ {
+ if ((*attrdef->m_function)(self, attrdef) != 0)
+ {
+ // post check returned an error, restore values
+ UNDO_AND_ERROR:
+ if (undoBuffer)
+ {
+ memcpy(sourceBuffer, undoBuffer, bufferSize);
+ free(undoBuffer);
+ }
+ return 1;
+ }
+ }
+ if (undoBuffer)
+ free(undoBuffer);
+ return 0;
+ }
+ else // simple attribute value
+ {
+
+ if (attrdef->m_function != NULL)
+ {
+ // post check function is provided, prepare undo buffer
+ sourceBuffer = ptr;
+ switch (attrdef->m_type)
+ {
+ case KX_PYATTRIBUTE_TYPE_BOOL:
+ bufferSize = sizeof(bool);
+ break;
+ case KX_PYATTRIBUTE_TYPE_SHORT:
+ bufferSize = sizeof(short);
+ break;
+ case KX_PYATTRIBUTE_TYPE_ENUM:
+ case KX_PYATTRIBUTE_TYPE_INT:
+ bufferSize = sizeof(int);
+ break;
+ case KX_PYATTRIBUTE_TYPE_FLOAT:
+ bufferSize = sizeof(float);
+ break;
+ case KX_PYATTRIBUTE_TYPE_STRING:
+ sourceBuffer = reinterpret_cast<STR_String*>(ptr)->Ptr();
+ if (sourceBuffer)
+ bufferSize = strlen(reinterpret_cast<char*>(sourceBuffer))+1;
+ break;
+ default:
+ PyErr_SetString(PyExc_AttributeError, "unknown attribute type, report to blender.org");
+ return 1;
+ }
+ if (bufferSize)
+ {
+ undoBuffer = malloc(bufferSize);
+ if (undoBuffer)
+ {
+ memcpy(undoBuffer, sourceBuffer, bufferSize);
+ }
+ }
+ }
+
+ switch (attrdef->m_type)
+ {
+ case KX_PYATTRIBUTE_TYPE_BOOL:
+ {
+ bool *var = reinterpret_cast<bool*>(ptr);
+ if (PyInt_Check(value))
+ {
+ *var = (PyInt_AsLong(value) != 0);
+ }
+ else if (PyBool_Check(value))
+ {
+ *var = (value == Py_True);
+ }
+ else
+ {
+ PyErr_SetString(PyExc_TypeError, "expected an integer or a bool");
+ goto FREE_AND_ERROR;
+ }
+ break;
+ }
+ case KX_PYATTRIBUTE_TYPE_SHORT:
+ {
+ short int *var = reinterpret_cast<short int*>(ptr);
+ if (PyInt_Check(value))
+ {
+ long val = PyInt_AsLong(value);
+ if (attrdef->m_clamp)
+ {
+ if (val < attrdef->m_imin)
+ val = attrdef->m_imin;
+ else if (val > attrdef->m_imax)
+ val = attrdef->m_imax;
+ }
+ else if (val < attrdef->m_imin || val > attrdef->m_imax)
+ {
+ PyErr_SetString(PyExc_ValueError, "value out of range");
+ goto FREE_AND_ERROR;
+ }
+ *var = (short int)val;
+ }
+ else
+ {
+ PyErr_SetString(PyExc_TypeError, "expected an integer");
+ goto FREE_AND_ERROR;
+ }
+ break;
+ }
+ case KX_PYATTRIBUTE_TYPE_ENUM:
+ // enum are equivalent to int, just make sure that the field size matches:
+ if (sizeof(int) != attrdef->m_size)
+ {
+ PyErr_SetString(PyExc_AttributeError, "attribute size check error, report to blender.org");
+ goto FREE_AND_ERROR;
+ }
+ // walkthrough
+ case KX_PYATTRIBUTE_TYPE_INT:
+ {
+ int *var = reinterpret_cast<int*>(ptr);
+ if (PyInt_Check(value))
+ {
+ long val = PyInt_AsLong(value);
+ if (attrdef->m_clamp)
+ {
+ if (val < attrdef->m_imin)
+ val = attrdef->m_imin;
+ else if (val > attrdef->m_imax)
+ val = attrdef->m_imax;
+ }
+ else if (val < attrdef->m_imin || val > attrdef->m_imax)
+ {
+ PyErr_SetString(PyExc_ValueError, "value out of range");
+ goto FREE_AND_ERROR;
+ }
+ *var = (int)val;
+ }
+ else
+ {
+ PyErr_SetString(PyExc_TypeError, "expected an integer");
+ goto FREE_AND_ERROR;
+ }
+ break;
+ }
+ case KX_PYATTRIBUTE_TYPE_FLOAT:
+ {
+ float *var = reinterpret_cast<float*>(ptr);
+ double val = PyFloat_AsDouble(value);
+ if (val == -1.0 && PyErr_Occurred())
+ {
+ PyErr_SetString(PyExc_TypeError, "expected a float");
+ goto FREE_AND_ERROR;
+ }
+ else if (attrdef->m_clamp)
+ {
+ if (val < attrdef->m_fmin)
+ val = attrdef->m_fmin;
+ else if (val > attrdef->m_fmax)
+ val = attrdef->m_fmax;
+ }
+ else if (val < attrdef->m_fmin || val > attrdef->m_fmax)
+ {
+ PyErr_SetString(PyExc_ValueError, "value out of range");
+ goto FREE_AND_ERROR;
+ }
+ *var = (float)val;
+ break;
+ }
+ case KX_PYATTRIBUTE_TYPE_STRING:
+ {
+ STR_String *var = reinterpret_cast<STR_String*>(ptr);
+ if (PyString_Check(value))
+ {
+ char *val = PyString_AsString(value);
+ if (attrdef->m_clamp)
+ {
+ if (strlen(val) < attrdef->m_imin)
+ {
+ // can't increase the length of the string
+ PyErr_SetString(PyExc_ValueError, "string length too short");
+ goto FREE_AND_ERROR;
+ }
+ else if (strlen(val) > attrdef->m_imax)
+ {
+ // trim the string
+ char c = val[attrdef->m_imax];
+ val[attrdef->m_imax] = 0;
+ *var = val;
+ val[attrdef->m_imax] = c;
+ break;
+ }
+ } else if (strlen(val) < attrdef->m_imin || strlen(val) > attrdef->m_imax)
+ {
+ PyErr_SetString(PyExc_ValueError, "string length out of range");
+ goto FREE_AND_ERROR;
+ }
+ *var = val;
+ }
+ else
+ {
+ PyErr_SetString(PyExc_TypeError, "expected a string");
+ goto FREE_AND_ERROR;
+ }
+ break;
+ }
+ default:
+ // should not happen
+ PyErr_SetString(PyExc_AttributeError, "unknown attribute type, report to blender.org");
+ goto FREE_AND_ERROR;
+ }
+ }
+ // check if post processing is needed
+ if (attrdef->m_function != NULL)
+ {
+ if ((*attrdef->m_function)(self, attrdef) != 0)
+ {
+ // restore value
+ RESTORE_AND_ERROR:
+ if (undoBuffer)
+ {
+ if (attrdef->m_type == KX_PYATTRIBUTE_TYPE_STRING)
+ {
+ // special case for STR_String: restore the string
+ STR_String *var = reinterpret_cast<STR_String*>(ptr);
+ *var = reinterpret_cast<char*>(undoBuffer);
+ }
+ else
+ {
+ // other field type have direct values
+ memcpy(ptr, undoBuffer, bufferSize);
+ }
+ }
+ FREE_AND_ERROR:
+ if (undoBuffer)
+ free(undoBuffer);
+ return 1;
+ }
+ }
+ if (undoBuffer)
+ free(undoBuffer);
+ return 0;
+ }
+ }
+ return -1;
+}
+
/*------------------------------
* PyObjectPlus repr -- representations
------------------------------*/
diff --git a/source/gameengine/Expressions/PyObjectPlus.h b/source/gameengine/Expressions/PyObjectPlus.h
index 3a054454a0b..e0e2213d984 100644
--- a/source/gameengine/Expressions/PyObjectPlus.h
+++ b/source/gameengine/Expressions/PyObjectPlus.h
@@ -86,6 +86,7 @@ static inline void Py_Fatal(const char *M) {
public: \
static PyTypeObject Type; \
static PyMethodDef Methods[]; \
+ static PyAttributeDef Attributes[]; \
static PyParentObject Parents[]; \
virtual PyTypeObject *GetType(void) {return &Type;}; \
virtual PyParentObject *GetParents(void) {return Parents;}
@@ -185,7 +186,10 @@ static inline void Py_Fatal(const char *M) {
#define KX_PYMETHODTABLE(class_name, method_name) \
{#method_name , (PyCFunction) class_name::sPy##method_name, METH_VARARGS, (PY_METHODCHAR)class_name::method_name##_doc}
-#define KX_PYMETHODTABLE_NOARG(class_name, method_name) \
+#define KX_PYMETHODTABLE_O(class_name, method_name) \
+ {#method_name , (PyCFunction) class_name::sPy##method_name, METH_O, (PY_METHODCHAR)class_name::method_name##_doc}
+
+#define KX_PYMETHODTABLE_NOARGS(class_name, method_name) \
{#method_name , (PyCFunction) class_name::sPy##method_name, METH_NOARGS, (PY_METHODCHAR)class_name::method_name##_doc}
/**
@@ -195,10 +199,130 @@ static inline void Py_Fatal(const char *M) {
const char class_name::method_name##_doc[] = doc_string; \
PyObject* class_name::Py##method_name(PyObject*, PyObject* args, PyObject*)
-#define KX_PYMETHODDEF_DOC_NOARG(class_name, method_name, doc_string) \
+#define KX_PYMETHODDEF_DOC_VARARGS(class_name, method_name, doc_string) \
+const char class_name::method_name##_doc[] = doc_string; \
+PyObject* class_name::Py##method_name(PyObject*, PyObject* args)
+
+#define KX_PYMETHODDEF_DOC_O(class_name, method_name, doc_string) \
+const char class_name::method_name##_doc[] = doc_string; \
+PyObject* class_name::Py##method_name(PyObject*, PyObject* value)
+
+#define KX_PYMETHODDEF_DOC_NOARGS(class_name, method_name, doc_string) \
const char class_name::method_name##_doc[] = doc_string; \
PyObject* class_name::Py##method_name(PyObject*)
+/**
+ * Attribute management
+ */
+enum KX_PYATTRIBUTE_TYPE {
+ KX_PYATTRIBUTE_TYPE_BOOL,
+ KX_PYATTRIBUTE_TYPE_ENUM,
+ KX_PYATTRIBUTE_TYPE_SHORT,
+ KX_PYATTRIBUTE_TYPE_INT,
+ KX_PYATTRIBUTE_TYPE_FLOAT,
+ KX_PYATTRIBUTE_TYPE_STRING,
+ KX_PYATTRIBUTE_TYPE_DUMMY,
+};
+
+enum KX_PYATTRIBUTE_ACCESS {
+ KX_PYATTRIBUTE_RW,
+ KX_PYATTRIBUTE_RO
+};
+
+struct KX_PYATTRIBUTE_DEF;
+typedef int (*KX_PYATTRIBUTE_FUNCTION)(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
+
+typedef struct KX_PYATTRIBUTE_DEF {
+ const char *m_name; // name of the python attribute
+ KX_PYATTRIBUTE_TYPE m_type; // type of value
+ KX_PYATTRIBUTE_ACCESS m_access; // read/write access or read-only
+ int m_imin; // minimum value in case of integer attributes (for string: minimum string length)
+ int m_imax; // maximum value in case of integer attributes (for string: maximum string length)
+ float m_fmin; // minimum value in case of float attributes
+ float m_fmax; // maximum value in case of float attributes
+ bool m_clamp; // enforce min/max value by clamping
+ size_t m_offset; // position of field in structure
+ size_t m_size; // size of field for runtime verification (enum only)
+ size_t m_length; // length of array, 1=simple attribute
+ KX_PYATTRIBUTE_FUNCTION m_function; // static function to check the assignment, returns 0 if no error
+ // The following pointers are just used to have compile time check for attribute type.
+ // It would have been good to use a union but that would require C99 compatibility
+ // to initialize specific union fields through designated initializers.
+ struct {
+ bool *m_boolPtr;
+ short int *m_shortPtr;
+ int *m_intPtr;
+ float *m_floatPtr;
+ STR_String *m_stringPtr;
+ } m_typeCheck;
+} PyAttributeDef;
+
+#define KX_PYATTRIBUTE_DUMMY(name) \
+ { name, KX_PYATTRIBUTE_TYPE_DUMMY, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, 0, 0, 1, NULL, {NULL, NULL, NULL, NULL, NULL} }
+
+#define KX_PYATTRIBUTE_BOOL_RW(name,object,field) \
+ { name, KX_PYATTRIBUTE_TYPE_BOOL, KX_PYATTRIBUTE_RW, 0, 1, 0.f, 0.f, false, offsetof(object,field), 0, 1, NULL, {&((object *)0)->field, NULL, NULL, NULL, NULL} }
+#define KX_PYATTRIBUTE_BOOL_RW_CHECK(name,object,field,function) \
+ { name, KX_PYATTRIBUTE_TYPE_BOOL, KX_PYATTRIBUTE_RW, 0, 1, 0.f, 0.f, false, offsetof(object,field), 0, 1, &object::function, {&((object *)0)->field, NULL, NULL, NULL, NULL} }
+#define KX_PYATTRIBUTE_BOOL_RO(name,object,field) \
+ { name, KX_PYATTRIBUTE_TYPE_BOOL, KX_PYATTRIBUTE_RO, 0, 1, 0.f, 0.f, false, offsetof(object,field), 0, 1, NULL, {&((object *)0)->field, NULL, NULL, NULL, NULL} }
+
+// enum field cannot be mapped to pointer (because we would need a pointer for each enum)
+// use field size to verify mapping at runtime only, assuming enum size is equal to int size.
+#define KX_PYATTRIBUTE_ENUM_RW(name,min,max,clamp,object,field) \
+ { name, KX_PYATTRIBUTE_TYPE_ENUM, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), sizeof(((object *)0)->field), 1, NULL, {NULL, NULL, NULL, NULL, NULL} }
+#define KX_PYATTRIBUTE_ENUM_RW_CHECK(name,min,max,clamp,object,field,function) \
+ { name, KX_PYATTRIBUTE_TYPE_ENUM, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), sizeof(((object *)0)->field), 1, &object::function, {NULL, NULL, NULL, NULL, NULL} }
+#define KX_PYATTRIBUTE_ENUM_RO(name,object,field) \
+ { name, KX_PYATTRIBUTE_TYPE_ENUM, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, offsetof(object,field), sizeof(((object *)0)->field), 1, NULL, {NULL, NULL, NULL, NULL, NULL} }
+
+#define KX_PYATTRIBUTE_SHORT_RW(name,min,max,clamp,object,field) \
+ { name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), 0, 1, NULL, {NULL, &((object *)0)->field, NULL, NULL, NULL} }
+#define KX_PYATTRIBUTE_SHORT_RW_CHECK(name,min,max,clamp,object,field,function) \
+ { name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), 0, 1, &object::function, {NULL, &((object *)0)->field, NULL, NULL, NULL} }
+#define KX_PYATTRIBUTE_SHORT_RO(name,object,field) \
+ { name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, offsetof(object,field), 0, 1, NULL, {NULL, &((object *)0)->field, NULL, NULL, NULL} }
+#define KX_PYATTRIBUTE_SHORT_ARRAY_RW(name,min,max,clamp,object,field,length) \
+ { name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), 0, length, NULL, {NULL, &((object *)0)->field, NULL, NULL, NULL} }
+#define KX_PYATTRIBUTE_SHORT_ARRAY_RW_CHECK(name,min,max,clamp,object,field,length,function) \
+ { name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), 0, length, &object::function, {NULL, &((object *)0)->field, NULL, NULL, NULL} }
+#define KX_PYATTRIBUTE_SHORT_ARRAY_RO(name,object,field,length) \
+ { name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, offsetof(object,field), 0, length, NULL, {NULL, &((object *)0)->field, NULL, NULL, NULL} }
+
+#define KX_PYATTRIBUTE_INT_RW(name,min,max,clamp,object,field) \
+ { name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), 0, 1, NULL, {NULL, NULL, &((object *)0)->field, NULL, NULL} }
+#define KX_PYATTRIBUTE_INT_RW_CHECK(name,min,max,clamp,object,field,function) \
+ { name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), 0, 1, &object::function, {NULL, NULL, &((object *)0)->field, NULL, NULL} }
+#define KX_PYATTRIBUTE_INT_RO(name,object,field) \
+ { name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, offsetof(object,field), 0, 1, NULL, {NULL, NULL, &((object *)0)->field, NULL, NULL} }
+#define KX_PYATTRIBUTE_INT_ARRAY_RW(name,min,max,clamp,object,field,length) \
+ { name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), 0, length, NULL, {NULL, NULL, &((object *)0)->field, NULL, NULL} }
+#define KX_PYATTRIBUTE_INT_ARRAY_RW_CHECK(name,min,max,clamp,object,field,length,function) \
+ { name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), 0, length, &object::function, {NULL, NULL, &((object *)0)->field, NULL, NULL} }
+#define KX_PYATTRIBUTE_INT_ARRAY_RO(name,object,field,length) \
+ { name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, offsetof(object,field), 0, length, NULL, {NULL, NULL, &((object *)0)->field, NULL, NULL} }
+
+// always clamp for float
+#define KX_PYATTRIBUTE_FLOAT_RW(name,min,max,object,field) \
+ { name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RW, 0, 0, min, max, true, offsetof(object,field), 0, 1, NULL, {NULL, NULL, NULL, &((object *)0)->field, NULL} }
+#define KX_PYATTRIBUTE_FLOAT_RW_CHECK(name,min,max,object,field,function) \
+ { name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RW, 0, 0, min, max, true, offsetof(object,field), 0, 1, &object::function, {NULL, NULL, NULL, &((object *)0)->field, NULL} }
+#define KX_PYATTRIBUTE_FLOAT_RO(name,object,field) \
+ { name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, offsetof(object,field), 0, 1, NULL, {NULL, NULL, NULL, &((object *)0)->field, NULL} }
+#define KX_PYATTRIBUTE_FLOAT_ARRAY_RW(name,min,max,object,field,length) \
+ { name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RW, 0, 0, min, max, true, offsetof(object,field), 0, length, NULL, {NULL, NULL, NULL, &((object *)0)->field, NULL} }
+#define KX_PYATTRIBUTE_FLOAT_ARRAY_RW_CHECK(name,min,max,object,field,length,function) \
+ { name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RW, 0, 0, min, max, true, offsetof(object,field), 0, length, &object::function, {NULL, NULL, NULL, &((object *)0)->field, NULL} }
+#define KX_PYATTRIBUTE_FLOAT_ARRAY_RO(name,object,field,length) \
+ { name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, offsetof(object,field), 0, length, NULL, {NULL, NULL, NULL, &((object *)0)->field, NULL} }
+
+#define KX_PYATTRIBUTE_STRING_RW(name,min,max,clamp,object,field) \
+ { name, KX_PYATTRIBUTE_TYPE_STRING, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), 0, 1, NULL, {NULL, NULL, NULL, NULL, &((object *)0)->field} }
+#define KX_PYATTRIBUTE_STRING_RW_CHECK(name,min,max,clamp,object,field,function) \
+ { name, KX_PYATTRIBUTE_TYPE_STRING, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), 0, 1, &object::function, {NULL, NULL, NULL, NULL, &((object *)0)->field} }
+#define KX_PYATTRIBUTE_STRING_RO(name,object,field) \
+ { name, KX_PYATTRIBUTE_TYPE_STRING, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, offsetof(object,field), 0, 1 , NULL, {NULL, NULL, NULL, NULL, &((object *)0)->field} }
+
/*------------------------------
* PyObjectPlus
------------------------------*/
@@ -229,6 +353,8 @@ public:
{
return ((PyObjectPlus*) PyObj)->_getattr(STR_String(attr));
}
+ static PyObject *_getattr_self(const PyAttributeDef attrlist[], void *self, const STR_String &attr);
+ static int _setattr_self(const PyAttributeDef attrlist[], void *self, const STR_String &attr, PyObject *value);
virtual int _delattr(const STR_String& attr);
virtual int _setattr(const STR_String& attr, PyObject *value); // _setattr method
diff --git a/source/gameengine/Expressions/Value.cpp b/source/gameengine/Expressions/Value.cpp
index 7296dfbec10..f2b5569c76e 100644
--- a/source/gameengine/Expressions/Value.cpp
+++ b/source/gameengine/Expressions/Value.cpp
@@ -32,6 +32,7 @@
//////////////////////////////////////////////////////////////////////
double CValue::m_sZeroVec[3] = {0.0,0.0,0.0};
+bool CValue::m_ignore_deprecation_warnings(false);
#ifndef NO_EXP_PYTHON_EMBEDDING
@@ -849,4 +850,15 @@ void CValue::SetValue(CValue* newval)
}
///////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
+/* deprecation warning management */
+void CValue::SetDeprecationWarnings(bool ignoreDeprecationWarnings)
+{
+ m_ignore_deprecation_warnings = ignoreDeprecationWarnings;
+}
+
+void CValue::ShowDeprecationWarning(const char* old_way,const char* new_way)
+{
+ if (!m_ignore_deprecation_warnings)
+ printf("Method %s is deprecated, please use %s instead.\n", old_way, new_way);
+}
diff --git a/source/gameengine/Expressions/Value.h b/source/gameengine/Expressions/Value.h
index 74fcdae5756..56a4991af27 100644
--- a/source/gameengine/Expressions/Value.h
+++ b/source/gameengine/Expressions/Value.h
@@ -318,6 +318,10 @@ public:
STR_String op2str(VALUE_OPERATOR op);
+ /** enable/disable display of deprecation warnings */
+ static void SetDeprecationWarnings(bool ignoreDeprecationWarnings);
+ /** Shows a deprecation warning */
+ static void ShowDeprecationWarning(const char* method,const char* prop);
// setting / getting flags
inline void SetSelected(bool bSelected) { m_ValFlags.Selected = bSelected; }
@@ -349,6 +353,7 @@ private:
ValueFlags m_ValFlags; // Frequently used flags in a bitfield (low memoryusage)
int m_refcount; // Reference Counter
static double m_sZeroVec[3];
+ static bool m_ignore_deprecation_warnings;
};
diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp
index 9ec4ea00337..a70830193db 100644
--- a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp
+++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp
@@ -74,7 +74,8 @@ bool SCA_2DFilterActuator::Update()
{
m_rendertools->Update2DFilter(m_propNames, m_gameObj, m_type, m_int_arg, m_shaderText);
}
- return true;
+ // once the filter is in place, no need to update it again => disable the actuator
+ return false;
}
diff --git a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp
index 7c37b237d60..fae8d2ba5a7 100644
--- a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp
@@ -149,21 +149,51 @@ PyParentObject SCA_ActuatorSensor::Parents[] = {
};
PyMethodDef SCA_ActuatorSensor::Methods[] = {
+ //Deprecated functions ------>
{"getActuator", (PyCFunction) SCA_ActuatorSensor::sPyGetActuator, METH_NOARGS, (PY_METHODCHAR)GetActuator_doc},
{"setActuator", (PyCFunction) SCA_ActuatorSensor::sPySetActuator, METH_VARARGS, (PY_METHODCHAR)SetActuator_doc},
+ //<----- Deprecated
{NULL,NULL} //Sentinel
};
+PyAttributeDef SCA_ActuatorSensor::Attributes[] = {
+ KX_PYATTRIBUTE_STRING_RW_CHECK("actuator",0,100,false,SCA_ActuatorSensor,m_checkactname,CheckActuator),
+ { NULL } //Sentinel
+};
+
PyObject* SCA_ActuatorSensor::_getattr(const STR_String& attr) {
+ PyObject* object = _getattr_self(Attributes, this, attr);
+ if (object != NULL)
+ return object;
_getattr_up(SCA_ISensor); /* implicit return! */
}
+int SCA_ActuatorSensor::CheckActuator(void *self, const PyAttributeDef*)
+{
+ SCA_ActuatorSensor* sensor = reinterpret_cast<SCA_ActuatorSensor*>(self);
+ SCA_IActuator* act = sensor->GetParent()->FindActuator(sensor->m_checkactname);
+ if (act) {
+ sensor->m_actuator = act;
+ return 0;
+ }
+ PyErr_SetString(PyExc_AttributeError, "string does not correspond to an actuator");
+ return 1;
+}
+
+int SCA_ActuatorSensor::_setattr(const STR_String& attr, PyObject *value) {
+ int ret = _setattr_self(Attributes, this, attr, value);
+ if (ret >= 0)
+ return ret;
+ return SCA_ISensor::_setattr(attr, value);
+}
+
/* 3. getActuator */
const char SCA_ActuatorSensor::GetActuator_doc[] =
"getActuator()\n"
"\tReturn the Actuator with which the sensor operates.\n";
PyObject* SCA_ActuatorSensor::PyGetActuator(PyObject* self)
{
+ ShowDeprecationWarning("getActuator()", "the actuator property");
return PyString_FromString(m_checkactname);
}
@@ -175,6 +205,7 @@ const char SCA_ActuatorSensor::SetActuator_doc[] =
"\tof this name, the call is ignored.\n";
PyObject* SCA_ActuatorSensor::PySetActuator(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("setActuator()", "the actuator property");
/* We should query whether the name exists. Or should we create a prop */
/* on the fly? */
char *actNameArg = NULL;
diff --git a/source/gameengine/GameLogic/SCA_ActuatorSensor.h b/source/gameengine/GameLogic/SCA_ActuatorSensor.h
index a71145f6852..3d64247461c 100644
--- a/source/gameengine/GameLogic/SCA_ActuatorSensor.h
+++ b/source/gameengine/GameLogic/SCA_ActuatorSensor.h
@@ -62,12 +62,14 @@ public:
/* --------------------------------------------------------------------- */
virtual PyObject* _getattr(const STR_String& attr);
+ virtual int _setattr(const STR_String& attr, PyObject *value);
/* 3. setProperty */
KX_PYMETHOD_DOC(SCA_ActuatorSensor,SetActuator);
/* 4. getProperty */
KX_PYMETHOD_DOC_NOARGS(SCA_ActuatorSensor,GetActuator);
+ static int CheckActuator(void *self, const PyAttributeDef*);
};
#endif
diff --git a/source/gameengine/GameLogic/SCA_DelaySensor.cpp b/source/gameengine/GameLogic/SCA_DelaySensor.cpp
index f15d4c7249f..4c97ca98d72 100644
--- a/source/gameengine/GameLogic/SCA_DelaySensor.cpp
+++ b/source/gameengine/GameLogic/SCA_DelaySensor.cpp
@@ -158,6 +158,7 @@ PyParentObject SCA_DelaySensor::Parents[] = {
};
PyMethodDef SCA_DelaySensor::Methods[] = {
+ //Deprecated functions ------>
/* setProperty */
{"setDelay", (PyCFunction) SCA_DelaySensor::sPySetDelay, METH_VARARGS, (PY_METHODCHAR)SetDelay_doc},
{"setDuration", (PyCFunction) SCA_DelaySensor::sPySetDuration, METH_VARARGS, (PY_METHODCHAR)SetDuration_doc},
@@ -166,13 +167,32 @@ PyMethodDef SCA_DelaySensor::Methods[] = {
{"getDelay", (PyCFunction) SCA_DelaySensor::sPyGetDelay, METH_NOARGS, (PY_METHODCHAR)GetDelay_doc},
{"getDuration", (PyCFunction) SCA_DelaySensor::sPyGetDuration, METH_NOARGS, (PY_METHODCHAR)GetDuration_doc},
{"getRepeat", (PyCFunction) SCA_DelaySensor::sPyGetRepeat, METH_NOARGS, (PY_METHODCHAR)GetRepeat_doc},
+ //<----- Deprecated
{NULL,NULL} //Sentinel
};
+PyAttributeDef SCA_DelaySensor::Attributes[] = {
+ KX_PYATTRIBUTE_INT_RW("delay",0,100000,true,SCA_DelaySensor,m_delay),
+ KX_PYATTRIBUTE_INT_RW("duration",0,100000,true,SCA_DelaySensor,m_duration),
+ KX_PYATTRIBUTE_BOOL_RW("repeat",SCA_DelaySensor,m_repeat),
+ { NULL } //Sentinel
+};
+
PyObject* SCA_DelaySensor::_getattr(const STR_String& attr) {
+ PyObject* object = _getattr_self(Attributes, this, attr);
+ if (object != NULL)
+ return object;
_getattr_up(SCA_ISensor);
}
+int SCA_DelaySensor::_setattr(const STR_String& attr, PyObject *value) {
+ int ret = _setattr_self(Attributes, this, attr, value);
+ if (ret >= 0)
+ return ret;
+ return SCA_ISensor::_setattr(attr, value);
+}
+
+
const char SCA_DelaySensor::SetDelay_doc[] =
"setDelay(delay)\n"
"\t- delay: length of the initial OFF period as number of frame\n"
@@ -180,6 +200,7 @@ const char SCA_DelaySensor::SetDelay_doc[] =
"\tSet the initial delay before the positive trigger\n";
PyObject* SCA_DelaySensor::PySetDelay(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("setDelay()", "the delay property");
int delay;
if(!PyArg_ParseTuple(args, "i", &delay)) {
@@ -201,6 +222,7 @@ const char SCA_DelaySensor::SetDuration_doc[] =
"\tIf > 0, a negative trigger is fired at the end of the ON pulse.\n";
PyObject* SCA_DelaySensor::PySetDuration(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("setDuration()", "the duration property");
int duration;
if(!PyArg_ParseTuple(args, "i", &duration)) {
@@ -221,6 +243,7 @@ const char SCA_DelaySensor::SetRepeat_doc[] =
"\tSet the sensor repeat mode\n";
PyObject* SCA_DelaySensor::PySetRepeat(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("setRepeat()", "the repeat property");
int repeat;
if(!PyArg_ParseTuple(args, "i", &repeat)) {
@@ -235,6 +258,7 @@ const char SCA_DelaySensor::GetDelay_doc[] =
"\tReturn the delay parameter value\n";
PyObject* SCA_DelaySensor::PyGetDelay(PyObject* self)
{
+ ShowDeprecationWarning("getDelay()", "the delay property");
return PyInt_FromLong(m_delay);
}
@@ -243,6 +267,7 @@ const char SCA_DelaySensor::GetDuration_doc[] =
"\tReturn the duration parameter value\n";
PyObject* SCA_DelaySensor::PyGetDuration(PyObject* self)
{
+ ShowDeprecationWarning("getDuration()", "the duration property");
return PyInt_FromLong(m_duration);
}
@@ -251,6 +276,7 @@ const char SCA_DelaySensor::GetRepeat_doc[] =
"\tReturn the repeat parameter value\n";
PyObject* SCA_DelaySensor::PyGetRepeat(PyObject* self)
{
+ ShowDeprecationWarning("getRepeat()", "the repeat property");
return BoolToPyArg(m_repeat);
}
diff --git a/source/gameengine/GameLogic/SCA_DelaySensor.h b/source/gameengine/GameLogic/SCA_DelaySensor.h
index a997fabe3cd..ff3afe16542 100644
--- a/source/gameengine/GameLogic/SCA_DelaySensor.h
+++ b/source/gameengine/GameLogic/SCA_DelaySensor.h
@@ -61,6 +61,7 @@ public:
/* --------------------------------------------------------------------- */
virtual PyObject* _getattr(const STR_String& attr);
+ virtual int _setattr(const STR_String& attr, PyObject *value);
/* setProperty */
KX_PYMETHOD_DOC(SCA_DelaySensor,SetDelay);
diff --git a/source/gameengine/GameLogic/SCA_IInputDevice.h b/source/gameengine/GameLogic/SCA_IInputDevice.h
index 66ad457aa03..a0d77ed3c03 100644
--- a/source/gameengine/GameLogic/SCA_IInputDevice.h
+++ b/source/gameengine/GameLogic/SCA_IInputDevice.h
@@ -75,7 +75,6 @@ public:
KX_TIMER0,
KX_TIMER1,
KX_TIMER2,
- KX_TIMER3,
// SYSTEM
diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp
index abd049e9d64..8286c0829a7 100644
--- a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp
+++ b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp
@@ -247,19 +247,52 @@ PyParentObject SCA_ILogicBrick::Parents[] = {
PyMethodDef SCA_ILogicBrick::Methods[] = {
{"getOwner", (PyCFunction) SCA_ILogicBrick::sPyGetOwner, METH_NOARGS},
- {"getExecutePriority", (PyCFunction) SCA_ILogicBrick::sPySetExecutePriority, METH_NOARGS},
+ // --> Deprecated
+ {"getExecutePriority", (PyCFunction) SCA_ILogicBrick::sPyGetExecutePriority, METH_NOARGS},
{"setExecutePriority", (PyCFunction) SCA_ILogicBrick::sPySetExecutePriority, METH_VARARGS},
+ // <-- Deprecated
{NULL,NULL} //Sentinel
};
+PyAttributeDef SCA_ILogicBrick::Attributes[] = {
+ KX_PYATTRIBUTE_INT_RW("executePriority",0,100000,false,SCA_ILogicBrick,m_Execute_Ueber_Priority),
+ {NULL} //Sentinel
+};
+int SCA_ILogicBrick::CheckProperty(void *self, const PyAttributeDef *attrdef)
+{
+ if (attrdef->m_type != KX_PYATTRIBUTE_TYPE_STRING || attrdef->m_length != 1) {
+ PyErr_SetString(PyExc_AttributeError, "inconsistent check function for attribute type, report to blender.org");
+ return 1;
+ }
+ SCA_ILogicBrick* brick = reinterpret_cast<SCA_ILogicBrick*>(self);
+ STR_String* var = reinterpret_cast<STR_String*>((char*)self+attrdef->m_offset);
+ CValue* prop = brick->GetParent()->FindIdentifier(*var);
+ bool error = prop->IsError();
+ prop->Release();
+ if (error) {
+ PyErr_SetString(PyExc_ValueError, "string does not correspond to a property");
+ return 1;
+ }
+ return 0;
+}
PyObject*
SCA_ILogicBrick::_getattr(const STR_String& attr)
{
+ PyObject* object = _getattr_self(Attributes, this, attr);
+ if (object != NULL)
+ return object;
_getattr_up(CValue);
}
+int SCA_ILogicBrick::_setattr(const STR_String& attr, PyObject *value)
+{
+ int ret = _setattr_self(Attributes, this, attr, value);
+ if (ret >= 0)
+ return ret;
+ return CValue::_setattr(attr, value);
+}
PyObject* SCA_ILogicBrick::PyGetOwner(PyObject* self)
@@ -281,6 +314,7 @@ PyObject* SCA_ILogicBrick::PySetExecutePriority(PyObject* self,
PyObject* args,
PyObject* kwds)
{
+ ShowDeprecationWarning("setExecutePriority()", "the executePriority property");
int priority=0;
@@ -297,6 +331,7 @@ PyObject* SCA_ILogicBrick::PySetExecutePriority(PyObject* self,
PyObject* SCA_ILogicBrick::PyGetExecutePriority(PyObject* self)
{
+ ShowDeprecationWarning("getExecutePriority()", "the executePriority property");
return PyInt_FromLong(m_Execute_Ueber_Priority);
}
diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.h b/source/gameengine/GameLogic/SCA_ILogicBrick.h
index c28711ac0f6..772bd65d577 100644
--- a/source/gameengine/GameLogic/SCA_ILogicBrick.h
+++ b/source/gameengine/GameLogic/SCA_ILogicBrick.h
@@ -79,6 +79,7 @@ public:
virtual bool LessComparedTo(SCA_ILogicBrick* other);
virtual PyObject* _getattr(const STR_String& attr);
+ virtual int _setattr(const STR_String& attr, PyObject *value);
static class SCA_LogicManager* m_sCurrentLogicManager;
@@ -89,6 +90,9 @@ public:
KX_PYMETHOD(SCA_ILogicBrick,SetExecutePriority);
KX_PYMETHOD_NOARGS(SCA_ILogicBrick,GetExecutePriority);
+ // check that attribute is a property
+ static int CheckProperty(void *self, const PyAttributeDef *attrdef);
+
enum KX_BOOL_TYPE {
KX_BOOL_NODEF = 0,
KX_TRUE,
diff --git a/source/gameengine/GameLogic/SCA_ISensor.cpp b/source/gameengine/GameLogic/SCA_ISensor.cpp
index b10ac676464..68a3a93eab0 100644
--- a/source/gameengine/GameLogic/SCA_ISensor.cpp
+++ b/source/gameengine/GameLogic/SCA_ISensor.cpp
@@ -139,71 +139,6 @@ void SCA_ISensor::DecLink() {
}
}
-/* python integration */
-
-PyTypeObject SCA_ISensor::Type = {
- PyObject_HEAD_INIT(&PyType_Type)
- 0,
- "SCA_ISensor",
- sizeof(SCA_ISensor),
- 0,
- PyDestructor,
- 0,
- __getattr,
- __setattr,
- 0, //&MyPyCompare,
- __repr,
- 0, //&cvalue_as_number,
- 0,
- 0,
- 0,
- 0
-};
-
-PyParentObject SCA_ISensor::Parents[] = {
- &SCA_ISensor::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
-};
-PyMethodDef SCA_ISensor::Methods[] = {
- {"isPositive", (PyCFunction) SCA_ISensor::sPyIsPositive,
- METH_NOARGS, (PY_METHODCHAR)IsPositive_doc},
- {"isTriggered", (PyCFunction) SCA_ISensor::sPyIsTriggered,
- METH_VARARGS, (PY_METHODCHAR)IsTriggered_doc},
- {"getUsePosPulseMode", (PyCFunction) SCA_ISensor::sPyGetUsePosPulseMode,
- METH_NOARGS, (PY_METHODCHAR)GetUsePosPulseMode_doc},
- {"setUsePosPulseMode", (PyCFunction) SCA_ISensor::sPySetUsePosPulseMode,
- METH_VARARGS, (PY_METHODCHAR)SetUsePosPulseMode_doc},
- {"getFrequency", (PyCFunction) SCA_ISensor::sPyGetFrequency,
- METH_NOARGS, (PY_METHODCHAR)GetFrequency_doc},
- {"setFrequency", (PyCFunction) SCA_ISensor::sPySetFrequency,
- METH_VARARGS, (PY_METHODCHAR)SetFrequency_doc},
- {"getUseNegPulseMode", (PyCFunction) SCA_ISensor::sPyGetUseNegPulseMode,
- METH_NOARGS, (PY_METHODCHAR)GetUseNegPulseMode_doc},
- {"setUseNegPulseMode", (PyCFunction) SCA_ISensor::sPySetUseNegPulseMode,
- METH_VARARGS, (PY_METHODCHAR)SetUseNegPulseMode_doc},
- {"getInvert", (PyCFunction) SCA_ISensor::sPyGetInvert,
- METH_NOARGS, (PY_METHODCHAR)GetInvert_doc},
- {"setInvert", (PyCFunction) SCA_ISensor::sPySetInvert,
- METH_VARARGS, (PY_METHODCHAR)SetInvert_doc},
- {"getLevel", (PyCFunction) SCA_ISensor::sPyGetLevel,
- METH_NOARGS, (PY_METHODCHAR)GetLevel_doc},
- {"setLevel", (PyCFunction) SCA_ISensor::sPySetLevel,
- METH_VARARGS, (PY_METHODCHAR)SetLevel_doc},
- {"reset", (PyCFunction) SCA_ISensor::sPyReset,
- METH_NOARGS, (PY_METHODCHAR)Reset_doc},
- {NULL,NULL} //Sentinel
-};
-
-
-PyObject*
-SCA_ISensor::_getattr(const STR_String& attr)
-{
- _getattr_up(SCA_ILogicBrick);
-}
-
-
void SCA_ISensor::RegisterToManager()
{
// sensor is just activated, initialize it
@@ -275,13 +210,17 @@ void SCA_ISensor::Activate(class SCA_LogicManager* logicmgr, CValue* event)
}
}
}
+/* ----------------------------------------------- */
+/* Python Functions */
+/* ----------------------------------------------- */
-/* Python functions: */
+//Deprecated Functions ------>
const char SCA_ISensor::IsPositive_doc[] =
"isPositive()\n"
"\tReturns whether the sensor is in an active state.\n";
PyObject* SCA_ISensor::PyIsPositive(PyObject* self)
{
+ ShowDeprecationWarning("isPositive()", "the read-only positive property");
int retval = IsPositiveTrigger();
return PyInt_FromLong(retval);
}
@@ -291,6 +230,7 @@ const char SCA_ISensor::IsTriggered_doc[] =
"\tReturns whether the sensor has triggered the current controller.\n";
PyObject* SCA_ISensor::PyIsTriggered(PyObject* self)
{
+ ShowDeprecationWarning("isTriggered()", "the read-only triggered property");
// check with the current controller
int retval = 0;
if (SCA_PythonController::m_sCurrentController)
@@ -306,6 +246,7 @@ const char SCA_ISensor::GetUsePosPulseMode_doc[] =
"\tReturns whether positive pulse mode is active.\n";
PyObject* SCA_ISensor::PyGetUsePosPulseMode(PyObject* self)
{
+ ShowDeprecationWarning("getUsePosPulseMode()", "the usePosPulseMode property");
return BoolToPyArg(m_pos_pulsemode);
}
@@ -319,6 +260,7 @@ const char SCA_ISensor::SetUsePosPulseMode_doc[] =
"\tSet whether to do pulsing when positive pulses occur.\n";
PyObject* SCA_ISensor::PySetUsePosPulseMode(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("setUsePosPulseMode()", "the usePosPulseMode property");
int pyarg = 0;
if(!PyArg_ParseTuple(args, "i", &pyarg)) { return NULL; }
m_pos_pulsemode = PyArgToBool(pyarg);
@@ -333,6 +275,7 @@ const char SCA_ISensor::GetFrequency_doc[] =
"\tReturns the frequency of the updates in pulse mode.\n" ;
PyObject* SCA_ISensor::PyGetFrequency(PyObject* self)
{
+ ShowDeprecationWarning("getFrequency()", "the frequency property");
return PyInt_FromLong(m_pulse_frequency);
}
@@ -346,6 +289,7 @@ const char SCA_ISensor::SetFrequency_doc[] =
"\tIf the frequency is negative, it is set to 0.\n" ;
PyObject* SCA_ISensor::PySetFrequency(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("setFrequency()", "the frequency property");
int pulse_frequencyArg = 0;
if(!PyArg_ParseTuple(args, "i", &pulse_frequencyArg)) {
@@ -368,6 +312,7 @@ const char SCA_ISensor::GetInvert_doc[] =
"\tReturns whether or not pulses from this sensor are inverted.\n" ;
PyObject* SCA_ISensor::PyGetInvert(PyObject* self)
{
+ ShowDeprecationWarning("getInvert()", "the invert property");
return BoolToPyArg(m_invert);
}
@@ -377,6 +322,7 @@ const char SCA_ISensor::SetInvert_doc[] =
"\tSet whether to invert pulses.\n";
PyObject* SCA_ISensor::PySetInvert(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("setInvert()", "the invert property");
int pyarg = 0;
if(!PyArg_ParseTuple(args, "i", &pyarg)) { return NULL; }
m_invert = PyArgToBool(pyarg);
@@ -392,6 +338,7 @@ const char SCA_ISensor::GetLevel_doc[] =
"\tA edge detector will wait for a state change before generating a pulse.\n";
PyObject* SCA_ISensor::PyGetLevel(PyObject* self)
{
+ ShowDeprecationWarning("getLevel()", "the level property");
return BoolToPyArg(m_level);
}
@@ -401,6 +348,7 @@ const char SCA_ISensor::SetLevel_doc[] =
"\tSet whether to detect level or edge transition when entering a state.\n";
PyObject* SCA_ISensor::PySetLevel(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("setLevel()", "the level property");
int pyarg = 0;
if(!PyArg_ParseTuple(args, "i", &pyarg)) { return NULL; }
m_level = PyArgToBool(pyarg);
@@ -412,6 +360,7 @@ const char SCA_ISensor::GetUseNegPulseMode_doc[] =
"\tReturns whether negative pulse mode is active.\n";
PyObject* SCA_ISensor::PyGetUseNegPulseMode(PyObject* self)
{
+ ShowDeprecationWarning("getUseNegPulseMode()", "the useNegPulseMode property");
return BoolToPyArg(m_neg_pulsemode);
}
@@ -422,21 +371,121 @@ const char SCA_ISensor::SetUseNegPulseMode_doc[] =
"\tSet whether to do pulsing when negative pulses occur.\n";
PyObject* SCA_ISensor::PySetUseNegPulseMode(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("setUseNegPulseMode()", "the useNegPulseMode property");
int pyarg = 0;
if(!PyArg_ParseTuple(args, "i", &pyarg)) { return NULL; }
m_neg_pulsemode = PyArgToBool(pyarg);
Py_Return;
}
+//<------Deprecated
-const char SCA_ISensor::Reset_doc[] =
+KX_PYMETHODDEF_DOC_NOARGS(SCA_ISensor, reset,
"reset()\n"
"\tReset sensor internal state, effect depends on the type of sensor and settings.\n"
-"\tThe sensor is put in its initial state as if it was just activated.\n";
-PyObject* SCA_ISensor::PyReset(PyObject* self)
+"\tThe sensor is put in its initial state as if it was just activated.\n")
{
Init();
Py_Return;
}
+/* ----------------------------------------------- */
+/* Python Integration Hooks */
+/* ----------------------------------------------- */
+
+PyTypeObject SCA_ISensor::Type = {
+ PyObject_HEAD_INIT(&PyType_Type)
+ 0,
+ "SCA_ISensor",
+ sizeof(SCA_ISensor),
+ 0,
+ PyDestructor,
+ 0,
+ __getattr,
+ __setattr,
+ 0, //&MyPyCompare,
+ __repr,
+ 0, //&cvalue_as_number,
+ 0,
+ 0,
+ 0,
+ 0
+};
+
+PyParentObject SCA_ISensor::Parents[] = {
+ &SCA_ISensor::Type,
+ &SCA_ILogicBrick::Type,
+ &CValue::Type,
+ NULL
+};
+PyMethodDef SCA_ISensor::Methods[] = {
+ //Deprecated functions ----->
+ {"isPositive", (PyCFunction) SCA_ISensor::sPyIsPositive,
+ METH_NOARGS, (PY_METHODCHAR)IsPositive_doc},
+ {"isTriggered", (PyCFunction) SCA_ISensor::sPyIsTriggered,
+ METH_VARARGS, (PY_METHODCHAR)IsTriggered_doc},
+ {"getUsePosPulseMode", (PyCFunction) SCA_ISensor::sPyGetUsePosPulseMode,
+ METH_NOARGS, (PY_METHODCHAR)GetUsePosPulseMode_doc},
+ {"setUsePosPulseMode", (PyCFunction) SCA_ISensor::sPySetUsePosPulseMode,
+ METH_VARARGS, (PY_METHODCHAR)SetUsePosPulseMode_doc},
+ {"getFrequency", (PyCFunction) SCA_ISensor::sPyGetFrequency,
+ METH_NOARGS, (PY_METHODCHAR)GetFrequency_doc},
+ {"setFrequency", (PyCFunction) SCA_ISensor::sPySetFrequency,
+ METH_VARARGS, (PY_METHODCHAR)SetFrequency_doc},
+ {"getUseNegPulseMode", (PyCFunction) SCA_ISensor::sPyGetUseNegPulseMode,
+ METH_NOARGS, (PY_METHODCHAR)GetUseNegPulseMode_doc},
+ {"setUseNegPulseMode", (PyCFunction) SCA_ISensor::sPySetUseNegPulseMode,
+ METH_VARARGS, (PY_METHODCHAR)SetUseNegPulseMode_doc},
+ {"getInvert", (PyCFunction) SCA_ISensor::sPyGetInvert,
+ METH_NOARGS, (PY_METHODCHAR)GetInvert_doc},
+ {"setInvert", (PyCFunction) SCA_ISensor::sPySetInvert,
+ METH_VARARGS, (PY_METHODCHAR)SetInvert_doc},
+ {"getLevel", (PyCFunction) SCA_ISensor::sPyGetLevel,
+ METH_NOARGS, (PY_METHODCHAR)GetLevel_doc},
+ {"setLevel", (PyCFunction) SCA_ISensor::sPySetLevel,
+ METH_VARARGS, (PY_METHODCHAR)SetLevel_doc},
+ //<----- Deprecated
+ KX_PYMETHODTABLE_NOARGS(SCA_ISensor, reset),
+ {NULL,NULL} //Sentinel
+};
+
+PyAttributeDef SCA_ISensor::Attributes[] = {
+ KX_PYATTRIBUTE_BOOL_RW("usePosPulseMode",SCA_ISensor,m_pos_pulsemode),
+ KX_PYATTRIBUTE_BOOL_RW("useNegPulseMode",SCA_ISensor,m_neg_pulsemode),
+ KX_PYATTRIBUTE_INT_RW("frequency",0,100000,true,SCA_ISensor,m_pulse_frequency),
+ KX_PYATTRIBUTE_BOOL_RW("invert",SCA_ISensor,m_invert),
+ KX_PYATTRIBUTE_BOOL_RW("level",SCA_ISensor,m_level),
+ // make these properties read-only in _setaddr, must still implement them in _getattr
+ KX_PYATTRIBUTE_DUMMY("triggered"),
+ KX_PYATTRIBUTE_DUMMY("positive"),
+ { NULL } //Sentinel
+};
+PyObject*
+SCA_ISensor::_getattr(const STR_String& attr)
+{
+ PyObject* object = _getattr_self(Attributes, this, attr);
+ if (object != NULL)
+ return object;
+ if (attr == "triggered")
+ {
+ int retval = 0;
+ if (SCA_PythonController::m_sCurrentController)
+ retval = SCA_PythonController::m_sCurrentController->IsTriggered(this);
+ return PyInt_FromLong(retval);
+ }
+ if (attr == "positive")
+ {
+ int retval = IsPositiveTrigger();
+ return PyInt_FromLong(retval);
+ }
+ _getattr_up(SCA_ILogicBrick);
+}
+
+int SCA_ISensor::_setattr(const STR_String& attr, PyObject *value)
+{
+ int ret = _setattr_self(Attributes, this, attr, value);
+ if (ret >= 0)
+ return ret;
+ return SCA_ILogicBrick::_setattr(attr, value);
+}
/* eof */
diff --git a/source/gameengine/GameLogic/SCA_ISensor.h b/source/gameengine/GameLogic/SCA_ISensor.h
index d1872009291..1b57c4621e4 100644
--- a/source/gameengine/GameLogic/SCA_ISensor.h
+++ b/source/gameengine/GameLogic/SCA_ISensor.h
@@ -93,8 +93,7 @@ public:
virtual bool Evaluate(CValue* event) = 0;
virtual bool IsPositiveTrigger();
virtual void Init();
-
- virtual PyObject* _getattr(const STR_String& attr);
+
virtual CValue* GetReplica()=0;
/** Set parameters for the pulsing behaviour.
@@ -141,6 +140,11 @@ public:
{ return !m_links; }
/* Python functions: */
+
+ virtual PyObject* _getattr(const STR_String& attr);
+ virtual int _setattr(const STR_String& attr, PyObject *value);
+
+ //Deprecated functions ----->
KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,IsPositive);
KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,IsTriggered);
KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,GetUsePosPulseMode);
@@ -153,8 +157,8 @@ public:
KX_PYMETHOD_DOC(SCA_ISensor,SetInvert);
KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,GetLevel);
KX_PYMETHOD_DOC(SCA_ISensor,SetLevel);
- KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,Reset);
-
+ //<------
+ KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,reset);
};
#endif //__SCA_ISENSOR
diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp
index 8b96840b149..694bca9bac5 100644
--- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp
@@ -304,6 +304,7 @@ PyParentObject SCA_JoystickSensor::Parents[] = {
PyMethodDef SCA_JoystickSensor::Methods[] = {
+ //Deprecated functions ------>
{"getIndex", (PyCFunction) SCA_JoystickSensor::sPyGetIndex, METH_NOARGS, (PY_METHODCHAR)GetIndex_doc},
{"setIndex", (PyCFunction) SCA_JoystickSensor::sPySetIndex, METH_O, (PY_METHODCHAR)SetIndex_doc},
{"getAxis", (PyCFunction) SCA_JoystickSensor::sPyGetAxis, METH_NOARGS, (PY_METHODCHAR)GetAxis_doc},
@@ -313,27 +314,76 @@ PyMethodDef SCA_JoystickSensor::Methods[] = {
{"setThreshold", (PyCFunction) SCA_JoystickSensor::sPySetThreshold, METH_VARARGS, (PY_METHODCHAR)SetThreshold_doc},
{"getButton", (PyCFunction) SCA_JoystickSensor::sPyGetButton, METH_NOARGS, (PY_METHODCHAR)GetButton_doc},
{"setButton", (PyCFunction) SCA_JoystickSensor::sPySetButton, METH_O, (PY_METHODCHAR)SetButton_doc},
- {"getButtonValue",(PyCFunction) SCA_JoystickSensor::sPyGetButtonValue, METH_NOARGS,(PY_METHODCHAR)GetButtonValue_doc},
{"getHat", (PyCFunction) SCA_JoystickSensor::sPyGetHat, METH_NOARGS, (PY_METHODCHAR)GetHat_doc},
{"setHat", (PyCFunction) SCA_JoystickSensor::sPySetHat, METH_VARARGS, (PY_METHODCHAR)SetHat_doc},
{"getNumAxes", (PyCFunction) SCA_JoystickSensor::sPyNumberOfAxes, METH_NOARGS, (PY_METHODCHAR)NumberOfAxes_doc},
{"getNumButtons",(PyCFunction) SCA_JoystickSensor::sPyNumberOfButtons,METH_NOARGS, (PY_METHODCHAR)NumberOfButtons_doc},
{"getNumHats", (PyCFunction) SCA_JoystickSensor::sPyNumberOfHats, METH_NOARGS, (PY_METHODCHAR)NumberOfHats_doc},
{"isConnected", (PyCFunction) SCA_JoystickSensor::sPyConnected, METH_NOARGS, (PY_METHODCHAR)Connected_doc},
+ {"getButtonValue",(PyCFunction) SCA_JoystickSensor::sPyGetButtonValue, METH_NOARGS,(PY_METHODCHAR)GetButtonValue_doc},
+ //<----- Deprecated
+ {"getButtonActiveList",(PyCFunction) SCA_JoystickSensor::sPyGetButtonActiveList, METH_NOARGS,(PY_METHODCHAR)GetButtonActiveList_doc},
+ {"getButtonStatus",(PyCFunction) SCA_JoystickSensor::sPyGetButtonStatus, METH_VARARGS,(PY_METHODCHAR)GetButtonStatus_doc},
{NULL,NULL} //Sentinel
};
+PyAttributeDef SCA_JoystickSensor::Attributes[] = {
+ KX_PYATTRIBUTE_SHORT_RW("index",0,JOYINDEX_MAX-1,true,SCA_JoystickSensor,m_joyindex),
+ KX_PYATTRIBUTE_INT_RW("threshold",0,32768,true,SCA_JoystickSensor,m_precision),
+ KX_PYATTRIBUTE_INT_RW("button",0,100,false,SCA_JoystickSensor,m_button),
+ KX_PYATTRIBUTE_INT_ARRAY_RW_CHECK("axis",0,3,true,SCA_JoystickSensor,m_axis,2,CheckAxis),
+ KX_PYATTRIBUTE_INT_ARRAY_RW_CHECK("hat",0,12,true,SCA_JoystickSensor,m_hat,2,CheckHat),
+ // dummy attributes will just be read-only in _setattr
+ // you still need to defined them in _getattr
+ KX_PYATTRIBUTE_DUMMY("axisPosition"),
+ KX_PYATTRIBUTE_DUMMY("numAxis"),
+ KX_PYATTRIBUTE_DUMMY("numButtons"),
+ KX_PYATTRIBUTE_DUMMY("numHats"),
+ KX_PYATTRIBUTE_DUMMY("connected"),
+ { NULL } //Sentinel
+};
PyObject* SCA_JoystickSensor::_getattr(const STR_String& attr) {
+ SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
+ if (attr == "axisPosition") {
+ if(joy)
+ return Py_BuildValue("[iiii]", joy->GetAxis10(), joy->GetAxis11(), joy->GetAxis20(), joy->GetAxis21());
+ else
+ return Py_BuildValue("[iiii]", 0, 0, 0, 0);
+ }
+ if (attr == "numAxis") {
+ return PyInt_FromLong( joy ? joy->GetNumberOfAxes() : 0 );
+ }
+ if (attr == "numButtons") {
+ return PyInt_FromLong( joy ? joy->GetNumberOfButtons() : 0 );
+ }
+ if (attr == "numHats") {
+ return PyInt_FromLong( joy ? joy->GetNumberOfHats() : 0 );
+ }
+ if (attr == "connected") {
+ return PyBool_FromLong( joy ? joy->Connected() : 0 );
+ }
+ PyObject* object = _getattr_self(Attributes, this, attr);
+ if (object != NULL)
+ return object;
_getattr_up(SCA_ISensor);
}
+int SCA_JoystickSensor::_setattr(const STR_String& attr, PyObject *value)
+{
+ int ret = _setattr_self(Attributes, this, attr, value);
+ if (ret >= 0)
+ return ret;
+ return SCA_ISensor::_setattr(attr, value);
+}
+
/* get index ---------------------------------------------------------- */
const char SCA_JoystickSensor::GetIndex_doc[] =
"getIndex\n"
"\tReturns the joystick index to use.\n";
PyObject* SCA_JoystickSensor::PyGetIndex( PyObject* self ) {
+ ShowDeprecationWarning("getIndex()", "the index property");
return PyInt_FromLong(m_joyindex);
}
@@ -343,6 +393,7 @@ const char SCA_JoystickSensor::SetIndex_doc[] =
"setIndex\n"
"\tSets the joystick index to use.\n";
PyObject* SCA_JoystickSensor::PySetIndex( PyObject* self, PyObject* value ) {
+ ShowDeprecationWarning("setIndex()", "the index property");
int index = PyInt_AsLong( value ); /* -1 on error, will raise an error in this case */
if (index < 0 || index >= JOYINDEX_MAX) {
PyErr_SetString(PyExc_ValueError, "joystick index out of range or not an int");
@@ -358,6 +409,7 @@ const char SCA_JoystickSensor::GetAxis_doc[] =
"getAxis\n"
"\tReturns the current axis this sensor reacts to.\n";
PyObject* SCA_JoystickSensor::PyGetAxis( PyObject* self) {
+ ShowDeprecationWarning("getAxis()", "the axis property");
return Py_BuildValue("[ii]",m_axis, m_axisf);
}
@@ -367,6 +419,7 @@ const char SCA_JoystickSensor::SetAxis_doc[] =
"setAxis\n"
"\tSets the current axis this sensor reacts to.\n";
PyObject* SCA_JoystickSensor::PySetAxis( PyObject* self, PyObject* args ) {
+ ShowDeprecationWarning("setAxis()", "the axis property");
int axis,axisflag;
if(!PyArg_ParseTuple(args, "ii", &axis, &axisflag)){
@@ -383,6 +436,7 @@ const char SCA_JoystickSensor::GetAxisValue_doc[] =
"getAxisValue\n"
"\tReturns a list of the values for the current state of each axis.\n";
PyObject* SCA_JoystickSensor::PyGetAxisValue( PyObject* self) {
+ ShowDeprecationWarning("getAxisValue()", "the axisPosition property");
SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
if(joy)
return Py_BuildValue("[iiii]", joy->GetAxis10(), joy->GetAxis11(), joy->GetAxis20(), joy->GetAxis21());
@@ -396,6 +450,7 @@ const char SCA_JoystickSensor::GetThreshold_doc[] =
"getThreshold\n"
"\tReturns the threshold of the axis.\n";
PyObject* SCA_JoystickSensor::PyGetThreshold( PyObject* self) {
+ ShowDeprecationWarning("getThreshold()", "the threshold property");
return PyInt_FromLong(m_precision);
}
@@ -405,6 +460,7 @@ const char SCA_JoystickSensor::SetThreshold_doc[] =
"setThreshold\n"
"\tSets the threshold of the axis.\n";
PyObject* SCA_JoystickSensor::PySetThreshold( PyObject* self, PyObject* args ) {
+ ShowDeprecationWarning("setThreshold()", "the threshold property");
int thresh;
if(!PyArg_ParseTuple(args, "i", &thresh)){
return NULL;
@@ -418,6 +474,7 @@ const char SCA_JoystickSensor::GetButton_doc[] =
"getButton\n"
"\tReturns the current button this sensor is checking.\n";
PyObject* SCA_JoystickSensor::PyGetButton( PyObject* self) {
+ ShowDeprecationWarning("getButton()", "the button property");
return PyInt_FromLong(m_button);
}
@@ -426,6 +483,7 @@ const char SCA_JoystickSensor::SetButton_doc[] =
"setButton\n"
"\tSets the button the sensor reacts to.\n";
PyObject* SCA_JoystickSensor::PySetButton( PyObject* self, PyObject* value ) {
+ ShowDeprecationWarning("setButton()", "the button property");
int button = PyInt_AsLong(value);
if(button==-1 && PyErr_Occurred()) {
PyErr_SetString(PyExc_ValueError, "expected an int");
@@ -440,6 +498,15 @@ const char SCA_JoystickSensor::GetButtonValue_doc[] =
"getButtonValue\n"
"\tReturns a list containing the indicies of the current pressed state of each button.\n";
PyObject* SCA_JoystickSensor::PyGetButtonValue( PyObject* self) {
+ ShowDeprecationWarning("getButtonValue()", "getButtonActiveList");
+ return PyGetButtonActiveList(self);
+}
+
+/* get button active list -------------------------------------------------- */
+const char SCA_JoystickSensor::GetButtonActiveList_doc[] =
+"getButtonActiveList\n"
+"\tReturns a list containing the indicies of the button currently pressed.\n";
+PyObject* SCA_JoystickSensor::PyGetButtonActiveList( PyObject* self) {
SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
PyObject *ls = PyList_New(0);
PyObject *value;
@@ -457,11 +524,30 @@ PyObject* SCA_JoystickSensor::PyGetButtonValue( PyObject* self) {
return ls;
}
+/* get button status -------------------------------------------------- */
+const char SCA_JoystickSensor::GetButtonStatus_doc[] =
+"getButtonStatus(buttonIndex)\n"
+"\tReturns a bool of the current pressed state of the specified button.\n";
+PyObject* SCA_JoystickSensor::PyGetButtonStatus( PyObject* self, PyObject* args ) {
+ SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
+ PyObject *value;
+ int index;
+
+ if(!PyArg_ParseTuple(args, "i", &index)){
+ return NULL;
+ }
+ if(joy && index >= 0 && index < joy->GetNumberOfButtons()) {
+ return PyBool_FromLong(joy->aButtonPressIsPositive(index) ? 1 : 0);
+ }
+ return PyBool_FromLong(0);
+}
+
/* get hat ----------------------------------------------------------- */
const char SCA_JoystickSensor::GetHat_doc[] =
"getHat\n"
"\tReturns the current direction of the hat.\n";
PyObject* SCA_JoystickSensor::PyGetHat( PyObject* self ) {
+ ShowDeprecationWarning("getHat()", "the hat property");
return Py_BuildValue("[ii]",m_hat, m_hatf);
}
@@ -471,6 +557,7 @@ const char SCA_JoystickSensor::SetHat_doc[] =
"setHat\n"
"\tSets the hat the sensor reacts to.\n";
PyObject* SCA_JoystickSensor::PySetHat( PyObject* self, PyObject* args ) {
+ ShowDeprecationWarning("setHat()", "the hat property");
int hat,hatflag;
if(!PyArg_ParseTuple(args, "ii", &hat, &hatflag)){
return NULL;
@@ -486,6 +573,7 @@ const char SCA_JoystickSensor::NumberOfAxes_doc[] =
"getNumAxes\n"
"\tReturns the number of axes .\n";
PyObject* SCA_JoystickSensor::PyNumberOfAxes( PyObject* self ) {
+ ShowDeprecationWarning("getNumAxes()", "the numAxis property");
SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
// when the joystick is null their is 0 exis still. dumb but scripters should use isConnected()
return PyInt_FromLong( joy ? joy->GetNumberOfAxes() : 0 );
@@ -496,6 +584,7 @@ const char SCA_JoystickSensor::NumberOfButtons_doc[] =
"getNumButtons\n"
"\tReturns the number of buttons .\n";
PyObject* SCA_JoystickSensor::PyNumberOfButtons( PyObject* self ) {
+ ShowDeprecationWarning("getNumButtons()", "the numButtons property");
SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
return PyInt_FromLong( joy ? joy->GetNumberOfButtons() : 0 );
}
@@ -505,6 +594,7 @@ const char SCA_JoystickSensor::NumberOfHats_doc[] =
"getNumHats\n"
"\tReturns the number of hats .\n";
PyObject* SCA_JoystickSensor::PyNumberOfHats( PyObject* self ) {
+ ShowDeprecationWarning("getNumHats()", "the numHats property");
SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
return PyInt_FromLong( joy ? joy->GetNumberOfHats() : 0 );
}
@@ -513,6 +603,7 @@ const char SCA_JoystickSensor::Connected_doc[] =
"getConnected\n"
"\tReturns True if a joystick is connected at this joysticks index.\n";
PyObject* SCA_JoystickSensor::PyConnected( PyObject* self ) {
+ ShowDeprecationWarning("getConnected()", "the connected property");
SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
return PyBool_FromLong( joy ? joy->Connected() : 0 );
}
diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.h b/source/gameengine/GameLogic/SCA_JoystickSensor.h
index d316ad1119c..fa11f1cc3d0 100644
--- a/source/gameengine/GameLogic/SCA_JoystickSensor.h
+++ b/source/gameengine/GameLogic/SCA_JoystickSensor.h
@@ -37,11 +37,11 @@ class SCA_JoystickSensor :public SCA_ISensor
class SCA_JoystickManager* m_pJoystickMgr;
/**
- * Axis 1-or-2
+ * Axis 1-or-2, MUST be followed by m_axisf
*/
int m_axis;
/**
- * Axis flag to find direction
+ * Axis flag to find direction, MUST be an int
*/
int m_axisf;
/**
@@ -53,11 +53,11 @@ class SCA_JoystickSensor :public SCA_ISensor
*/
int m_buttonf;
/**
- * The actual hat
+ * The actual hat. MUST be followed by m_hatf
*/
int m_hat;
/**
- * Flag to find direction 1-12
+ * Flag to find direction 0-11, MUST be an int
*/
int m_hatf;
/**
@@ -122,6 +122,7 @@ public:
/* --------------------------------------------------------------------- */
virtual PyObject* _getattr(const STR_String& attr);
+ virtual int _setattr(const STR_String& attr, PyObject *value);
/* Joystick Index */
KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetIndex);
@@ -136,6 +137,8 @@ public:
KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetButton);
KX_PYMETHOD_DOC_O(SCA_JoystickSensor,SetButton);
KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetButtonValue);
+ KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetButtonActiveList);
+ KX_PYMETHOD_DOC_VARARGS(SCA_JoystickSensor,GetButtonStatus);
/* Hats */
KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetHat);
KX_PYMETHOD_DOC_VARARGS(SCA_JoystickSensor,SetHat);
@@ -144,6 +147,26 @@ public:
KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,NumberOfButtons);
KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,NumberOfHats);
KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,Connected);
+
+ /* attribute check */
+ static int CheckAxis(void *self, const PyAttributeDef*)
+ {
+ SCA_JoystickSensor* sensor = reinterpret_cast<SCA_JoystickSensor*>(self);
+ if (sensor->m_axis < 1)
+ sensor->m_axis = 1;
+ else if (sensor->m_axis > 2)
+ sensor->m_axis = 2;
+ return 0;
+ }
+ static int CheckHat(void *self, const PyAttributeDef*)
+ {
+ SCA_JoystickSensor* sensor = reinterpret_cast<SCA_JoystickSensor*>(self);
+ if (sensor->m_hat < 1)
+ sensor->m_hat = 1;
+ else if (sensor->m_hat > 2)
+ sensor->m_hat = 2;
+ return 0;
+ }
};
diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
index fa39a13679f..981d165287b 100644
--- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
@@ -545,42 +545,17 @@ void SCA_KeyboardSensor::LogKeystrokes(void)
/* ------------------------------------------------------------------------- */
-/* Python functions : specific */
+/* Python Functions */
/* ------------------------------------------------------------------------- */
-
-PyObject* SCA_KeyboardSensor::PySetAllMode(PyObject* self,
- PyObject* args,
- PyObject* kwds)
-{
- bool allkeys;
-
- if (!PyArg_ParseTuple(args, "i", &allkeys))
- {
- return NULL;
- }
-
- m_bAllKeys = allkeys;
- Py_Return
-}
-
-
-
-PyObject* SCA_KeyboardSensor::sPySetAllMode(PyObject* self,
- PyObject* args,
- PyObject* kwds)
-{
-// printf("sPyIsPositive\n");
- return ((SCA_KeyboardSensor*) self)->PyIsPositive(self);
-}
-
-
+//Deprecated ----->
/** 1. GetKey : check which key this sensor looks at */
const char SCA_KeyboardSensor::GetKey_doc[] =
"getKey()\n"
"\tReturn the code of the key this sensor is listening to.\n" ;
PyObject* SCA_KeyboardSensor::PyGetKey(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("getKey()", "the key property");
return PyInt_FromLong(m_hotkey);
}
@@ -591,6 +566,7 @@ const char SCA_KeyboardSensor::SetKey_doc[] =
"\tSet the key this sensor should listen to.\n" ;
PyObject* SCA_KeyboardSensor::PySetKey(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("setKey()", "the key property");
int keyCode;
if(!PyArg_ParseTuple(args, "i", &keyCode)) {
@@ -611,6 +587,7 @@ const char SCA_KeyboardSensor::GetHold1_doc[] =
"\tsensor is listening to.\n" ;
PyObject* SCA_KeyboardSensor::PyGetHold1(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("getHold1()", "the hold1 property");
return PyInt_FromLong(m_qual);
}
@@ -621,6 +598,7 @@ const char SCA_KeyboardSensor::SetHold1_doc[] =
"\tSet the first modifier to the key this sensor should listen to.\n" ;
PyObject* SCA_KeyboardSensor::PySetHold1(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("setHold1()", "the hold1 property");
int keyCode;
if(!PyArg_ParseTuple(args, "i", &keyCode)) {
@@ -641,6 +619,7 @@ const char SCA_KeyboardSensor::GetHold2_doc[] =
"\tsensor is listening to.\n" ;
PyObject* SCA_KeyboardSensor::PyGetHold2(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("getHold2()", "the hold2 property");
return PyInt_FromLong(m_qual2);
}
@@ -651,6 +630,7 @@ const char SCA_KeyboardSensor::SetHold2_doc[] =
"\tSet the first modifier to the key this sensor should listen to.\n" ;
PyObject* SCA_KeyboardSensor::PySetHold2(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("setHold2()", "the hold2 property");
int keyCode;
if(!PyArg_ParseTuple(args, "i", &keyCode)) {
@@ -671,6 +651,8 @@ const char SCA_KeyboardSensor::GetPressedKeys_doc[] =
PyObject* SCA_KeyboardSensor::PyGetPressedKeys(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("getPressedKeys()", "getEventList()");
+
SCA_IInputDevice* inputdev = m_pKeyboardMgr->GetInputDevice();
int num = inputdev->GetNumJustEvents();
@@ -711,6 +693,8 @@ const char SCA_KeyboardSensor::GetCurrentlyPressedKeys_doc[] =
PyObject* SCA_KeyboardSensor::PyGetCurrentlyPressedKeys(PyObject* self, PyObject* args, PyObject* kwds)
{
+ShowDeprecationWarning("getCurrentlyPressedKeys()", "getEventList()");
+
SCA_IInputDevice* inputdev = m_pKeyboardMgr->GetInputDevice();
int num = inputdev->GetNumActiveEvents();
@@ -743,9 +727,54 @@ SCA_IInputDevice* inputdev = m_pKeyboardMgr->GetInputDevice();
Py_Return;
}
+//<---- Deprecated
+
+KX_PYMETHODDEF_DOC_NOARGS(SCA_KeyboardSensor, getEventList,
+"getEventList()\n"
+"\tGet the list of the keyboard events in this frame.\n")
+{
+ SCA_IInputDevice* inputdev = m_pKeyboardMgr->GetInputDevice();
+
+ PyObject* resultlist = PyList_New(0);
+
+ for (int i=SCA_IInputDevice::KX_BEGINKEY ; i< SCA_IInputDevice::KX_ENDKEY;i++)
+ {
+ const SCA_InputEvent & inevent = inputdev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) i);
+ if (inevent.m_status != SCA_InputEvent::KX_NO_INPUTSTATUS)
+ {
+ PyObject* keypair = PyList_New(2);
+ PyList_SetItem(keypair,0,PyInt_FromLong(i));
+ PyList_SetItem(keypair,1,PyInt_FromLong(inevent.m_status));
+ PyList_Append(resultlist,keypair);
+ }
+ }
+ return resultlist;
+}
+
+KX_PYMETHODDEF_DOC_O(SCA_KeyboardSensor, getKeyStatus,
+"getKeyStatus(keycode)\n"
+"\tGet the given key's status (KX_NO_INPUTSTATUS, KX_JUSTACTIVATED, KX_ACTIVE or KX_JUSTRELEASED).\n")
+{
+ if (PyInt_Check(value))
+ {
+ int keycode = PyInt_AsLong(value);
+
+ if ((keycode < SCA_IInputDevice::KX_BEGINKEY)
+ || (keycode > SCA_IInputDevice::KX_ENDKEY)){
+ PyErr_SetString(PyExc_AttributeError, "invalid keycode specified!");
+ return NULL;
+ }
+
+ SCA_IInputDevice* inputdev = m_pKeyboardMgr->GetInputDevice();
+ const SCA_InputEvent & inevent = inputdev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) keycode);
+ return PyInt_FromLong(inevent.m_status);
+ }
+
+ Py_Return;
+}
/* ------------------------------------------------------------------------- */
-/* Python functions : integration hooks */
+/* Python Integration Hooks */
/* ------------------------------------------------------------------------- */
PyTypeObject SCA_KeyboardSensor::Type = {
@@ -776,23 +805,44 @@ PyParentObject SCA_KeyboardSensor::Parents[] = {
};
PyMethodDef SCA_KeyboardSensor::Methods[] = {
- {"getKey", (PyCFunction) SCA_KeyboardSensor::sPyGetKey, METH_VARARGS, (PY_METHODCHAR)GetKey_doc},
- {"setKey", (PyCFunction) SCA_KeyboardSensor::sPySetKey, METH_VARARGS, (PY_METHODCHAR)SetKey_doc},
- {"getHold1", (PyCFunction) SCA_KeyboardSensor::sPyGetHold1, METH_VARARGS, (PY_METHODCHAR)GetHold1_doc},
- {"setHold1", (PyCFunction) SCA_KeyboardSensor::sPySetHold1, METH_VARARGS, (PY_METHODCHAR)SetHold1_doc},
- {"getHold2", (PyCFunction) SCA_KeyboardSensor::sPyGetHold2, METH_VARARGS, (PY_METHODCHAR)GetHold2_doc},
- {"setHold2", (PyCFunction) SCA_KeyboardSensor::sPySetHold2, METH_VARARGS, (PY_METHODCHAR)SetHold2_doc},
-// {"getUseAllKeys", (PyCFunction) SCA_KeyboardSensor::sPyGetUseAllKeys, METH_VARARGS, (PY_METHODCHAR)GetUseAllKeys_doc},
-// {"setUseAllKeys", (PyCFunction) SCA_KeyboardSensor::sPySetUseAllKeys, METH_VARARGS, (PY_METHODCHAR)SetUseAllKeys_doc},
- {"getPressedKeys", (PyCFunction) SCA_KeyboardSensor::sPyGetPressedKeys, METH_VARARGS, (PY_METHODCHAR)GetPressedKeys_doc},
- {"getCurrentlyPressedKeys", (PyCFunction) SCA_KeyboardSensor::sPyGetCurrentlyPressedKeys, METH_VARARGS, (PY_METHODCHAR)GetCurrentlyPressedKeys_doc},
-// {"getKeyEvents", (PyCFunction) SCA_KeyboardSensor::sPyGetKeyEvents, METH_VARARGS, (PY_METHODCHAR)GetKeyEvents_doc},
- {NULL,NULL} //Sentinel
+ //Deprecated functions ------>
+ {"getKey", (PyCFunction) SCA_KeyboardSensor::sPyGetKey, METH_VARARGS, (PY_METHODCHAR)GetKey_doc},
+ {"setKey", (PyCFunction) SCA_KeyboardSensor::sPySetKey, METH_VARARGS, (PY_METHODCHAR)SetKey_doc},
+ {"getHold1", (PyCFunction) SCA_KeyboardSensor::sPyGetHold1, METH_VARARGS, (PY_METHODCHAR)GetHold1_doc},
+ {"setHold1", (PyCFunction) SCA_KeyboardSensor::sPySetHold1, METH_VARARGS, (PY_METHODCHAR)SetHold1_doc},
+ {"getHold2", (PyCFunction) SCA_KeyboardSensor::sPyGetHold2, METH_VARARGS, (PY_METHODCHAR)GetHold2_doc},
+ {"setHold2", (PyCFunction) SCA_KeyboardSensor::sPySetHold2, METH_VARARGS, (PY_METHODCHAR)SetHold2_doc},
+ {"getPressedKeys", (PyCFunction) SCA_KeyboardSensor::sPyGetPressedKeys, METH_VARARGS, (PY_METHODCHAR)GetPressedKeys_doc},
+ {"getCurrentlyPressedKeys", (PyCFunction) SCA_KeyboardSensor::sPyGetCurrentlyPressedKeys, METH_VARARGS, (PY_METHODCHAR)GetCurrentlyPressedKeys_doc},
+ //<----- Deprecated
+ KX_PYMETHODTABLE_NOARGS(SCA_KeyboardSensor, getEventList),
+ KX_PYMETHODTABLE_O(SCA_KeyboardSensor, getKeyStatus),
+ {NULL,NULL} //Sentinel
+};
+
+PyAttributeDef SCA_KeyboardSensor::Attributes[] = {
+ KX_PYATTRIBUTE_BOOL_RW("useAllKeys",SCA_KeyboardSensor,m_bAllKeys),
+ KX_PYATTRIBUTE_INT_RW("key",0,SCA_IInputDevice::KX_ENDKEY,true,SCA_KeyboardSensor,m_hotkey),
+ KX_PYATTRIBUTE_SHORT_RW("hold1",0,SCA_IInputDevice::KX_ENDKEY,true,SCA_KeyboardSensor,m_qual),
+ KX_PYATTRIBUTE_SHORT_RW("hold2",0,SCA_IInputDevice::KX_ENDKEY,true,SCA_KeyboardSensor,m_qual2),
+ KX_PYATTRIBUTE_STRING_RW("toggleProperty",0,100,false,SCA_KeyboardSensor,m_toggleprop),
+ KX_PYATTRIBUTE_STRING_RW("targetProperty",0,100,false,SCA_KeyboardSensor,m_targetprop),
+ { NULL } //Sentinel
};
PyObject*
SCA_KeyboardSensor::_getattr(const STR_String& attr)
{
+ PyObject* object = _getattr_self(Attributes, this, attr);
+ if (object != NULL)
+ return object;
_getattr_up(SCA_ISensor);
}
+int SCA_KeyboardSensor::_setattr(const STR_String& attr, PyObject *value)
+{
+ int ret = _setattr_self(Attributes, this, attr, value);
+ if (ret >= 0)
+ return ret;
+ return SCA_ISensor::_setattr(attr, value);
+}
diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.h b/source/gameengine/GameLogic/SCA_KeyboardSensor.h
index b86f6931d27..4efbe9366cc 100644
--- a/source/gameengine/GameLogic/SCA_KeyboardSensor.h
+++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.h
@@ -127,15 +127,9 @@ public:
/* --------------------------------------------------------------------- */
virtual PyObject* _getattr(const STR_String& attr);
+ virtual int _setattr(const STR_String& attr, PyObject *value);
-
- PyObject* PySetAllMode(PyObject* self,
- PyObject* args,
- PyObject* kwds);
- static PyObject* sPySetAllMode(PyObject* self,
- PyObject* args,
- PyObject* kwds);
-
+ //Deprecated functions ----->
/** 1. GetKey : check which key this sensor looks at */
KX_PYMETHOD_DOC(SCA_KeyboardSensor,GetKey);
/** 2. SetKey: change the key to look at */
@@ -152,6 +146,12 @@ public:
KX_PYMETHOD_DOC(SCA_KeyboardSensor,GetPressedKeys);
/** 9. GetCurrrentlyPressedKeys: */
KX_PYMETHOD_DOC(SCA_KeyboardSensor,GetCurrentlyPressedKeys);
+ // <------
+
+ // KeyEvents:
+ KX_PYMETHOD_DOC_NOARGS(SCA_KeyboardSensor,getEventList);
+ // KeyStatus:
+ KX_PYMETHOD_DOC_O(SCA_KeyboardSensor,getKeyStatus);
};
#endif //__KX_KEYBOARDSENSOR
diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.cpp b/source/gameengine/GameLogic/SCA_MouseSensor.cpp
index d4952ce4777..09b46e6443e 100644
--- a/source/gameengine/GameLogic/SCA_MouseSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_MouseSensor.cpp
@@ -25,7 +25,7 @@
*
* The Original Code is: all of this file.
*
- * Contributor(s): none yet.
+ * Contributor(s): José I. Romero (cleanup and fixes)
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -59,25 +59,7 @@ SCA_MouseSensor::SCA_MouseSensor(SCA_MouseManager* eventmgr,
m_mousemode = mousemode;
m_triggermode = true;
- switch (m_mousemode) {
- case KX_MOUSESENSORMODE_LEFTBUTTON:
- m_hotkey = SCA_IInputDevice::KX_LEFTMOUSE;
- break;
- case KX_MOUSESENSORMODE_MIDDLEBUTTON:
- m_hotkey = SCA_IInputDevice::KX_MIDDLEMOUSE;
- break;
- case KX_MOUSESENSORMODE_RIGHTBUTTON:
- m_hotkey = SCA_IInputDevice::KX_RIGHTMOUSE;
- break;
- case KX_MOUSESENSORMODE_WHEELUP:
- m_hotkey = SCA_IInputDevice::KX_WHEELUPMOUSE;
- break;
- case KX_MOUSESENSORMODE_WHEELDOWN:
- m_hotkey = SCA_IInputDevice::KX_WHEELDOWNMOUSE;
- break;
- default:
- ; /* ignore, no hotkey */
- }
+ UpdateHotkey(this, NULL);
Init();
}
@@ -92,7 +74,38 @@ SCA_MouseSensor::~SCA_MouseSensor()
/* Nothing to be done here. */
}
-
+int SCA_MouseSensor::UpdateHotkey(void *self, const PyAttributeDef*)
+{
+ // gosh, this function is so damn stupid
+ // its here because of a design mistake in the mouse sensor, it should only
+ // have 3 trigger modes (button, wheel, move), and let the user set the
+ // hotkey separately, like the other sensors. but instead it has a mode for
+ // each friggin key and i have to update the hotkey based on it... genius!
+ SCA_MouseSensor* sensor = reinterpret_cast<SCA_MouseSensor*>(self);
+
+ switch (sensor->m_mousemode) {
+ case KX_MOUSESENSORMODE_LEFTBUTTON:
+ sensor->m_hotkey = SCA_IInputDevice::KX_LEFTMOUSE;
+ break;
+ case KX_MOUSESENSORMODE_MIDDLEBUTTON:
+ sensor->m_hotkey = SCA_IInputDevice::KX_MIDDLEMOUSE;
+ break;
+ case KX_MOUSESENSORMODE_RIGHTBUTTON:
+ sensor->m_hotkey = SCA_IInputDevice::KX_RIGHTMOUSE;
+ break;
+ case KX_MOUSESENSORMODE_WHEELUP:
+ sensor->m_hotkey = SCA_IInputDevice::KX_WHEELUPMOUSE;
+ break;
+ case KX_MOUSESENSORMODE_WHEELDOWN:
+ sensor->m_hotkey = SCA_IInputDevice::KX_WHEELDOWNMOUSE;
+ break;
+ default:
+ ; /* ignore, no hotkey */
+ }
+ // return value is used in _setattr(),
+ // 0=attribute checked ok (see Attributes array definition)
+ return 0;
+}
CValue* SCA_MouseSensor::GetReplica()
{
@@ -137,15 +150,6 @@ bool SCA_MouseSensor::Evaluate(CValue* event)
bool reset = m_reset && m_level;
SCA_IInputDevice* mousedev = m_pMouseMgr->GetInputDevice();
-
-
-// SCA_ILogicBrick::RegisterEvent(event);
-// if (m_mousemode == KX_MOUSESENSORMODE_MOVEMENT) cout << "\nChecking for movement...";
-//CValue* val = event->GetProperty("val");
-
- /* both MOUSEX and MOUSEY. Treat all of these as key-presses. */
- /* So, treat KX_MOUSESENSORMODE_POSITION as */
- /* KX_MOUSESENSORMODE_POSITIONX || KX_MOUSESENSORMODE_POSITIONY */
m_reset = false;
switch (m_mousemode) {
case KX_MOUSESENSORMODE_LEFTBUTTON:
@@ -155,42 +159,34 @@ bool SCA_MouseSensor::Evaluate(CValue* event)
case KX_MOUSESENSORMODE_WHEELDOWN:
{
const SCA_InputEvent& event = mousedev->GetEventValue(m_hotkey);
- if (event.m_status == SCA_InputEvent::KX_JUSTACTIVATED)
- {
+ switch (event.m_status){
+ case SCA_InputEvent::KX_JUSTACTIVATED:
m_val = 1;
result = true;
- } else
- {
- if (event.m_status == SCA_InputEvent::KX_JUSTRELEASED)
+ break;
+ case SCA_InputEvent::KX_JUSTRELEASED:
+ m_val = 0;
+ result = true;
+ break;
+ case SCA_InputEvent::KX_ACTIVE:
+ if (m_val == 0)
+ {
+ m_val = 1;
+ if (m_level)
+ result = true;
+ }
+ break;
+ default:
+ if (m_val == 1)
{
m_val = 0;
result = true;
- } else
- {
- if (event.m_status == SCA_InputEvent::KX_ACTIVE)
- {
- if (m_val == 0)
- {
- m_val = 1;
- if (m_level)
- {
- result = true;
- }
- }
- } else
- {
- if (m_val == 1)
- {
- m_val = 0;
- result = true;
- }
- }
}
+ break;
}
break;
}
case KX_MOUSESENSORMODE_MOVEMENT:
-
{
const SCA_InputEvent& eventX = mousedev->GetEventValue(SCA_IInputDevice::KX_MOUSEX);
const SCA_InputEvent& eventY = mousedev->GetEventValue(SCA_IInputDevice::KX_MOUSEY);
@@ -198,27 +194,26 @@ bool SCA_MouseSensor::Evaluate(CValue* event)
if (eventX.m_status == SCA_InputEvent::KX_JUSTACTIVATED ||
eventY.m_status == SCA_InputEvent::KX_JUSTACTIVATED ||
eventX.m_status == SCA_InputEvent::KX_ACTIVE ||
- eventY.m_status == SCA_InputEvent::KX_ACTIVE)
-
+ eventY.m_status == SCA_InputEvent::KX_ACTIVE)
{
m_val = 1;
result = true;
- } else
- {
- if (eventX.m_status == SCA_InputEvent::KX_JUSTRELEASED ||
+ }
+ else if (eventX.m_status == SCA_InputEvent::KX_JUSTRELEASED ||
eventY.m_status == SCA_InputEvent::KX_JUSTRELEASED )
+ {
+ m_val = 0;
+ result = true;
+ }
+ else //KX_NO_IMPUTSTATUS
+ {
+ if (m_val == 1)
{
m_val = 0;
result = true;
- } else
- {
- if (m_val == 1)
- {
- m_val = 0;
- result = true;
- }
}
}
+
break;
}
default:
@@ -243,18 +238,67 @@ void SCA_MouseSensor::setY(short y)
bool SCA_MouseSensor::isValid(SCA_MouseSensor::KX_MOUSESENSORMODE m)
{
- bool res = false;
+ return ((m > KX_MOUSESENSORMODE_NODEF) && (m < KX_MOUSESENSORMODE_MAX));
+}
- res = ((m > KX_MOUSESENSORMODE_NODEF) && (m < KX_MOUSESENSORMODE_MAX));
+/* ------------------------------------------------------------------------- */
+/* Python functions */
+/* ------------------------------------------------------------------------- */
+
+//Deprecated functions ------>
+/* get x position ---------------------------------------------------------- */
+const char SCA_MouseSensor::GetXPosition_doc[] =
+"getXPosition\n"
+"\tReturns the x-coordinate of the mouse sensor, in frame coordinates.\n"
+"\tThe lower-left corner is the origin. The coordinate is given in\n"
+"\tpixels\n";
+PyObject* SCA_MouseSensor::PyGetXPosition(PyObject* self,
+ PyObject* args,
+ PyObject* kwds) {
+ ShowDeprecationWarning("getXPosition()", "the position property");
+ return PyInt_FromLong(m_x);
+}
+
+/* get y position ---------------------------------------------------------- */
+const char SCA_MouseSensor::GetYPosition_doc[] =
+"getYPosition\n"
+"\tReturns the y-coordinate of the mouse sensor, in frame coordinates.\n"
+"\tThe lower-left corner is the origin. The coordinate is given in\n"
+"\tpixels\n";
+PyObject* SCA_MouseSensor::PyGetYPosition(PyObject* self,
+ PyObject* args,
+ PyObject* kwds) {
+ ShowDeprecationWarning("getYPosition()", "the position property");
+ return PyInt_FromLong(m_y);
+}
+//<----- Deprecated
+
+KX_PYMETHODDEF_DOC_O(SCA_MouseSensor, getButtonStatus,
+"getButtonStatus(button)\n"
+"\tGet the given button's status (KX_NO_INPUTSTATUS, KX_JUSTACTIVATED, KX_ACTIVE or KX_JUSTRELEASED).\n")
+{
+ if (PyInt_Check(value))
+ {
+ int button = PyInt_AsLong(value);
+
+ if ((button < SCA_IInputDevice::KX_LEFTMOUSE)
+ || (button > SCA_IInputDevice::KX_MIDDLEMOUSE)){
+ PyErr_SetString(PyExc_ValueError, "invalid button specified!");
+ return NULL;
+ }
+
+ SCA_IInputDevice* mousedev = m_pMouseMgr->GetInputDevice();
+ const SCA_InputEvent& event = mousedev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) button);
+ return PyInt_FromLong(event.m_status);
+ }
- return res;
+ Py_Return;
}
/* ------------------------------------------------------------------------- */
-/* Python functions */
+/* Python Integration Hooks */
/* ------------------------------------------------------------------------- */
-/* Integration hooks ------------------------------------------------------- */
PyTypeObject SCA_MouseSensor::Type = {
PyObject_HEAD_INIT(&PyType_Type)
0,
@@ -283,37 +327,34 @@ PyParentObject SCA_MouseSensor::Parents[] = {
};
PyMethodDef SCA_MouseSensor::Methods[] = {
+ //Deprecated functions ------>
{"getXPosition", (PyCFunction) SCA_MouseSensor::sPyGetXPosition, METH_VARARGS, (PY_METHODCHAR)GetXPosition_doc},
{"getYPosition", (PyCFunction) SCA_MouseSensor::sPyGetYPosition, METH_VARARGS, (PY_METHODCHAR)GetYPosition_doc},
+ //<----- Deprecated
+ KX_PYMETHODTABLE_O(SCA_MouseSensor, getButtonStatus),
{NULL,NULL} //Sentinel
};
-PyObject* SCA_MouseSensor::_getattr(const STR_String& attr) {
- _getattr_up(SCA_ISensor);
-}
+PyAttributeDef SCA_MouseSensor::Attributes[] = {
+ KX_PYATTRIBUTE_SHORT_RW_CHECK("mode",KX_MOUSESENSORMODE_NODEF,KX_MOUSESENSORMODE_MAX-1,true,SCA_MouseSensor,m_mousemode,UpdateHotkey),
+ KX_PYATTRIBUTE_SHORT_ARRAY_RO("position",SCA_MouseSensor,m_x,2),
+ { NULL } //Sentinel
+};
-/* get x position ---------------------------------------------------------- */
-const char SCA_MouseSensor::GetXPosition_doc[] =
-"getXPosition\n"
-"\tReturns the x-coordinate of the mouse sensor, in frame coordinates.\n"
-"\tThe lower-left corner is the origin. The coordinate is given in\n"
-"\tpixels\n";
-PyObject* SCA_MouseSensor::PyGetXPosition(PyObject* self,
- PyObject* args,
- PyObject* kwds) {
- return PyInt_FromLong(m_x);
+PyObject* SCA_MouseSensor::_getattr(const STR_String& attr)
+{
+ PyObject* object = _getattr_self(Attributes, this, attr);
+ if (object != NULL)
+ return object;
+ _getattr_up(SCA_ISensor);
}
-/* get y position ---------------------------------------------------------- */
-const char SCA_MouseSensor::GetYPosition_doc[] =
-"getYPosition\n"
-"\tReturns the y-coordinate of the mouse sensor, in frame coordinates.\n"
-"\tThe lower-left corner is the origin. The coordinate is given in\n"
-"\tpixels\n";
-PyObject* SCA_MouseSensor::PyGetYPosition(PyObject* self,
- PyObject* args,
- PyObject* kwds) {
- return PyInt_FromLong(m_y);
+int SCA_MouseSensor::_setattr(const STR_String& attr, PyObject *value)
+{
+ int ret = _setattr_self(Attributes, this, attr, value);
+ if (ret >= 0)
+ return ret;
+ return SCA_ISensor::_setattr(attr, value);
}
/* eof */
diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.h b/source/gameengine/GameLogic/SCA_MouseSensor.h
index 26a1c5e3fd2..82af2ce9c04 100644
--- a/source/gameengine/GameLogic/SCA_MouseSensor.h
+++ b/source/gameengine/GameLogic/SCA_MouseSensor.h
@@ -24,7 +24,7 @@
*
* The Original Code is: all of this file.
*
- * Contributor(s): none yet.
+ * Contributor(s): José I. Romero (cleanup and fixes)
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -58,7 +58,7 @@ class SCA_MouseSensor : public SCA_ISensor
SCA_IInputDevice::KX_EnumInputs m_hotkey;
/**
- * valid x coordinate
+ * valid x coordinate, MUST be followed by y coordinate
*/
short m_x;
@@ -87,6 +87,8 @@ class SCA_MouseSensor : public SCA_ISensor
bool isValid(KX_MOUSESENSORMODE);
+ static int UpdateHotkey(void *self, const PyAttributeDef*);
+
SCA_MouseSensor(class SCA_MouseManager* keybdmgr,
int startx,int starty,
short int mousemode,
@@ -108,11 +110,17 @@ class SCA_MouseSensor : public SCA_ISensor
/* --------------------------------------------------------------------- */
virtual PyObject* _getattr(const STR_String& attr);
+ virtual int _setattr(const STR_String& attr, PyObject *value);
+ //Deprecated functions ----->
/* read x-coordinate */
KX_PYMETHOD_DOC(SCA_MouseSensor,GetXPosition);
/* read y-coordinate */
KX_PYMETHOD_DOC(SCA_MouseSensor,GetYPosition);
+ //<----- deprecated
+
+ // get button status
+ KX_PYMETHOD_DOC_O(SCA_MouseSensor,getButtonStatus);
};
diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp
index 3b541e87f02..566d3b63487 100644
--- a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp
+++ b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp
@@ -245,17 +245,35 @@ PyParentObject SCA_PropertyActuator::Parents[] = {
};
PyMethodDef SCA_PropertyActuator::Methods[] = {
+ //Deprecated functions ------>
{"setProperty", (PyCFunction) SCA_PropertyActuator::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc},
{"getProperty", (PyCFunction) SCA_PropertyActuator::sPyGetProperty, METH_VARARGS, (PY_METHODCHAR)GetProperty_doc},
{"setValue", (PyCFunction) SCA_PropertyActuator::sPySetValue, METH_VARARGS, (PY_METHODCHAR)SetValue_doc},
{"getValue", (PyCFunction) SCA_PropertyActuator::sPyGetValue, METH_VARARGS, (PY_METHODCHAR)GetValue_doc},
+ //<----- Deprecated
{NULL,NULL} //Sentinel
};
+PyAttributeDef SCA_PropertyActuator::Attributes[] = {
+ KX_PYATTRIBUTE_STRING_RW_CHECK("property",0,100,false,SCA_PropertyActuator,m_propname,CheckProperty),
+ KX_PYATTRIBUTE_STRING_RW("value",0,100,false,SCA_PropertyActuator,m_exprtxt),
+ { NULL } //Sentinel
+};
+
PyObject* SCA_PropertyActuator::_getattr(const STR_String& attr) {
+ PyObject* object = _getattr_self(Attributes, this, attr);
+ if (object != NULL)
+ return object;
_getattr_up(SCA_IActuator);
}
+int SCA_PropertyActuator::_setattr(const STR_String& attr, PyObject *value) {
+ int ret = _setattr_self(Attributes, this, attr, value);
+ if (ret >= 0)
+ return ret;
+ return SCA_IActuator::_setattr(attr, value);
+}
+
/* 1. setProperty */
const char SCA_PropertyActuator::SetProperty_doc[] =
"setProperty(name)\n"
@@ -264,6 +282,7 @@ const char SCA_PropertyActuator::SetProperty_doc[] =
"\tof this name, the call is ignored.\n";
PyObject* SCA_PropertyActuator::PySetProperty(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("setProperty()", "the 'property' property");
/* Check whether the name exists first ! */
char *nameArg;
if (!PyArg_ParseTuple(args, "s", &nameArg)) {
@@ -288,6 +307,7 @@ const char SCA_PropertyActuator::GetProperty_doc[] =
"\tReturn the property on which the actuator operates.\n";
PyObject* SCA_PropertyActuator::PyGetProperty(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("getProperty()", "the 'property' property");
return PyString_FromString(m_propname);
}
@@ -300,6 +320,7 @@ const char SCA_PropertyActuator::SetValue_doc[] =
"\t action is ignored.\n";
PyObject* SCA_PropertyActuator::PySetValue(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("setValue()", "the value property");
char *valArg;
if(!PyArg_ParseTuple(args, "s", &valArg)) {
return NULL;
@@ -316,6 +337,7 @@ const char SCA_PropertyActuator::GetValue_doc[] =
"\tReturns the value with which the actuator operates.\n";
PyObject* SCA_PropertyActuator::PyGetValue(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("getValue()", "the value property");
return PyString_FromString(m_exprtxt);
}
diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.h b/source/gameengine/GameLogic/SCA_PropertyActuator.h
index 1e435684572..cdfeee4c67d 100644
--- a/source/gameengine/GameLogic/SCA_PropertyActuator.h
+++ b/source/gameengine/GameLogic/SCA_PropertyActuator.h
@@ -86,6 +86,7 @@ public:
/* --------------------------------------------------------------------- */
virtual PyObject* _getattr(const STR_String& attr);
+ virtual int _setattr(const STR_String& attr, PyObject *value);
// python wrapped methods
KX_PYMETHOD_DOC(SCA_PropertyActuator,SetProperty);
diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.cpp b/source/gameengine/GameLogic/SCA_PropertySensor.cpp
index 64e3d49c6cb..a6f7a9cd82b 100644
--- a/source/gameengine/GameLogic/SCA_PropertySensor.cpp
+++ b/source/gameengine/GameLogic/SCA_PropertySensor.cpp
@@ -293,7 +293,7 @@ CValue* SCA_PropertySensor::FindIdentifier(const STR_String& identifiername)
return GetParent()->FindIdentifier(identifiername);
}
-bool SCA_PropertySensor::validValueForProperty(char *val, STR_String &prop)
+int SCA_PropertySensor::validValueForProperty(void *self, const PyAttributeDef*)
{
bool result = true;
/* There is no type checking at this moment, unfortunately... */
@@ -333,25 +333,46 @@ PyParentObject SCA_PropertySensor::Parents[] = {
};
PyMethodDef SCA_PropertySensor::Methods[] = {
+ //Deprecated functions ------>
{"getType", (PyCFunction) SCA_PropertySensor::sPyGetType, METH_VARARGS, (PY_METHODCHAR)GetType_doc},
{"setType", (PyCFunction) SCA_PropertySensor::sPySetType, METH_VARARGS, (PY_METHODCHAR)SetType_doc},
{"getProperty", (PyCFunction) SCA_PropertySensor::sPyGetProperty, METH_VARARGS, (PY_METHODCHAR)GetProperty_doc},
{"setProperty", (PyCFunction) SCA_PropertySensor::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc},
{"getValue", (PyCFunction) SCA_PropertySensor::sPyGetValue, METH_VARARGS, (PY_METHODCHAR)GetValue_doc},
{"setValue", (PyCFunction) SCA_PropertySensor::sPySetValue, METH_VARARGS, (PY_METHODCHAR)SetValue_doc},
+ //<----- Deprecated
{NULL,NULL} //Sentinel
};
+PyAttributeDef SCA_PropertySensor::Attributes[] = {
+ KX_PYATTRIBUTE_INT_RW("type",KX_PROPSENSOR_NODEF,KX_PROPSENSOR_MAX-1,false,SCA_PropertySensor,m_checktype),
+ KX_PYATTRIBUTE_STRING_RW_CHECK("property",0,100,false,SCA_PropertySensor,m_checkpropname,CheckProperty),
+ KX_PYATTRIBUTE_STRING_RW_CHECK("value",0,100,false,SCA_PropertySensor,m_checkpropval,validValueForProperty),
+ { NULL } //Sentinel
+};
+
+
PyObject* SCA_PropertySensor::_getattr(const STR_String& attr) {
+ PyObject* object = _getattr_self(Attributes, this, attr);
+ if (object != NULL)
+ return object;
_getattr_up(SCA_ISensor); /* implicit return! */
}
+int SCA_PropertySensor::_setattr(const STR_String& attr, PyObject *value) {
+ int ret = _setattr_self(Attributes, this, attr, value);
+ if (ret >= 0)
+ return ret;
+ return SCA_ISensor::_setattr(attr, value);
+}
+
/* 1. getType */
const char SCA_PropertySensor::GetType_doc[] =
"getType()\n"
"\tReturns the type of check this sensor performs.\n";
PyObject* SCA_PropertySensor::PyGetType(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("getType()", "the type property");
return PyInt_FromLong(m_checktype);
}
@@ -364,6 +385,7 @@ const char SCA_PropertySensor::SetType_doc[] =
"\tSet the type of check to perform.\n";
PyObject* SCA_PropertySensor::PySetType(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("setType()", "the type property");
int typeArg;
if (!PyArg_ParseTuple(args, "i", &typeArg)) {
@@ -384,6 +406,7 @@ const char SCA_PropertySensor::GetProperty_doc[] =
"\tReturn the property with which the sensor operates.\n";
PyObject* SCA_PropertySensor::PyGetProperty(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("getProperty()", "the 'property' property");
return PyString_FromString(m_checkpropname);
}
@@ -395,6 +418,7 @@ const char SCA_PropertySensor::SetProperty_doc[] =
"\tof this name, the call is ignored.\n";
PyObject* SCA_PropertySensor::PySetProperty(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("setProperty()", "the 'property' property");
/* We should query whether the name exists. Or should we create a prop */
/* on the fly? */
char *propNameArg = NULL;
@@ -419,6 +443,7 @@ const char SCA_PropertySensor::GetValue_doc[] =
"\tReturns the value with which the sensor operates.\n";
PyObject* SCA_PropertySensor::PyGetValue(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("getValue()", "the value property");
return PyString_FromString(m_checkpropval);
}
@@ -431,6 +456,7 @@ const char SCA_PropertySensor::SetValue_doc[] =
"\t action is ignored.\n";
PyObject* SCA_PropertySensor::PySetValue(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("setValue()", "the value property");
/* Here, we need to check whether the value is 'valid' for this property.*/
/* We know that the property exists, or is NULL. */
char *propValArg = NULL;
@@ -438,11 +464,12 @@ PyObject* SCA_PropertySensor::PySetValue(PyObject* self, PyObject* args, PyObjec
if(!PyArg_ParseTuple(args, "s", &propValArg)) {
return NULL;
}
-
- if (validValueForProperty(propValArg, m_checkpropname)) {
- m_checkpropval = propValArg;
+ STR_String oldval = m_checkpropval;
+ m_checkpropval = propValArg;
+ if (validValueForProperty(self, NULL)) {
+ m_checkpropval = oldval;
+ return NULL;
}
-
Py_Return;
}
diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.h b/source/gameengine/GameLogic/SCA_PropertySensor.h
index 6871cb3afdc..e625e84a36f 100644
--- a/source/gameengine/GameLogic/SCA_PropertySensor.h
+++ b/source/gameengine/GameLogic/SCA_PropertySensor.h
@@ -47,10 +47,6 @@ class SCA_PropertySensor : public SCA_ISensor
bool m_recentresult;
CExpression* m_range_expr;
- /**
- * Test whether this is a sensible value (type check)
- */
- bool validValueForProperty(char *val, STR_String &prop);
protected:
public:
@@ -90,6 +86,7 @@ public:
/* --------------------------------------------------------------------- */
virtual PyObject* _getattr(const STR_String& attr);
+ virtual int _setattr(const STR_String& attr, PyObject *value);
/* 1. getType */
KX_PYMETHOD_DOC(SCA_PropertySensor,GetType);
@@ -103,7 +100,10 @@ public:
KX_PYMETHOD_DOC(SCA_PropertySensor,GetValue);
/* 6. setValue */
KX_PYMETHOD_DOC(SCA_PropertySensor,SetValue);
-
+ /**
+ * Test whether this is a sensible value (type check)
+ */
+ static int validValueForProperty(void* self, const PyAttributeDef*);
};
#endif
diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp
index c354ab39747..e879481a444 100644
--- a/source/gameengine/GameLogic/SCA_PythonController.cpp
+++ b/source/gameengine/GameLogic/SCA_PythonController.cpp
@@ -233,9 +233,11 @@ PyMethodDef SCA_PythonController::Methods[] = {
{"getActuator", (PyCFunction) SCA_PythonController::sPyGetActuator, METH_O, (PY_METHODCHAR)SCA_PythonController::GetActuator_doc},
{"getSensors", (PyCFunction) SCA_PythonController::sPyGetSensors, METH_NOARGS, (PY_METHODCHAR)SCA_PythonController::GetSensors_doc},
{"getSensor", (PyCFunction) SCA_PythonController::sPyGetSensor, METH_O, (PY_METHODCHAR)SCA_PythonController::GetSensor_doc},
- {"getScript", (PyCFunction) SCA_PythonController::sPyGetScript, METH_NOARGS},
{"setScript", (PyCFunction) SCA_PythonController::sPySetScript, METH_O},
+ //Deprecated functions ------>
+ {"getScript", (PyCFunction) SCA_PythonController::sPyGetScript, METH_NOARGS},
{"getState", (PyCFunction) SCA_PythonController::sPyGetState, METH_NOARGS},
+ //<----- Deprecated
{NULL,NULL} //Sentinel
};
@@ -329,9 +331,27 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr)
PyObject* SCA_PythonController::_getattr(const STR_String& attr)
{
+ if (attr == "script") {
+ return PyString_FromString(m_scriptText);
+ }
+ if (attr == "state") {
+ return PyInt_FromLong(m_statemask);
+ }
_getattr_up(SCA_IController);
}
+int SCA_PythonController::_setattr(const STR_String& attr, PyObject *value)
+{
+ if (attr == "script") {
+ PyErr_SetString(PyExc_AttributeError, "script is read only, use setScript() to update the script");
+ return 1;
+ }
+ if (attr == "state") {
+ PyErr_SetString(PyExc_AttributeError, "state is read only");
+ return 1;
+ }
+ return SCA_IController::_setattr(attr, value);
+}
PyObject* SCA_PythonController::PyGetActuators(PyObject* self)
@@ -420,6 +440,7 @@ SCA_PythonController::PyGetSensors(PyObject* self)
/* 1. getScript */
PyObject* SCA_PythonController::PyGetScript(PyObject* self)
{
+ ShowDeprecationWarning("getScript()", "the script property");
return PyString_FromString(m_scriptText);
}
@@ -443,6 +464,7 @@ PyObject* SCA_PythonController::PySetScript(PyObject* self, PyObject* value)
/* 1. getScript */
PyObject* SCA_PythonController::PyGetState(PyObject* self)
{
+ ShowDeprecationWarning("getState()", "the state property");
return PyInt_FromLong(m_statemask);
}
diff --git a/source/gameengine/GameLogic/SCA_PythonController.h b/source/gameengine/GameLogic/SCA_PythonController.h
index d9b2e242bea..1918cc488d8 100644
--- a/source/gameengine/GameLogic/SCA_PythonController.h
+++ b/source/gameengine/GameLogic/SCA_PythonController.h
@@ -77,6 +77,7 @@ class SCA_PythonController : public SCA_IController
static PyObject* sPyAddActiveActuator(PyObject* self,
PyObject* args);
virtual PyObject* _getattr(const STR_String& attr);
+ virtual int _setattr(const STR_String& attr, PyObject *value);
KX_PYMETHOD_DOC_NOARGS(SCA_PythonController,GetSensors);
KX_PYMETHOD_DOC_NOARGS(SCA_PythonController,GetActuators);
diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.cpp b/source/gameengine/GameLogic/SCA_RandomActuator.cpp
index 7b50a483cd8..840b95d559a 100644
--- a/source/gameengine/GameLogic/SCA_RandomActuator.cpp
+++ b/source/gameengine/GameLogic/SCA_RandomActuator.cpp
@@ -339,6 +339,7 @@ PyParentObject SCA_RandomActuator::Parents[] = {
};
PyMethodDef SCA_RandomActuator::Methods[] = {
+ //Deprecated functions ------>
{"setSeed", (PyCFunction) SCA_RandomActuator::sPySetSeed, METH_VARARGS, (PY_METHODCHAR)SetSeed_doc},
{"getSeed", (PyCFunction) SCA_RandomActuator::sPyGetSeed, METH_VARARGS, (PY_METHODCHAR)GetSeed_doc},
{"getPara1", (PyCFunction) SCA_RandomActuator::sPyGetPara1, METH_VARARGS, (PY_METHODCHAR)GetPara1_doc},
@@ -346,6 +347,7 @@ PyMethodDef SCA_RandomActuator::Methods[] = {
{"getDistribution", (PyCFunction) SCA_RandomActuator::sPyGetDistribution, METH_VARARGS, (PY_METHODCHAR)GetDistribution_doc},
{"setProperty", (PyCFunction) SCA_RandomActuator::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc},
{"getProperty", (PyCFunction) SCA_RandomActuator::sPyGetProperty, METH_VARARGS, (PY_METHODCHAR)GetProperty_doc},
+ //<----- Deprecated
{"setBoolConst", (PyCFunction) SCA_RandomActuator::sPySetBoolConst, METH_VARARGS, (PY_METHODCHAR)SetBoolConst_doc},
{"setBoolUniform", (PyCFunction) SCA_RandomActuator::sPySetBoolUniform, METH_VARARGS, (PY_METHODCHAR)SetBoolUniform_doc},
{"setBoolBernouilli",(PyCFunction) SCA_RandomActuator::sPySetBoolBernouilli, METH_VARARGS, (PY_METHODCHAR)SetBoolBernouilli_doc},
@@ -359,10 +361,42 @@ PyMethodDef SCA_RandomActuator::Methods[] = {
{NULL,NULL} //Sentinel
};
+PyAttributeDef SCA_RandomActuator::Attributes[] = {
+ KX_PYATTRIBUTE_FLOAT_RO("para1",SCA_RandomActuator,m_parameter1),
+ KX_PYATTRIBUTE_FLOAT_RO("para2",SCA_RandomActuator,m_parameter2),
+ KX_PYATTRIBUTE_ENUM_RO("distribution",SCA_RandomActuator,m_distribution),
+ KX_PYATTRIBUTE_STRING_RW_CHECK("property",0,100,false,SCA_RandomActuator,m_propname,CheckProperty),
+ { NULL } //Sentinel
+};
+
PyObject* SCA_RandomActuator::_getattr(const STR_String& attr) {
+ PyObject* object = _getattr_self(Attributes, this, attr);
+ if (object != NULL)
+ return object;
+ if (attr == "seed") {
+ return PyInt_FromLong(m_base->GetSeed());
+ }
_getattr_up(SCA_IActuator);
}
+int SCA_RandomActuator::_setattr(const STR_String& attr, PyObject *value)
+{
+ int ret = _setattr_self(Attributes, this, attr, value);
+ if (ret >= 0)
+ return ret;
+ if (attr == "seed") {
+ if (PyInt_Check(value)) {
+ int ival = PyInt_AsLong(value);
+ m_base->SetSeed(ival);
+ return 0;
+ } else {
+ PyErr_SetString(PyExc_TypeError, "expected an integer");
+ return 1;
+ }
+ }
+ return SCA_IActuator::_setattr(attr, value);
+}
+
/* 1. setSeed */
const char SCA_RandomActuator::SetSeed_doc[] =
"setSeed(seed)\n"
@@ -371,6 +405,7 @@ const char SCA_RandomActuator::SetSeed_doc[] =
"\tequal series. If the seed is 0, the generator will produce\n"
"\tthe same value on every call.\n";
PyObject* SCA_RandomActuator::PySetSeed(PyObject* self, PyObject* args, PyObject* kwds) {
+ ShowDeprecationWarning("setSeed()", "the seed property");
long seedArg;
if(!PyArg_ParseTuple(args, "i", &seedArg)) {
return NULL;
@@ -386,6 +421,7 @@ const char SCA_RandomActuator::GetSeed_doc[] =
"\tReturns the initial seed of the generator. Equal seeds produce\n"
"\tequal series.\n";
PyObject* SCA_RandomActuator::PyGetSeed(PyObject* self, PyObject* args, PyObject* kwds) {
+ ShowDeprecationWarning("getSeed()", "the seed property");
return PyInt_FromLong(m_base->GetSeed());
}
@@ -396,6 +432,7 @@ const char SCA_RandomActuator::GetPara1_doc[] =
"\tto the documentation of the generator types for the meaning\n"
"\tof this value.";
PyObject* SCA_RandomActuator::PyGetPara1(PyObject* self, PyObject* args, PyObject* kwds) {
+ ShowDeprecationWarning("getPara1()", "the para1 property");
return PyFloat_FromDouble(m_parameter1);
}
@@ -406,6 +443,7 @@ const char SCA_RandomActuator::GetPara2_doc[] =
"\tto the documentation of the generator types for the meaning\n"
"\tof this value.";
PyObject* SCA_RandomActuator::PyGetPara2(PyObject* self, PyObject* args, PyObject* kwds) {
+ ShowDeprecationWarning("getPara2()", "the para2 property");
return PyFloat_FromDouble(m_parameter2);
}
@@ -414,6 +452,7 @@ const char SCA_RandomActuator::GetDistribution_doc[] =
"getDistribution()\n"
"\tReturns the type of the active distribution.\n";
PyObject* SCA_RandomActuator::PyGetDistribution(PyObject* self, PyObject* args, PyObject* kwds) {
+ ShowDeprecationWarning("getDistribution()", "the distribution property");
return PyInt_FromLong(m_distribution);
}
@@ -424,6 +463,7 @@ const char SCA_RandomActuator::SetProperty_doc[] =
"\tSet the property to which the random value is assigned. If the \n"
"\tgenerator and property types do not match, the assignment is ignored.\n";
PyObject* SCA_RandomActuator::PySetProperty(PyObject* self, PyObject* args, PyObject* kwds) {
+ ShowDeprecationWarning("setProperty()", "the 'property' property");
char *nameArg;
if (!PyArg_ParseTuple(args, "s", &nameArg)) {
return NULL;
@@ -446,6 +486,7 @@ const char SCA_RandomActuator::GetProperty_doc[] =
"\tReturn the property to which the random value is assigned. If the \n"
"\tgenerator and property types do not match, the assignment is ignored.\n";
PyObject* SCA_RandomActuator::PyGetProperty(PyObject* self, PyObject* args, PyObject* kwds) {
+ ShowDeprecationWarning("getProperty()", "the 'property' property");
return PyString_FromString(m_propname);
}
@@ -463,9 +504,7 @@ PyObject* SCA_RandomActuator::PySetBoolConst(PyObject* self,
}
m_distribution = KX_RANDOMACT_BOOL_CONST;
- if (paraArg) {
- m_parameter1 = 1;
- }
+ m_parameter1 = (paraArg) ? 1.0 : 0.0;
Py_Return;
}
diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.h b/source/gameengine/GameLogic/SCA_RandomActuator.h
index f6da0595d1a..de8faaf9c72 100644
--- a/source/gameengine/GameLogic/SCA_RandomActuator.h
+++ b/source/gameengine/GameLogic/SCA_RandomActuator.h
@@ -97,6 +97,7 @@ class SCA_RandomActuator : public SCA_IActuator
/* --------------------------------------------------------------------- */
virtual PyObject* _getattr(const STR_String& attr);
+ virtual int _setattr(const STR_String& attr, PyObject *value);
/* 1. setSeed */
KX_PYMETHOD_DOC(SCA_RandomActuator,SetSeed);
@@ -135,7 +136,6 @@ class SCA_RandomActuator : public SCA_IActuator
KX_PYMETHOD_DOC(SCA_RandomActuator,SetFloatNormal);
/* 20. setFloatNegativeExponential, */
KX_PYMETHOD_DOC(SCA_RandomActuator,SetFloatNegativeExponential);
-
}; /* end of class KX_EditObjectActuator : public SCA_PropertyActuator */
#endif
diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.cpp b/source/gameengine/GameLogic/SCA_RandomSensor.cpp
index 202fd6382e6..8fae0bbeaba 100644
--- a/source/gameengine/GameLogic/SCA_RandomSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_RandomSensor.cpp
@@ -160,10 +160,39 @@ PyMethodDef SCA_RandomSensor::Methods[] = {
{NULL,NULL} //Sentinel
};
+PyAttributeDef SCA_RandomSensor::Attributes[] = {
+ KX_PYATTRIBUTE_BOOL_RO("lastDraw",SCA_RandomSensor,m_lastdraw),
+ {NULL} //Sentinel
+};
+
PyObject* SCA_RandomSensor::_getattr(const STR_String& attr) {
+ PyObject* object = _getattr_self(Attributes, this, attr);
+ if (object != NULL)
+ return object;
+ if (attr == "seed") {
+ return PyInt_FromLong(m_basegenerator->GetSeed());
+ }
_getattr_up(SCA_ISensor);
}
+int SCA_RandomSensor::_setattr(const STR_String& attr, PyObject *value)
+{
+ int ret = _setattr_self(Attributes, this, attr, value);
+ if (ret >= 0)
+ return ret;
+ if (attr == "seed") {
+ if (PyInt_Check(value)) {
+ int ival = PyInt_AsLong(value);
+ m_basegenerator->SetSeed(ival);
+ return 0;
+ } else {
+ PyErr_SetString(PyExc_TypeError, "expected an integer");
+ return 1;
+ }
+ }
+ return SCA_ISensor::_setattr(attr, value);
+}
+
/* 1. setSeed */
const char SCA_RandomSensor::SetSeed_doc[] =
"setSeed(seed)\n"
@@ -172,6 +201,7 @@ const char SCA_RandomSensor::SetSeed_doc[] =
"\tequal series. If the seed is 0, the generator will produce\n"
"\tthe same value on every call.\n";
PyObject* SCA_RandomSensor::PySetSeed(PyObject* self, PyObject* args, PyObject* kwds) {
+ ShowDeprecationWarning("setSeed()", "the seed property");
long seedArg;
if(!PyArg_ParseTuple(args, "i", &seedArg)) {
return NULL;
@@ -188,6 +218,7 @@ const char SCA_RandomSensor::GetSeed_doc[] =
"\tReturns the initial seed of the generator. Equal seeds produce\n"
"\tequal series.\n";
PyObject* SCA_RandomSensor::PyGetSeed(PyObject* self, PyObject* args, PyObject* kwds) {
+ ShowDeprecationWarning("getSeed()", "the seed property");
return PyInt_FromLong(m_basegenerator->GetSeed());
}
@@ -196,6 +227,7 @@ const char SCA_RandomSensor::GetLastDraw_doc[] =
"getLastDraw()\n"
"\tReturn the last value that was drawn.\n";
PyObject* SCA_RandomSensor::PyGetLastDraw(PyObject* self, PyObject* args, PyObject* kwds) {
+ ShowDeprecationWarning("getLastDraw()", "the lastDraw property");
return PyInt_FromLong(m_lastdraw);
}
diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.h b/source/gameengine/GameLogic/SCA_RandomSensor.h
index d29bfb6837a..009efc32aac 100644
--- a/source/gameengine/GameLogic/SCA_RandomSensor.h
+++ b/source/gameengine/GameLogic/SCA_RandomSensor.h
@@ -61,6 +61,7 @@ public:
/* --------------------------------------------------------------------- */
virtual PyObject* _getattr(const STR_String& attr);
+ virtual int _setattr(const STR_String& attr, PyObject *value);
/* 1. setSeed */
KX_PYMETHOD_DOC(SCA_RandomSensor,SetSeed);
diff --git a/source/gameengine/GamePlayer/ghost/CMakeLists.txt b/source/gameengine/GamePlayer/ghost/CMakeLists.txt
index 5e0ca93ac06..a3cd8296da3 100644
--- a/source/gameengine/GamePlayer/ghost/CMakeLists.txt
+++ b/source/gameengine/GamePlayer/ghost/CMakeLists.txt
@@ -70,5 +70,9 @@ SET(INC
${PYTHON_INC}
)
+IF(WITH_FFMPEG)
+ ADD_DEFINITIONS(-DWITH_FFMPEG)
+ENDIF(WITH_FFMPEG)
+
BLENDERLIB_NOLIST(gp_ghost "${SRC}" "${INC}")
#env.BlenderLib (libname='gp_ghost', sources=source_files, includes = incs, defines = [], libtype='player',priority=0, compileflags=cflags)
diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
index e326df57a3d..81a0f1f4e99 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
+++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
@@ -530,6 +530,7 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode)
bool fixed_framerate= (SYS_GetCommandLineInt(syshandle, "fixed_framerate", fixedFr) != 0);
bool frameRate = (SYS_GetCommandLineInt(syshandle, "show_framerate", 0) != 0);
bool useLists = (SYS_GetCommandLineInt(syshandle, "displaylists", G.fileflags & G_FILE_DISPLAY_LISTS) != 0);
+ bool nodepwarnings = (SYS_GetCommandLineInt(syshandle, "ignore_deprecation_warnings", 0) != 0);
if(GLEW_ARB_multitexture && GLEW_VERSION_1_1)
m_blendermat = (SYS_GetCommandLineInt(syshandle, "blender_material", 1) != 0);
@@ -604,6 +605,8 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode)
m_ketsjiengine->SetAudioDevice(m_audiodevice);
m_ketsjiengine->SetTimingDisplay(frameRate, false, false);
+ CValue::SetDeprecationWarnings(nodepwarnings);
+
m_ketsjiengine->SetUseFixedTime(fixed_framerate);
m_ketsjiengine->SetTimingDisplay(frameRate, profile, properties);
@@ -686,8 +689,9 @@ bool GPG_Application::startEngine(void)
initGameKeys();
initPythonConstraintBinding();
initMathutils();
+#ifdef WITH_FFMPEG
initVideoTexture();
-
+#endif
// Set the GameLogic.globalDict from marshal'd data, so we can
// load new blend files and keep data in GameLogic.globalDict
loadGamePythonConfig(m_pyGlobalDictString, m_pyGlobalDictString_Length);
diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
index 8293cfeb36d..c09772c6196 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
+++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
@@ -163,11 +163,10 @@ void usage(const char* program)
consoleoption = "";
#endif
- printf("usage: %s [-w [-p l t w h]] %s[-g gamengineoptions] "
+ printf("usage: %s [-w l t w h] %s[-g gamengineoptions] "
"[-s stereomode] filename.blend\n", program, consoleoption);
printf(" -h: Prints this command summary\n");
printf(" -w: display in a window\n");
- printf(" -p: specify window position\n");
printf(" l = window left coordinate\n");
printf(" t = window top coordinate\n");
printf(" w = window width\n");
@@ -191,17 +190,18 @@ void usage(const char* program)
printf(" -c: keep console window open\n");
#endif
printf(" -d: turn debugging on\n");
- printf(" -g: game engine options:\n");
- printf(" Name Default Description\n");
- printf(" ----------------------------------------\n");
- printf(" fixedtime 0 Do the same timestep each frame \"Enable all frames\"\n");
- printf(" nomipmap 0 Disable mipmaps\n");
- printf(" show_framerate 0 Show the frame rate\n");
- printf(" show_properties 0 Show debug properties\n");
- printf(" show_profile 0 Show profiling information\n");
- printf(" blender_material 0 Enable material settings\n");
+ printf(" -g: game engine options:\n\n");
+ printf(" Name Default Description\n");
+ printf(" ------------------------------------------------------------------------\n");
+ printf(" fixedtime 0 \"Enable all frames\"\n");
+ printf(" nomipmap 0 Disable mipmaps\n");
+ printf(" show_framerate 0 Show the frame rate\n");
+ printf(" show_properties 0 Show debug properties\n");
+ printf(" show_profile 0 Show profiling information\n");
+ printf(" blender_material 0 Enable material settings\n");
+ printf(" ignore_deprecation_warnings 0 Ignore deprecation warnings\n");
printf("\n");
- printf("example: %s -p 10 10 320 200 -g noaudio c:\\loadtest.blend\n", program);
+ printf("example: %s -w 10 10 320 200 -g noaudio c:\\loadtest.blend\n", program);
printf("example: %s -g show_framerate = 0 c:\\loadtest.blend\n", program);
}
diff --git a/source/gameengine/GamePlayer/ghost/Makefile b/source/gameengine/GamePlayer/ghost/Makefile
index 52e219db8f2..5f90d804611 100644
--- a/source/gameengine/GamePlayer/ghost/Makefile
+++ b/source/gameengine/GamePlayer/ghost/Makefile
@@ -82,3 +82,6 @@ CPPFLAGS += -I$(NAN_STRING)/include
CPPFLAGS += -I$(NAN_GHOST)/include
CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION)
+ifeq ($(WITH_FFMPEG), true)
+ CPPFLAGS += -DWITH_FFMPEG
+endif
diff --git a/source/gameengine/GamePlayer/ghost/SConscript b/source/gameengine/GamePlayer/ghost/SConscript
index a7ee2d51d14..7ad2fdd37a7 100644
--- a/source/gameengine/GamePlayer/ghost/SConscript
+++ b/source/gameengine/GamePlayer/ghost/SConscript
@@ -49,5 +49,8 @@ cflags = []
if env['OURPLATFORM']=='win32-vc':
cflags = ['/GR']
+defs = ''
+if env['WITH_BF_FFMPEG']:
+ defs += ' WITH_FFMPEG'
-env.BlenderLib (libname='gp_ghost', sources=source_files, includes = incs, defines = [], libtype='player',priority=5, compileflags=cflags)
+env.BlenderLib (libname='gp_ghost', sources=source_files, includes = incs, defines = Split(defs), libtype='player',priority=5, compileflags=cflags)
diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp
index 3a20bbfbb11..534c48661b7 100644
--- a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp
+++ b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp
@@ -17,10 +17,11 @@
#include "BulletSoftBody/btSoftBody.h"
-KX_BulletPhysicsController::KX_BulletPhysicsController (const CcdConstructionInfo& ci, bool dyna)
-: KX_IPhysicsController(dyna,(PHY_IPhysicsController*)this),
+KX_BulletPhysicsController::KX_BulletPhysicsController (const CcdConstructionInfo& ci, bool dyna, bool compound)
+: KX_IPhysicsController(dyna,compound,(PHY_IPhysicsController*)this),
CcdPhysicsController(ci),
-m_savedCollisionFlags(0)
+m_savedCollisionFlags(0),
+m_bulletChildShape(NULL)
{
}
@@ -175,6 +176,152 @@ void KX_BulletPhysicsController::setRigidBody(bool rigid)
{
}
+/* This function dynamically adds the collision shape of another controller to
+ the current controller shape provided it is a compound shape.
+ The idea is that dynamic parenting on a compound object will dynamically extend the shape
+*/
+void KX_BulletPhysicsController::AddCompoundChild(KX_IPhysicsController* child)
+{
+ if (child == NULL || !IsCompound())
+ return;
+ // other controller must be a bullet controller too
+ // verify that body and shape exist and match
+ KX_BulletPhysicsController* childCtrl = dynamic_cast<KX_BulletPhysicsController*>(child);
+ btRigidBody* rootBody = GetRigidBody();
+ btRigidBody* childBody = childCtrl->GetRigidBody();
+ if (!rootBody || !childBody)
+ return;
+ const btCollisionShape* rootShape = rootBody->getCollisionShape();
+ const btCollisionShape* childShape = childBody->getCollisionShape();
+ if (!rootShape ||
+ !childShape ||
+ rootShape->getShapeType() != COMPOUND_SHAPE_PROXYTYPE ||
+ childShape->getShapeType() == COMPOUND_SHAPE_PROXYTYPE)
+ return;
+ btCompoundShape* compoundShape = (btCompoundShape*)rootShape;
+ // compute relative transformation between parent and child
+ btTransform rootTrans;
+ btTransform childTrans;
+ rootBody->getMotionState()->getWorldTransform(rootTrans);
+ childBody->getMotionState()->getWorldTransform(childTrans);
+ btVector3 rootScale = rootShape->getLocalScaling();
+ rootScale[0] = 1.0/rootScale[0];
+ rootScale[1] = 1.0/rootScale[1];
+ rootScale[2] = 1.0/rootScale[2];
+ // relative scale = child_scale/parent_scale
+ btVector3 relativeScale = childShape->getLocalScaling()*rootScale;
+ btMatrix3x3 rootRotInverse = rootTrans.getBasis().transpose();
+ // relative pos = parent_rot^-1 * ((parent_pos-child_pos)/parent_scale)
+ btVector3 relativePos = rootRotInverse*((childTrans.getOrigin()-rootTrans.getOrigin())*rootScale);
+ // relative rot = parent_rot^-1 * child_rot
+ btMatrix3x3 relativeRot = rootRotInverse*childTrans.getBasis();
+ // create a proxy shape info to store the transformation
+ CcdShapeConstructionInfo* proxyShapeInfo = new CcdShapeConstructionInfo();
+ // store the transformation to this object shapeinfo
+ proxyShapeInfo->m_childTrans.setOrigin(relativePos);
+ proxyShapeInfo->m_childTrans.setBasis(relativeRot);
+ proxyShapeInfo->m_childScale.setValue(relativeScale[0], relativeScale[1], relativeScale[2]);
+ // we will need this to make sure that we remove the right proxy later when unparenting
+ proxyShapeInfo->m_userData = childCtrl;
+ proxyShapeInfo->SetProxy(childCtrl->GetShapeInfo()->AddRef());
+ // add to parent compound shapeinfo
+ GetShapeInfo()->AddShape(proxyShapeInfo);
+ // create new bullet collision shape from the object shapeinfo and set scaling
+ btCollisionShape* newChildShape = proxyShapeInfo->CreateBulletShape();
+ newChildShape->setLocalScaling(relativeScale);
+ // add bullet collision shape to parent compound collision shape
+ compoundShape->addChildShape(proxyShapeInfo->m_childTrans,newChildShape);
+ // remember we created this shape
+ childCtrl->m_bulletChildShape = newChildShape;
+ // recompute inertia of parent
+ if (!rootBody->isStaticOrKinematicObject())
+ {
+ btVector3 localInertia;
+ float mass = 1.f/rootBody->getInvMass();
+ compoundShape->calculateLocalInertia(mass,localInertia);
+ rootBody->setMassProps(mass,localInertia);
+ }
+ // must update the broadphase cache,
+ GetPhysicsEnvironment()->refreshCcdPhysicsController(this);
+ // remove the children
+ GetPhysicsEnvironment()->disableCcdPhysicsController(childCtrl);
+}
+
+/* Reverse function of the above, it will remove a shape from a compound shape
+ provided that the former was added to the later using AddCompoundChild()
+*/
+void KX_BulletPhysicsController::RemoveCompoundChild(KX_IPhysicsController* child)
+{
+ if (child == NULL || !IsCompound())
+ return;
+ // other controller must be a bullet controller too
+ // verify that body and shape exist and match
+ KX_BulletPhysicsController* childCtrl = dynamic_cast<KX_BulletPhysicsController*>(child);
+ btRigidBody* rootBody = GetRigidBody();
+ btRigidBody* childBody = childCtrl->GetRigidBody();
+ if (!rootBody || !childBody)
+ return;
+ const btCollisionShape* rootShape = rootBody->getCollisionShape();
+ if (!rootShape ||
+ rootShape->getShapeType() != COMPOUND_SHAPE_PROXYTYPE)
+ return;
+ btCompoundShape* compoundShape = (btCompoundShape*)rootShape;
+ // retrieve the shapeInfo
+ CcdShapeConstructionInfo* childShapeInfo = childCtrl->GetShapeInfo();
+ CcdShapeConstructionInfo* rootShapeInfo = GetShapeInfo();
+ // and verify that the child is part of the parent
+ int i = rootShapeInfo->FindChildShape(childShapeInfo, childCtrl);
+ if (i < 0)
+ return;
+ rootShapeInfo->RemoveChildShape(i);
+ if (childCtrl->m_bulletChildShape)
+ {
+ int numChildren = compoundShape->getNumChildShapes();
+ for (i=0; i<numChildren; i++)
+ {
+ if (compoundShape->getChildShape(i) == childCtrl->m_bulletChildShape)
+ {
+ compoundShape->removeChildShapeByIndex(i);
+ compoundShape->recalculateLocalAabb();
+ break;
+ }
+ }
+ delete childCtrl->m_bulletChildShape;
+ childCtrl->m_bulletChildShape = NULL;
+ }
+ // recompute inertia of parent
+ if (!rootBody->isStaticOrKinematicObject())
+ {
+ btVector3 localInertia;
+ float mass = 1.f/rootBody->getInvMass();
+ compoundShape->calculateLocalInertia(mass,localInertia);
+ rootBody->setMassProps(mass,localInertia);
+ }
+ // must update the broadphase cache,
+ GetPhysicsEnvironment()->refreshCcdPhysicsController(this);
+ // reactivate the children
+ GetPhysicsEnvironment()->enableCcdPhysicsController(childCtrl);
+}
+
+void KX_BulletPhysicsController::SetMass(MT_Scalar newmass)
+{
+ btRigidBody *body = GetRigidBody();
+ if (body && body->getActivationState() != DISABLE_SIMULATION &&
+ newmass>MT_EPSILON && GetMass()>MT_EPSILON)
+ {
+ btVector3 grav = body->getGravity();
+ btVector3 accel = grav / GetMass();
+
+ btBroadphaseProxy* handle = body->getBroadphaseHandle();
+ GetPhysicsEnvironment()->updateCcdPhysicsController(this,
+ newmass,
+ body->getCollisionFlags(),
+ handle->m_collisionFilterGroup,
+ handle->m_collisionFilterMask);
+ body->setGravity(accel);
+ }
+}
+
void KX_BulletPhysicsController::SuspendDynamics(bool ghost)
{
btRigidBody *body = GetRigidBody();
@@ -205,7 +352,7 @@ void KX_BulletPhysicsController::RestoreDynamics()
m_savedCollisionFlags,
m_savedCollisionFilterGroup,
m_savedCollisionFilterMask);
- GetRigidBody()->forceActivationState(m_savedActivationState);
+ body->forceActivationState(m_savedActivationState);
}
}
@@ -251,6 +398,7 @@ SG_Controller* KX_BulletPhysicsController::GetReplica(class SG_Node* destnode)
physicsreplica->setParentCtrl(ccdParent);
physicsreplica->PostProcessReplica(motionstate,parentctrl);
physicsreplica->m_userdata = (PHY_IPhysicsController*)physicsreplica;
+ physicsreplica->m_bulletChildShape = NULL;
return physicsreplica;
}
diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.h b/source/gameengine/Ketsji/KX_BulletPhysicsController.h
index d5fca4ec6d3..44fbde7054e 100644
--- a/source/gameengine/Ketsji/KX_BulletPhysicsController.h
+++ b/source/gameengine/Ketsji/KX_BulletPhysicsController.h
@@ -13,10 +13,11 @@ private:
short int m_savedCollisionFilterGroup;
short int m_savedCollisionFilterMask;
MT_Scalar m_savedMass;
+ btCollisionShape* m_bulletChildShape;
public:
- KX_BulletPhysicsController (const CcdConstructionInfo& ci, bool dyna);
+ KX_BulletPhysicsController (const CcdConstructionInfo& ci, bool dyna, bool compound);
virtual ~KX_BulletPhysicsController ();
///////////////////////////////////
@@ -40,8 +41,11 @@ public:
virtual void setPosition(const MT_Point3& pos);
virtual void setScaling(const MT_Vector3& scaling);
virtual MT_Scalar GetMass();
+ virtual void SetMass(MT_Scalar newmass);
virtual MT_Vector3 getReactionForce();
virtual void setRigidBody(bool rigid);
+ virtual void AddCompoundChild(KX_IPhysicsController* child);
+ virtual void RemoveCompoundChild(KX_IPhysicsController* child);
virtual void resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ);
diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
index 0e7a6d92ec1..46e46b014b5 100644
--- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
+++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
@@ -1084,7 +1084,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
ci.m_bSoft = objprop->m_softbody;
MT_Vector3 scaling = gameobj->NodeGetWorldScaling();
ci.m_scaling.setValue(scaling[0], scaling[1], scaling[2]);
- KX_BulletPhysicsController* physicscontroller = new KX_BulletPhysicsController(ci,isbulletdyna);
+ KX_BulletPhysicsController* physicscontroller = new KX_BulletPhysicsController(ci,isbulletdyna,objprop->m_hasCompoundChildren);
// shapeInfo is reference counted, decrement now as we don't use it anymore
if (shapeInfo)
shapeInfo->Release();
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index e4a37b589a8..42316c6c873 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -252,6 +252,20 @@ void KX_GameObject::SetParent(KX_Scene *scene, KX_GameObject* obj)
if (rootlist->RemoveValue(this))
// the object was in parent list, decrement ref count as it's now removed
Release();
+ // if the new parent is a compound object, add this object shape to the compound shape.
+ // step 0: verify this object has physical controller
+ if (m_pPhysicsController1)
+ {
+ // step 1: find the top parent (not necessarily obj)
+ KX_GameObject* rootobj = (KX_GameObject*)obj->GetSGNode()->GetRootSGParent()->GetSGClientObject();
+ // step 2: verify it has a physical controller and compound shape
+ if (rootobj != NULL &&
+ rootobj->m_pPhysicsController1 != NULL &&
+ rootobj->m_pPhysicsController1->IsCompound())
+ {
+ rootobj->m_pPhysicsController1->AddCompoundChild(m_pPhysicsController1);
+ }
+ }
}
}
@@ -260,6 +274,8 @@ void KX_GameObject::RemoveParent(KX_Scene *scene)
// check on valid node in case a python controller holds a reference to a deleted object
if (GetSGNode() && GetSGNode()->GetSGParent())
{
+ // get the root object to remove us from compound object if needed
+ KX_GameObject* rootobj = (KX_GameObject*)GetSGNode()->GetRootSGParent()->GetSGClientObject();
// Set us to the right spot
GetSGNode()->SetLocalScale(GetSGNode()->GetWorldScaling());
GetSGNode()->SetLocalOrientation(GetSGNode()->GetWorldOrientation());
@@ -275,6 +291,13 @@ void KX_GameObject::RemoveParent(KX_Scene *scene)
rootlist->Add(AddRef());
if (m_pPhysicsController1)
{
+ // in case this controller was added as a child shape to the parent
+ if (rootobj != NULL &&
+ rootobj->m_pPhysicsController1 != NULL &&
+ rootobj->m_pPhysicsController1->IsCompound())
+ {
+ rootobj->m_pPhysicsController1->RemoveCompoundChild(m_pPhysicsController1);
+ }
m_pPhysicsController1->RestoreDynamics();
}
}
@@ -1106,7 +1129,7 @@ PyObject* KX_GameObject::_getattr(const STR_String& attr)
if (m_pPhysicsController1)
{
if (attr == "mass")
- return PyFloat_FromDouble(GetPhysicsController()->GetMass());
+ return PyFloat_FromDouble(m_pPhysicsController1->GetMass());
}
if (attr == "parent")
@@ -1148,10 +1171,6 @@ PyObject* KX_GameObject::_getattr(const STR_String& attr)
int KX_GameObject::_setattr(const STR_String& attr, PyObject *value) // _setattr method
{
- if (attr == "mass") {
- PyErr_SetString(PyExc_AttributeError, "attribute \"mass\" is read only");
- return 1;
- }
if (attr == "parent") {
PyErr_SetString(PyExc_AttributeError, "attribute \"mass\" is read only\nUse setParent()");
@@ -1180,6 +1199,11 @@ int KX_GameObject::_setattr(const STR_String& attr, PyObject *value) // _setattr
return 0;
}
}
+ if (attr == "mass") {
+ if (m_pPhysicsController1)
+ m_pPhysicsController1->SetMass(val);
+ return 0;
+ }
}
if (PySequence_Check(value))
@@ -2082,7 +2106,6 @@ bool ConvertPythonToGameObject(PyObject * value, KX_GameObject **object, bool py
PyErr_SetString(PyExc_TypeError, "Expected KX_GameObject or a string for a name of a KX_GameObject, None is invalid");
return false;
}
- return (py_none_ok ? true : false);
}
if (PyString_Check(value)) {
diff --git a/source/gameengine/Ketsji/KX_IPhysicsController.cpp b/source/gameengine/Ketsji/KX_IPhysicsController.cpp
index 5cd66efd965..a38222c5f7e 100644
--- a/source/gameengine/Ketsji/KX_IPhysicsController.cpp
+++ b/source/gameengine/Ketsji/KX_IPhysicsController.cpp
@@ -35,9 +35,10 @@
#include "PHY_DynamicTypes.h"
-KX_IPhysicsController::KX_IPhysicsController(bool dyna,void* userdata)
+KX_IPhysicsController::KX_IPhysicsController(bool dyna, bool compound, void* userdata)
: m_bDyna(dyna),
+ m_bCompound(compound),
m_suspendDynamics(false),
m_userdata(userdata)
{
diff --git a/source/gameengine/Ketsji/KX_IPhysicsController.h b/source/gameengine/Ketsji/KX_IPhysicsController.h
index 4ea283e9f98..13501f1fbbd 100644
--- a/source/gameengine/Ketsji/KX_IPhysicsController.h
+++ b/source/gameengine/Ketsji/KX_IPhysicsController.h
@@ -32,6 +32,7 @@
#include "SG_Controller.h"
#include "MT_Vector3.h"
#include "MT_Point3.h"
+#include "MT_Transform.h"
#include "MT_Matrix3x3.h"
struct KX_ClientObjectInfo;
@@ -48,10 +49,11 @@ class KX_IPhysicsController : public SG_Controller
{
protected:
bool m_bDyna;
+ bool m_bCompound;
bool m_suspendDynamics;
void* m_userdata;
public:
- KX_IPhysicsController(bool dyna,void* userdata);
+ KX_IPhysicsController(bool dyna,bool compound, void* userdata);
virtual ~KX_IPhysicsController();
@@ -76,8 +78,11 @@ public:
virtual void setPosition(const MT_Point3& pos)=0;
virtual void setScaling(const MT_Vector3& scaling)=0;
virtual MT_Scalar GetMass()=0;
+ virtual void SetMass(MT_Scalar newmass)=0;
virtual MT_Vector3 getReactionForce()=0;
virtual void setRigidBody(bool rigid)=0;
+ virtual void AddCompoundChild(KX_IPhysicsController* child) = 0;
+ virtual void RemoveCompoundChild(KX_IPhysicsController* child) = 0;
virtual void SuspendDynamics(bool ghost=false)=0;
virtual void RestoreDynamics()=0;
@@ -92,6 +97,10 @@ public:
return m_bDyna;
}
+ bool IsCompound(void) {
+ return m_bCompound;
+ }
+
virtual MT_Scalar GetRadius()=0;
virtual void SetSumoTransform(bool nondynaonly)=0;
// todo: remove next line !
diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
index 8bcda4479e1..1271474802c 100644
--- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
+++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
@@ -732,6 +732,26 @@ void KX_KetsjiEngine::Render()
// do the rendering
//RenderFrame(scene);
RenderFrame(scene, cam);
+
+ list<class KX_Camera*>* cameras = scene->GetCameras();
+
+ // Draw the scene once for each camera with an enabled viewport
+ list<KX_Camera*>::iterator it = cameras->begin();
+ while(it != cameras->end())
+ {
+ if((*it)->GetViewport())
+ {
+ if (scene->IsClearingZBuffer())
+ m_rasterizer->ClearDepthBuffer();
+
+ m_rendertools->SetAuxilaryClientInfo(scene);
+
+ // do the rendering
+ RenderFrame(scene, (*it));
+ }
+
+ it++;
+ }
}
} // if(m_rasterizer->Stereo())
diff --git a/source/gameengine/Ketsji/KX_OdePhysicsController.cpp b/source/gameengine/Ketsji/KX_OdePhysicsController.cpp
index 6a701a5f25b..dc6990267d4 100644
--- a/source/gameengine/Ketsji/KX_OdePhysicsController.cpp
+++ b/source/gameengine/Ketsji/KX_OdePhysicsController.cpp
@@ -50,7 +50,7 @@ KX_OdePhysicsController::KX_OdePhysicsController(
float extends[3],
float radius
)
-: KX_IPhysicsController(dyna,(PHY_IPhysicsController*)this),
+: KX_IPhysicsController(dyna,false,(PHY_IPhysicsController*)this),
ODEPhysicsController(
dyna,fullRigidBody,phantom,motionstate,
space,world,mass,friction,restitution,
diff --git a/source/gameengine/Ketsji/KX_OdePhysicsController.h b/source/gameengine/Ketsji/KX_OdePhysicsController.h
index 53050f6ce3e..e3b5336c0b5 100644
--- a/source/gameengine/Ketsji/KX_OdePhysicsController.h
+++ b/source/gameengine/Ketsji/KX_OdePhysicsController.h
@@ -73,6 +73,8 @@ public:
virtual MT_Scalar GetMass();
virtual MT_Vector3 getReactionForce();
virtual void setRigidBody(bool rigid);
+ virtual void AddCompoundChild(KX_IPhysicsController* child) { }
+ virtual void RemoveCompoundChild(KX_IPhysicsController* child) { }
virtual void SuspendDynamics(bool);
virtual void RestoreDynamics();
diff --git a/source/gameengine/Ketsji/KX_PolyProxy.cpp b/source/gameengine/Ketsji/KX_PolyProxy.cpp
index c6f6bc2db01..bb9072b34dc 100644
--- a/source/gameengine/Ketsji/KX_PolyProxy.cpp
+++ b/source/gameengine/Ketsji/KX_PolyProxy.cpp
@@ -65,15 +65,15 @@ PyParentObject KX_PolyProxy::Parents[] = {
};
PyMethodDef KX_PolyProxy::Methods[] = {
- KX_PYMETHODTABLE_NOARG(KX_PolyProxy,getMaterialIndex),
- KX_PYMETHODTABLE_NOARG(KX_PolyProxy,getNumVertex),
- KX_PYMETHODTABLE_NOARG(KX_PolyProxy,isVisible),
- KX_PYMETHODTABLE_NOARG(KX_PolyProxy,isCollider),
- KX_PYMETHODTABLE_NOARG(KX_PolyProxy,getMaterialName),
- KX_PYMETHODTABLE_NOARG(KX_PolyProxy,getTextureName),
+ KX_PYMETHODTABLE_NOARGS(KX_PolyProxy,getMaterialIndex),
+ KX_PYMETHODTABLE_NOARGS(KX_PolyProxy,getNumVertex),
+ KX_PYMETHODTABLE_NOARGS(KX_PolyProxy,isVisible),
+ KX_PYMETHODTABLE_NOARGS(KX_PolyProxy,isCollider),
+ KX_PYMETHODTABLE_NOARGS(KX_PolyProxy,getMaterialName),
+ KX_PYMETHODTABLE_NOARGS(KX_PolyProxy,getTextureName),
KX_PYMETHODTABLE(KX_PolyProxy,getVertexIndex),
- KX_PYMETHODTABLE_NOARG(KX_PolyProxy,getMesh),
- KX_PYMETHODTABLE_NOARG(KX_PolyProxy,getMaterial),
+ KX_PYMETHODTABLE_NOARGS(KX_PolyProxy,getMesh),
+ KX_PYMETHODTABLE_NOARGS(KX_PolyProxy,getMaterial),
{NULL,NULL} //Sentinel
};
@@ -171,7 +171,7 @@ void KX_PolyProxy::ReplicaSetName(STR_String) {};
// stuff for python integration
-KX_PYMETHODDEF_DOC_NOARG(KX_PolyProxy, getMaterialIndex,
+KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getMaterialIndex,
"getMaterialIndex() : return the material index of the polygon in the mesh\n")
{
RAS_MaterialBucket* polyBucket = m_polygon->GetMaterial();
@@ -186,31 +186,31 @@ KX_PYMETHODDEF_DOC_NOARG(KX_PolyProxy, getMaterialIndex,
return PyInt_FromLong(matid);
}
-KX_PYMETHODDEF_DOC_NOARG(KX_PolyProxy, getNumVertex,
+KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getNumVertex,
"getNumVertex() : returns the number of vertex of the polygon, 3 or 4\n")
{
return PyInt_FromLong(m_polygon->VertexCount());
}
-KX_PYMETHODDEF_DOC_NOARG(KX_PolyProxy, isVisible,
+KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, isVisible,
"isVisible() : returns whether the polygon is visible or not\n")
{
return PyInt_FromLong(m_polygon->IsVisible());
}
-KX_PYMETHODDEF_DOC_NOARG(KX_PolyProxy, isCollider,
+KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, isCollider,
"isCollider() : returns whether the polygon is receives collision or not\n")
{
return PyInt_FromLong(m_polygon->IsCollider());
}
-KX_PYMETHODDEF_DOC_NOARG(KX_PolyProxy, getMaterialName,
+KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getMaterialName,
"getMaterialName() : returns the polygon material name, \"NoMaterial\" if no material\n")
{
return PyString_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetMaterialName());
}
-KX_PYMETHODDEF_DOC_NOARG(KX_PolyProxy, getTextureName,
+KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getTextureName,
"getTexturelName() : returns the polygon texture name, \"NULL\" if no texture\n")
{
return PyString_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetTextureName());
@@ -239,14 +239,14 @@ KX_PYMETHODDEF_DOC(KX_PolyProxy, getVertexIndex,
return PyInt_FromLong(0);
}
-KX_PYMETHODDEF_DOC_NOARG(KX_PolyProxy, getMesh,
+KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getMesh,
"getMesh() : returns a mesh proxy\n")
{
KX_MeshProxy* meshproxy = new KX_MeshProxy((RAS_MeshObject*)m_mesh);
return meshproxy;
}
-KX_PYMETHODDEF_DOC_NOARG(KX_PolyProxy, getMaterial,
+KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getMaterial,
"getMaterial() : returns a material\n")
{
RAS_IPolyMaterial *polymat = m_polygon->GetMaterial()->GetPolyMaterial();
diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp
index 7ac817488fe..60921449037 100644
--- a/source/gameengine/Ketsji/KX_PythonInit.cpp
+++ b/source/gameengine/Ketsji/KX_PythonInit.cpp
@@ -966,11 +966,11 @@ PyObject* initGameLogic(KX_KetsjiEngine *engine, KX_Scene* scene) // quick hack
KX_MACRO_addTypesToDict(d, KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP, KX_SoundActuator::KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP);
/* 7. Action actuator */
- KX_MACRO_addTypesToDict(d, KX_ACTIONACT_PLAY, BL_ActionActuator::KX_ACT_ACTION_PLAY);
- KX_MACRO_addTypesToDict(d, KX_ACTIONACT_FLIPPER, BL_ActionActuator::KX_ACT_ACTION_FLIPPER);
- KX_MACRO_addTypesToDict(d, KX_ACTIONACT_LOOPSTOP, BL_ActionActuator::KX_ACT_ACTION_LOOPSTOP);
- KX_MACRO_addTypesToDict(d, KX_ACTIONACT_LOOPEND, BL_ActionActuator::KX_ACT_ACTION_LOOPEND);
- KX_MACRO_addTypesToDict(d, KX_ACTIONACT_PROPERTY, BL_ActionActuator::KX_ACT_ACTION_PROPERTY);
+ KX_MACRO_addTypesToDict(d, KX_ACTIONACT_PLAY, ACT_ACTION_PLAY);
+ KX_MACRO_addTypesToDict(d, KX_ACTIONACT_FLIPPER, ACT_ACTION_FLIPPER);
+ KX_MACRO_addTypesToDict(d, KX_ACTIONACT_LOOPSTOP, ACT_ACTION_LOOP_STOP);
+ KX_MACRO_addTypesToDict(d, KX_ACTIONACT_LOOPEND, ACT_ACTION_LOOP_END);
+ KX_MACRO_addTypesToDict(d, KX_ACTIONACT_PROPERTY, ACT_ACTION_FROM_PROP);
/*8. GL_BlendFunc */
KX_MACRO_addTypesToDict(d, BL_ZERO, GL_ZERO);
diff --git a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp
index d44ab477749..176ccf1a84a 100644
--- a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp
+++ b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp
@@ -133,10 +133,12 @@ KX_PYMETHODDEF_DOC(KX_SCA_DynamicActuator, getOperation,
KX_SCA_DynamicActuator::KX_SCA_DynamicActuator(SCA_IObject *gameobj,
short dyn_operation,
+ float setmass,
PyTypeObject* T) :
SCA_IActuator(gameobj, T),
- m_dyn_operation(dyn_operation)
+ m_dyn_operation(dyn_operation),
+ m_setmass(setmass)
{
} /* End of constructor */
@@ -179,6 +181,9 @@ bool KX_SCA_DynamicActuator::Update()
case 3:
controller->setRigidBody(false);
break;
+ case 4:
+ controller->SetMass(m_setmass);
+ break;
}
return false;
diff --git a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h
index b47c3a511d9..de2fab68d15 100644
--- a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h
+++ b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h
@@ -45,10 +45,12 @@ class KX_SCA_DynamicActuator : public SCA_IActuator
// dynamics operation to apply to the game object
short m_dyn_operation;
+ float m_setmass;
public:
KX_SCA_DynamicActuator(
SCA_IObject* gameobj,
short dyn_operation,
+ float setmass,
PyTypeObject* T=&Type
);
diff --git a/source/gameengine/Ketsji/KX_SumoPhysicsController.cpp b/source/gameengine/Ketsji/KX_SumoPhysicsController.cpp
index c842ca1ee14..7631ee05b0b 100644
--- a/source/gameengine/Ketsji/KX_SumoPhysicsController.cpp
+++ b/source/gameengine/Ketsji/KX_SumoPhysicsController.cpp
@@ -205,6 +205,10 @@ MT_Scalar KX_SumoPhysicsController::GetMass()
return SumoPhysicsController::getMass();
}
+void KX_SumoPhysicsController::SetMass(MT_Scalar newmass)
+{
+}
+
MT_Scalar KX_SumoPhysicsController::GetRadius()
{
return SumoPhysicsController::GetRadius();
diff --git a/source/gameengine/Ketsji/KX_SumoPhysicsController.h b/source/gameengine/Ketsji/KX_SumoPhysicsController.h
index abe48d99043..46c8ba6df45 100644
--- a/source/gameengine/Ketsji/KX_SumoPhysicsController.h
+++ b/source/gameengine/Ketsji/KX_SumoPhysicsController.h
@@ -53,7 +53,7 @@ public:
class SM_Object* sumoObj,
class PHY_IMotionState* motionstate
,bool dyna)
- : KX_IPhysicsController(dyna,NULL) ,
+ : KX_IPhysicsController(dyna,false,NULL) ,
SumoPhysicsController(sumoScene,/*solidscene,*/sumoObj,motionstate,dyna)
{
};
@@ -78,12 +78,16 @@ public:
void SuspendDynamics(bool);
void RestoreDynamics();
+ virtual void AddCompoundChild(KX_IPhysicsController* child) { }
+ virtual void RemoveCompoundChild(KX_IPhysicsController* child) { }
+
virtual void getOrientation(MT_Quaternion& orn);
virtual void setOrientation(const MT_Matrix3x3& orn);
virtual void setPosition(const MT_Point3& pos);
virtual void setScaling(const MT_Vector3& scaling);
virtual MT_Scalar GetMass();
+ virtual void SetMass(MT_Scalar newmass);
virtual MT_Scalar GetRadius();
virtual MT_Vector3 getReactionForce();
virtual void setRigidBody(bool rigid);
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
index c9c30c1b450..d09ad58fe3b 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
@@ -74,10 +74,10 @@ CcdPhysicsController::CcdPhysicsController (const CcdConstructionInfo& ci)
///???
-#ifdef WIN32
+/*#ifdef WIN32
if (GetRigidBody() && !GetRigidBody()->isStaticObject())
GetRigidBody()->setLinearVelocity(startVel);
-#endif
+#endif*/
}
@@ -1276,7 +1276,7 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, bool polytope,bo
// assume no shape information
// no support for dynamic change of shape yet
- assert(m_meshObject == NULL);
+ assert(IsUnused());
m_shapeType = PHY_SHAPE_NONE;
m_vertexArray.clear();
m_polygonIndexArray.clear();
@@ -1398,6 +1398,17 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, bool polytope,bo
return true;
}
+bool CcdShapeConstructionInfo::SetProxy(CcdShapeConstructionInfo* shapeInfo)
+{
+ if (shapeInfo == NULL)
+ return false;
+ // no support for dynamic change
+ assert(IsUnused());
+ m_shapeType = PHY_SHAPE_PROXY;
+ m_shapeProxy = shapeInfo;
+ return true;
+}
+
btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape()
{
btCollisionShape* collisionShape = 0;
@@ -1406,9 +1417,12 @@ btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape()
btCompoundShape* compoundShape = 0;
CcdShapeConstructionInfo* nextShapeInfo;
+ if (m_shapeType == PHY_SHAPE_PROXY && m_shapeProxy != NULL)
+ return m_shapeProxy->CreateBulletShape();
+
switch (m_shapeType)
{
- case PHY_SHAPE_NONE:
+ default:
break;
case PHY_SHAPE_BOX:
@@ -1522,6 +1536,10 @@ CcdShapeConstructionInfo::~CcdShapeConstructionInfo()
m_meshShapeMap.erase(mit);
}
}
+ if (m_shapeType == PHY_SHAPE_PROXY && m_shapeProxy != NULL)
+ {
+ m_shapeProxy->Release();
+ }
}
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h
index 054ec91122a..c771aa2624b 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h
@@ -67,11 +67,13 @@ public:
m_height(1.0),
m_halfExtend(0.f,0.f,0.f),
m_childScale(1.0f,1.0f,1.0f),
+ m_userData(NULL),
m_refCount(1),
m_meshObject(NULL),
m_unscaledShape(NULL),
m_useGimpact(false),
- m_weldingThreshold(0.f)
+ m_weldingThreshold(0.f),
+ m_shapeProxy(NULL)
{
m_childTrans.setIdentity();
}
@@ -92,6 +94,11 @@ public:
return 0;
}
+ bool IsUnused(void)
+ {
+ return (m_meshObject==NULL && m_shapeArray.size() == 0 && m_shapeProxy == NULL);
+ }
+
void AddShape(CcdShapeConstructionInfo* shapeInfo);
btTriangleMeshShape* GetMeshShape(void)
@@ -105,6 +112,32 @@ public:
return m_shapeArray.at(i);
}
+ int FindChildShape(CcdShapeConstructionInfo* shapeInfo, void* userData)
+ {
+ if (shapeInfo == NULL)
+ return -1;
+ for (int i=0; i<m_shapeArray.size(); i++)
+ {
+ CcdShapeConstructionInfo* childInfo = m_shapeArray.at(i);
+ if ((userData == NULL || userData == childInfo->m_userData) &&
+ (childInfo == shapeInfo ||
+ (childInfo->m_shapeType == PHY_SHAPE_PROXY &&
+ childInfo->m_shapeProxy == shapeInfo)))
+ return i;
+ }
+ return -1;
+ }
+
+ bool RemoveChildShape(int i)
+ {
+ if (i < 0 || i >= m_shapeArray.size())
+ return false;
+ m_shapeArray.at(i)->Release();
+ if (i < m_shapeArray.size()-1)
+ m_shapeArray[i] = m_shapeArray.back();
+ m_shapeArray.pop_back();
+ return true;
+ }
bool SetMesh(RAS_MeshObject* mesh, bool polytope,bool useGimpact);
RAS_MeshObject* GetMesh(void)
@@ -112,6 +145,12 @@ public:
return m_meshObject;
}
+ bool SetProxy(CcdShapeConstructionInfo* shapeInfo);
+ CcdShapeConstructionInfo* GetProxy(void)
+ {
+ return m_shapeProxy;
+ }
+
btCollisionShape* CreateBulletShape();
// member variables
@@ -121,6 +160,7 @@ public:
btVector3 m_halfExtend;
btTransform m_childTrans;
btVector3 m_childScale;
+ void* m_userData;
std::vector<btPoint3> m_vertexArray; // Contains both vertex array for polytope shape and
// triangle array for concave mesh shape.
// In this case a triangle is made of 3 consecutive points
@@ -146,7 +186,7 @@ protected:
std::vector<CcdShapeConstructionInfo*> m_shapeArray; // for compound shapes
bool m_useGimpact; //use gimpact for concave dynamic/moving collision detection
float m_weldingThreshold; //welding closeby vertices together can improve softbody stability etc.
-
+ CcdShapeConstructionInfo* m_shapeProxy; // only used for PHY_SHAPE_PROXY, pointer to actual shape info
};
struct CcdConstructionInfo
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
index 4fe35630784..d2274c1e8d6 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
@@ -536,12 +536,24 @@ void CcdPhysicsEnvironment::disableCcdPhysicsController(CcdPhysicsController* ct
{
} else
{
- m_dynamicsWorld->removeCollisionObject(body);
+ m_dynamicsWorld->removeCollisionObject(ctrl->GetCollisionObject());
}
}
}
}
+void CcdPhysicsEnvironment::refreshCcdPhysicsController(CcdPhysicsController* ctrl)
+{
+ btCollisionObject* obj = ctrl->GetCollisionObject();
+ if (obj)
+ {
+ btBroadphaseProxy* proxy = obj->getBroadphaseHandle();
+ if (proxy)
+ {
+ m_dynamicsWorld->getPairCache()->cleanProxyFromPairs(proxy,m_dynamicsWorld->getDispatcher());
+ }
+ }
+}
void CcdPhysicsEnvironment::beginFrame()
{
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
index 74384dd8cf2..4b28d3fddfc 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
@@ -196,6 +196,8 @@ protected:
void enableCcdPhysicsController(CcdPhysicsController* ctrl);
+ void refreshCcdPhysicsController(CcdPhysicsController* ctrl);
+
btBroadphaseInterface* getBroadphase();
btDispatcher* getDispatcher();
diff --git a/source/gameengine/Physics/common/PHY_DynamicTypes.h b/source/gameengine/Physics/common/PHY_DynamicTypes.h
index 3b3e42c38d2..09126264dcc 100644
--- a/source/gameengine/Physics/common/PHY_DynamicTypes.h
+++ b/source/gameengine/Physics/common/PHY_DynamicTypes.h
@@ -95,7 +95,8 @@ typedef enum PHY_ShapeType {
PHY_SHAPE_CONE,
PHY_SHAPE_MESH,
PHY_SHAPE_POLYTOPE,
- PHY_SHAPE_COMPOUND
+ PHY_SHAPE_COMPOUND,
+ PHY_SHAPE_PROXY
} PHY_ShapeType;
diff --git a/source/gameengine/PyDoc/BL_ActionActuator.py b/source/gameengine/PyDoc/BL_ActionActuator.py
index b68d3014115..3e95befe16b 100644
--- a/source/gameengine/PyDoc/BL_ActionActuator.py
+++ b/source/gameengine/PyDoc/BL_ActionActuator.py
@@ -5,9 +5,52 @@ from SCA_IActuator import *
class BL_ActionActuator(SCA_IActuator):
"""
Action Actuators apply an action to an actor.
+
+ @ivar action: The name of the action to set as the current action.
+ @type action: string
+ @ivar start: Specifies the starting frame of the animation.
+ @type start: float
+ @type end: Specifies the ending frame of the animation.
+ @type end: float
+ @ivar blendin: Specifies the number of frames of animation to generate when making transitions between actions.
+ @type blendin: float
+ @ivar priority: Sets the priority of this actuator. Actuators will lower
+ priority numbers will override actuators with higher
+ numbers.
+ @type priority: integer
+ @ivar frame: Sets the current frame for the animation.
+ @type frame: float
+ @ivar property: Sets the property to be used in FromProp playback mode.
+ @type property: string
+ @ivar blendTime: Sets the internal frame timer. This property must be in
+ the range from 0.0 to blendin.
+ @type blendTime: float
+ @ivar type: The operation mode of the actuator.
+ KX_ACTIONACT_PLAY, KX_ACTIONACT_PROPERTY, KX_ACTIONACT_FLIPPER,
+ KX_ACTIONACT_LOOPSTOP, KX_ACTIONACT_LOOPEND
+ @type type: integer
+ @ivar continue: The actions continue option, True or False.
+ When True, the action will always play from where last left off,
+ otherwise negative events to this actuator will reset it to its start frame.
+ @type: boolean
+ @ivar frameProperty: The name of the property that is set to the current frame number.
+ @type frameProperty: string
"""
+ def setChannel(channel, matrix, mode = False):
+ """
+ @param channel: A string specifying the name of the bone channel.
+ @type channel: string
+ @param matrix: A 4x4 matrix specifying the overriding transformation
+ as an offset from the bone's rest position.
+ @type matrix: list [[float]]
+ @param mode: True for armature/world space, False for bone space
+ @type mode: boolean
+ """
+
+ #--The following methods are deprecated--
def setAction(action, reset = True):
"""
+ DEPRECATED: use the 'action' property
Sets the current action.
@param action: The name of the action to set as the current action.
@@ -21,6 +64,7 @@ class BL_ActionActuator(SCA_IActuator):
def setStart(start):
"""
+ DEPRECATED: use the 'start' property
Specifies the starting frame of the animation.
@param start: the starting frame of the animation
@@ -29,6 +73,7 @@ class BL_ActionActuator(SCA_IActuator):
def setEnd(end):
"""
+ DEPRECATED: use the 'end' property
Specifies the ending frame of the animation.
@param end: the ending frame of the animation
@@ -36,6 +81,7 @@ class BL_ActionActuator(SCA_IActuator):
"""
def setBlendin(blendin):
"""
+ DEPRECATED: use the 'blendin' property
Specifies the number of frames of animation to generate
when making transitions between actions.
@@ -45,6 +91,7 @@ class BL_ActionActuator(SCA_IActuator):
def setPriority(priority):
"""
+ DEPRECATED: use the 'priority' property
Sets the priority of this actuator.
@param priority: Specifies the new priority. Actuators will lower
@@ -54,6 +101,7 @@ class BL_ActionActuator(SCA_IActuator):
"""
def setFrame(frame):
"""
+ DEPRECATED: use the 'frame' property
Sets the current frame for the animation.
@param frame: Specifies the new current frame for the animation
@@ -62,6 +110,7 @@ class BL_ActionActuator(SCA_IActuator):
def setProperty(prop):
"""
+ DEPRECATED: use the 'property' property
Sets the property to be used in FromProp playback mode.
@param prop: the name of the property to use.
@@ -70,6 +119,7 @@ class BL_ActionActuator(SCA_IActuator):
def setBlendtime(blendtime):
"""
+ DEPRECATED: use the 'blendTime' property
Sets the internal frame timer.
Allows the script to directly modify the internal timer
@@ -81,6 +131,7 @@ class BL_ActionActuator(SCA_IActuator):
def setType(mode):
"""
+ DEPRECATED: use the 'type' property
Sets the operation mode of the actuator
@param mode: KX_ACTIONACT_PLAY, KX_ACTIONACT_PROPERTY, KX_ACTIONACT_FLIPPER, KX_ACTIONACT_LOOPSTOP, KX_ACTIONACT_LOOPEND
@@ -89,6 +140,7 @@ class BL_ActionActuator(SCA_IActuator):
def setContinue(cont):
"""
+ DEPRECATED: use the 'continue' property
Set the actions continue option True or False. see getContinue.
@param cont: The continue option.
@@ -97,6 +149,7 @@ class BL_ActionActuator(SCA_IActuator):
def getType():
"""
+ DEPRECATED: use the 'type' property
Returns the operation mode of the actuator
@rtype: integer
@@ -105,6 +158,7 @@ class BL_ActionActuator(SCA_IActuator):
def getContinue():
"""
+ DEPRECATED: use the 'continue' property
When True, the action will always play from where last left off, otherwise negative events to this actuator will reset it to its start frame.
@rtype: bool
@@ -112,6 +166,7 @@ class BL_ActionActuator(SCA_IActuator):
def getAction():
"""
+ DEPRECATED: use the 'action' property
getAction() returns the name of the action associated with this actuator.
@rtype: string
@@ -119,24 +174,28 @@ class BL_ActionActuator(SCA_IActuator):
def getStart():
"""
+ DEPRECATED: use the 'start' property
Returns the starting frame of the action.
@rtype: float
"""
def getEnd():
"""
+ DEPRECATED: use the 'end' property
Returns the last frame of the action.
@rtype: float
"""
def getBlendin():
"""
+ DEPRECATED: use the 'blendin' property
Returns the number of interpolation animation frames to be generated when this actuator is triggered.
@rtype: float
"""
def getPriority():
"""
+ DEPRECATED: use the 'priority' property
Returns the priority for this actuator. Actuators with lower Priority numbers will
override actuators with higher numbers.
@@ -144,33 +203,27 @@ class BL_ActionActuator(SCA_IActuator):
"""
def getFrame():
"""
+ DEPRECATED: use the 'frame' property
Returns the current frame number.
@rtype: float
"""
def getProperty():
"""
+ DEPRECATED: use the 'property' property
Returns the name of the property to be used in FromProp mode.
@rtype: string
"""
- def setChannel(channel, matrix, mode = False):
- """
- @param channel: A string specifying the name of the bone channel.
- @type channel: string
- @param matrix: A 4x4 matrix specifying the overriding transformation
- as an offset from the bone's rest position.
- @type matrix: list [[float]]
- @param mode: True for armature/world space, False for bone space
- @type mode: boolean
- """
def setFrameProperty(prop):
"""
+ DEPRECATED: use the 'frameProperty' property
@param prop: A string specifying the property of the object that will be updated with the action frame number.
@type prop: string
"""
def getFrameProperty():
"""
+ DEPRECATED: use the 'frameProperty' property
Returns the name of the property that is set to the current frame number.
@rtype: string
diff --git a/source/gameengine/PyDoc/BL_ShapeActionActuator.py b/source/gameengine/PyDoc/BL_ShapeActionActuator.py
index a26b276a2da..209ff4e5580 100644
--- a/source/gameengine/PyDoc/BL_ShapeActionActuator.py
+++ b/source/gameengine/PyDoc/BL_ShapeActionActuator.py
@@ -4,10 +4,38 @@ from SCA_IActuator import *
class BL_ShapeActionActuator(SCA_IActuator):
"""
- ShapeAction Actuators apply an shape action to an mesh object.
+ ShapeAction Actuators apply an shape action to an mesh object.\
+
+ @ivar action: The name of the action to set as the current shape action.
+ @type action: string
+ @ivar start: Specifies the starting frame of the shape animation.
+ @type start: float
+ @type end: Specifies the ending frame of the shape animation.
+ @type end: float
+ @ivar blendin: Specifies the number of frames of animation to generate when making transitions between actions.
+ @type blendin: float
+ @ivar priority: Sets the priority of this actuator. Actuators will lower
+ priority numbers will override actuators with higher
+ numbers.
+ @type priority: integer
+ @ivar frame: Sets the current frame for the animation.
+ @type frame: float
+ @ivar property: Sets the property to be used in FromProp playback mode.
+ @type property: string
+ @ivar blendTime: Sets the internal frame timer. This property must be in
+ the range from 0.0 to blendin.
+ @type blendTime: float
+ @ivar type: The operation mode of the actuator.
+ KX_ACTIONACT_PLAY, KX_ACTIONACT_PROPERTY, KX_ACTIONACT_FLIPPER,
+ KX_ACTIONACT_LOOPSTOP, KX_ACTIONACT_LOOPEND
+ @type type: integer
+ @ivar frameProperty: The name of the property that is set to the current frame number.
+ @type frameProperty: string
+
"""
def setAction(action, reset = True):
"""
+ DEPRECATED: use the 'action' property
Sets the current action.
@param action: The name of the action to set as the current action.
@@ -21,6 +49,7 @@ class BL_ShapeActionActuator(SCA_IActuator):
def setStart(start):
"""
+ DEPRECATED: use the 'start' property
Specifies the starting frame of the animation.
@param start: the starting frame of the animation
@@ -29,6 +58,7 @@ class BL_ShapeActionActuator(SCA_IActuator):
def setEnd(end):
"""
+ DEPRECATED: use the 'end' property
Specifies the ending frame of the animation.
@param end: the ending frame of the animation
@@ -36,6 +66,7 @@ class BL_ShapeActionActuator(SCA_IActuator):
"""
def setBlendin(blendin):
"""
+ DEPRECATED: use the 'blendin' property
Specifies the number of frames of animation to generate
when making transitions between actions.
@@ -45,6 +76,7 @@ class BL_ShapeActionActuator(SCA_IActuator):
def setPriority(priority):
"""
+ DEPRECATED: use the 'priority' property
Sets the priority of this actuator.
@param priority: Specifies the new priority. Actuators will lower
@@ -54,6 +86,7 @@ class BL_ShapeActionActuator(SCA_IActuator):
"""
def setFrame(frame):
"""
+ DEPRECATED: use the 'frame' property
Sets the current frame for the animation.
@param frame: Specifies the new current frame for the animation
@@ -62,6 +95,7 @@ class BL_ShapeActionActuator(SCA_IActuator):
def setProperty(prop):
"""
+ DEPRECATED: use the 'property' property
Sets the property to be used in FromProp playback mode.
@param prop: the name of the property to use.
@@ -70,6 +104,7 @@ class BL_ShapeActionActuator(SCA_IActuator):
def setBlendtime(blendtime):
"""
+ DEPRECATED: use the 'blendTime' property
Sets the internal frame timer.
Allows the script to directly modify the internal timer
@@ -81,37 +116,25 @@ class BL_ShapeActionActuator(SCA_IActuator):
def setType(mode):
"""
+ DEPRECATED: use the 'type' property
Sets the operation mode of the actuator
@param mode: KX_ACTIONACT_PLAY, KX_ACTIONACT_PROPERTY, KX_ACTIONACT_FLIPPER, KX_ACTIONACT_LOOPSTOP, KX_ACTIONACT_LOOPEND
@type mode: integer
"""
- def setContinue(cont):
- """
- Set the actions continue option True or False. see getContinue.
-
- @param cont: The continue option.
- @type cont: bool
- """
-
def getType():
"""
+ DEPRECATED: use the 'type' property
Returns the operation mode of the actuator
@rtype: integer
@return: KX_ACTIONACT_PLAY, KX_ACTIONACT_PROPERTY, KX_ACTIONACT_FLIPPER, KX_ACTIONACT_LOOPSTOP, KX_ACTIONACT_LOOPEND
"""
- def getContinue():
- """
- When True, the action will always play from where last left off, otherwise negative events to this actuator will reset it to its start frame.
-
- @rtype: bool
- """
-
def getAction():
"""
+ DEPRECATED: use the 'action' property
getAction() returns the name of the action associated with this actuator.
@rtype: string
@@ -119,24 +142,28 @@ class BL_ShapeActionActuator(SCA_IActuator):
def getStart():
"""
+ DEPRECATED: use the 'start' property
Returns the starting frame of the action.
@rtype: float
"""
def getEnd():
"""
+ DEPRECATED: use the 'end' property
Returns the last frame of the action.
@rtype: float
"""
def getBlendin():
"""
+ DEPRECATED: use the 'blendin' property
Returns the number of interpolation animation frames to be generated when this actuator is triggered.
@rtype: float
"""
def getPriority():
"""
+ DEPRECATED: use the 'priority' property
Returns the priority for this actuator. Actuators with lower Priority numbers will
override actuators with higher numbers.
@@ -144,23 +171,27 @@ class BL_ShapeActionActuator(SCA_IActuator):
"""
def getFrame():
"""
+ DEPRECATED: use the 'frame' property
Returns the current frame number.
@rtype: float
"""
def getProperty():
"""
+ DEPRECATED: use the 'property' property
Returns the name of the property to be used in FromProp mode.
@rtype: string
"""
def setFrameProperty(prop):
"""
+ DEPRECATED: use the 'frameProperty' property
@param prop: A string specifying the property of the object that will be updated with the action frame number.
@type prop: string
"""
def getFrameProperty():
"""
+ DEPRECATED: use the 'frameProperty' property
Returns the name of the property that is set to the current frame number.
@rtype: string
diff --git a/source/gameengine/PyDoc/KX_ActuatorSensor.py b/source/gameengine/PyDoc/KX_ActuatorSensor.py
index cdfbf27576e..b0e138a8009 100644
--- a/source/gameengine/PyDoc/KX_ActuatorSensor.py
+++ b/source/gameengine/PyDoc/KX_ActuatorSensor.py
@@ -8,15 +8,22 @@ class KX_ActuatorSensor(SCA_ISensor):
Actuator sensor detect change in actuator state of the parent object.
It generates a positive pulse if the corresponding actuator is activated
and a negative pulse if the actuator is deactivated.
+
+ Properties:
+
+ @ivar actuator: the name of the actuator that the sensor is monitoring.
+ @type actuator: string
"""
def getActuator():
"""
+ DEPRECATED: use the actuator property
Return the Actuator with which the sensor operates.
@rtype: string
"""
def setActuator(name):
"""
+ DEPRECATED: use the actuator property
Sets the Actuator with which to operate. If there is no Actuator
of this name, the function has no effect.
diff --git a/source/gameengine/PyDoc/SCA_DelaySensor.py b/source/gameengine/PyDoc/SCA_DelaySensor.py
index 19df589ea7b..b99ed08bed5 100644
--- a/source/gameengine/PyDoc/SCA_DelaySensor.py
+++ b/source/gameengine/PyDoc/SCA_DelaySensor.py
@@ -13,9 +13,21 @@ class SCA_DelaySensor(SCA_ISensor):
The sensor runs the OFF-ON cycle once unless the repeat option is set: the
OFF-ON cycle repeats indefinately (or the OFF cycle if duration is 0).
Use SCA_ISensor::reset() at any time to restart sensor.
+
+ Properties:
+
+ @ivar delay: length of the initial OFF period as number of frame, 0 for immediate trigger.
+ @type delay: integer.
+ @ivar duration: length of the ON period in number of frame after the initial OFF period.
+ If duration is greater than 0, a negative trigger is sent at the end of the ON pulse.
+ @type duration: integer
+ @ivar repeat: 1 if the OFF-ON cycle should be repeated indefinately, 0 if it should run once.
+ @type repeat: integer
+
"""
def setDelay(delay):
"""
+ DEPRECATED: use the delay property
Set the initial delay before the positive trigger.
@param delay: length of the initial OFF period as number of frame, 0 for immediate trigger
@@ -23,6 +35,7 @@ class SCA_DelaySensor(SCA_ISensor):
"""
def setDuration(duration):
"""
+ DEPRECATED: use the duration property
Set the duration of the ON pulse after initial delay and the generation of the positive trigger.
If duration is greater than 0, a negative trigger is sent at the end of the ON pulse.
@@ -31,6 +44,7 @@ class SCA_DelaySensor(SCA_ISensor):
"""
def setRepeat(repeat):
"""
+ DEPRECATED: use the repeat property
Set if the sensor repeat mode.
@param repeat: 1 if the OFF-ON cycle should be repeated indefinately, 0 if it should run once.
@@ -38,18 +52,21 @@ class SCA_DelaySensor(SCA_ISensor):
"""
def getDelay():
"""
+ DEPRECATED: use the delay property
Return the delay parameter value.
@rtype: integer
"""
def getDuration():
"""
+ DEPRECATED: use the duration property
Return the duration parameter value
@rtype: integer
"""
def getRepeat():
"""
+ DEPRECATED: use the repeat property
Return the repeat parameter value
@rtype: KX_TRUE or KX_FALSE
diff --git a/source/gameengine/PyDoc/SCA_ILogicBrick.py b/source/gameengine/PyDoc/SCA_ILogicBrick.py
index ea09fcaea37..18cb900f28d 100644
--- a/source/gameengine/PyDoc/SCA_ILogicBrick.py
+++ b/source/gameengine/PyDoc/SCA_ILogicBrick.py
@@ -5,6 +5,9 @@ from KX_GameObject import *
class SCA_ILogicBrick:
"""
Base class for all logic bricks.
+
+ @ivar executePriority: This determines the order controllers are evaluated, and actuators are activated (lower priority is executed first).
+ @type executePriority: int
"""
def getOwner():
@@ -13,6 +16,8 @@ class SCA_ILogicBrick:
@rtype: L{KX_GameObject}
"""
+
+ #--The following methods are deprecated--
def setExecutePriority(priority):
"""
Sets the priority of this logic brick.
@@ -20,6 +25,8 @@ class SCA_ILogicBrick:
This determines the order controllers are evaluated, and actuators are activated.
Bricks with lower priority will be executed first.
+ Deprecated: Use the "executePriority" property instead.
+
@type priority: integer
@param priority: the priority of this logic brick.
"""
@@ -27,6 +34,8 @@ class SCA_ILogicBrick:
"""
Gets the execution priority of this logic brick.
+ Deprecated: Use the "executePriority" property instead.
+
@rtype: integer
@return: this logic bricks current priority.
"""
diff --git a/source/gameengine/PyDoc/SCA_ISensor.py b/source/gameengine/PyDoc/SCA_ISensor.py
index 14858505e24..ab35996aa50 100644
--- a/source/gameengine/PyDoc/SCA_ISensor.py
+++ b/source/gameengine/PyDoc/SCA_ISensor.py
@@ -5,8 +5,35 @@ from SCA_ILogicBrick import *
class SCA_ISensor(SCA_ILogicBrick):
"""
Base class for all sensor logic bricks.
+
+ @ivar usePosPulseMode: Flag to turn positive pulse mode on and off.
+ @type usePosPulseMode: boolean
+ @ivar useNegPulseMode: Flag to turn negative pulse mode on and off.
+ @type useNegPulseMode: boolean
+ @ivar frequency: The frequency for pulse mode sensors.
+ @type frequency: int
+ @ivar level: Flag to set whether to detect level or edge transition when entering a state.
+ It makes a difference only in case of logic state transition (state actuator).
+ A level detector will immediately generate a pulse, negative or positive
+ depending on the sensor condition, as soon as the state is activated.
+ A edge detector will wait for a state change before generating a pulse.
+ @type level: boolean
+ @ivar invert: Flag to set if this sensor activates on positive or negative events.
+ @type invert: boolean
+ @ivar triggered: True if this sensor brick is in a positive state. (Read only)
+ @type triggered: boolean
+ @ivar positive: True if this sensor brick is in a positive state. (Read only)
+ @type positive: boolean
"""
+ def reset():
+ """
+ Reset sensor internal state, effect depends on the type of sensor and settings.
+
+ The sensor is put in its initial state as if it was just activated.
+ """
+
+ #--The following methods are deprecated--
def isPositive():
"""
True if this sensor brick is in a positive state.
@@ -82,10 +109,3 @@ class SCA_ISensor(SCA_ILogicBrick):
@param level: Detect level instead of edge? (KX_TRUE, KX_FALSE)
@type level: boolean
"""
- def reset():
- """
- Reset sensor internal state, effect depends on the type of sensor and settings.
-
- The sensor is put in its initial state as if it was just activated.
- """
-
diff --git a/source/gameengine/PyDoc/SCA_JoystickSensor.py b/source/gameengine/PyDoc/SCA_JoystickSensor.py
index d1dab9afcaf..111ee7f4cfa 100644
--- a/source/gameengine/PyDoc/SCA_JoystickSensor.py
+++ b/source/gameengine/PyDoc/SCA_JoystickSensor.py
@@ -5,15 +5,58 @@ from SCA_ISensor import *
class SCA_JoystickSensor(SCA_ISensor):
"""
This sensor detects player joystick events.
+
+ Properties:
+
+ @ivar axisPosition: (read-only) The state of the joysticks axis as a list of 4 values, each spesifying the value of an axis between -32767 and 32767 depending on how far the axis is pushed, 0 for nothing.
+ The first 2 values are used by most joysticks and gamepads for directional control. 3rd and 4th values are only on some joysticks and can be used for arbitary controls.
+ left:[-32767, 0, ...], right:[32767, 0, ...], up:[0, -32767, ...], down:[0, 32767, ...]
+ @type axisPosition: [integer, integer, integer, integer]
+ @ivar numAxis: (read-only) The number of axes for the joystick at this index.
+ @type numAxis: integer
+ @ivar numButtons: (read-only) The number of buttons for the joystick at this index.
+ @type numButtons: integer
+ @ivar numHats: (read-only) The number of hats for the joystick at this index.
+ @type numHats: integer
+ @ivar connected: (read-only) True if a joystick is connected at this joysticks index.
+ @type connected: boolean
+ @ivar index: The joystick index to use (from 0 to 7). The first joystick is always 0.
+ @type index: integer
+ @ivar threshold: Axis threshold. Joystick axis motion below this threshold wont trigger an event. Use values between (0 and 32767), lower values are more sensitive.
+ @type threshold: integer
+ @ivar button: The button index the sensor reacts to (first button = 0). When the "All Events" toggle is set, this option has no effect.
+ @type button: integer
+ @ivar axis: The axis this sensor reacts to, as a list of two values [axisIndex, axisDirection]
+ axisIndex: the axis index to use when detecting axis movement, 1=primary directional control, 2=secondary directional control.
+ axisDirection: 0=right, 1=up, 2=left, 3=down
+ @type axis: [integer, integer]
+ @ivar hat: The hat the sensor reacts to, as a list of two values: [hatIndex, hatDirection]
+ hatIndex: the hat index to use when detecting hat movement, 1=primary hat, 2=secondary hat.
+ hatDirection: 0-11
+ @type hat: [integer, integer]
"""
+ def getButtonActiveList():
+ """
+ Returns a list containing the indicies of the currently pressed buttons.
+ @rtype: list
+ """
+ def getButtonStatus(buttonIndex):
+ """
+ Returns a bool of the current pressed state of the specified button.
+ @param buttonIndex: the button index, 0=first button
+ @type buttonIndex: integer
+ @rtype: bool
+ """
def getIndex():
"""
+ DEPRECATED: use the 'index' property.
Returns the joystick index to use (from 1 to 8).
@rtype: integer
"""
def setIndex(index):
"""
+ DEPRECATED: use the 'index' property.
Sets the joystick index to use.
@param index: The index of this joystick sensor, Clamped between 1 and 8.
@type index: integer
@@ -21,6 +64,7 @@ class SCA_JoystickSensor(SCA_ISensor):
"""
def getAxis():
"""
+ DEPRECATED: use the 'axis' property.
Returns the current axis this sensor reacts to. See L{getAxisValue()<SCA_JoystickSensor.getAxisValue>} for the current axis state.
@rtype: list
@return: 2 values returned are [axisIndex, axisDirection] - see L{setAxis()<SCA_JoystickSensor.setAxis>} for their purpose.
@@ -28,6 +72,7 @@ class SCA_JoystickSensor(SCA_ISensor):
"""
def setAxis(axisIndex, axisDirection):
"""
+ DEPRECATED: use the 'axis' property.
@param axisIndex: Set the axis index to use when detecting axis movement.
@type axisIndex: integer from 1 to 2
@param axisDirection: Set the axis direction used for detecting motion. 0:right, 1:up, 2:left, 3:down.
@@ -36,6 +81,7 @@ class SCA_JoystickSensor(SCA_ISensor):
"""
def getAxisValue():
"""
+ DEPRECATED: use the 'axisPosition' property.
Returns the state of the joysticks axis. See differs to L{getAxis()<SCA_JoystickSensor.getAxis>} returning the current state of the joystick.
@rtype: list
@return: 4 values, each spesifying the value of an axis between -32767 and 32767 depending on how far the axis is pushed, 0 for nothing.
@@ -47,60 +93,71 @@ class SCA_JoystickSensor(SCA_ISensor):
"""
def getThreshold():
"""
+ DEPRECATED: use the 'threshold' property.
Get the axis threshold. See L{setThreshold()<SCA_JoystickSensor.setThreshold>} for details.
@rtype: integer
"""
def setThreshold(threshold):
"""
+ DEPRECATED: use the 'threshold' property.
Set the axis threshold.
@param threshold: Joystick axis motion below this threshold wont trigger an event. Use values between (0 and 32767), lower values are more sensitive.
@type threshold: integer
"""
def getButton():
"""
+ DEPRECATED: use the 'button' property.
Returns the button index the sensor reacts to. See L{getButtonValue()<SCA_JoystickSensor.getButtonValue>} for a list of pressed buttons.
@rtype: integer
@note: When the "All Events" toggle is set, this option has no effect.
"""
def setButton(index):
"""
+ DEPRECATED: use the 'button' property.
Sets the button index the sensor reacts to when the "All Events" option is not set.
@note: When the "All Events" toggle is set, this option has no effect.
"""
def getButtonValue():
"""
+ DEPRECATED: use the 'getButtonActiveList' method.
Returns a list containing the indicies of the currently pressed buttons.
@rtype: list
"""
def getHat():
"""
+ DEPRECATED: use the 'hat' property.
Returns the current hat direction this sensor is set to.
[hatNumber, hatDirection].
@rtype: list
@note: When the "All Events" toggle is set, this option has no effect.
"""
- def setHat(index):
+ def setHat(index,direction):
"""
+ DEPRECATED: use the 'hat' property.
Sets the hat index the sensor reacts to when the "All Events" option is not set.
@type index: integer
"""
def getNumAxes():
"""
+ DEPRECATED: use the 'numAxis' property.
Returns the number of axes for the joystick at this index.
@rtype: integer
"""
def getNumButtons():
"""
+ DEPRECATED: use the 'numButtons' property.
Returns the number of buttons for the joystick at this index.
@rtype: integer
"""
def getNumHats():
"""
+ DEPRECATED: use the 'numHats' property.
Returns the number of hats for the joystick at this index.
@rtype: integer
"""
def isConnected():
"""
+ DEPRECATED: use the 'connected' property.
Returns True if a joystick is detected at this joysticks index.
@rtype: bool
"""
diff --git a/source/gameengine/PyDoc/SCA_KeyboardSensor.py b/source/gameengine/PyDoc/SCA_KeyboardSensor.py
index 2f741f7d6a2..f6a7a7d8a97 100644
--- a/source/gameengine/PyDoc/SCA_KeyboardSensor.py
+++ b/source/gameengine/PyDoc/SCA_KeyboardSensor.py
@@ -7,44 +7,99 @@ class SCA_KeyboardSensor(SCA_ISensor):
A keyboard sensor detects player key presses.
See module L{GameKeys} for keycode values.
+
+ @ivar key: The key code this sensor is looking for.
+ @type key: keycode from L{GameKeys} module
+ @ivar hold1: The key code for the first modifier this sensor is looking for.
+ @type hold1: keycode from L{GameKeys} module
+ @ivar hold2: The key code for the second modifier this sensor is looking for.
+ @type hold2: keycode from L{GameKeys} module
+ @ivar toggleProperty: The name of the property that indicates whether or not to log keystrokes as a string.
+ @type toggleProperty: string
+ @ivar targetProperty: The name of the property that receives keystrokes in case in case a string is logged.
+ @type targetProperty: string
+ @ivar useAllKeys: Flag to determine whether or not to accept all keys.
+ @type useAllKeys: boolean
"""
+ def getEventList():
+ """
+ Get a list of pressed keys that have either been pressed, or just released, or are active this frame.
+
+ @rtype: list of key status. [[keycode, status]]
+ @return: A list of keyboard events
+ """
+
+ def getKeyStatus(keycode):
+ """
+ Get the status of a key.
+
+ @rtype: key state (KX_NO_INPUTSTATUS, KX_JUSTACTIVATED, KX_ACTIVE or KX_JUSTRELEASED)
+ @return: The state of the given key
+ @type keycode: integer
+ @param keycode: The code that represents the key you want to get the state of
+ """
+ #--The following methods are deprecated--
def getKey():
"""
Returns the key code this sensor is looking for.
+
+ Deprecated: Use the "key" property instead.
+
+ @rtype: keycode from L{GameKeys} module
"""
def setKey(keycode):
"""
Set the key this sensor should listen for.
+ Deprecated: Use the "key" property instead.
+
@type keycode: keycode from L{GameKeys} module
"""
def getHold1():
"""
Returns the key code for the first modifier this sensor is looking for.
+
+ Deprecated: Use the "hold1" property instead.
+
+ @rtype: keycode from L{GameKeys} module
"""
- def setHold1():
+ def setHold1(keycode):
"""
Sets the key code for the first modifier this sensor should look for.
+
+ Deprecated: Use the "hold1" property instead.
+
+ @type keycode: keycode from L{GameKeys} module
"""
def getHold2():
"""
Returns the key code for the second modifier this sensor is looking for.
+
+ Deprecated: Use the "hold2" property instead.
+
+ @rtype: keycode from L{GameKeys} module
"""
- def setHold2():
+ def setHold2(keycode):
"""
Sets the key code for the second modifier this sensor should look for.
+
+ Deprecated: Use the "hold2" property instead.
+
+ @type keycode: keycode from L{GameKeys} module
"""
def getPressedKeys():
"""
Get a list of keys that have either been pressed, or just released this frame.
+ Deprecated: Use getEventList() instead.
+
@rtype: list of key status. [[keycode, status]]
"""
@@ -52,7 +107,7 @@ class SCA_KeyboardSensor(SCA_ISensor):
"""
Get a list of currently pressed keys that have either been pressed, or just released
+ Deprecated: Use getEventList() instead.
+
@rtype: list of key status. [[keycode, status]]
- """
-
-
+ """ \ No newline at end of file
diff --git a/source/gameengine/PyDoc/SCA_MouseSensor.py b/source/gameengine/PyDoc/SCA_MouseSensor.py
index 06b261f67fa..9550cbb4105 100644
--- a/source/gameengine/PyDoc/SCA_MouseSensor.py
+++ b/source/gameengine/PyDoc/SCA_MouseSensor.py
@@ -5,10 +5,20 @@ from SCA_ISensor import *
class SCA_MouseSensor(SCA_ISensor):
"""
Mouse Sensor logic brick.
+
+ Properties:
+
+ @ivar position: current [x,y] coordinates of the mouse, in frame coordinates (pixels)
+ @type position: [integer,interger]
+ @ivar mode: sensor mode: 1=KX_MOUSESENSORMODE_LEFTBUTTON 2=KX_MOUSESENSORMODE_MIDDLEBUTTON
+ 3=KX_MOUSESENSORMODE_RIGHTBUTTON 4=KX_MOUSESENSORMODE_WHEELUP
+ 5=KX_MOUSESENSORMODE_WHEELDOWN 9=KX_MOUSESENSORMODE_MOVEMENT
+ @type mode: integer
"""
def getXPosition():
"""
+ DEPRECATED: use the position property
Gets the x coordinate of the mouse.
@rtype: integer
@@ -16,6 +26,7 @@ class SCA_MouseSensor(SCA_ISensor):
"""
def getYPosition():
"""
+ DEPRECATED: use the position property
Gets the y coordinate of the mouse.
@rtype: integer
diff --git a/source/gameengine/PyDoc/SCA_PropertyActuator.py b/source/gameengine/PyDoc/SCA_PropertyActuator.py
index dc1233ddfb7..52aefcae651 100644
--- a/source/gameengine/PyDoc/SCA_PropertyActuator.py
+++ b/source/gameengine/PyDoc/SCA_PropertyActuator.py
@@ -5,9 +5,17 @@ from SCA_IActuator import *
class SCA_PropertyActuator(SCA_IActuator):
"""
Property Actuator
+
+ Properties:
+
+ @ivar property: the property on which to operate.
+ @type property: string
+ @ivar value: the value with which the actuator operates.
+ @type value: string
"""
def setProperty(prop):
"""
+ DEPRECATED: use the 'property' property
Set the property on which to operate.
If there is no property of this name, the call is ignored.
@@ -17,12 +25,14 @@ class SCA_PropertyActuator(SCA_IActuator):
"""
def getProperty():
"""
+ DEPRECATED: use the 'property' property
Returns the name of the property on which to operate.
@rtype: string
"""
def setValue(value):
"""
+ DEPRECATED: use the 'value' property
Set the value with which the actuator operates.
If the value is not compatible with the type of the
@@ -32,6 +42,7 @@ class SCA_PropertyActuator(SCA_IActuator):
"""
def getValue():
"""
+ DEPRECATED: use the 'value' property
Gets the value with which this actuator operates.
@rtype: string
diff --git a/source/gameengine/PyDoc/SCA_PropertySensor.py b/source/gameengine/PyDoc/SCA_PropertySensor.py
index 22de8d8b986..949ffd3b703 100644
--- a/source/gameengine/PyDoc/SCA_PropertySensor.py
+++ b/source/gameengine/PyDoc/SCA_PropertySensor.py
@@ -5,10 +5,22 @@ from SCA_ISensor import *
class SCA_PropertySensor(SCA_ISensor):
"""
Activates when the game object property matches.
+
+ Properties:
+
+ @ivar type: type of check on the property:
+ KX_PROPSENSOR_EQUAL(1), KX_PROPSENSOR_NOTEQUAL(2), KX_PROPSENSOR_INTERVAL(3),
+ KX_PROPSENSOR_CHANGED(4), KX_PROPSENSOR_EXPRESSION(5)
+ @type type: integer
+ @ivar property: the property with which the sensor operates.
+ @type property: string
+ @ivar value: the value with which the sensor compares to the value of the property.
+ @type value: string
"""
def getType():
"""
+ DEPRECATED: use the type property
Gets when to activate this sensor.
@return: KX_PROPSENSOR_EQUAL, KX_PROPSENSOR_NOTEQUAL,
@@ -18,6 +30,7 @@ class SCA_PropertySensor(SCA_ISensor):
def setType(checktype):
"""
+ DEPRECATED: use the type property
Set the type of check to perform.
@type checktype: KX_PROPSENSOR_EQUAL, KX_PROPSENSOR_NOTEQUAL,
@@ -27,6 +40,7 @@ class SCA_PropertySensor(SCA_ISensor):
def getProperty():
"""
+ DEPRECATED: use the property property
Return the property with which the sensor operates.
@rtype: string
@@ -34,6 +48,7 @@ class SCA_PropertySensor(SCA_ISensor):
"""
def setProperty(name):
"""
+ DEPRECATED: use the property property
Sets the property with which to operate. If there is no property
of that name, this call is ignored.
@@ -41,6 +56,7 @@ class SCA_PropertySensor(SCA_ISensor):
"""
def getValue():
"""
+ DEPRECATED: use the value property
Return the value with which the sensor compares to the value of the property.
@rtype: string
@@ -48,6 +64,7 @@ class SCA_PropertySensor(SCA_ISensor):
"""
def setValue(value):
"""
+ DEPRECATED: use the value property
Set the value with which the sensor operates. If the value
is not compatible with the type of the property, the subsequent
action is ignored.
diff --git a/source/gameengine/PyDoc/SCA_PythonController.py b/source/gameengine/PyDoc/SCA_PythonController.py
index 6d91736d636..06f2b7e9d1d 100644
--- a/source/gameengine/PyDoc/SCA_PythonController.py
+++ b/source/gameengine/PyDoc/SCA_PythonController.py
@@ -6,6 +6,14 @@ class SCA_PythonController(SCA_IController):
"""
A Python controller uses a Python script to activate it's actuators,
based on it's sensors.
+
+ Properties:
+
+ @ivar script: the Python script this controller executes
+ @type script: string, read-only
+ @ivar state: the controllers state bitmask.
+ This can be used with the GameObject's state to test if the controller is active.
+ @type state: integer
"""
def getSensors():
@@ -36,6 +44,7 @@ class SCA_PythonController(SCA_IController):
"""
def getScript():
"""
+ DEPRECATED: use the script property
Gets the Python script this controller executes.
@rtype: string
@@ -48,6 +57,7 @@ class SCA_PythonController(SCA_IController):
"""
def getState():
"""
+ DEPRECATED: use the state property
Get the controllers state bitmask, this can be used with the GameObject's state to test if the the controller is active.
This for instance will always be true however you could compare with a previous state to see when the state was activated.
GameLogic.getCurrentController().getState() & GameLogic.getCurrentController().getOwner().getState()
diff --git a/source/gameengine/PyDoc/SCA_RandomActuator.py b/source/gameengine/PyDoc/SCA_RandomActuator.py
index 353b398b1ff..000a1af7846 100644
--- a/source/gameengine/PyDoc/SCA_RandomActuator.py
+++ b/source/gameengine/PyDoc/SCA_RandomActuator.py
@@ -5,9 +5,35 @@ from SCA_IActuator import *
class SCA_RandomActuator(SCA_IActuator):
"""
Random Actuator
+
+ Properties:
+
+ @ivar seed: Seed of the random number generator.
+ Equal seeds produce equal series. If the seed is 0,
+ the generator will produce the same value on every call.
+ @type seed: integer
+ @ivar para1: the first parameter of the active distribution.
+ Refer to the documentation of the generator types for the meaning
+ of this value.
+ @type para1: float, read-only
+ @ivar para2: the second parameter of the active distribution.
+ Refer to the documentation of the generator types for the meaning
+ of this value.
+ @type para2: float, read-only
+ @ivar distribution: distribution type:
+ KX_RANDOMACT_BOOL_CONST, KX_RANDOMACT_BOOL_UNIFORM, KX_RANDOMACT_BOOL_BERNOUILLI,
+ KX_RANDOMACT_INT_CONST, KX_RANDOMACT_INT_UNIFORM, KX_RANDOMACT_INT_POISSON,
+ KX_RANDOMACT_FLOAT_CONST, KX_RANDOMACT_FLOAT_UNIFORM, KX_RANDOMACT_FLOAT_NORMAL,
+ KX_RANDOMACT_FLOAT_NEGATIVE_EXPONENTIAL
+ @type distribution: integer, read-only
+ @ivar property: the name of the property to set with the random value.
+ If the generator and property types do not match, the assignment is ignored.
+ @type property: string
+
"""
def setSeed(seed):
"""
+ DEPRECATED: use the seed property
Sets the seed of the random number generator.
Equal seeds produce equal series. If the seed is 0,
@@ -17,12 +43,14 @@ class SCA_RandomActuator(SCA_IActuator):
"""
def getSeed():
"""
+ DEPRECATED: use the seed property
Returns the initial seed of the generator.
@rtype: integer
"""
def getPara1():
"""
+ DEPRECATED: use the para1 property
Returns the first parameter of the active distribution.
Refer to the documentation of the generator types for the meaning
@@ -32,6 +60,7 @@ class SCA_RandomActuator(SCA_IActuator):
"""
def getPara2():
"""
+ DEPRECATED: use the para2 property
Returns the second parameter of the active distribution.
Refer to the documentation of the generator types for the meaning
@@ -41,6 +70,7 @@ class SCA_RandomActuator(SCA_IActuator):
"""
def getDistribution():
"""
+ DEPRECATED: use the distribution property
Returns the type of random distribution.
@rtype: distribution type
@@ -51,6 +81,7 @@ class SCA_RandomActuator(SCA_IActuator):
"""
def setProperty(property):
"""
+ DEPRECATED: use the property property
Set the property to which the random value is assigned.
If the generator and property types do not match, the assignment is ignored.
@@ -60,6 +91,7 @@ class SCA_RandomActuator(SCA_IActuator):
"""
def getProperty():
"""
+ DEPRECATED: use the property property
Returns the name of the property to set.
@rtype: string
diff --git a/source/nan_definitions.mk b/source/nan_definitions.mk
index 258cfc6f586..495eb60a7f8 100644
--- a/source/nan_definitions.mk
+++ b/source/nan_definitions.mk
@@ -100,13 +100,13 @@ endif
ifeq ($(FREE_WINDOWS), true)
export NAN_FTGL ?= $(LCGDIR)/gcc/ftgl
export NAN_FFMPEG ?= $(LCGDIR)/gcc/ffmpeg
- export NAN_FFMPEGLIBS ?= $(NAN_FFMPEG)/lib/libavformat.a $(NAN_FFMPEG)/lib/libavutil.a $(NAN_FFMPEG)/lib/libavcodec.a
- export NAN_FFMPEGCFLAGS ?= -I$(NAN_FFMPEG)/include
+ export NAN_FFMPEGLIBS ?= $(NAN_FFMPEG)/lib/libavformat.a $(NAN_FFMPEG)/lib/libavutil.a $(NAN_FFMPEG)/lib/libavcodec.a $(NAN_FFMPEG)/lib/libavdevice.a
+ export NAN_FFMPEGCFLAGS ?= -I$(NAN_FFMPEG)/include -I$(NANBLENDERHOME)/extern/ffmpeg
else
export NAN_FTGL ?= $(LCGDIR)/ftgl
export NAN_FFMPEG ?= $(LCGDIR)/ffmpeg
- export NAN_FFMPEGLIBS ?= $(NAN_FFMPEG)/lib/libavformat.a $(NAN_FFMPEG)/lib/libavcodec.a $(NAN_FFMPEG)/lib/libswscale.a $(NAN_FFMPEG)/lib/libavutil.a
- export NAN_FFMPEGCFLAGS ?= -I$(NAN_FFMPEG)/include
+ export NAN_FFMPEGLIBS ?= $(NAN_FFMPEG)/lib/libavformat.a $(NAN_FFMPEG)/lib/libavcodec.a $(NAN_FFMPEG)/lib/libswscale.a $(NAN_FFMPEG)/lib/libavutil.a $(NAN_FFMPEG)/lib/libavdevice.a
+ export NAN_FFMPEGCFLAGS ?= -I$(NAN_FFMPEG)/include -I$(NANBLENDERHOME)/extern/ffmpeg
endif
export WITH_OPENEXR ?= true
@@ -353,8 +353,8 @@ endif
export NAN_SDLLIBS ?= $(NAN_SDL)/lib/libSDL.a
export NAN_SDLCFLAGS ?= -I$(NAN_SDL)/include/SDL
export NAN_FFMPEG ?= $(LCGDIR)/ffmpeg
- export NAN_FFMPEGLIBS = $(NAN_FFMPEG)/lib/libavformat.a $(NAN_FFMPEG)/lib/libavcodec.a $(NAN_FFMPEG)/lib/libswscale.a $(NAN_FFMPEG)/lib/libavutil.a $(NAN_FFMPEG)/lib/libogg.a $(NAN_FFMPEG)/lib/libfaad.a $(NAN_FFMPEG)/lib/libmp3lame.a $(NAN_FFMPEG)/lib/libvorbis.a $(NAN_FFMPEG)/lib/libx264.a $(NAN_FFMPEG)/lib/libfaac.a $(NAN_ZLIB)/lib/libz.a
- export NAN_FFMPEGCFLAGS ?= -I$(NAN_FFMPEG)/include
+ export NAN_FFMPEGLIBS = $(NAN_FFMPEG)/lib/libavformat.a $(NAN_FFMPEG)/lib/libavcodec.a $(NAN_FFMPEG)/lib/libswscale.a $(NAN_FFMPEG)/lib/libavutil.a $(NAN_FFMPEG)/lib/libavdevice.a $(NAN_FFMPEG)/lib/libogg.a $(NAN_FFMPEG)/lib/libfaad.a $(NAN_FFMPEG)/lib/libmp3lame.a $(NAN_FFMPEG)/lib/libvorbis.a $(NAN_FFMPEG)/lib/libx264.a $(NAN_FFMPEG)/lib/libfaac.a $(NAN_ZLIB)/lib/libz.a
+ export NAN_FFMPEGCFLAGS ?= -I$(NAN_FFMPEG)/include -I$(NANBLENDERHOME)/extern/ffmpeg
# Uncomment the following line to use Mozilla inplace of netscape
# CPPFLAGS +=-DMOZ_NOT_NET
@@ -403,7 +403,7 @@ endif
ifneq ($(NAN_USE_FFMPEG_CONFIG), true)
export NAN_FFMPEG ?= /usr
- export NAN_FFMPEGLIBS ?= -L$(NAN_FFMPEG)/lib -lavformat -lavcodec -lavutil -lswscale -ldts -lz
+ export NAN_FFMPEGLIBS ?= -L$(NAN_FFMPEG)/lib -lavformat -lavcodec -lavutil -lswscale -lavdevice -ldts -lz
export NAN_FFMPEGCFLAGS ?= -I$(NAN_FFMPEG)/include
endif