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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2008-09-01 11:03:09 +0400
committerCampbell Barton <ideasman42@gmail.com>2008-09-01 11:03:09 +0400
commit546127d964e1144e76fcf4bb28049c68b7eae298 (patch)
tree576daae034e52a57b756eb5a0aec01037c2b9f4f
parentbb57536018048922d589cf7aad5eb86e66f13f6c (diff)
svn merge -r 16297:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender
-rw-r--r--CMakeLists.txt13
-rw-r--r--source/blender/blenkernel/intern/ipo.c2
-rw-r--r--source/blender/include/BIF_editarmature.h3
-rw-r--r--source/blender/makesdna/DNA_sensor_types.h5
-rw-r--r--source/blender/src/buttons_logic.c7
-rw-r--r--source/blender/src/drawgpencil.c19
-rw-r--r--source/blender/src/editarmature.c29
-rw-r--r--source/blender/src/editnode.c5
-rw-r--r--source/blender/src/editobject.c1
-rw-r--r--source/blender/src/gpencil.c172
-rw-r--r--source/blender/src/header_view3d.c4
-rw-r--r--source/blender/src/transform_conversions.c29
-rw-r--r--source/gameengine/Converter/BL_ArmatureObject.cpp6
-rw-r--r--source/gameengine/Converter/BL_ArmatureObject.h1
-rw-r--r--source/gameengine/Converter/KX_ConvertSensors.cpp1
-rw-r--r--source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp105
-rw-r--r--source/gameengine/GameLogic/Joystick/SCA_Joystick.h170
-rw-r--r--source/gameengine/GameLogic/Joystick/SCA_JoystickDefines.h2
-rw-r--r--source/gameengine/GameLogic/SCA_JoystickManager.cpp17
-rw-r--r--source/gameengine/GameLogic/SCA_JoystickManager.h4
-rw-r--r--source/gameengine/GameLogic/SCA_JoystickSensor.cpp128
-rw-r--r--source/gameengine/GameLogic/SCA_JoystickSensor.h37
-rw-r--r--source/gameengine/PyDoc/KX_GameObject.py12
-rw-r--r--source/gameengine/PyDoc/KX_ObjectActuator.py4
-rw-r--r--source/gameengine/PyDoc/KX_PolyProxy.py2
-rw-r--r--source/gameengine/PyDoc/KX_TrackToActuator.py2
-rw-r--r--source/gameengine/PyDoc/Rasterizer.py3
-rw-r--r--source/gameengine/PyDoc/SCA_DelaySensor.py2
28 files changed, 450 insertions, 335 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index dc7876a3b61..d9bee46a2da 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -255,7 +255,11 @@ IF(WIN32)
SET(GETTEXT ${LIBDIR}/gettext)
SET(GETTEXT_INC ${GETTEXT}/include)
- SET(GETTEXT_LIB gnu_gettext)
+ IF(CMAKE_CL_64)
+ SET(GETTEXT_LIB gettextlib)
+ ELSE(CMAKE_CL_64)
+ SET(GETTEXT_LIB gnu_gettext)
+ ENDIF(CMAKE_CL_64)
SET(GETTEXT_LIBPATH ${GETTEXT}/lib)
SET(FREETYPE ${LIBDIR}/freetype)
@@ -286,7 +290,12 @@ IF(WIN32)
SET(FFMPEG_LIB avcodec-51 avformat-51 avutil-49)
SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
+ IF(CMAKE_CL_64)
+ SET(LLIBS kernel32 user32 vfw32 winmm ws2_32 )
+ ELSE(CMAKE_CL_64)
SET(LLIBS kernel32 user32 gdi32 comdlg32 advapi32 shell32 ole32 oleaut32 uuid ws2_32 vfw32 winmm)
+ ENDIF(CMAKE_CL_64)
+
IF(WITH_OPENAL)
SET(LLIBS ${LLIBS} dxguid)
ENDIF(WITH_OPENAL)
@@ -324,7 +333,7 @@ IF(WIN32)
SET(WINTAB_INC ${LIBDIR}/wintab/include)
IF(CMAKE_CL_64)
- SET(PLATFORM_LINKFLAGS "/NODEFAULTLIB:libc.lib;MSVCRT.lib ")
+ SET(PLATFORM_LINKFLAGS "/MACHINE:X64 /NODEFAULTLIB:libc.lib;MSVCRT.lib ")
ELSE(CMAKE_CL_64)
SET(PLATFORM_LINKFLAGS "/NODEFAULTLIB:libc.lib ")
ENDIF(CMAKE_CL_64)
diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c
index e85c87a5784..e8a25aaaf80 100644
--- a/source/blender/blenkernel/intern/ipo.c
+++ b/source/blender/blenkernel/intern/ipo.c
@@ -1695,6 +1695,8 @@ void set_icu_vars(IpoCurve *icu)
icu->ymax= 5.0; break;
case MA_ADD:
icu->ymax= 1.0; break;
+ case MA_EMIT:
+ icu->ymax= 2.0; break;
default:
icu->ymax= 1.0; break;
}
diff --git a/source/blender/include/BIF_editarmature.h b/source/blender/include/BIF_editarmature.h
index b2bdb2dad73..fdd00a67465 100644
--- a/source/blender/include/BIF_editarmature.h
+++ b/source/blender/include/BIF_editarmature.h
@@ -100,13 +100,14 @@ struct Bone *get_indexed_bone (struct Object *ob, int index);
void make_editArmature(void);
void make_trans_bones (char mode);
+void remake_editArmature(void);
+void editbones_to_armature(struct ListBase *list, struct Object *ob);
int do_pose_selectbuffer(struct Base *base, unsigned int *buffer, short hits);
void generateSkeleton(void);
void mouse_armature(void);
-void remake_editArmature(void);
void selectconnected_armature(void);
void selectconnected_posearmature(void);
void armature_select_hierarchy(short direction, short add_to_sel);
diff --git a/source/blender/makesdna/DNA_sensor_types.h b/source/blender/makesdna/DNA_sensor_types.h
index d508ff3a552..3e0075c00bd 100644
--- a/source/blender/makesdna/DNA_sensor_types.h
+++ b/source/blender/makesdna/DNA_sensor_types.h
@@ -164,7 +164,7 @@ typedef struct bSensor {
typedef struct bJoystickSensor {
char name[32];
short type;
- short pad;
+ short joyindex;
int axis;
int axisf;
int button;
@@ -266,6 +266,7 @@ typedef struct bJoystickSensor {
#define SENS_JOY_HAT_DIR 0
#define SENS_DELAY_REPEAT 1
-
+// should match JOYINDEX_MAX in SCA_JoystickDefines.h */
+#define SENS_JOY_MAXINDEX 8
#endif
diff --git a/source/blender/src/buttons_logic.c b/source/blender/src/buttons_logic.c
index 9b41b646bc8..0b6986c2c8e 100644
--- a/source/blender/src/buttons_logic.c
+++ b/source/blender/src/buttons_logic.c
@@ -1444,10 +1444,13 @@ static short draw_sensorbuttons(bSensor *sens, uiBlock *block, short xco, short
draw_default_sensor_header(sens, block, xco, yco, width);
joy= sens->data;
-
+
+ uiDefButS(block, NUM, 1, "Index:", xco+10, yco-44, 0.6 * (width-120), 19,
+ &joy->joyindex, 0, SENS_JOY_MAXINDEX-1, 100, 0,
+ "Spesify which joystick to use");
str= "Type %t|Button %x0|Axis %x1|Hat%x2";
- uiDefButS(block, MENU, B_REDR, str, xco+10, yco-44, 0.6 * (width-20), 19,
+ uiDefButS(block, MENU, B_REDR, str, xco+87, yco-44, 0.6 * (width-150), 19,
&joy->type, 0, 31, 0, 0,
"The type of event this joystick sensor is triggered on.");
diff --git a/source/blender/src/drawgpencil.c b/source/blender/src/drawgpencil.c
index 4b6b5ab26c8..15f65bfe3cf 100644
--- a/source/blender/src/drawgpencil.c
+++ b/source/blender/src/drawgpencil.c
@@ -145,6 +145,13 @@ void gp_ui_delframe_cb (void *gpd, void *gpl)
allqueue(REDRAWACTION, 0);
}
+/* convert the active layer to geometry */
+void gp_ui_convertlayer_cb (void *gpd, void *gpl)
+{
+ gpencil_layer_setactive(gpd, gpl);
+ gpencil_convert_menu();
+}
+
/* ------- Drawing Code ------- */
/* draw the controls for a given layer */
@@ -166,7 +173,7 @@ static void gp_drawui_layer (uiBlock *block, bGPdata *gpd, bGPDlayer *gpl, short
/* rounded header */
if (active) uiBlockSetCol(block, TH_BUT_ACTION);
rb_col= (active)?-20:20;
- uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-8, *yco-2, width, 24, NULL, 5.0, 0.0, 15 , rb_col-20, "");
+ uiDefBut(block, ROUNDBOX, B_REDR, "", *xco-8, *yco-2, width, 24, NULL, 5.0, 0.0, 15 , rb_col-20, "");
if (active) uiBlockSetCol(block, TH_AUTO);
/* lock toggle */
@@ -249,8 +256,14 @@ static void gp_drawui_layer (uiBlock *block, bGPdata *gpd, bGPDlayer *gpl, short
/* options */
uiBlockBeginAlign(block);
- but= uiDefBut(block, BUT, B_REDR, "Del Active Frame", *xco+160, *yco-75, 140, 20, NULL, 0, 0, 0, 0, "Erases the the active frame for this layer (Hotkey = Alt-XKEY/DEL)");
- uiButSetFunc(but, gp_ui_delframe_cb, gpd, gpl);
+ if (curarea->spacetype == SPACE_VIEW3D) {
+ but= uiDefBut(block, BUT, B_REDR, "Convert to...", *xco+160, *yco-75, 140, 20, NULL, 0, 0, 0, 0, "Converts this layer's strokes to geometry (Hotkey = Alt-Shift-C)");
+ uiButSetFunc(but, gp_ui_convertlayer_cb, gpd, gpl);
+ }
+ else {
+ but= uiDefBut(block, BUT, B_REDR, "Del Active Frame", *xco+160, *yco-75, 140, 20, NULL, 0, 0, 0, 0, "Erases the the active frame for this layer (Hotkey = Alt-XKEY/DEL)");
+ uiButSetFunc(but, gp_ui_delframe_cb, gpd, gpl);
+ }
but= uiDefBut(block, BUT, B_REDR, "Del Last Stroke", *xco+160, *yco-95, 140, 20, NULL, 0, 0, 0, 0, "Erases the last stroke from the active frame (Hotkey = Alt-XKEY/DEL)");
uiButSetFunc(but, gp_ui_delstroke_cb, gpd, gpl);
diff --git a/source/blender/src/editarmature.c b/source/blender/src/editarmature.c
index 01a0c330b47..5e50c8117cc 100644
--- a/source/blender/src/editarmature.c
+++ b/source/blender/src/editarmature.c
@@ -440,9 +440,23 @@ void docenter_armature (Object *ob, int centermode)
}
/* helper for apply_armature_pose2bones - fixes parenting of objects that are bone-parented to armature */
-static void applyarmature_fix_boneparents (Object *ob)
+static void applyarmature_fix_boneparents (Object *armob)
{
+ Object *ob;
+ /* go through all objects in database */
+ for (ob= G.main->object.first; ob; ob= ob->id.next) {
+ /* if parent is bone in this armature, apply corrections */
+ if ((ob->parent == armob) && (ob->partype == PARBONE)) {
+ /* apply current transform from parent (not yet destroyed),
+ * then calculate new parent inverse matrix
+ */
+ apply_obmat(ob);
+
+ what_does_parent(ob);
+ Mat4Invert(ob->parentinv, workob.obmat);
+ }
+ }
}
/* set the current pose as the restpose */
@@ -463,6 +477,9 @@ void apply_armature_pose2bones(void)
}
arm= get_armature(ob);
+ /* helpful warnings... */
+ // TODO: add warnings to be careful about actions, applying deforms first, etc.
+
/* Get editbones of active armature to alter */
if (G.edbo.first) BLI_freelistN(&G.edbo);
make_boneList(&G.edbo, &arm->bonebase, NULL);
@@ -485,9 +502,9 @@ void apply_armature_pose2bones(void)
float premat[3][3], imat[3][3],pmat[3][3], tmat[3][3];
float delta[3], eul[3];
- /* obtain new auto-yrotation */
+ /* obtain new auto y-rotation */
VecSubf(delta, curbone->tail, curbone->head);
- vec_roll_to_mat3(delta, curbone->roll, premat);
+ vec_roll_to_mat3(delta, 0.0, premat);
Mat3Inv(imat, premat);
/* get pchan 'visual' matrix */
@@ -503,9 +520,11 @@ void apply_armature_pose2bones(void)
/* clear transform values for pchan */
pchan->loc[0]= pchan->loc[1]= pchan->loc[2]= 0;
- pchan->size[0]= pchan->size[1]= pchan->size[2]= 1;
pchan->quat[1]= pchan->quat[2]= pchan->quat[3]= 0;
- pchan->quat[0]= 1;
+ pchan->quat[0]= pchan->size[0]= pchan->size[1]= pchan->size[2]= 1;
+
+ /* set anim lock */
+ curbone->flag |= BONE_UNKEYED;
}
/* convert editbones back to bones */
diff --git a/source/blender/src/editnode.c b/source/blender/src/editnode.c
index eba6c5b4488..d3ba153e600 100644
--- a/source/blender/src/editnode.c
+++ b/source/blender/src/editnode.c
@@ -2001,7 +2001,10 @@ void node_hide(SpaceNode *snode)
void node_insert_key(SpaceNode *snode)
{
bNode *node= editnode_get_active(snode->edittree);
-
+
+ if(node == NULL)
+ return;
+
if(node->type==CMP_NODE_TIME) {
if(node->custom1<node->custom2) {
diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c
index dded38a00e8..2094074e3f3 100644
--- a/source/blender/src/editobject.c
+++ b/source/blender/src/editobject.c
@@ -2828,6 +2828,7 @@ void convertmenu(void)
if(G.scene->id.lib) return;
obact= OBACT;
+ if (obact == NULL) return;
if(!obact->flag & SELECT) return;
if(G.obedit) return;
diff --git a/source/blender/src/gpencil.c b/source/blender/src/gpencil.c
index 0148ace20d4..6bbaecc2956 100644
--- a/source/blender/src/gpencil.c
+++ b/source/blender/src/gpencil.c
@@ -46,6 +46,7 @@
#include "BLI_blenlib.h"
#include "DNA_listBase.h"
+#include "DNA_armature_types.h"
#include "DNA_curve_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_object_types.h"
@@ -59,11 +60,13 @@
#include "BKE_global.h"
#include "BKE_utildefines.h"
#include "BKE_blender.h"
+#include "BKE_armature.h"
#include "BKE_curve.h"
#include "BIF_gl.h"
#include "BIF_glutil.h"
#include "BIF_butspace.h"
+#include "BIF_editarmature.h"
#include "BIF_editview.h"
#include "BIF_graphics.h"
#include "BIF_interface.h"
@@ -719,8 +722,10 @@ static void gp_strokepoint_convertcoords (bGPDstroke *gps, bGPDspoint *pt, float
}
}
+/* --- */
+
/* convert stroke to 3d path */
-static void gp_layer_to_path (bGPDlayer *gpl, bGPDstroke *gps, Curve *cu)
+static void gp_stroke_to_path (bGPDlayer *gpl, bGPDstroke *gps, Curve *cu)
{
bGPDspoint *pt;
Nurb *nu;
@@ -756,7 +761,7 @@ static void gp_layer_to_path (bGPDlayer *gpl, bGPDstroke *gps, Curve *cu)
}
/* convert stroke to 3d bezier */
-static void gp_layer_to_bezier (bGPDlayer *gpl, bGPDstroke *gps, Curve *cu)
+static void gp_stroke_to_bezier (bGPDlayer *gpl, bGPDstroke *gps, Curve *cu)
{
bGPDspoint *pt;
Nurb *nu;
@@ -828,18 +833,105 @@ static void gp_layer_to_curve (bGPdata *gpd, bGPDlayer *gpl, short mode)
for (gps= gpf->strokes.first; gps; gps= gps->next) {
switch (mode) {
case 1:
- gp_layer_to_path(gpl, gps, cu);
+ gp_stroke_to_path(gpl, gps, cu);
break;
case 2:
- gp_layer_to_bezier(gpl, gps, cu);
+ gp_stroke_to_bezier(gpl, gps, cu);
break;
}
}
}
+/* --- */
+
+/* convert a stroke to a bone chain */
+static void gp_stroke_to_bonechain (bGPDlayer *gpl, bGPDstroke *gps, bArmature *arm, ListBase *bones)
+{
+ EditBone *ebo, *prev=NULL;
+ bGPDspoint *pt, *ptn;
+ int i;
+
+ /* add each segment separately */
+ for (i=0, pt=gps->points, ptn=gps->points+1; i < (gps->totpoints-1); prev=ebo, i++, pt++, ptn++) {
+ float p3da[3], p3db[3];
+
+ /* get coordinates to add at */
+ gp_strokepoint_convertcoords(gps, pt, p3da);
+ gp_strokepoint_convertcoords(gps, ptn, p3db);
+
+ /* allocate new bone */
+ ebo= MEM_callocN(sizeof(EditBone), "eBone");
+
+ VecCopyf(ebo->head, p3da);
+ VecCopyf(ebo->tail, p3db);
+
+ /* add new bone - note: sync with editarmature.c::add_editbone() */
+ BLI_strncpy(ebo->name, "Stroke", 32);
+ unique_editbone_name(bones, ebo->name);
+
+ BLI_addtail(bones, ebo);
+
+ ebo->flag |= BONE_CONNECTED;
+ ebo->weight= 1.0F;
+ ebo->dist= 0.25F;
+ ebo->xwidth= 0.1;
+ ebo->zwidth= 0.1;
+ ebo->ease1= 1.0;
+ ebo->ease2= 1.0;
+ ebo->rad_head= pt->pressure * gpl->thickness * 0.1;
+ ebo->rad_tail= ptn->pressure * gpl->thickness * 0.1;
+ ebo->segments= 1;
+ ebo->layer= arm->layer;
+
+ /* set parenting */
+ // TODO: also adjust roll....
+ ebo->parent= prev;
+ }
+}
+
+/* convert a given grease-pencil layer to a 3d-curve representation (using current view if appropriate) */
+static void gp_layer_to_armature (bGPdata *gpd, bGPDlayer *gpl, short mode)
+{
+ bGPDframe *gpf= gpencil_layer_getframe(gpl, CFRA, 0);
+ bGPDstroke *gps;
+ Object *ob;
+ bArmature *arm;
+ ListBase bones = {0,0};
+
+ /* error checking */
+ if (ELEM3(NULL, gpd, gpl, gpf))
+ return;
+
+ /* only convert if there are any strokes on this layer's frame to convert */
+ if (gpf->strokes.first == NULL)
+ return;
+
+ /* initialise the armature */
+ arm= add_armature(gpl->info);
+
+ /* init the armature object (remove rotation and assign armature data to it) */
+ add_object_draw(OB_ARMATURE);
+ ob= OBACT;
+ ob->loc[0]= ob->loc[1]= ob->loc[2]= 0;
+ ob->rot[0]= ob->rot[1]= ob->rot[2]= 0;
+ ob->data= arm;
+
+ /* convert segments to bones, strokes to bone chains */
+ for (gps= gpf->strokes.first; gps; gps= gps->next) {
+ gp_stroke_to_bonechain(gpl, gps, arm, &bones);
+ }
+
+ /* flush editbones to armature */
+ editbones_to_armature(&bones, ob);
+ if (bones.first) BLI_freelistN(&bones);
+}
+
+/* --- */
+
/* convert grease-pencil strokes to another representation
* mode: 1 - Active layer to path
* 2 - Active layer to bezier
+ * 3 - Active layer to armature
*/
void gpencil_convert_operation (short mode)
{
@@ -862,6 +954,12 @@ void gpencil_convert_operation (short mode)
gp_layer_to_curve(gpd, gpl, mode);
}
break;
+ case 3: /* active layer only (to armature) */
+ {
+ bGPDlayer *gpl= gpencil_layer_getactive(gpd);
+ gp_layer_to_armature(gpd, gpl, mode);
+ }
+ break;
}
/* redraw and undo-push */
@@ -879,7 +977,7 @@ void gpencil_convert_menu (void)
/* only show menu if it will be relevant */
if (gpd == NULL) return;
- mode= pupmenu("Grease Pencil Convert %t|Active Layer To Path%x1|Active Layer to Bezier%x2");
+ mode= pupmenu("Grease Pencil Convert %t|Active Layer To Path%x1|Active Layer to Bezier%x2|Active Layer to Armature%x3");
if (mode <= 0) return;
gpencil_convert_operation(mode);
@@ -1210,9 +1308,18 @@ static void gp_stroke_newfrombuffer (tGPsdata *p)
bGPDspoint *pt;
tGPspoint *ptc;
int i, totelem;
+
+ /* macro to test if only converting endpoints */
+ #define GP_BUFFER2STROKE_ENDPOINTS ((gpd->flag & GP_DATA_EDITPAINT) && (G.qual & LR_CTRLKEY))
- /* get total number of points to allocate space for */
- totelem = gpd->sbuffer_size;
+ /* get total number of points to allocate space for:
+ * - in 'Draw Mode', holding the Ctrl-Modifier will only take endpoints
+ * - otherwise, do whole stroke
+ */
+ if (GP_BUFFER2STROKE_ENDPOINTS)
+ totelem = (gpd->sbuffer_size >= 2) ? 2: gpd->sbuffer_size;
+ else
+ totelem = gpd->sbuffer_size;
/* exit with error if no valid points from this stroke */
if (totelem == 0) {
@@ -1233,18 +1340,50 @@ static void gp_stroke_newfrombuffer (tGPsdata *p)
gps->flag= gpd->sbuffer_sflag;
/* copy points from the buffer to the stroke */
- for (i=0, ptc=gpd->sbuffer; i < gpd->sbuffer_size && ptc; i++, ptc++) {
- /* convert screen-coordinates to appropriate coordinates (and store them) */
- gp_stroke_convertcoords(p, &ptc->x, &pt->x);
-
- /* copy pressure */
- pt->pressure= ptc->pressure;
-
- pt++;
+ if (GP_BUFFER2STROKE_ENDPOINTS) {
+ /* 'Draw Mode' + Ctrl-Modifier - only endpoints */
+ {
+ /* first point */
+ ptc= gpd->sbuffer;
+
+ /* convert screen-coordinates to appropriate coordinates (and store them) */
+ gp_stroke_convertcoords(p, &ptc->x, &pt->x);
+
+ /* copy pressure */
+ pt->pressure= ptc->pressure;
+
+ pt++;
+ }
+
+ if (totelem == 2) {
+ /* last point if applicable */
+ ptc= ((tGPspoint *)gpd->sbuffer) + (gpd->sbuffer_size - 1);
+
+ /* convert screen-coordinates to appropriate coordinates (and store them) */
+ gp_stroke_convertcoords(p, &ptc->x, &pt->x);
+
+ /* copy pressure */
+ pt->pressure= ptc->pressure;
+ }
+ }
+ else {
+ /* convert all points (normal behaviour) */
+ for (i=0, ptc=gpd->sbuffer; i < gpd->sbuffer_size && ptc; i++, ptc++) {
+ /* convert screen-coordinates to appropriate coordinates (and store them) */
+ gp_stroke_convertcoords(p, &ptc->x, &pt->x);
+
+ /* copy pressure */
+ pt->pressure= ptc->pressure;
+
+ pt++;
+ }
}
/* add stroke to frame */
BLI_addtail(&p->gpf->strokes, gps);
+
+ /* undefine macro to test if only converting endpoints */
+ #undef GP_BUFFER2STROKE_ENDPOINTS
}
/* --- 'Eraser' for 'Paint' Tool ------ */
@@ -1677,7 +1816,8 @@ short gpencil_do_paint (ScrArea *sa, short mbut)
/* currently, we will only 'paint' if:
* 1. draw-mode on gpd is set (for accessibility reasons)
- * (single 'dots' are only available via this method)
+ * a) single dots are only available by this method if a single click is made
+ * b) a straight line is drawn if ctrl-modifier is held (check is done when stroke is converted!)
* 2. if shift-modifier is held + lmb -> 'quick paint'
*
* OR
diff --git a/source/blender/src/header_view3d.c b/source/blender/src/header_view3d.c
index cac23d09047..2467b8d73d2 100644
--- a/source/blender/src/header_view3d.c
+++ b/source/blender/src/header_view3d.c
@@ -4370,6 +4370,9 @@ static void do_view3d_pose_armaturemenu(void *arg, int event)
case 18:
pose_autoside_names(event-16);
break;
+ case 19: /* assign pose as restpose */
+ apply_armature_pose2bones();
+ break;
}
allqueue(REDRAWVIEW3D, 0);
@@ -4395,6 +4398,7 @@ static uiBlock *view3d_pose_armaturemenu(void *arg_unused)
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Relax Pose|W", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 15, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Apply Pose as Restpose|Ctrl A", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 19, "");
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
diff --git a/source/blender/src/transform_conversions.c b/source/blender/src/transform_conversions.c
index 1b027760ce8..eb0d4ba3515 100644
--- a/source/blender/src/transform_conversions.c
+++ b/source/blender/src/transform_conversions.c
@@ -4011,6 +4011,35 @@ void autokeyframe_pose_cb_func(Object *ob, int tmode, short targetless_ik)
insertkey_smarter(id, ID_PO, pchan->name, NULL, AC_SIZE_Z);
}
}
+ else if (IS_AUTOKEY_FLAG(AUTOMATKEY)) {
+ int matok=0;
+
+ /* check one to make sure we're not trying to set visual loc keys on
+ bones inside of a chain, which only leads to tears. */
+ matok= insertmatrixkey(id, ID_PO, pchan->name, NULL, AC_LOC_X);
+ insertmatrixkey(id, ID_PO, pchan->name, NULL, AC_LOC_Y);
+ insertmatrixkey(id, ID_PO, pchan->name, NULL, AC_LOC_Z);
+
+ if (matok == 0) {
+ insertkey(id, ID_PO, pchan->name, NULL, AC_LOC_X, 0);
+ insertkey(id, ID_PO, pchan->name, NULL, AC_LOC_Y, 0);
+ insertkey(id, ID_PO, pchan->name, NULL, AC_LOC_Z, 0);
+ }
+
+ /* check one to make sure we're not trying to set visual rot keys on
+ bones inside of a chain, which only leads to tears. */
+ matok= insertmatrixkey(id, ID_PO, pchan->name, NULL, AC_QUAT_W);
+ insertmatrixkey(id, ID_PO, pchan->name, NULL, AC_QUAT_X);
+ insertmatrixkey(id, ID_PO, pchan->name, NULL, AC_QUAT_Y);
+ insertmatrixkey(id, ID_PO, pchan->name, NULL, AC_QUAT_Z);
+
+ if (matok == 0) {
+ insertkey(id, ID_PO, pchan->name, NULL, AC_QUAT_W, 0);
+ insertkey(id, ID_PO, pchan->name, NULL, AC_QUAT_X, 0);
+ insertkey(id, ID_PO, pchan->name, NULL, AC_QUAT_Y, 0);
+ insertkey(id, ID_PO, pchan->name, NULL, AC_QUAT_Z, 0);
+ }
+ }
/* insert keyframe in any channel that's appropriate */
else {
insertkey(id, ID_PO, pchan->name, NULL, AC_SIZE_X, 0);
diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp
index 340ed2b1644..bf774bf7568 100644
--- a/source/gameengine/Converter/BL_ArmatureObject.cpp
+++ b/source/gameengine/Converter/BL_ArmatureObject.cpp
@@ -53,6 +53,7 @@ BL_ArmatureObject::BL_ArmatureObject(
: KX_GameObject(sgReplicationInfo,callbacks),
m_objArma(armature),
+ m_framePose(NULL),
m_lastframe(0.0),
m_activeAct(NULL),
m_activePriority(999),
@@ -123,10 +124,15 @@ bool BL_ArmatureObject::SetActiveAction(BL_ActionActuator *act, short priority,
m_activePriority = 9999;
m_lastframe= curtime;
m_activeAct = NULL;
+ // remember the pose at the start of the frame
+ m_framePose = m_pose;
}
if (priority<=m_activePriority)
{
+ if (priority<m_activePriority)
+ // this action overwrites the previous ones, start from initial pose to cancel their effects
+ m_pose = m_framePose;
if (m_activeAct && (m_activeAct!=act))
m_activeAct->SetBlendTime(0.0); /* Reset the blend timer */
m_activeAct = act;
diff --git a/source/gameengine/Converter/BL_ArmatureObject.h b/source/gameengine/Converter/BL_ArmatureObject.h
index 73a35621dc4..6f2c0d2f4c9 100644
--- a/source/gameengine/Converter/BL_ArmatureObject.h
+++ b/source/gameengine/Converter/BL_ArmatureObject.h
@@ -82,6 +82,7 @@ protected:
Object *m_objArma;
struct bArmature *m_armature;
struct bPose *m_pose;
+ struct bPose *m_framePose;
double m_lastframe;
class BL_ActionActuator *m_activeAct;
short m_activePriority;
diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp
index db47dc2dd3d..74819431858 100644
--- a/source/gameengine/Converter/KX_ConvertSensors.cpp
+++ b/source/gameengine/Converter/KX_ConvertSensors.cpp
@@ -713,6 +713,7 @@ void BL_ConvertSensors(struct Object* blenderobject,
gamesensor = new SCA_JoystickSensor(
eventmgr,
gameobj,
+ bjoy->joyindex,
joysticktype,
axis,axisf,
prec,
diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp
index 18d7b6ffcd0..ec0b0303b68 100644
--- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp
+++ b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp
@@ -29,9 +29,9 @@
#include "SCA_Joystick.h"
#include "SCA_JoystickPrivate.h"
-
-SCA_Joystick::SCA_Joystick()
+SCA_Joystick::SCA_Joystick(short int index)
:
+ m_joyindex(index),
m_axis10(0),
m_axis11(0),
m_axis20(0),
@@ -52,50 +52,53 @@ SCA_Joystick::~SCA_Joystick()
delete m_private;
}
-SCA_Joystick *SCA_Joystick::m_instance = NULL;
+SCA_Joystick *SCA_Joystick::m_instance[JOYINDEX_MAX];
int SCA_Joystick::m_refCount = 0;
-SCA_Joystick *SCA_Joystick::GetInstance()
+SCA_Joystick *SCA_Joystick::GetInstance( short int joyindex )
{
- if (m_instance == 0)
+ if (joyindex < 0 || joyindex >= JOYINDEX_MAX) {
+ echo("Error-invalid joystick index: " << joyindex);
+ return NULL;
+ }
+
+ if (m_refCount == 0)
{
- m_instance = new SCA_Joystick();
- m_instance->CreateJoystickDevice();
+ int i;
+ // do this once only
+ if(SDL_InitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_VIDEO ) == -1 ){
+ echo("Error-Initializing-SDL: " << SDL_GetError());
+ return NULL;
+ }
+ for (i=0; i<JOYINDEX_MAX; i++) {
+ m_instance[i] = new SCA_Joystick(i);
+ m_instance[i]->CreateJoystickDevice();
+ }
m_refCount = 1;
}
else
{
m_refCount++;
}
- return m_instance;
+ return m_instance[joyindex];
}
void SCA_Joystick::ReleaseInstance()
{
if (--m_refCount == 0)
{
- DestroyJoystickDevice();
- delete m_instance;
- m_instance = NULL;
+ int i;
+ for (i=0; i<JOYINDEX_MAX; i++) {
+ if (m_instance[i]) {
+ m_instance[i]->DestroyJoystickDevice();
+ delete m_instance[i];
+ }
+ m_instance[i]= NULL;
+ }
+ SDL_QuitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_VIDEO );
}
}
-
-bool SCA_Joystick::CreateJoystickDevice()
-{
- bool init = false;
- init = pCreateJoystickDevice();
- return init;
-}
-
-
-void SCA_Joystick::DestroyJoystickDevice()
-{
- if(m_isinit)
- pDestroyJoystickDevice();
-}
-
-
void SCA_Joystick::HandleEvents()
{
if(m_isinit)
@@ -334,42 +337,46 @@ int SCA_Joystick::GetNumberOfHats()
return -1;
}
-bool SCA_Joystick::pCreateJoystickDevice()
+bool SCA_Joystick::CreateJoystickDevice(void)
{
if(m_isinit == false){
- if(SDL_InitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_VIDEO ) == -1 ){
- echo("Error-Initializing-SDL: " << SDL_GetError());
- return false;
- }
- if(SDL_NumJoysticks() > 0){
- for(int i=0; i<SDL_NumJoysticks();i++){
- m_private->m_joystick = SDL_JoystickOpen(i);
- SDL_JoystickEventState(SDL_ENABLE);
- m_numjoys = i;
- }
- echo("Joystick-initialized");
- m_isinit = true;
- return true;
- }else{
- echo("Joystick-Error: " << SDL_NumJoysticks() << " avaiable joystick(s)");
+ if (m_joyindex>=SDL_NumJoysticks()) {
+ // don't print a message, because this is done anyway
+ //echo("Joystick-Error: " << SDL_NumJoysticks() << " avaiable joystick(s)");
return false;
}
+
+ m_private->m_joystick = SDL_JoystickOpen(m_joyindex);
+ SDL_JoystickEventState(SDL_ENABLE);
+
+ echo("Joystick " << m_joyindex << " initialized");
+ m_isinit = true;
}
- return false;
+ return true;
}
-void SCA_Joystick::pDestroyJoystickDevice()
+void SCA_Joystick::DestroyJoystickDevice(void)
{
- echo("Closing-");
- for(int i=0; i<SDL_NumJoysticks(); i++){
- if(SDL_JoystickOpened(i)){
+ if (m_isinit){
+ if(SDL_JoystickOpened(m_joyindex)){
+ echo("Closing-joystick " << m_joyindex);
SDL_JoystickClose(m_private->m_joystick);
}
+ m_isinit = false;
}
- SDL_QuitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_VIDEO );
}
+int SCA_Joystick::Connected(void)
+{
+ if (m_isinit){
+ if(SDL_JoystickOpened(m_joyindex)){
+ return 1;
+ }
+ }
+
+ return 0;
+}
void SCA_Joystick::pFillAxes()
{
diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.h b/source/gameengine/GameLogic/Joystick/SCA_Joystick.h
index 1e853070b09..d318d28e0f7 100644
--- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.h
+++ b/source/gameengine/GameLogic/Joystick/SCA_Joystick.h
@@ -1,72 +1,36 @@
/**
-
* ***** 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): snailrose.
-
*
-
* ***** END GPL LICENSE BLOCK *****
-
*/
#ifndef _SCA_JOYSTICK_H_
-
#define _SCA_JOYSTICK_H_
-
-
#include "SCA_JoystickDefines.h"
-
-
-
-
/*
-
* Basic Joystick class
* I will make this class a singleton because there should be only one joystick
* even if there are more than one scene using it and count how many scene are using it.
@@ -76,7 +40,7 @@
class SCA_Joystick
{
- static SCA_Joystick *m_instance;
+ static SCA_Joystick *m_instance[JOYINDEX_MAX];
static int m_refCount;
class PrivateData;
@@ -85,226 +49,136 @@ class SCA_Joystick
int m_joyindex;
- /*!
-
- * the number of avail joysticks
-
- */
-
- int m_numjoys;
-
/*
-
*support for 2 axes
-
*/
int m_axis10,m_axis11;
-
int m_axis20,m_axis21;
- /*
-
+ /*
* Precision or range of the axes
-
*/
-
int m_prec;
/*
-
* multiple axis values stored here
-
*/
-
int m_axisnum;
-
int m_axisvalue;
/*
-
* max # of axes avail
-
*/
-
/*disabled
-
int m_axismax;
-
*/
/*
-
* button values stored here
-
*/
-
int m_buttonnum;
/*
-
* max # of buttons avail
-
*/
int m_buttonmax;
-
/*
-
* hat values stored here
-
*/
-
int m_hatnum;
-
int m_hatdir;
/*
* max # of hats avail
-
disabled
-
int m_hatmax;
-
*/
-
/* is the joystick initialized ?*/
-
bool m_isinit;
-
/* is triggered */
-
bool m_istrig;
/*
-
* Open the joystick
-
*/
-
- bool pCreateJoystickDevice(void);
+ bool CreateJoystickDevice(void);
/*
-
* Close the joystick
-
*/
-
- void pDestroyJoystickDevice(void);
-
+ void DestroyJoystickDevice(void);
-
/*
-
* event callbacks
-
*/
void OnAxisMotion(void);
-
void OnHatMotion(void);
-
void OnButtonUp(void);
-
void OnButtonDown(void);
-
void OnNothing(void);
-
void OnBallMotion(void){}
/*
-
* fills the axis mnember values
-
*/
-
void pFillAxes(void);
-
-
-
void pFillButtons(void);
/*
-
* returns m_axis10,m_axis11...
-
*/
-
int pGetAxis(int axisnum, int udlr);
-
+
/*
-
* gets the current button
-
*/
int pGetButtonPress(int button);
/*
-
* returns if no button is pressed
-
*/
-
int pGetButtonRelease(int button);
/*
-
* gets the current hat direction
-
*/
-
int pGetHat(int direction);
- SCA_Joystick();
+ SCA_Joystick(short int index);
~SCA_Joystick();
- bool CreateJoystickDevice(void);
-
- void DestroyJoystickDevice(void);
-
-
public:
- static SCA_Joystick *GetInstance();
-
+ static SCA_Joystick *GetInstance( short int joyindex );
void ReleaseInstance();
-
void HandleEvents();
/*
-
*/
bool aUpAxisIsPositive(int axis);
-
bool aDownAxisIsPositive(int axis);
-
bool aLeftAxisIsPositive(int axis);
-
bool aRightAxisIsPositive(int axis);
-
bool aButtonPressIsPositive(int button);
-
bool aButtonReleaseIsPositive(int button);
-
bool aHatIsPositive(int dir);
/*
-
* precision is default '3200' which is overridden by input
-
*/
void cSetPrecision(int val);
-
-
int GetAxis10(void){
return m_axis10;
@@ -312,77 +186,55 @@ public:
}
int GetAxis11(void){
-
return m_axis11;
-
}
int GetAxis20(void){
-
return m_axis20;
-
}
int GetAxis21(void){
-
return m_axis21;
-
}
int GetButton(void){
-
return m_buttonnum;
-
}
int GetHat(void){
-
return m_hatdir;
-
}
int GetThreshold(void){
-
return m_prec;
-
}
bool IsTrig(void){
-
return m_istrig;
-
}
-
/*
-
* returns true if an event is being processed
-
*/
bool GetJoyAxisMotion(void);
-
bool GetJoyButtonPress(void);
-
bool GetJoyButtonRelease(void);
-
bool GetJoyHatMotion(void);
/*
-
* returns the # of...
-
*/
int GetNumberOfAxes(void);
-
int GetNumberOfButtons(void);
-
int GetNumberOfHats(void);
-
-
+ /*
+ * Test if the joystick is connected
+ */
+ int Connected(void);
};
diff --git a/source/gameengine/GameLogic/Joystick/SCA_JoystickDefines.h b/source/gameengine/GameLogic/Joystick/SCA_JoystickDefines.h
index 15a421188b9..8d8f88ecaf2 100644
--- a/source/gameengine/GameLogic/Joystick/SCA_JoystickDefines.h
+++ b/source/gameengine/GameLogic/Joystick/SCA_JoystickDefines.h
@@ -38,6 +38,8 @@
#define echo(x) std::cout << x << std::endl;
#endif
+#define JOYINDEX_MAX 8
+
/* function callbacks */
#define HANDLE_AXISMOTION(fn) ((fn)(), 0L)
#define HANDLE_HATMOTION(fn) ((fn)(), 0L)
diff --git a/source/gameengine/GameLogic/SCA_JoystickManager.cpp b/source/gameengine/GameLogic/SCA_JoystickManager.cpp
index 8ff28ba0b51..08c36326712 100644
--- a/source/gameengine/GameLogic/SCA_JoystickManager.cpp
+++ b/source/gameengine/GameLogic/SCA_JoystickManager.cpp
@@ -40,13 +40,20 @@ SCA_JoystickManager::SCA_JoystickManager(class SCA_LogicManager* logicmgr)
: SCA_EventManager(JOY_EVENTMGR),
m_logicmgr(logicmgr)
{
- m_joystick = SCA_Joystick::GetInstance();
+ int i;
+ for (i=0; i<JOYINDEX_MAX; i++) {
+ m_joystick[i] = SCA_Joystick::GetInstance( i );
+ }
+ //m_joystick = NULL;
}
SCA_JoystickManager::~SCA_JoystickManager()
{
- m_joystick->ReleaseInstance();
+ int i;
+ for (i=0; i<JOYINDEX_MAX; i++) {
+ m_joystick[i]->ReleaseInstance();
+ }
}
@@ -58,17 +65,17 @@ void SCA_JoystickManager::NextFrame(double curtime,double deltatime)
SCA_JoystickSensor* joysensor = (SCA_JoystickSensor*)(*it);
if(!joysensor->IsSuspended())
{
- m_joystick->HandleEvents();
+ m_joystick[joysensor->GetJoyIndex()]->HandleEvents();
joysensor->Activate(m_logicmgr, NULL);
}
}
}
-SCA_Joystick *SCA_JoystickManager::GetJoystickDevice()
+SCA_Joystick *SCA_JoystickManager::GetJoystickDevice( short int joyindex)
{
/*
*Return the instance of SCA_Joystick for use
*/
- return m_joystick;
+ return m_joystick[joyindex];
}
diff --git a/source/gameengine/GameLogic/SCA_JoystickManager.h b/source/gameengine/GameLogic/SCA_JoystickManager.h
index f2bb27965fa..d3a7ac95bea 100644
--- a/source/gameengine/GameLogic/SCA_JoystickManager.h
+++ b/source/gameengine/GameLogic/SCA_JoystickManager.h
@@ -40,12 +40,12 @@ class SCA_JoystickManager : public SCA_EventManager
/**
* SDL Joystick Class Instance
*/
- SCA_Joystick *m_joystick;
+ SCA_Joystick *m_joystick[JOYINDEX_MAX];
public:
SCA_JoystickManager(class SCA_LogicManager* logicmgr);
virtual ~SCA_JoystickManager();
virtual void NextFrame(double curtime,double deltatime);
- SCA_Joystick* GetJoystickDevice(void);
+ SCA_Joystick* GetJoystickDevice(short int joyindex);
};
diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp
index 3fb439eb25b..37f58f1ef1b 100644
--- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp
@@ -39,6 +39,7 @@
SCA_JoystickSensor::SCA_JoystickSensor(class SCA_JoystickManager* eventmgr,
SCA_IObject* gameobj,
+ short int joyindex,
short int joymode,
int axis, int axisf,int prec,
int button, int buttonf,
@@ -53,7 +54,8 @@ SCA_JoystickSensor::SCA_JoystickSensor(class SCA_JoystickManager* eventmgr,
m_hat(hat),
m_hatf(hatf),
m_precision(prec),
- m_joymode(joymode)
+ m_joymode(joymode),
+ m_joyindex(joyindex)
{
/*
std::cout << " axis " << m_axis << std::endl;
@@ -99,7 +101,7 @@ bool SCA_JoystickSensor::IsPositiveTrigger()
bool SCA_JoystickSensor::Evaluate(CValue* event)
{
- SCA_Joystick *js = m_pJoystickMgr->GetJoystickDevice();
+ SCA_Joystick *js = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
bool result = false;
bool reset = m_reset && m_level;
@@ -293,6 +295,8 @@ PyParentObject SCA_JoystickSensor::Parents[] = {
PyMethodDef SCA_JoystickSensor::Methods[] = {
+ {"getIndex", (PyCFunction) SCA_JoystickSensor::sPyGetIndex, METH_NOARGS, GetIndex_doc},
+ {"setIndex", (PyCFunction) SCA_JoystickSensor::sPySetIndex, METH_O, SetIndex_doc},
{"getAxis", (PyCFunction) SCA_JoystickSensor::sPyGetAxis, METH_NOARGS, GetAxis_doc},
{"setAxis", (PyCFunction) SCA_JoystickSensor::sPySetAxis, METH_VARARGS, SetAxis_doc},
{"getAxisValue", (PyCFunction) SCA_JoystickSensor::sPyGetRealAxis, METH_NOARGS, GetRealAxis_doc},
@@ -305,6 +309,7 @@ PyMethodDef SCA_JoystickSensor::Methods[] = {
{"getNumAxes", (PyCFunction) SCA_JoystickSensor::sPyNumberOfAxes, METH_NOARGS, NumberOfAxes_doc},
{"getNumButtons",(PyCFunction) SCA_JoystickSensor::sPyNumberOfButtons,METH_NOARGS, NumberOfButtons_doc},
{"getNumHats", (PyCFunction) SCA_JoystickSensor::sPyNumberOfHats, METH_NOARGS, NumberOfHats_doc},
+ {"getConnected", (PyCFunction) SCA_JoystickSensor::sPyConnected, METH_NOARGS, Connected_doc},
{NULL,NULL} //Sentinel
};
@@ -314,14 +319,36 @@ PyObject* SCA_JoystickSensor::_getattr(const STR_String& attr) {
}
+/* get index ---------------------------------------------------------- */
+char SCA_JoystickSensor::GetIndex_doc[] =
+"getIndex\n"
+"\tReturns the joystick index to use.\n";
+PyObject* SCA_JoystickSensor::PyGetIndex( PyObject* self ) {
+ return PyInt_FromLong(m_joyindex);
+}
+
+
+/* set index ---------------------------------------------------------- */
+char SCA_JoystickSensor::SetIndex_doc[] =
+"setIndex\n"
+"\tSets the joystick index to use.\n";
+PyObject* SCA_JoystickSensor::PySetIndex( PyObject* self, PyObject* value ) {
+ int index = PyInt_AsLong( value ); /* -1 on error, will raise an error in this case */
+ if (index < 0 or index >= JOYINDEX_MAX) {
+ PyErr_SetString(PyExc_ValueError, "joystick index out of range or not an int");
+ return NULL;
+ }
+
+ m_joyindex = index;
+ Py_RETURN_NONE;
+}
+
/* get axis ---------------------------------------------------------- */
char SCA_JoystickSensor::GetAxis_doc[] =
"getAxis\n"
"\tReturns the current state of the axis.\n";
-PyObject* SCA_JoystickSensor::PyGetAxis( PyObject* self,
- PyObject* args,
- PyObject* kwds) {
- return Py_BuildValue("[ii]",m_axis, m_axisf);
+PyObject* SCA_JoystickSensor::PyGetAxis( PyObject* self) {
+ return PyInt_FromLong(m_joyindex);
}
@@ -329,9 +356,7 @@ PyObject* SCA_JoystickSensor::PyGetAxis( PyObject* self,
char SCA_JoystickSensor::SetAxis_doc[] =
"setAxis\n"
"\tSets the current state of the axis.\n";
-PyObject* SCA_JoystickSensor::PySetAxis( PyObject* self,
- PyObject* args,
- PyObject* kwds) {
+PyObject* SCA_JoystickSensor::PySetAxis( PyObject* self, PyObject* args ) {
int axis,axisflag;
if(!PyArg_ParseTuple(args, "ii", &axis, &axisflag)){
@@ -339,7 +364,7 @@ PyObject* SCA_JoystickSensor::PySetAxis( PyObject* self,
}
m_axis = axis;
m_axisf = axisflag;
- Py_Return;
+ Py_RETURN_NONE;
}
@@ -347,16 +372,9 @@ PyObject* SCA_JoystickSensor::PySetAxis( PyObject* self,
char SCA_JoystickSensor::GetRealAxis_doc[] =
"getAxisValue\n"
"\tReturns a list of the values for each axis .\n";
-PyObject* SCA_JoystickSensor::PyGetRealAxis( PyObject* self,
- PyObject* args,
- PyObject* kwds) {
- int a,b,c,d;
- SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice();
- a = joy->GetAxis10();
- b = joy->GetAxis11();
- c = joy->GetAxis20();
- d = joy->GetAxis21();
- return Py_BuildValue("[iiii]",a,b,c,d);
+PyObject* SCA_JoystickSensor::PyGetRealAxis( PyObject* self) {
+ SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
+ return Py_BuildValue("[iiii]", joy->GetAxis10(), joy->GetAxis11(), joy->GetAxis20(), joy->GetAxis21());
}
@@ -364,10 +382,8 @@ PyObject* SCA_JoystickSensor::PyGetRealAxis( PyObject* self,
char SCA_JoystickSensor::GetThreshold_doc[] =
"getThreshold\n"
"\tReturns the threshold of the axis.\n";
-PyObject* SCA_JoystickSensor::PyGetThreshold( PyObject* self,
- PyObject* args,
- PyObject* kwds) {
- return Py_BuildValue("i", m_precision);
+PyObject* SCA_JoystickSensor::PyGetThreshold( PyObject* self) {
+ return PyInt_FromLong(m_precision);
}
@@ -375,15 +391,13 @@ PyObject* SCA_JoystickSensor::PyGetThreshold( PyObject* self,
char SCA_JoystickSensor::SetThreshold_doc[] =
"setThreshold\n"
"\tSets the threshold of the axis.\n";
-PyObject* SCA_JoystickSensor::PySetThreshold( PyObject* self,
- PyObject* args,
- PyObject* kwds) {
+PyObject* SCA_JoystickSensor::PySetThreshold( PyObject* self, PyObject* args ) {
int thresh;
if(!PyArg_ParseTuple(args, "i", &thresh)){
return NULL;
}
m_precision = thresh;
- Py_Return;
+ Py_RETURN_NONE;
}
@@ -391,9 +405,7 @@ PyObject* SCA_JoystickSensor::PySetThreshold( PyObject* self,
char SCA_JoystickSensor::GetButton_doc[] =
"getButton\n"
"\tReturns the currently pressed button.\n";
-PyObject* SCA_JoystickSensor::PyGetButton( PyObject* self,
- PyObject* args,
- PyObject* kwds) {
+PyObject* SCA_JoystickSensor::PyGetButton( PyObject* self) {
return Py_BuildValue("[ii]",m_button, m_buttonf);
}
@@ -402,16 +414,14 @@ PyObject* SCA_JoystickSensor::PyGetButton( PyObject* self,
char SCA_JoystickSensor::SetButton_doc[] =
"setButton\n"
"\tSets the button the sensor reacts to.\n";
-PyObject* SCA_JoystickSensor::PySetButton( PyObject* self,
- PyObject* args,
- PyObject* kwds) {
+PyObject* SCA_JoystickSensor::PySetButton( PyObject* self, PyObject* args ) {
int button,buttonflag;
if(!PyArg_ParseTuple(args, "ii", &button, &buttonflag)){
return NULL;
}
m_button = button;
m_buttonf = buttonflag;
- Py_Return;
+ Py_RETURN_NONE;
}
@@ -419,9 +429,7 @@ PyObject* SCA_JoystickSensor::PySetButton( PyObject* self,
char SCA_JoystickSensor::GetHat_doc[] =
"getHat\n"
"\tReturns the current direction of the hat.\n";
-PyObject* SCA_JoystickSensor::PyGetHat( PyObject* self,
- PyObject* args,
- PyObject* kwds) {
+PyObject* SCA_JoystickSensor::PyGetHat( PyObject* self ) {
return Py_BuildValue("[ii]",m_hat, m_hatf);
}
@@ -430,16 +438,14 @@ PyObject* SCA_JoystickSensor::PyGetHat( PyObject* self,
char SCA_JoystickSensor::SetHat_doc[] =
"setHat\n"
"\tSets the hat the sensor reacts to.\n";
-PyObject* SCA_JoystickSensor::PySetHat( PyObject* self,
- PyObject* args,
- PyObject* kwds) {
+PyObject* SCA_JoystickSensor::PySetHat( PyObject* self, PyObject* args ) {
int hat,hatflag;
if(!PyArg_ParseTuple(args, "ii", &hat, &hatflag)){
return NULL;
}
m_hat = hat;
m_hatf = hatflag;
- Py_Return;
+ Py_RETURN_NONE;
}
@@ -447,37 +453,33 @@ PyObject* SCA_JoystickSensor::PySetHat( PyObject* self,
char SCA_JoystickSensor::NumberOfAxes_doc[] =
"getNumAxes\n"
"\tReturns the number of axes .\n";
-PyObject* SCA_JoystickSensor::PyNumberOfAxes( PyObject* self,
- PyObject* args,
- PyObject* kwds) {
- int num;
- SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice();
- num = joy->GetNumberOfAxes();
- return Py_BuildValue("i",num);
+PyObject* SCA_JoystickSensor::PyNumberOfAxes( PyObject* self ) {
+ SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
+ return PyInt_FromLong( joy->GetNumberOfAxes() );
}
char SCA_JoystickSensor::NumberOfButtons_doc[] =
"getNumButtons\n"
"\tReturns the number of buttons .\n";
-PyObject* SCA_JoystickSensor::PyNumberOfButtons( PyObject* self,
- PyObject* args,
- PyObject* kwds) {
- int num;
- SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice();
- num = joy->GetNumberOfButtons();
- return Py_BuildValue("i",num);
+PyObject* SCA_JoystickSensor::PyNumberOfButtons( PyObject* self ) {
+ SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
+ return PyInt_FromLong( joy->GetNumberOfButtons() );
}
char SCA_JoystickSensor::NumberOfHats_doc[] =
"getNumHats\n"
"\tReturns the number of hats .\n";
-PyObject* SCA_JoystickSensor::PyNumberOfHats( PyObject* self,
- PyObject* args,
- PyObject* kwds) {
- int num;
- SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice();
- num = joy->GetNumberOfHats();
- return Py_BuildValue("i",num);
+PyObject* SCA_JoystickSensor::PyNumberOfHats( PyObject* self ) {
+ SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
+ return PyInt_FromLong( joy->GetNumberOfHats() );
+}
+
+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 ) {
+ SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
+ return PyBool_FromLong( joy->Connected() );
}
diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.h b/source/gameengine/GameLogic/SCA_JoystickSensor.h
index 69068da6494..a21146b568b 100644
--- a/source/gameengine/GameLogic/SCA_JoystickSensor.h
+++ b/source/gameengine/GameLogic/SCA_JoystickSensor.h
@@ -72,6 +72,10 @@ class SCA_JoystickSensor :public SCA_ISensor
* The mode to determine axis,button or hat
*/
short int m_joymode;
+ /**
+ * Select which joystick to use
+ */
+ short int m_joyindex;
enum KX_JOYSENSORMODE {
KX_JOYSENSORMODE_NODEF = 0,
@@ -85,6 +89,7 @@ class SCA_JoystickSensor :public SCA_ISensor
public:
SCA_JoystickSensor(class SCA_JoystickManager* eventmgr,
SCA_IObject* gameobj,
+ short int joyindex,
short int joymode,
int axis, int axisf,int prec,
int button, int buttonf,
@@ -97,28 +102,36 @@ public:
virtual bool IsPositiveTrigger();
virtual void Init();
+ short int GetJoyIndex(void){
+ return m_joyindex;
+ }
+
/* --------------------------------------------------------------------- */
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
virtual PyObject* _getattr(const STR_String& attr);
+ /* Joystick Index */
+ KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetIndex);
+ KX_PYMETHOD_DOC_O(SCA_JoystickSensor,SetIndex);
/* Axes*/
- KX_PYMETHOD_DOC(SCA_JoystickSensor,GetAxis);
- KX_PYMETHOD_DOC(SCA_JoystickSensor,SetAxis);
- KX_PYMETHOD_DOC(SCA_JoystickSensor,GetRealAxis);
- KX_PYMETHOD_DOC(SCA_JoystickSensor,GetThreshold);
- KX_PYMETHOD_DOC(SCA_JoystickSensor,SetThreshold);
+ KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetAxis);
+ KX_PYMETHOD_DOC_VARARGS(SCA_JoystickSensor,SetAxis);
+ KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetRealAxis);
+ KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetThreshold);
+ KX_PYMETHOD_DOC_VARARGS(SCA_JoystickSensor,SetThreshold);
/* Buttons */
- KX_PYMETHOD_DOC(SCA_JoystickSensor,GetButton);
- KX_PYMETHOD_DOC(SCA_JoystickSensor,SetButton);
+ KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetButton);
+ KX_PYMETHOD_DOC_VARARGS(SCA_JoystickSensor,SetButton);
/* Hats */
- KX_PYMETHOD_DOC(SCA_JoystickSensor,GetHat);
- KX_PYMETHOD_DOC(SCA_JoystickSensor,SetHat);
+ KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetHat);
+ KX_PYMETHOD_DOC_VARARGS(SCA_JoystickSensor,SetHat);
/* number of */
- KX_PYMETHOD_DOC(SCA_JoystickSensor,NumberOfAxes);
- KX_PYMETHOD_DOC(SCA_JoystickSensor,NumberOfButtons);
- KX_PYMETHOD_DOC(SCA_JoystickSensor,NumberOfHats);
+ KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,NumberOfAxes);
+ KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,NumberOfButtons);
+ KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,NumberOfHats);
+ KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,Connected);
};
diff --git a/source/gameengine/PyDoc/KX_GameObject.py b/source/gameengine/PyDoc/KX_GameObject.py
index 2136ce54e30..916851fa2a2 100644
--- a/source/gameengine/PyDoc/KX_GameObject.py
+++ b/source/gameengine/PyDoc/KX_GameObject.py
@@ -30,11 +30,11 @@ class KX_GameObject:
Delete this object, can be used inpace of the EndObject Actuator.
The actual removal of the object from the scene is delayed.
"""
- def getVisible(visible):
+ def getVisible():
"""
Gets the game object's visible flag.
- @type visible: boolean
+ @rtype: boolean
"""
def setVisible(visible):
"""
@@ -49,12 +49,12 @@ class KX_GameObject:
@rtype: int
@return: the objects state.
"""
- def setState():
+ def setState(state):
"""
- Sets the game object's visible flag.
+ Sets the game object's state flag.
The bitmasks for states from 1 to 30 can be set with (1<<0, 1<<1, 1<<2 ... 1<<29)
- @type visible: boolean
+ @type state: integer
"""
def setPosition(pos):
"""
@@ -342,7 +342,7 @@ class KX_GameObject:
@param poly: polygon option: 1=>return value is a 4-tuple and the 4th element is a L{KX_PolyProxy}
@type poly: int
@rtype: 3-tuple (L{KX_GameObject}, 3-tuple (x,y,z), 3-tuple (nx,ny,nz))
- or 4-tuple (L{KX_GameObject}, 3-tuple (x,y,z), 3-tuple (nx,ny,nz), L{KX_PolyProxy))
+ or 4-tuple (L{KX_GameObject}, 3-tuple (x,y,z), 3-tuple (nx,ny,nz), L{KX_PolyProxy})
@return: (object,hitpoint,hitnormal) or (object,hitpoint,hitnormal,polygon)
If no hit, returns (None,None,None) or (None,None,None,None)
If the object hit is not a static mesh, polygon is None
diff --git a/source/gameengine/PyDoc/KX_ObjectActuator.py b/source/gameengine/PyDoc/KX_ObjectActuator.py
index db577d21e6f..b7b76473292 100644
--- a/source/gameengine/PyDoc/KX_ObjectActuator.py
+++ b/source/gameengine/PyDoc/KX_ObjectActuator.py
@@ -111,9 +111,7 @@ class KX_ObjectActuator(SCA_IActuator):
For the servo control actuator, this is the target speed.
@rtype: list [vx, vy, vz, local]
- @return: A four item list, containing the vector velocity, and whether
- the velocity is applied in local coordinates (True) or world
- coordinates (False)
+ @return: A four item list, containing the vector velocity, and whether the velocity is applied in local coordinates (True) or world coordinates (False)
"""
def setLinearVelocity(vx, vy, vz, local):
"""
diff --git a/source/gameengine/PyDoc/KX_PolyProxy.py b/source/gameengine/PyDoc/KX_PolyProxy.py
index 3bd664554cd..d895390d0b0 100644
--- a/source/gameengine/PyDoc/KX_PolyProxy.py
+++ b/source/gameengine/PyDoc/KX_PolyProxy.py
@@ -59,7 +59,7 @@ class KX_PolyProxy:
@rtype: integer
@return: the material index in the mesh
-
+ """
def getNumVertex():
"""
Returns the number of vertex of the polygon.
diff --git a/source/gameengine/PyDoc/KX_TrackToActuator.py b/source/gameengine/PyDoc/KX_TrackToActuator.py
index 2ecd94f38ae..948302991b7 100644
--- a/source/gameengine/PyDoc/KX_TrackToActuator.py
+++ b/source/gameengine/PyDoc/KX_TrackToActuator.py
@@ -21,7 +21,7 @@ class KX_TrackToActuator(SCA_IActuator):
@type object: L{KX_GameObject}, string or None
@param object: Either a reference to a game object or the name of the object to track.
"""
- def getObject():
+ def getObject(name_only):
"""
Returns the name of the object to track.
diff --git a/source/gameengine/PyDoc/Rasterizer.py b/source/gameengine/PyDoc/Rasterizer.py
index a21173b71b0..7afdcf07f2e 100644
--- a/source/gameengine/PyDoc/Rasterizer.py
+++ b/source/gameengine/PyDoc/Rasterizer.py
@@ -84,7 +84,8 @@ def setMousePosition(x, y):
"""
Sets the mouse cursor position.
- @type x, y: integer
+ @type x: integer
+ @type y: integer
"""
def setBackgroundColor(rgba):
diff --git a/source/gameengine/PyDoc/SCA_DelaySensor.py b/source/gameengine/PyDoc/SCA_DelaySensor.py
index 46b74f461a7..19df589ea7b 100644
--- a/source/gameengine/PyDoc/SCA_DelaySensor.py
+++ b/source/gameengine/PyDoc/SCA_DelaySensor.py
@@ -1,6 +1,6 @@
# $Id$
# Documentation for SCA_DelaySensor
-from SCA_IActuator import *
+from SCA_ISensor import *
class SCA_DelaySensor(SCA_ISensor):
"""