diff options
author | Campbell Barton <ideasman42@gmail.com> | 2008-06-24 09:02:01 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2008-06-24 09:02:01 +0400 |
commit | cf8807581eae39e44ceb33158df8916a2afb2eb6 (patch) | |
tree | 680521cb1896b743cf6f5f7f3ed49b448d066155 /source | |
parent | 8a7eab4e56227469c8031b0dc4a65912e14c0c7f (diff) |
svn merge -r15309:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender/
Note the mail message failed to come through for 15309 which was just a merge from trunk.
Diffstat (limited to 'source')
44 files changed, 1467 insertions, 350 deletions
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 05f2e69fce1..5b96bf11056 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -350,7 +350,7 @@ static void copy_pose_channel_data(bPoseChannel *pchan, const bPoseChannel *chan pchan->flag= chan->flag; con= chan->constraints.first; - for(pcon= pchan->constraints.first; pcon; pcon= pcon->next) { + for(pcon= pchan->constraints.first; pcon; pcon= pcon->next, con= con->next) { pcon->enforce= con->enforce; pcon->headtail= con->headtail; } diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index f06ef221795..458171cc232 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -2596,6 +2596,7 @@ static void precalc_effectors(Object *ob, ParticleSystem *psys, ParticleSystemMo for(ec= lb->first; ec; ec= ec->next) { PartDeflect *pd= ec->ob->pd; + co = NULL; if(ec->type==PSYS_EC_EFFECTOR && pd->forcefield==PFIELD_GUIDE && ec->ob->type==OB_CURVE && part->phystype!=PART_PHYS_BOIDS) { diff --git a/source/blender/blenlib/BLI_arithb.h b/source/blender/blenlib/BLI_arithb.h index 4bfb1016a72..2e5866039d5 100644 --- a/source/blender/blenlib/BLI_arithb.h +++ b/source/blender/blenlib/BLI_arithb.h @@ -375,6 +375,7 @@ void LocQuatSizeToMat4(float mat[][4], float loc[3], float quat[4], float size[3 void tubemap(float x, float y, float z, float *u, float *v); void spheremap(float x, float y, float z, float *u, float *v); +int LineIntersectLine(float v1[3], float v2[3], float v3[3], float v4[3], float i1[3], float i2[3]); int LineIntersectsTriangle(float p1[3], float p2[3], float v0[3], float v1[3], float v2[3], float *lambda, float *uv); int RayIntersectsTriangle(float p1[3], float d[3], float v0[3], float v1[3], float v2[3], float *lambda, float *uv); int SweepingSphereIntersectsTriangleUV(float p1[3], float p2[3], float radius, float v0[3], float v1[3], float v2[3], float *lambda, float *ipoint); diff --git a/source/blender/blenlib/intern/arithb.c b/source/blender/blenlib/intern/arithb.c index f9a9ffac74e..d89a818bbf1 100644 --- a/source/blender/blenlib/intern/arithb.c +++ b/source/blender/blenlib/intern/arithb.c @@ -4040,6 +4040,74 @@ int AxialLineIntersectsTriangle(int axis, float p1[3], float p2[3], float v0[3], return 1; } +/* Returns the number of point of interests + * 0 - lines are colinear + * 1 - lines are coplanar, i1 is set to intersection + * 2 - i1 and i2 are the nearest points on line 1 (v1, v2) and line 2 (v3, v4) respectively + * */ +int LineIntersectLine(float v1[3], float v2[3], float v3[3], float v4[3], float i1[3], float i2[3]) +{ + float a[3], b[3], c[3], ab[3], cb[3], dir1[3], dir2[3]; + float d; + + VecSubf(c, v3, v1); + VecSubf(a, v2, v1); + VecSubf(b, v4, v3); + + VecCopyf(dir1, a); + Normalize(dir1); + VecCopyf(dir2, b); + Normalize(dir2); + d = Inpf(dir1, dir2); + if (d == 1.0f || d == -1.0f) { + /* colinear */ + return 0; + } + + Crossf(ab, a, b); + d = Inpf(c, ab); + + /* test if the two lines are coplanar */ + if (d > -0.000001f && d < 0.000001f) { + Crossf(cb, c, b); + + VecMulf(a, Inpf(cb, ab) / Inpf(ab, ab)); + VecAddf(i1, v1, a); + VecCopyf(i2, i1); + + return 1; /* one intersection only */ + } + /* if not */ + else { + float n[3], t[3]; + float v3t[3], v4t[3]; + VecSubf(t, v1, v3); + + /* offset between both plane where the lines lies */ + Crossf(n, a, b); + Projf(t, t, n); + + /* for the first line, offset the second line until it is coplanar */ + VecAddf(v3t, v3, t); + VecAddf(v4t, v4, t); + + VecSubf(c, v3t, v1); + VecSubf(a, v2, v1); + VecSubf(b, v4t, v3); + + Crossf(ab, a, b); + Crossf(cb, c, b); + + VecMulf(a, Inpf(cb, ab) / Inpf(ab, ab)); + VecAddf(i1, v1, a); + + /* for the second line, just substract the offset from the first intersection point */ + VecSubf(i2, i1, t); + + return 2; /* two nearest points */ + } +} + int AabbIntersectAabb(float min1[3], float max1[3], float min2[3], float max2[3]) { return (min1[0]<max2[0] && min1[1]<max2[1] && min1[2]<max2[2] && diff --git a/source/blender/imbuf/IMB_imbuf_types.h b/source/blender/imbuf/IMB_imbuf_types.h index 94203bab447..73ef83393b0 100644 --- a/source/blender/imbuf/IMB_imbuf_types.h +++ b/source/blender/imbuf/IMB_imbuf_types.h @@ -149,6 +149,7 @@ typedef enum { #define IB_zbuffloat (1 << 16) #define IB_multilayer (1 << 17) #define IB_imginfo (1 << 18) +#define IB_animdeinterlace (1 << 19) /* * The bit flag is stored in the ImBuf.ftype variable. diff --git a/source/blender/imbuf/intern/anim.c b/source/blender/imbuf/intern/anim.c index 87d67f5263b..7fc8145c4a7 100644 --- a/source/blender/imbuf/intern/anim.c +++ b/source/blender/imbuf/intern/anim.c @@ -638,6 +638,7 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position) { AVPacket packet; int64_t pts_to_search = 0; int pos_found = 1; + int filter_y = 0; if (anim == 0) return (0); @@ -722,6 +723,18 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position) { } if(frameFinished && pos_found == 1) { + if (anim->ib_flags & IB_animdeinterlace) { + if (avpicture_deinterlace( + anim->pFrame, + anim->pFrame, + anim->pCodecCtx->pix_fmt, + anim->pCodecCtx->width, + anim->pCodecCtx->height) + < 0) { + filter_y = 1; + } + } + if (G.order == B_ENDIAN) { int * dstStride = anim->pFrameRGB->linesize; @@ -823,6 +836,10 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position) { av_free_packet(&packet); } + if (filter_y && ibuf) { + IMB_filtery(ibuf); + } + return(ibuf); } @@ -983,6 +1000,7 @@ struct ImBuf * IMB_anim_absolute(struct anim * anim, int position) { char head[256], tail[256]; unsigned short digits; int pic; + int filter_y = (anim->ib_flags & IB_animdeinterlace); if (anim == NULL) return(0); @@ -1040,6 +1058,7 @@ struct ImBuf * IMB_anim_absolute(struct anim * anim, int position) { case ANIM_FFMPEG: ibuf = ffmpeg_fetchibuf(anim, position); if (ibuf) anim->curposition = position; + filter_y = 0; /* done internally */ break; #endif #ifdef WITH_REDCODE @@ -1052,6 +1071,7 @@ struct ImBuf * IMB_anim_absolute(struct anim * anim, int position) { if (ibuf) { if (anim->ib_flags & IB_ttob) IMB_flipy(ibuf); + if (filter_y) IMB_filtery(ibuf); sprintf(ibuf->name, "%s.%04d", anim->name, anim->curposition + 1); } diff --git a/source/blender/include/transform.h b/source/blender/include/transform.h index 7d497dc05ec..4e3b80134f9 100644 --- a/source/blender/include/transform.h +++ b/source/blender/include/transform.h @@ -102,9 +102,9 @@ typedef struct TransCon { /* Apply function pointer for linear vectorial transformation */ /* The last three parameters are pointers to the in/out/printable vectors */ void (*applySize)(struct TransInfo *, struct TransData *, float [3][3]); - /* Apply function pointer for rotation transformation (prototype will change */ - void (*applyRot)(struct TransInfo *, struct TransData *, float [3]); - /* Apply function pointer for rotation transformation (prototype will change */ + /* Apply function pointer for size transformation */ + void (*applyRot)(struct TransInfo *, struct TransData *, float [3], float *); + /* Apply function pointer for rotation transformation */ } TransCon; typedef struct TransDataIpokey { diff --git a/source/blender/makesdna/DNA_actuator_types.h b/source/blender/makesdna/DNA_actuator_types.h index 417ba540e2c..70d603a6ed9 100644 --- a/source/blender/makesdna/DNA_actuator_types.h +++ b/source/blender/makesdna/DNA_actuator_types.h @@ -50,6 +50,7 @@ typedef struct bActionActuator { short type, flag; /* Playback type */ int sta, end; /* Start & End frames */ char name[32]; /* For property-driven playback */ + char frameProp[32]; /* Set this property to the actions current frame */ int blendin; /* Number of frames of blending */ short priority; /* Execution priority */ short strideaxis; /* Displacement axis */ diff --git a/source/blender/makesdna/DNA_controller_types.h b/source/blender/makesdna/DNA_controller_types.h index cc9215e7d14..376f95b0145 100644 --- a/source/blender/makesdna/DNA_controller_types.h +++ b/source/blender/makesdna/DNA_controller_types.h @@ -66,6 +66,10 @@ typedef struct bController { #define CONT_LOGIC_OR 1 #define CONT_EXPRESSION 2 #define CONT_PYTHON 3 +#define CONT_LOGIC_NAND 4 +#define CONT_LOGIC_NOR 5 +#define CONT_LOGIC_XOR 6 +#define CONT_LOGIC_XNOR 7 /* controller->flag */ #define CONT_SHOW 1 diff --git a/source/blender/makesdna/DNA_sensor_types.h b/source/blender/makesdna/DNA_sensor_types.h index 3fd57a85349..ae7b92bb06c 100644 --- a/source/blender/makesdna/DNA_sensor_types.h +++ b/source/blender/makesdna/DNA_sensor_types.h @@ -144,7 +144,7 @@ typedef struct bSensor { /* just add here, to avoid align errors... */ short invert; /* Whether or not to invert the output. */ - short freq2; /* The negative pulsing frequency? Not used anymore... */ + short level; /* Whether the sensor is level base (edge by default) */ int pad; } bSensor; diff --git a/source/blender/python/api2_2x/Mathutils.c b/source/blender/python/api2_2x/Mathutils.c index 87ac3e3e6ba..85c56a61628 100644 --- a/source/blender/python/api2_2x/Mathutils.c +++ b/source/blender/python/api2_2x/Mathutils.c @@ -1452,8 +1452,8 @@ PyObject *M_Mathutils_LineIntersect( PyObject * self, PyObject * args ) "vectors must be of the same size\n" ) ); if( vec1->size == 3 || vec1->size == 2) { - float a[3], b[3], c[3], ab[3], cb[3], dir1[3], dir2[3]; - float d; + int result; + if (vec1->size == 3) { VECCOPY(v1, vec1->vec); VECCOPY(v2, vec2->vec); @@ -1477,63 +1477,19 @@ PyObject *M_Mathutils_LineIntersect( PyObject * self, PyObject * args ) v4[1] = vec4->vec[1]; v4[2] = 0.0f; } + + result = LineIntersectLine(v1, v2, v3, v4, i1, i2); - VecSubf(c, v3, v1); - VecSubf(a, v2, v1); - VecSubf(b, v4, v3); - - VECCOPY(dir1, a); - Normalize(dir1); - VECCOPY(dir2, b); - Normalize(dir2); - d = Inpf(dir1, dir2); - if (d == 1.0f || d == -1.0f) { + if (result == 0) { /* colinear */ return EXPP_incr_ret( Py_None ); } - - Crossf(ab, a, b); - d = Inpf(c, ab); - - /* test if the two lines are coplanar */ - if (d > -0.000001f && d < 0.000001f) { - Crossf(cb, c, b); - - VecMulf(a, Inpf(cb, ab) / Inpf(ab, ab)); - VecAddf(i1, v1, a); - VECCOPY(i2, i1); - } - /* if not */ else { - float n[3], t[3]; - VecSubf(t, v1, v3); - - /* offset between both plane where the lines lies */ - Crossf(n, a, b); - Projf(t, t, n); - - /* for the first line, offset the second line until it is coplanar */ - VecAddf(v3, v3, t); - VecAddf(v4, v4, t); - - VecSubf(c, v3, v1); - VecSubf(a, v2, v1); - VecSubf(b, v4, v3); - - Crossf(ab, a, b); - Crossf(cb, c, b); - - VecMulf(a, Inpf(cb, ab) / Inpf(ab, ab)); - VecAddf(i1, v1, a); - - /* for the second line, just substract the offset from the first intersection point */ - VecSubf(i2, i1, t); + tuple = PyTuple_New( 2 ); + PyTuple_SetItem( tuple, 0, newVectorObject(i1, vec1->size, Py_NEW) ); + PyTuple_SetItem( tuple, 1, newVectorObject(i2, vec1->size, Py_NEW) ); + return tuple; } - - tuple = PyTuple_New( 2 ); - PyTuple_SetItem( tuple, 0, newVectorObject(i1, vec1->size, Py_NEW) ); - PyTuple_SetItem( tuple, 1, newVectorObject(i2, vec1->size, Py_NEW) ); - return tuple; } else { return ( EXPP_ReturnPyObjError( PyExc_TypeError, diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 6e3973237a4..8aebeed38e5 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -2675,9 +2675,9 @@ void RE_set_max_threads(int threads) void RE_init_threadcount(Render *re) { - if ((re->r.mode & R_FIXED_THREADS)==0 || commandline_threads == 0) { /* Automatic threads */ + if(commandline_threads >= 1) { /* only set as an arg in background mode */ + re->r.threads= MIN2(commandline_threads, BLENDER_MAX_THREADS); + } else if ((re->r.mode & R_FIXED_THREADS)==0 || commandline_threads == 0) { /* Automatic threads */ re->r.threads = BLI_system_thread_count(); - } else if(commandline_threads >= 1 && commandline_threads<=BLENDER_MAX_THREADS) { - re->r.threads= commandline_threads; } } diff --git a/source/blender/src/buttons_logic.c b/source/blender/src/buttons_logic.c index c4fc17bc4d0..bfa451428c3 100644 --- a/source/blender/src/buttons_logic.c +++ b/source/blender/src/buttons_logic.c @@ -740,6 +740,14 @@ static char *controller_name(int type) return "AND"; case CONT_LOGIC_OR: return "OR"; + case CONT_LOGIC_NAND: + return "NAND"; + case CONT_LOGIC_NOR: + return "NOR"; + case CONT_LOGIC_XOR: + return "XOR"; + case CONT_LOGIC_XNOR: + return "XNOR"; case CONT_EXPRESSION: return "Expression"; case CONT_PYTHON: @@ -750,7 +758,7 @@ static char *controller_name(int type) static char *controller_pup(void) { - return "Controllers %t|AND %x0|OR %x1|Expression %x2|Python %x3"; + return "Controllers %t|AND %x0|OR %x1|XOR %x6|NAND %x4|NOR %x5|XNOR %x7|Expression %x2|Python %x3"; } static char *actuator_name(int type) @@ -1066,6 +1074,10 @@ static void draw_default_sensor_header(bSensor *sens, (short)(x + 10 + 0.85 * (w-20)), (short)(y - 19), (short)(0.15 * (w-20)), 19, &sens->invert, 0.0, 0.0, 0, 0, "Invert the level (output) of this sensor"); + uiDefButS(block, TOG, 1, "Lvl", + (short)(x + 10 + 0.70 * (w-20)), (short)(y - 19), (short)(0.15 * (w-20)), 19, + &sens->level, 0.0, 0.0, 0, 0, + "Level detector versus edge detector (only applicable in case of logic state transition)"); } static short draw_sensorbuttons(bSensor *sens, uiBlock *block, short xco, short yco, short width,char* objectname) @@ -1673,31 +1685,34 @@ static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, sh #else str= "Action types %t|Play %x0|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x6"; #endif - uiDefButS(block, MENU, B_REDR, str, xco+30, yco-24, width-60, 19, &aa->type, 0.0, 0.0, 0.0, 0.0, "Action playback type"); - uiDefIDPoinBut(block, test_actionpoin_but, ID_AC, 1, "AC: ", xco+30, yco-44, width-60, 19, &aa->act, "Action name"); + uiDefButS(block, MENU, B_REDR, str, xco+30, yco-24, (width-60)/2, 19, &aa->type, 0.0, 0.0, 0.0, 0.0, "Action playback type"); + uiDefIDPoinBut(block, test_actionpoin_but, ID_AC, 1, "AC: ", xco+30 + ((width-60)/2), yco-24, (width-60)/2, 19, &aa->act, "Action name"); if(aa->type == ACT_ACTION_FROM_PROP) { - uiDefBut(block, TEX, 0, "Prop: ",xco+30, yco-64, width-60, 19, aa->name, 0.0, 31.0, 0, 0, "Use this property to define the Action position"); + uiDefBut(block, TEX, 0, "Prop: ",xco+30, yco-44, width-60, 19, aa->name, 0.0, 31.0, 0, 0, "Use this property to define the Action position"); } else { - uiDefButI(block, NUM, 0, "Sta: ",xco+30, yco-64, (width-60)/2, 19, &aa->sta, 0.0, MAXFRAMEF, 0, 0, "Start frame"); - uiDefButI(block, NUM, 0, "End: ",xco+30+(width-60)/2, yco-64, (width-60)/2, 19, &aa->end, 0.0, MAXFRAMEF, 0, 0, "End frame"); + uiDefButI(block, NUM, 0, "Sta: ",xco+30, yco-44, (width-60)/2, 19, &aa->sta, 0.0, MAXFRAMEF, 0, 0, "Start frame"); + uiDefButI(block, NUM, 0, "End: ",xco+30+(width-60)/2, yco-44, (width-60)/2, 19, &aa->end, 0.0, MAXFRAMEF, 0, 0, "End frame"); } + + uiDefButI(block, NUM, 0, "Blendin: ", xco+30, yco-64, (width-60)/2, 19, &aa->blendin, 0.0, MAXFRAMEF, 0.0, 0.0, "Number of frames of motion blending"); + uiDefButS(block, NUM, 0, "Priority: ", xco+30+(width-60)/2, yco-64, (width-60)/2, 19, &aa->priority, 0.0, 100.0, 0.0, 0.0, "Execution priority - lower numbers will override actions with higher numbers"); - - - uiDefButI(block, NUM, 0, "Blendin: ", xco+30, yco-84, (width-60)/2, 19, &aa->blendin, 0.0, MAXFRAMEF, 0.0, 0.0, "Number of frames of motion blending"); - uiDefButS(block, NUM, 0, "Priority: ", xco+30+(width-60)/2, yco-84, (width-60)/2, 19, &aa->priority, 0.0, 100.0, 0.0, 0.0, "Execution priority - lower numbers will override actions with higher numbers"); + uiDefBut(block, TEX, 0, "FrameProp: ",xco+30, yco-84, width-60, 19, aa->frameProp, 0.0, 31.0, 0, 0, "Assign this property this actions current frame number"); + #ifdef __NLA_ACTION_BY_MOTION_ACTUATOR if(aa->type == ACT_ACTION_MOTION) { - uiDefButF(block, NUM, 0, "Cycle: ",xco+30, yco-104, (width-60)/2, 19, &aa->stridelength, 0.0, 2500.0, 0, 0, "Distance covered by a single cycle of the action"); + uiDefButF(block, NUM, 0, "Cycle: ",xco+30, yco-84, (width-60)/2, 19, &aa->stridelength, 0.0, 2500.0, 0, 0, "Distance covered by a single cycle of the action"); } #endif + + yco-=ysize; break; } diff --git a/source/blender/src/buttons_scene.c b/source/blender/src/buttons_scene.c index 3797a92f16f..1c98950080a 100644 --- a/source/blender/src/buttons_scene.c +++ b/source/blender/src/buttons_scene.c @@ -900,7 +900,7 @@ static void seq_panel_filter_video() "Convert input to float data"); uiDefButBitI(block, TOG, SEQ_FILTERY, - B_SEQ_BUT_RELOAD, "FilterY", + B_SEQ_BUT_RELOAD_FILE, "De-Inter", 170,110,80,19, &last_seq->flag, 0.0, 21.0, 100, 0, "For video movies to remove fields"); diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c index 3c945775b5b..2e5785eaab8 100644 --- a/source/blender/src/editobject.c +++ b/source/blender/src/editobject.c @@ -5942,7 +5942,7 @@ void hide_objects(int select) Base *base; short changed = 0, changed_act = 0; for(base = FIRSTBASE; base; base=base->next){ - if(TESTBASELIB(base)==select){ + if ((base->lay & G.vd->lay) && (TESTBASELIB(base)==select)) { base->flag &= ~SELECT; base->object->flag = base->flag; base->object->restrictflag |= OB_RESTRICT_VIEW; diff --git a/source/blender/src/editseq.c b/source/blender/src/editseq.c index fb0fac4489d..b9351f82d1e 100644 --- a/source/blender/src/editseq.c +++ b/source/blender/src/editseq.c @@ -2634,12 +2634,13 @@ void set_filter_seq(void) ed= G.scene->ed; if(ed==0) return; - if(okee("Set FilterY")==0) return; + if(okee("Set Deinterlace")==0) return; WHILE_SEQ(ed->seqbasep) { if(seq->flag & SELECT) { if(seq->type==SEQ_MOVIE) { seq->flag |= SEQ_FILTERY; + reload_sequence_new_file(seq); } } diff --git a/source/blender/src/sequence.c b/source/blender/src/sequence.c index 6d22a639168..fab55801992 100644 --- a/source/blender/src/sequence.c +++ b/source/blender/src/sequence.c @@ -445,7 +445,10 @@ void reload_sequence_new_file(Sequence * seq) seq->strip->len = seq->len; } else if (seq->type == SEQ_MOVIE) { if(seq->anim) IMB_free_anim(seq->anim); - seq->anim = openanim(str, IB_rect); + seq->anim = openanim( + str, IB_rect | + ((seq->flag & SEQ_FILTERY) + ? IB_animdeinterlace : 0)); if (!seq->anim) { return; @@ -1445,7 +1448,7 @@ static void input_preprocess(Sequence * seq, TStripElem* se, int cfra) seq->strip->orx= se->ibuf->x; seq->strip->ory= se->ibuf->y; - if(seq->flag & SEQ_FILTERY) { + if((seq->flag & SEQ_FILTERY) && seq->type != SEQ_MOVIE) { IMB_filtery(se->ibuf); } @@ -1772,8 +1775,11 @@ static void do_build_seq_ibuf(Sequence * seq, TStripElem *se, int cfra, BLI_join_dirfile(name, seq->strip->dir, seq->strip->stripdata->name); BLI_convertstringcode(name, G.sce); BLI_convertstringframe(name, G.scene->r.cfra); - - seq->anim = openanim(name, IB_rect); + + seq->anim = openanim( + name, IB_rect | + ((seq->flag & SEQ_FILTERY) + ? IB_animdeinterlace : 0)); } if(seq->anim) { IMB_anim_set_preseek(seq->anim, seq->anim_preseek); diff --git a/source/blender/src/space.c b/source/blender/src/space.c index 075e47afa9e..e6c866569f0 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -4994,11 +4994,13 @@ static void winqreadseqspace(ScrArea *sa, void *spacedata, BWinEvent *evt) } break; case DKEY: - if (G.qual == (LR_CTRLKEY|LR_SHIFTKEY)) + if (G.qual == (LR_CTRLKEY|LR_SHIFTKEY)) { duplicate_marker(); - else if ((G.qual==LR_SHIFTKEY)) { + } else if ((G.qual==LR_SHIFTKEY)) { if(sseq->mainb) break; add_duplicate_seq(); + } else if (G.qual == 0) { + set_filter_seq(); } break; case EKEY: @@ -5006,10 +5008,6 @@ static void winqreadseqspace(ScrArea *sa, void *spacedata, BWinEvent *evt) if((G.qual==0)) transform_seq('e', 0); break; - case FKEY: - if((G.qual==0)) - set_filter_seq(); - break; case GKEY: if (G.qual & LR_CTRLKEY) transform_markers('g', 0); diff --git a/source/blender/src/transform.c b/source/blender/src/transform.c index f2b4f43a028..513940b501d 100644 --- a/source/blender/src/transform.c +++ b/source/blender/src/transform.c @@ -2621,7 +2621,7 @@ static void applyRotation(TransInfo *t, float angle, float axis[3]) continue; if (t->con.applyRot) { - t->con.applyRot(t, td, axis); + t->con.applyRot(t, td, axis, NULL); VecRotToMat3(axis, angle * td->factor, mat); } else if (t->flag & T_PROP_EDIT) { @@ -2654,7 +2654,7 @@ int Rotation(TransInfo *t, short mval[2]) snapGrid(t, &final); if (t->con.applyRot) { - t->con.applyRot(t, NULL, axis); + t->con.applyRot(t, NULL, axis, &final); } applySnapping(t, &final); @@ -3314,7 +3314,7 @@ int PushPull(TransInfo *t, short mval[2]) } if (t->con.applyRot && t->con.mode & CON_APPLY) { - t->con.applyRot(t, NULL, axis); + t->con.applyRot(t, NULL, axis, NULL); } for(i = 0 ; i < t->total; i++, td++) { @@ -3326,7 +3326,7 @@ int PushPull(TransInfo *t, short mval[2]) VecSubf(vec, t->center, td->center); if (t->con.applyRot && t->con.mode & CON_APPLY) { - t->con.applyRot(t, td, axis); + t->con.applyRot(t, td, axis, NULL); if (isLockConstraint(t)) { float dvec[3]; Projf(dvec, vec, axis); diff --git a/source/blender/src/transform_constraints.c b/source/blender/src/transform_constraints.c index 2d01c2303fc..796b013cb88 100644 --- a/source/blender/src/transform_constraints.c +++ b/source/blender/src/transform_constraints.c @@ -393,7 +393,7 @@ static void applyObjectConstraintSize(TransInfo *t, TransData *td, float smat[3] * (ie: not doing counterclockwise rotations when the mouse moves clockwise). */ -static void applyAxisConstraintRot(TransInfo *t, TransData *td, float vec[3]) +static void applyAxisConstraintRot(TransInfo *t, TransData *td, float vec[3], float *angle) { if (!td && t->con.mode & CON_APPLY) { int mode = t->con.mode & (CON_AXIS0|CON_AXIS1|CON_AXIS2); @@ -413,9 +413,9 @@ static void applyAxisConstraintRot(TransInfo *t, TransData *td, float vec[3]) break; } /* don't flip axis if asked to or if num input */ - if (!(mode & CON_NOFLIP) && hasNumInput(&t->num) == 0) { + if (angle && (mode & CON_NOFLIP) == 0 && hasNumInput(&t->num) == 0) { if (Inpf(vec, t->viewinv[2]) > 0.0f) { - VecMulf(vec, -1.0f); + *angle = -(*angle); } } } @@ -435,10 +435,15 @@ static void applyAxisConstraintRot(TransInfo *t, TransData *td, float vec[3]) * (ie: not doing counterclockwise rotations when the mouse moves clockwise). */ -static void applyObjectConstraintRot(TransInfo *t, TransData *td, float vec[3]) +static void applyObjectConstraintRot(TransInfo *t, TransData *td, float vec[3], float *angle) { - if (td && t->con.mode & CON_APPLY) { + if (t->con.mode & CON_APPLY) { int mode = t->con.mode & (CON_AXIS0|CON_AXIS1|CON_AXIS2); + + /* on setup call, use first object */ + if (td == NULL) { + td= t->data; + } switch(mode) { case CON_AXIS0: @@ -454,9 +459,9 @@ static void applyObjectConstraintRot(TransInfo *t, TransData *td, float vec[3]) VECCOPY(vec, td->axismtx[2]); break; } - if (!(mode & CON_NOFLIP)) { + if (angle && (mode & CON_NOFLIP) == 0 && hasNumInput(&t->num) == 0) { if (Inpf(vec, t->viewinv[2]) > 0.0f) { - VecMulf(vec, -1.0f); + *angle = -(*angle); } } } diff --git a/source/blender/src/transform_snap.c b/source/blender/src/transform_snap.c index 295cfa4574c..d16308f17ae 100644 --- a/source/blender/src/transform_snap.c +++ b/source/blender/src/transform_snap.c @@ -412,7 +412,7 @@ float RotationBetween(TransInfo *t, float p1[3], float p2[3]) if (t->con.applyRot != NULL && (t->con.mode & CON_APPLY)) { float axis[3], tmp[3]; - t->con.applyRot(t, NULL, axis); + t->con.applyRot(t, NULL, axis, NULL); Projf(tmp, end, axis); VecSubf(end, end, tmp); @@ -737,136 +737,6 @@ void TargetSnapClosest(TransInfo *t) } /*================================================================*/ - -/* find snapping point on face, return 1 on success */ -int snapFace(MFace *face, EditFace *efa, MVert *verts, float *intersect, float *loc, float *no) -{ - MVert *v[4]; - EditVert *eve[4]; - int totvert; - int result = 0; - - v[0] = verts + face->v1; - v[1] = verts + face->v2; - v[2] = verts + face->v3; - - if (face->v4) - { - v[3] = verts + face->v4; - totvert = 4; - } - else - { - v[3] = NULL; - totvert = 3; - } - - if (efa) - { - eve[0] = efa->v1; - eve[1] = efa->v2; - eve[2] = efa->v3; - eve[3] = efa->v4; - } - - switch(G.scene->snap_mode) - { - case SCE_SNAP_MODE_VERTEX: - { - float min_dist = FLT_MAX; - int i; - - for(i = 0; i < totvert; i++) - { - - if (efa == NULL || (eve[i]->f1 & SELECT) == 0) - { - float vert_dist = VecLenf(v[i]->co, intersect); - - if (vert_dist < min_dist) - { - result = 1; - - min_dist = vert_dist; - - VECCOPY(loc, v[i]->co); - NormalShortToFloat(no, v[i]->no); - } - } - } - break; - } - case SCE_SNAP_MODE_EDGE: - { - float min_dist = FLT_MAX; - int i; - - for(i = 0; i < totvert; i++) - { - MVert *v1, *v2; - EditVert *eve1, *eve2; - - v1 = v[i]; - v2 = v[(i + 1) % totvert]; - - eve1 = eve[i]; - eve2 = eve[(i + 1) % totvert]; - - if (efa == NULL || ((eve1->f1 & SELECT) == 0 && (eve2->f1 & SELECT) == 0)) - { - float edge_loc[3]; - float vec[3]; - float mul; - float edge_dist; - - VecSubf(edge_loc, v2->co, v1->co); - VecSubf(vec, intersect, v1->co); - - mul = Inpf(vec, edge_loc) / Inpf(edge_loc, edge_loc); - - VecMulf(edge_loc, mul); - VecAddf(edge_loc, edge_loc, v1->co); - - edge_dist = VecLenf(edge_loc, intersect); - - if (edge_dist < min_dist) - { - float n1[3], n2[3]; - result = 1; - - min_dist = edge_dist; - - VECCOPY(loc, edge_loc); - - NormalShortToFloat(n1, v1->no); - NormalShortToFloat(n2, v2->no); - VecLerpf(no, n1, n2, mul); - Normalize(no); - } - } - } - break; - } - case SCE_SNAP_MODE_FACE: - { - if (efa == NULL || ((efa->f1 & SELECT) == 0)) - { - result = 1; - - VECCOPY(loc, intersect); - - if (totvert == 4) - CalcNormFloat4(v[0]->co, v[1]->co, v[2]->co, v[3]->co, no); - else - CalcNormFloat(v[0]->co, v[1]->co, v[2]->co, no); - } - break; - } - } - - return result; -} - int snapDerivedMesh(Object *ob, DerivedMesh *dm, float obmat[][4], float ray_start[3], float ray_normal[3], short mval[2], float *loc, float *no, int *dist, float *depth, short EditMesh) { int retval = 0; @@ -891,7 +761,7 @@ int snapDerivedMesh(Object *ob, DerivedMesh *dm, float obmat[][4], float ray_sta Mat4Mul3Vecfl(imat, ray_normal_local); - /* If number of vert is more than an arbitrary limit, + /* If number of vert is more than an arbitrary limit, * test against boundbox first * */ if (totface > 16) { @@ -900,117 +770,219 @@ int snapDerivedMesh(Object *ob, DerivedMesh *dm, float obmat[][4], float ray_sta } if (test == 1) { - MVert *verts = dm->getVertArray(dm); - MFace *faces = dm->getFaceArray(dm); - int *index_array = NULL; - int index = 0; - int i; - if (EditMesh) + switch (G.scene->snap_mode) { - index_array = dm->getFaceDataArray(dm, CD_ORIGINDEX); - EM_init_index_arrays(0, 0, 1); - } - - for( i = 0; i < totface; i++) { - EditFace *efa = NULL; - MFace *f = faces + i; - float lambda; - int result; - - test = 1; /* reset for every face */ - - if (EditMesh) - { - if (index_array) - { - index = index_array[i]; - } - else - { - index = i; - } + case SCE_SNAP_MODE_FACE: + { + MVert *verts = dm->getVertArray(dm); + MFace *faces = dm->getFaceArray(dm); + int *index_array = NULL; + int index = 0; + int i; - if (index == ORIGINDEX_NONE) + if (EditMesh) { - test = 0; + index_array = dm->getFaceDataArray(dm, CD_ORIGINDEX); + EM_init_index_arrays(0, 0, 1); } - else - { - efa = EM_get_face_for_index(index); + + for( i = 0; i < totface; i++) { + EditFace *efa = NULL; + MFace *f = faces + i; + float lambda; + int result; - if (efa && efa->f1 & SELECT) + test = 1; /* reset for every face */ + + if (EditMesh) { - test = 0; + if (index_array) + { + index = index_array[i]; + } + else + { + index = i; + } + + if (index == ORIGINDEX_NONE) + { + test = 0; + } + else + { + efa = EM_get_face_for_index(index); + + if (efa && efa->f & SELECT) + { + test = 0; + } + } } - } - } - - - if (test) - { - result = RayIntersectsTriangle(ray_start_local, ray_normal_local, verts[f->v1].co, verts[f->v2].co, verts[f->v3].co, &lambda, NULL); - - if (result) { - float location[3], normal[3]; - float intersect[3]; - VECCOPY(intersect, ray_normal_local); - VecMulf(intersect, lambda); - VecAddf(intersect, intersect, ray_start_local); - if (snapFace(f, efa, verts, intersect, location, normal)) - { - float new_depth; - int screen_loc[2]; - int new_dist; - - Mat4MulVecfl(obmat, location); - - new_depth = VecLenf(location, ray_start); - - project_int(location, screen_loc); - new_dist = abs(screen_loc[0] - mval[0]) + abs(screen_loc[1] - mval[1]); + if (test) + { + result = RayIntersectsTriangle(ray_start_local, ray_normal_local, verts[f->v1].co, verts[f->v2].co, verts[f->v3].co, &lambda, NULL); - if (new_dist <= *dist && new_depth < *depth) - { - *depth = new_depth; - retval = 1; + if (result) { + float location[3], normal[3]; + float intersect[3]; + float new_depth; + int screen_loc[2]; + int new_dist; - VECCOPY(loc, location); - VECCOPY(no, normal); + VECCOPY(intersect, ray_normal_local); + VecMulf(intersect, lambda); + VecAddf(intersect, intersect, ray_start_local); - Mat3MulVecfl(timat, no); - Normalize(no); - - project_int(loc, screen_loc); + VECCOPY(location, intersect); + + if (f->v4) + CalcNormFloat4(verts[f->v1].co, verts[f->v2].co, verts[f->v3].co, verts[f->v4].co, normal); + else + CalcNormFloat(verts[f->v1].co, verts[f->v2].co, verts[f->v3].co, normal); + + Mat4MulVecfl(obmat, location); + + new_depth = VecLenf(location, ray_start); + + project_int(location, screen_loc); + new_dist = abs(screen_loc[0] - mval[0]) + abs(screen_loc[1] - mval[1]); + + if (new_dist <= *dist && new_depth < *depth) + { + *depth = new_depth; + retval = 1; + + VECCOPY(loc, location); + VECCOPY(no, normal); + + Mat3MulVecfl(timat, no); + Normalize(no); + + *dist = new_dist; + } + } + + if (f->v4 && result == 0) + { + result = RayIntersectsTriangle(ray_start_local, ray_normal_local, verts[f->v3].co, verts[f->v4].co, verts[f->v1].co, &lambda, NULL); - *dist = new_dist; - } + if (result) { + float location[3], normal[3]; + float intersect[3]; + float new_depth; + int screen_loc[2]; + int new_dist; + + VECCOPY(intersect, ray_normal_local); + VecMulf(intersect, lambda); + VecAddf(intersect, intersect, ray_start_local); + + VECCOPY(location, intersect); + + if (f->v4) + CalcNormFloat4(verts[f->v1].co, verts[f->v2].co, verts[f->v3].co, verts[f->v4].co, normal); + else + CalcNormFloat(verts[f->v1].co, verts[f->v2].co, verts[f->v3].co, normal); + + Mat4MulVecfl(obmat, location); + + new_depth = VecLenf(location, ray_start); + + project_int(location, screen_loc); + new_dist = abs(screen_loc[0] - mval[0]) + abs(screen_loc[1] - mval[1]); + + if (new_dist <= *dist && new_depth < *depth) + { + *depth = new_depth; + retval = 1; + + VECCOPY(loc, location); + VECCOPY(no, normal); + + Mat3MulVecfl(timat, no); + Normalize(no); + + *dist = new_dist; + } + } + } } } - - if (f->v4 && result == 0) + + if (EditMesh) { - result = RayIntersectsTriangle(ray_start_local, ray_normal_local, verts[f->v3].co, verts[f->v4].co, verts[f->v1].co, &lambda, NULL); + EM_free_index_arrays(); + } + break; + } + case SCE_SNAP_MODE_VERTEX: + { + MVert *verts = dm->getVertArray(dm); + int *index_array = NULL; + int index = 0; + int i; + + if (EditMesh) + { + index_array = dm->getVertDataArray(dm, CD_ORIGINDEX); + EM_init_index_arrays(1, 0, 0); + } + + for( i = 0; i < totvert; i++) { + EditVert *eve = NULL; + MVert *v = verts + i; - if (result) { - float location[3], normal[3]; - float intersect[3]; + test = 1; /* reset for every vert */ + + if (EditMesh) + { + if (index_array) + { + index = index_array[i]; + } + else + { + index = i; + } - VECCOPY(intersect, ray_normal_local); - VecMulf(intersect, lambda); - VecAddf(intersect, intersect, ray_start_local); - - if (snapFace(f, efa, verts, intersect, location, normal)) - { + if (index == ORIGINDEX_NONE) + { + test = 0; + } + else + { + eve = EM_get_vert_for_index(index); + + if (eve && eve->f & SELECT) + { + test = 0; + } + } + } + + + if (test) + { + float dvec[3]; + + VecSubf(dvec, v->co, ray_start_local); + + if (Inpf(ray_normal_local, dvec) > 0) + { + float location[3]; float new_depth; int screen_loc[2]; int new_dist; + VECCOPY(location, v->co); + Mat4MulVecfl(obmat, location); - new_depth = VecLenf(location, ray_start); + new_depth = VecLenf(location, ray_start); project_int(location, screen_loc); new_dist = abs(screen_loc[0] - mval[0]) + abs(screen_loc[1] - mval[1]); @@ -1021,8 +993,8 @@ int snapDerivedMesh(Object *ob, DerivedMesh *dm, float obmat[][4], float ray_sta retval = 1; VECCOPY(loc, location); - VECCOPY(no, normal); + NormalShortToFloat(no, v->no); Mat3MulVecfl(timat, no); Normalize(no); @@ -1031,12 +1003,145 @@ int snapDerivedMesh(Object *ob, DerivedMesh *dm, float obmat[][4], float ray_sta } } } + + if (EditMesh) + { + EM_free_index_arrays(); + } + break; + } + case SCE_SNAP_MODE_EDGE: + { + MVert *verts = dm->getVertArray(dm); + MEdge *edges = dm->getEdgeArray(dm); + int totedge = dm->getNumEdges(dm); + int *index_array = NULL; + int index = 0; + int i; + + if (EditMesh) + { + index_array = dm->getEdgeDataArray(dm, CD_ORIGINDEX); + EM_init_index_arrays(0, 1, 0); + } + + for( i = 0; i < totedge; i++) { + EditEdge *eed = NULL; + MEdge *e = edges + i; + + test = 1; /* reset for every vert */ + + if (EditMesh) + { + if (index_array) + { + index = index_array[i]; + } + else + { + index = i; + } + + if (index == ORIGINDEX_NONE) + { + test = 0; + } + else + { + eed = EM_get_edge_for_index(index); + + if (eed && ((eed->v1->f & SELECT) || (eed->v2->f & SELECT))) + { + test = 0; + } + } + } + + + if (test) + { + float intersect[3] = {0, 0, 0}, ray_end[3], dvec[3]; + int result; + + VECCOPY(ray_end, ray_normal_local); + VecMulf(ray_end, 2000); + VecAddf(ray_end, ray_start_local, ray_end); + + result = LineIntersectLine(verts[e->v1].co, verts[e->v2].co, ray_start_local, ray_end, intersect, dvec); /* dvec used but we don't care about result */ + + if (result) + { + float edge_loc[3], vec[3]; + float mul; + + /* check for behind ray_start */ + VecSubf(dvec, intersect, ray_start_local); + + VecSubf(edge_loc, verts[e->v1].co, verts[e->v2].co); + VecSubf(vec, intersect, verts[e->v2].co); + + mul = Inpf(vec, edge_loc) / Inpf(edge_loc, edge_loc); + + if (mul > 1) { + mul = 1; + VECCOPY(intersect, verts[e->v1].co); + } + else if (mul < 0) { + mul = 0; + VECCOPY(intersect, verts[e->v2].co); + } + + if (Inpf(ray_normal_local, dvec) > 0) + { + float location[3]; + float new_depth; + int screen_loc[2]; + int new_dist; + + VECCOPY(location, intersect); + + Mat4MulVecfl(obmat, location); + + new_depth = VecLenf(location, ray_start); + + project_int(location, screen_loc); + new_dist = abs(screen_loc[0] - mval[0]) + abs(screen_loc[1] - mval[1]); + + if (new_dist <= *dist && new_depth < *depth) + { + float n1[3], n2[3]; + + *depth = new_depth; + retval = 1; + + VecSubf(edge_loc, verts[e->v1].co, verts[e->v2].co); + VecSubf(vec, intersect, verts[e->v2].co); + + mul = Inpf(vec, edge_loc) / Inpf(edge_loc, edge_loc); + + NormalShortToFloat(n1, verts[e->v1].no); + NormalShortToFloat(n2, verts[e->v2].no); + VecLerpf(no, n2, n1, mul); + Normalize(no); + + VECCOPY(loc, location); + + Mat3MulVecfl(timat, no); + Normalize(no); + + *dist = new_dist; + } + } + } + } + } + + if (EditMesh) + { + EM_free_index_arrays(); + } + break; } - } - - if (EditMesh) - { - EM_free_index_arrays(); } } } diff --git a/source/creator/creator.c b/source/creator/creator.c index 2e6b5d7353e..9589f1e3e94 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -195,7 +195,7 @@ static void print_help(void) printf (" (formats that can be compiled into blender, not available on all systems)\n"); printf (" \tHDR TIFF EXR MULTILAYER MPEG AVICODEC QUICKTIME CINEON DPX DDS\n"); printf (" -x <bool>\tSet option to add the file extension to the end of the file.\n"); - printf (" -t <threads>\tUse amount of <threads> for rendering.\n"); + printf (" -t <threads>\tUse amount of <threads> for rendering (background mode only).\n"); printf (" [1-8], 0 for systems processor count.\n"); printf ("\nAnimation playback options:\n"); printf (" -a <file(s)>\tPlayback <file(s)>, only operates this way when -b is not used.\n"); @@ -723,6 +723,8 @@ int main(int argc, char **argv) a++; if(G.background) { RE_set_max_threads(atoi(argv[a])); + } else { + printf("Warning: threads can only be set in background mode\n"); } break; case 'x': /* extension */ diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index ad126ebf123..83be5d3a14f 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -49,6 +49,7 @@ #include "BLI_arithb.h" #include "MT_Matrix4x4.h" #include "BKE_utildefines.h" +#include "FloatValue.h" #ifdef HAVE_CONFIG_H #include <config.h> @@ -348,6 +349,18 @@ bool BL_ActionActuator::Update(double curtime, bool frame) break; } + /* Set the property if its defined */ + if (m_framepropname) { + CValue* propowner = GetParent(); + CValue* oldprop = propowner->GetProperty(m_framepropname); + CValue* newval = new CFloatValue(m_localtime); + if (oldprop) { + oldprop->SetValue(newval); + } else { + propowner->SetProperty(m_framepropname, newval); + } + newval->Release(); + } if (bNegativeEvent) m_blendframe=0.0; @@ -446,6 +459,7 @@ PyMethodDef BL_ActionActuator::Methods[] = { {"setPriority", (PyCFunction) BL_ActionActuator::sPySetPriority, METH_VARARGS, SetPriority_doc}, {"setFrame", (PyCFunction) BL_ActionActuator::sPySetFrame, METH_VARARGS, SetFrame_doc}, {"setProperty", (PyCFunction) BL_ActionActuator::sPySetProperty, METH_VARARGS, SetProperty_doc}, + {"setFrameProperty", (PyCFunction) BL_ActionActuator::sPySetFrameProperty, METH_VARARGS, SetFrameProperty_doc}, {"setBlendtime", (PyCFunction) BL_ActionActuator::sPySetBlendtime, METH_VARARGS, SetBlendtime_doc}, {"getAction", (PyCFunction) BL_ActionActuator::sPyGetAction, METH_VARARGS, GetAction_doc}, @@ -455,6 +469,7 @@ PyMethodDef BL_ActionActuator::Methods[] = { {"getPriority", (PyCFunction) BL_ActionActuator::sPyGetPriority, METH_VARARGS, GetPriority_doc}, {"getFrame", (PyCFunction) BL_ActionActuator::sPyGetFrame, METH_VARARGS, GetFrame_doc}, {"getProperty", (PyCFunction) BL_ActionActuator::sPyGetProperty, METH_VARARGS, GetProperty_doc}, + {"getFrameProperty", (PyCFunction) BL_ActionActuator::sPyGetFrameProperty, METH_VARARGS, GetFrameProperty_doc}, {"setChannel", (PyCFunction) BL_ActionActuator::sPySetChannel, METH_VARARGS, SetChannel_doc}, // {"getChannel", (PyCFunction) BL_ActionActuator::sPyGetChannel, METH_VARARGS}, {"getType", (PyCFunction) BL_ActionActuator::sPyGetType, METH_VARARGS, GetType_doc}, @@ -502,6 +517,21 @@ PyObject* BL_ActionActuator::PyGetProperty(PyObject* self, return result; } +/* getProperty */ +char BL_ActionActuator::GetFrameProperty_doc[] = +"getFrameProperty()\n" +"\tReturns the name of the property, that is set to the current frame number.\n"; + +PyObject* BL_ActionActuator::PyGetFrameProperty(PyObject* self, + PyObject* args, + PyObject* kwds) { + PyObject *result; + + result = Py_BuildValue("s", (const char *)m_framepropname); + + return result; +} + /* getFrame */ char BL_ActionActuator::GetFrame_doc[] = "getFrame()\n" @@ -763,6 +793,25 @@ PyObject* BL_ActionActuator::PySetProperty(PyObject* self, return Py_None; } +/* setFrameProperty */ +char BL_ActionActuator::SetFrameProperty_doc[] = +"setFrameProperty(prop)\n" +"\t - prop : A string specifying the property of the frame set up update.\n"; + +PyObject* BL_ActionActuator::PySetFrameProperty(PyObject* self, + PyObject* args, + PyObject* kwds) { + char *string; + + if (PyArg_ParseTuple(args,"s",&string)) + { + m_framepropname = string; + } + + Py_INCREF(Py_None); + return Py_None; +} + /* PyObject* BL_ActionActuator::PyGetChannel(PyObject* self, PyObject* args, diff --git a/source/gameengine/Converter/BL_ActionActuator.h b/source/gameengine/Converter/BL_ActionActuator.h index 62edcc7fad7..190f727c9c3 100644 --- a/source/gameengine/Converter/BL_ActionActuator.h +++ b/source/gameengine/Converter/BL_ActionActuator.h @@ -40,6 +40,7 @@ public: Py_Header; BL_ActionActuator(SCA_IObject* gameobj, const STR_String& propname, + const STR_String& framepropname, float starttime, float endtime, struct bAction *action, @@ -67,7 +68,8 @@ public: m_blendpose(NULL), m_userpose(NULL), m_action(action), - m_propname(propname) + m_propname(propname), + m_framepropname(framepropname) { }; virtual ~BL_ActionActuator(); @@ -84,6 +86,7 @@ public: KX_PYMETHOD_DOC(BL_ActionActuator,SetEnd); KX_PYMETHOD_DOC(BL_ActionActuator,SetFrame); KX_PYMETHOD_DOC(BL_ActionActuator,SetProperty); + KX_PYMETHOD_DOC(BL_ActionActuator,SetFrameProperty); KX_PYMETHOD_DOC(BL_ActionActuator,SetBlendtime); KX_PYMETHOD_DOC(BL_ActionActuator,SetChannel); @@ -94,6 +97,7 @@ public: KX_PYMETHOD_DOC(BL_ActionActuator,GetEnd); KX_PYMETHOD_DOC(BL_ActionActuator,GetFrame); KX_PYMETHOD_DOC(BL_ActionActuator,GetProperty); + KX_PYMETHOD_DOC(BL_ActionActuator,GetFrameProperty); // KX_PYMETHOD(BL_ActionActuator,GetChannel); KX_PYMETHOD_DOC(BL_ActionActuator,GetType); KX_PYMETHOD_DOC(BL_ActionActuator,SetType); @@ -138,6 +142,7 @@ protected: struct bPose* m_userpose; struct bAction *m_action; STR_String m_propname; + STR_String m_framepropname; }; enum { diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index c02c2a29595..89e2925a6c1 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -178,10 +178,12 @@ void BL_ConvertActuators(char* maggiename, if (blenderobject->type==OB_ARMATURE){ bActionActuator* actact = (bActionActuator*) bact->data; STR_String propname = (actact->name ? actact->name : ""); + STR_String propframe = (actact->frameProp ? actact->frameProp : ""); BL_ActionActuator* tmpbaseact = new BL_ActionActuator( gameobj, propname, + propframe, actact->sta, actact->end, actact->act, diff --git a/source/gameengine/Converter/KX_ConvertControllers.cpp b/source/gameengine/Converter/KX_ConvertControllers.cpp index 179dd9f8478..da490b4ee85 100644 --- a/source/gameengine/Converter/KX_ConvertControllers.cpp +++ b/source/gameengine/Converter/KX_ConvertControllers.cpp @@ -35,6 +35,10 @@ // Controller #include "SCA_ANDController.h" #include "SCA_ORController.h" +#include "SCA_NANDController.h" +#include "SCA_NORController.h" +#include "SCA_XORController.h" +#include "SCA_XNORController.h" #include "SCA_PythonController.h" #include "SCA_ExpressionController.h" @@ -112,6 +116,30 @@ void BL_ConvertControllers( LinkControllerToActuators(gamecontroller,bcontr,logicmgr,converter); break; } + case CONT_LOGIC_NAND: + { + gamecontroller = new SCA_NANDController(gameobj); + LinkControllerToActuators(gamecontroller,bcontr,logicmgr,converter); + break; + } + case CONT_LOGIC_NOR: + { + gamecontroller = new SCA_NORController(gameobj); + LinkControllerToActuators(gamecontroller,bcontr,logicmgr,converter); + break; + } + case CONT_LOGIC_XOR: + { + gamecontroller = new SCA_XORController(gameobj); + LinkControllerToActuators(gamecontroller,bcontr,logicmgr,converter); + break; + } + case CONT_LOGIC_XNOR: + { + gamecontroller = new SCA_XNORController(gameobj); + LinkControllerToActuators(gamecontroller,bcontr,logicmgr,converter); + break; + } case CONT_EXPRESSION: { bExpressionCont* bexpcont = (bExpressionCont*) bcontr->data; diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp index 80fa3838d60..e7e4eeae7d2 100644 --- a/source/gameengine/Converter/KX_ConvertSensors.cpp +++ b/source/gameengine/Converter/KX_ConvertSensors.cpp @@ -251,6 +251,7 @@ void BL_ConvertSensors(struct Object* blenderobject, bool neg_pulsemode = false; int frequency = 0; bool invert = false; + bool level = false; while(sens) { @@ -263,7 +264,8 @@ void BL_ConvertSensors(struct Object* blenderobject, frequency = sens->freq; invert = !(sens->invert == 0); - + level = !(sens->level == 0); + switch (sens->type) { case SENS_ALWAYS: @@ -711,6 +713,7 @@ void BL_ConvertSensors(struct Object* blenderobject, neg_pulsemode, frequency); gamesensor->SetInvert(invert); + gamesensor->SetLevel(level); gamesensor->SetName(STR_String(sens->name)); gameobj->AddSensor(gamesensor); diff --git a/source/gameengine/GameLogic/SCA_ISensor.cpp b/source/gameengine/GameLogic/SCA_ISensor.cpp index 1c29eb27be5..6cfae9d8919 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.cpp +++ b/source/gameengine/GameLogic/SCA_ISensor.cpp @@ -55,6 +55,7 @@ SCA_ISensor::SCA_ISensor(SCA_IObject* gameobj, m_links = 0; m_suspended = false; m_invert = false; + m_level = false; m_pos_ticks = 0; m_neg_ticks = 0; m_pos_pulsemode = false; @@ -95,6 +96,10 @@ void SCA_ISensor::SetInvert(bool inv) { m_invert = inv; } +void SCA_ISensor::SetLevel(bool lvl) { + m_level = lvl; +} + float SCA_ISensor::GetNumber() { return IsPositiveTrigger(); @@ -177,6 +182,10 @@ PyMethodDef SCA_ISensor::Methods[] = { METH_VARARGS, GetInvert_doc}, {"setInvert", (PyCFunction) SCA_ISensor::sPySetInvert, METH_VARARGS, SetInvert_doc}, + {"getLevel", (PyCFunction) SCA_ISensor::sPyGetLevel, + METH_VARARGS, GetLevel_doc}, + {"setLevel", (PyCFunction) SCA_ISensor::sPySetLevel, + METH_VARARGS, SetLevel_doc}, {NULL,NULL} //Sentinel }; @@ -328,6 +337,31 @@ PyObject* SCA_ISensor::PySetInvert(PyObject* self, PyObject* args, PyObject* kwd Py_Return; } +char SCA_ISensor::GetLevel_doc[] = +"getLevel()\n" +"\tReturns whether this sensor is a level detector or a edge detector.\n" +"\tIt makes a difference only in case of logic state transition (state actuator).\n" +"\tA level detector will immediately generate a pulse if the condition for the\n" +"\tdetector is met when entering the state. A edge detector will wait for an off-on\n" +"\ttransition to occur.\n" +"\tOnly some sensors implement this feature: keyboard.\n"; +PyObject* SCA_ISensor::PyGetLevel(PyObject* self, PyObject* args, PyObject* kwds) +{ + return BoolToPyArg(m_level); +} + +char SCA_ISensor::SetLevel_doc[] = +"setLevel(level?)\n" +"\t- level?: Detect level instead of edge? (KX_TRUE, KX_FALSE)\n" +"\tSet whether to detect level or edge transition when entering a state.\n"; +PyObject* SCA_ISensor::PySetLevel(PyObject* self, PyObject* args, PyObject* kwds) +{ + int pyarg = 0; + if(!PyArg_ParseTuple(args, "i", &pyarg)) { return NULL; } + m_level = PyArgToBool(pyarg); + Py_Return; +} + char SCA_ISensor::GetUseNegPulseMode_doc[] = "getUseNegPulseMode()\n" "\tReturns whether negative pulse mode is active.\n"; diff --git a/source/gameengine/GameLogic/SCA_ISensor.h b/source/gameengine/GameLogic/SCA_ISensor.h index 292b2d160ae..3527b87ebdb 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.h +++ b/source/gameengine/GameLogic/SCA_ISensor.h @@ -61,6 +61,9 @@ class SCA_ISensor : public SCA_ILogicBrick /** invert the output signal*/ bool m_invert; + /** detect level instead of edge*/ + bool m_level; + /** Sensor must ignore updates? */ bool m_suspended; @@ -105,6 +108,8 @@ public: virtual void Delete() { Release(); } /** Set inversion of pulses on or off. */ void SetInvert(bool inv); + /** set the level detection on or off */ + void SetLevel(bool lvl); void RegisterToManager(); virtual float GetNumber(); @@ -134,6 +139,8 @@ public: KX_PYMETHOD_DOC(SCA_ISensor,SetUseNegPulseMode); KX_PYMETHOD_DOC(SCA_ISensor,GetInvert); KX_PYMETHOD_DOC(SCA_ISensor,SetInvert); + KX_PYMETHOD_DOC(SCA_ISensor,GetLevel); + KX_PYMETHOD_DOC(SCA_ISensor,SetLevel); }; diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index 81938f05af1..8668c22f044 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -69,7 +69,7 @@ std::cout << " hat flag " << m_hatf << std::endl; void SCA_JoystickSensor::Init() { - m_istrig=0; + m_istrig=(m_invert)?1:0; } SCA_JoystickSensor::~SCA_JoystickSensor() diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp index c6c06846e3b..43ce25f94df 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp +++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp @@ -77,7 +77,7 @@ void SCA_KeyboardSensor::Init() // by the state engine. It reinitializes the sensor as if it was just created. // However, if the target key is pressed when the sensor is reactivated, it // will not generated an event (see remark in Evaluate()). - m_val = 0; + m_val = (m_invert)?1:0; } CValue* SCA_KeyboardSensor::GetReplica() @@ -176,10 +176,10 @@ bool SCA_KeyboardSensor::Evaluate(CValue* eventval) { if (m_val == 0) { - //see comment below - //m_val = 1; - //result = true; - ; + if (m_level) { + m_val = 1; + result = true; + } } } else { @@ -229,15 +229,11 @@ bool SCA_KeyboardSensor::Evaluate(CValue* eventval) { if (m_val == 0) { - //hmm, this abnormal situation may occur in the following cases: - //- the key was pressed while the scene was suspended - //- this is a new scene and the key is active from the start - //In the second case, it's dangerous to activate the sensor - //(think of a key to go to next scene) - //What we really need is a edge/level flag in the key sensor - //m_val = 1; - //result = true; - ; + if (m_level) + { + m_val = 1; + result = true; + } } } } diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.cpp b/source/gameengine/GameLogic/SCA_MouseSensor.cpp index 11e67eda014..42d35837489 100644 --- a/source/gameengine/GameLogic/SCA_MouseSensor.cpp +++ b/source/gameengine/GameLogic/SCA_MouseSensor.cpp @@ -83,7 +83,7 @@ SCA_MouseSensor::SCA_MouseSensor(SCA_MouseManager* eventmgr, void SCA_MouseSensor::Init() { - m_val = 0; /* stores the latest attribute */ + m_val = (m_invert)?1:0; /* stores the latest attribute */ } SCA_MouseSensor::~SCA_MouseSensor() @@ -168,10 +168,11 @@ bool SCA_MouseSensor::Evaluate(CValue* event) { if (m_val == 0) { - //dangerous - //m_val = 1; - //result = true; - ; + if (m_level) + { + m_val = 1; + result = true; + } } } else { diff --git a/source/gameengine/GameLogic/SCA_NANDController.cpp b/source/gameengine/GameLogic/SCA_NANDController.cpp new file mode 100644 index 00000000000..5b869ee8298 --- /dev/null +++ b/source/gameengine/GameLogic/SCA_NANDController.cpp @@ -0,0 +1,144 @@ +/** + * 'Nand' together all inputs + * + * $Id$ + * + * ***** 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 ***** + */ + +#include "SCA_NANDController.h" +#include "SCA_ISensor.h" +#include "SCA_LogicManager.h" +#include "BoolValue.h" + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +/* ------------------------------------------------------------------------- */ +/* Native functions */ +/* ------------------------------------------------------------------------- */ + +SCA_NANDController::SCA_NANDController(SCA_IObject* gameobj, + PyTypeObject* T) + : + SCA_IController(gameobj,T) +{ +} + + + +SCA_NANDController::~SCA_NANDController() +{ +} + + + +void SCA_NANDController::Trigger(SCA_LogicManager* logicmgr) +{ + + bool sensorresult = false; + + for (vector<SCA_ISensor*>::const_iterator is=m_linkedsensors.begin(); + !(is==m_linkedsensors.end());is++) + { + SCA_ISensor* sensor = *is; + if (!sensor->IsPositiveTrigger()) + { + sensorresult = true; + break; + } + } + + CValue* newevent = new CBoolValue(sensorresult); + + for (vector<SCA_IActuator*>::const_iterator i=m_linkedactuators.begin(); + !(i==m_linkedactuators.end());i++) + { + SCA_IActuator* actua = *i;//m_linkedactuators.at(i); + logicmgr->AddActiveActuator(actua,newevent); + } + + // every actuator that needs the event, has a it's own reference to it now so + // release it (so to be clear: if there is no actuator, it's deleted right now) + newevent->Release(); + +} + + + +CValue* SCA_NANDController::GetReplica() +{ + CValue* replica = new SCA_NANDController(*this); + // this will copy properties and so on... + CValue::AddDataToReplica(replica); + + return replica; +} + + + +/* ------------------------------------------------------------------------- */ +/* Python functions */ +/* ------------------------------------------------------------------------- */ + +/* Integration hooks ------------------------------------------------------- */ +PyTypeObject SCA_NANDController::Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "SCA_NANDController", + sizeof(SCA_NANDController), + 0, + PyDestructor, + 0, + __getattr, + __setattr, + 0, //&MyPyCompare, + __repr, + 0, //&cvalue_as_number, + 0, + 0, + 0, + 0 +}; + +PyParentObject SCA_NANDController::Parents[] = { + &SCA_NANDController::Type, + &SCA_IController::Type, + &SCA_ILogicBrick::Type, + &CValue::Type, + NULL +}; + +PyMethodDef SCA_NANDController::Methods[] = { + {NULL,NULL} //Sentinel +}; + +PyObject* SCA_NANDController::_getattr(const STR_String& attr) { + _getattr_up(SCA_IController); +} + +/* eof */ diff --git a/source/gameengine/GameLogic/SCA_NANDController.h b/source/gameengine/GameLogic/SCA_NANDController.h new file mode 100644 index 00000000000..1193ff64f07 --- /dev/null +++ b/source/gameengine/GameLogic/SCA_NANDController.h @@ -0,0 +1,56 @@ +/** + * SCA_NANDController.h + * + * $Id$ + * + * ***** 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 ***** + */ + +#ifndef __KX_NANDCONTROLLER +#define __KX_NANDCONTROLLER + +#include "SCA_IController.h" + +class SCA_NANDController : public SCA_IController +{ + Py_Header; + //virtual void Trigger(class SCA_LogicManager* logicmgr); +public: + SCA_NANDController(SCA_IObject* gameobj,PyTypeObject* T=&Type); + virtual ~SCA_NANDController(); + virtual CValue* GetReplica(); + virtual void Trigger(SCA_LogicManager* logicmgr); + + /* --------------------------------------------------------------------- */ + /* Python interface ---------------------------------------------------- */ + /* --------------------------------------------------------------------- */ + + virtual PyObject* _getattr(const STR_String& attr); + +}; + +#endif //__KX_NANDCONTROLLER + diff --git a/source/gameengine/GameLogic/SCA_NORController.cpp b/source/gameengine/GameLogic/SCA_NORController.cpp new file mode 100644 index 00000000000..2866dec0b74 --- /dev/null +++ b/source/gameengine/GameLogic/SCA_NORController.cpp @@ -0,0 +1,144 @@ +/** + * 'Nor' together all inputs + * + * $Id$ + * + * ***** 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 ***** + */ + +#include "SCA_NORController.h" +#include "SCA_ISensor.h" +#include "SCA_LogicManager.h" +#include "BoolValue.h" + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +/* ------------------------------------------------------------------------- */ +/* Native functions */ +/* ------------------------------------------------------------------------- */ + +SCA_NORController::SCA_NORController(SCA_IObject* gameobj, + PyTypeObject* T) + : + SCA_IController(gameobj,T) +{ +} + + + +SCA_NORController::~SCA_NORController() +{ +} + + + +void SCA_NORController::Trigger(SCA_LogicManager* logicmgr) +{ + + bool sensorresult = true; + + for (vector<SCA_ISensor*>::const_iterator is=m_linkedsensors.begin(); + !(is==m_linkedsensors.end());is++) + { + SCA_ISensor* sensor = *is; + if (sensor->IsPositiveTrigger()) + { + sensorresult = false; + break; + } + } + + CValue* newevent = new CBoolValue(sensorresult); + + for (vector<SCA_IActuator*>::const_iterator i=m_linkedactuators.begin(); + !(i==m_linkedactuators.end());i++) + { + SCA_IActuator* actua = *i;//m_linkedactuators.at(i); + logicmgr->AddActiveActuator(actua,newevent); + } + + // every actuator that needs the event, has a it's own reference to it now so + // release it (so to be clear: if there is no actuator, it's deleted right now) + newevent->Release(); + +} + + + +CValue* SCA_NORController::GetReplica() +{ + CValue* replica = new SCA_NORController(*this); + // this will copy properties and so on... + CValue::AddDataToReplica(replica); + + return replica; +} + + + +/* ------------------------------------------------------------------------- */ +/* Python functions */ +/* ------------------------------------------------------------------------- */ + +/* Integration hooks ------------------------------------------------------- */ +PyTypeObject SCA_NORController::Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "SCA_NORController", + sizeof(SCA_NORController), + 0, + PyDestructor, + 0, + __getattr, + __setattr, + 0, //&MyPyCompare, + __repr, + 0, //&cvalue_as_number, + 0, + 0, + 0, + 0 +}; + +PyParentObject SCA_NORController::Parents[] = { + &SCA_NORController::Type, + &SCA_IController::Type, + &SCA_ILogicBrick::Type, + &CValue::Type, + NULL +}; + +PyMethodDef SCA_NORController::Methods[] = { + {NULL,NULL} //Sentinel +}; + +PyObject* SCA_NORController::_getattr(const STR_String& attr) { + _getattr_up(SCA_IController); +} + +/* eof */ diff --git a/source/gameengine/GameLogic/SCA_NORController.h b/source/gameengine/GameLogic/SCA_NORController.h new file mode 100644 index 00000000000..aab59e3d46c --- /dev/null +++ b/source/gameengine/GameLogic/SCA_NORController.h @@ -0,0 +1,56 @@ +/** + * SCA_NORController.h + * + * $Id$ + * + * ***** 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 ***** + */ + +#ifndef __KX_NORCONTROLLER +#define __KX_NORCONTROLLER + +#include "SCA_IController.h" + +class SCA_NORController : public SCA_IController +{ + Py_Header; + //virtual void Trigger(class SCA_LogicManager* logicmgr); +public: + SCA_NORController(SCA_IObject* gameobj,PyTypeObject* T=&Type); + virtual ~SCA_NORController(); + virtual CValue* GetReplica(); + virtual void Trigger(SCA_LogicManager* logicmgr); + + /* --------------------------------------------------------------------- */ + /* Python interface ---------------------------------------------------- */ + /* --------------------------------------------------------------------- */ + + virtual PyObject* _getattr(const STR_String& attr); + +}; + +#endif //__KX_NORCONTROLLER + diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.cpp b/source/gameengine/GameLogic/SCA_PropertySensor.cpp index d6eb246ffd2..655e9060238 100644 --- a/source/gameengine/GameLogic/SCA_PropertySensor.cpp +++ b/source/gameengine/GameLogic/SCA_PropertySensor.cpp @@ -54,7 +54,6 @@ SCA_PropertySensor::SCA_PropertySensor(SCA_EventManager* eventmgr, m_checkpropval(propval), m_checkpropmaxval(propmaxval), m_checkpropname(propname), - m_lastresult(false), m_range_expr(NULL) { //CParser pars; @@ -78,6 +77,7 @@ SCA_PropertySensor::SCA_PropertySensor(SCA_EventManager* eventmgr, void SCA_PropertySensor::Init() { m_recentresult = false; + m_lastresult = m_invert?true:false; } void SCA_PropertySensor::PrecalculateRangeExpression() diff --git a/source/gameengine/GameLogic/SCA_XNORController.cpp b/source/gameengine/GameLogic/SCA_XNORController.cpp new file mode 100644 index 00000000000..3ef7c07fe0a --- /dev/null +++ b/source/gameengine/GameLogic/SCA_XNORController.cpp @@ -0,0 +1,148 @@ +/** + * 'Xnor' together all inputs + * + * $Id$ + * + * ***** 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 ***** + */ + +#include "SCA_XNORController.h" +#include "SCA_ISensor.h" +#include "SCA_LogicManager.h" +#include "BoolValue.h" + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +/* ------------------------------------------------------------------------- */ +/* Native functions */ +/* ------------------------------------------------------------------------- */ + +SCA_XNORController::SCA_XNORController(SCA_IObject* gameobj, + PyTypeObject* T) + : + SCA_IController(gameobj,T) +{ +} + + + +SCA_XNORController::~SCA_XNORController() +{ +} + + + +void SCA_XNORController::Trigger(SCA_LogicManager* logicmgr) +{ + + bool sensorresult = true; + + for (vector<SCA_ISensor*>::const_iterator is=m_linkedsensors.begin(); + !(is==m_linkedsensors.end());is++) + { + SCA_ISensor* sensor = *is; + if (sensor->IsPositiveTrigger()) + { + if (sensorresult == false) + { + sensorresult = true; + break; + } + sensorresult = false; + } + } + + CValue* newevent = new CBoolValue(sensorresult); + + for (vector<SCA_IActuator*>::const_iterator i=m_linkedactuators.begin(); + !(i==m_linkedactuators.end());i++) + { + SCA_IActuator* actua = *i;//m_linkedactuators.at(i); + logicmgr->AddActiveActuator(actua,newevent); + } + + // every actuator that needs the event, has a it's own reference to it now so + // release it (so to be clear: if there is no actuator, it's deleted right now) + newevent->Release(); + +} + + + +CValue* SCA_XNORController::GetReplica() +{ + CValue* replica = new SCA_XNORController(*this); + // this will copy properties and so on... + CValue::AddDataToReplica(replica); + + return replica; +} + + + +/* ------------------------------------------------------------------------- */ +/* Python functions */ +/* ------------------------------------------------------------------------- */ + +/* Integration hooks ------------------------------------------------------- */ +PyTypeObject SCA_XNORController::Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "SCA_XNORController", + sizeof(SCA_XNORController), + 0, + PyDestructor, + 0, + __getattr, + __setattr, + 0, //&MyPyCompare, + __repr, + 0, //&cvalue_as_number, + 0, + 0, + 0, + 0 +}; + +PyParentObject SCA_XNORController::Parents[] = { + &SCA_XNORController::Type, + &SCA_IController::Type, + &SCA_ILogicBrick::Type, + &CValue::Type, + NULL +}; + +PyMethodDef SCA_XNORController::Methods[] = { + {NULL,NULL} //Sentinel +}; + +PyObject* SCA_XNORController::_getattr(const STR_String& attr) { + _getattr_up(SCA_IController); +} + +/* eof */ diff --git a/source/gameengine/GameLogic/SCA_XNORController.h b/source/gameengine/GameLogic/SCA_XNORController.h new file mode 100644 index 00000000000..4b1eaee95d8 --- /dev/null +++ b/source/gameengine/GameLogic/SCA_XNORController.h @@ -0,0 +1,56 @@ +/** + * SCA_XNORController.h + * + * $Id$ + * + * ***** 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 ***** + */ + +#ifndef __KX_XNORCONTROLLER +#define __KX_XNORCONTROLLER + +#include "SCA_IController.h" + +class SCA_XNORController : public SCA_IController +{ + Py_Header; + //virtual void Trigger(class SCA_LogicManager* logicmgr); +public: + SCA_XNORController(SCA_IObject* gameobj,PyTypeObject* T=&Type); + virtual ~SCA_XNORController(); + virtual CValue* GetReplica(); + virtual void Trigger(SCA_LogicManager* logicmgr); + + /* --------------------------------------------------------------------- */ + /* Python interface ---------------------------------------------------- */ + /* --------------------------------------------------------------------- */ + + virtual PyObject* _getattr(const STR_String& attr); + +}; + +#endif //__KX_XNORCONTROLLER + diff --git a/source/gameengine/GameLogic/SCA_XORController.cpp b/source/gameengine/GameLogic/SCA_XORController.cpp new file mode 100644 index 00000000000..6499c62f5f2 --- /dev/null +++ b/source/gameengine/GameLogic/SCA_XORController.cpp @@ -0,0 +1,148 @@ +/** + * 'Xor' together all inputs + * + * $Id$ + * + * ***** 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 ***** + */ + +#include "SCA_XORController.h" +#include "SCA_ISensor.h" +#include "SCA_LogicManager.h" +#include "BoolValue.h" + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +/* ------------------------------------------------------------------------- */ +/* Native functions */ +/* ------------------------------------------------------------------------- */ + +SCA_XORController::SCA_XORController(SCA_IObject* gameobj, + PyTypeObject* T) + : + SCA_IController(gameobj,T) +{ +} + + + +SCA_XORController::~SCA_XORController() +{ +} + + + +void SCA_XORController::Trigger(SCA_LogicManager* logicmgr) +{ + + bool sensorresult = false; + + for (vector<SCA_ISensor*>::const_iterator is=m_linkedsensors.begin(); + !(is==m_linkedsensors.end());is++) + { + SCA_ISensor* sensor = *is; + if (sensor->IsPositiveTrigger()) + { + if (sensorresult == true) + { + sensorresult = false; + break; + } + sensorresult = true; + } + } + + CValue* newevent = new CBoolValue(sensorresult); + + for (vector<SCA_IActuator*>::const_iterator i=m_linkedactuators.begin(); + !(i==m_linkedactuators.end());i++) + { + SCA_IActuator* actua = *i;//m_linkedactuators.at(i); + logicmgr->AddActiveActuator(actua,newevent); + } + + // every actuator that needs the event, has a it's own reference to it now so + // release it (so to be clear: if there is no actuator, it's deleted right now) + newevent->Release(); + +} + + + +CValue* SCA_XORController::GetReplica() +{ + CValue* replica = new SCA_XORController(*this); + // this will copy properties and so on... + CValue::AddDataToReplica(replica); + + return replica; +} + + + +/* ------------------------------------------------------------------------- */ +/* Python functions */ +/* ------------------------------------------------------------------------- */ + +/* Integration hooks ------------------------------------------------------- */ +PyTypeObject SCA_XORController::Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "SCA_XORController", + sizeof(SCA_XORController), + 0, + PyDestructor, + 0, + __getattr, + __setattr, + 0, //&MyPyCompare, + __repr, + 0, //&cvalue_as_number, + 0, + 0, + 0, + 0 +}; + +PyParentObject SCA_XORController::Parents[] = { + &SCA_XORController::Type, + &SCA_IController::Type, + &SCA_ILogicBrick::Type, + &CValue::Type, + NULL +}; + +PyMethodDef SCA_XORController::Methods[] = { + {NULL,NULL} //Sentinel +}; + +PyObject* SCA_XORController::_getattr(const STR_String& attr) { + _getattr_up(SCA_IController); +} + +/* eof */ diff --git a/source/gameengine/GameLogic/SCA_XORController.h b/source/gameengine/GameLogic/SCA_XORController.h new file mode 100644 index 00000000000..f50cd33c125 --- /dev/null +++ b/source/gameengine/GameLogic/SCA_XORController.h @@ -0,0 +1,56 @@ +/** + * SCA_XORController.h + * + * $Id$ + * + * ***** 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 ***** + */ + +#ifndef __KX_XORCONTROLLER +#define __KX_XORCONTROLLER + +#include "SCA_IController.h" + +class SCA_XORController : public SCA_IController +{ + Py_Header; + //virtual void Trigger(class SCA_LogicManager* logicmgr); +public: + SCA_XORController(SCA_IObject* gameobj,PyTypeObject* T=&Type); + virtual ~SCA_XORController(); + virtual CValue* GetReplica(); + virtual void Trigger(SCA_LogicManager* logicmgr); + + /* --------------------------------------------------------------------- */ + /* Python interface ---------------------------------------------------- */ + /* --------------------------------------------------------------------- */ + + virtual PyObject* _getattr(const STR_String& attr); + +}; + +#endif //__KX_XORCONTROLLER + diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp index f306f0dbfbb..f89d32bbe66 100644 --- a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp +++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp @@ -74,7 +74,7 @@ KX_MouseFocusSensor::KX_MouseFocusSensor(SCA_MouseManager* eventmgr, void KX_MouseFocusSensor::Init() { - m_mouse_over_in_previous_frame = false; + m_mouse_over_in_previous_frame = (m_invert)?true:false; m_positive_event = false; m_hitObject = 0; } @@ -92,13 +92,13 @@ bool KX_MouseFocusSensor::Evaluate(CValue* event) obHasFocus = ParentObjectHasFocus(); if (!obHasFocus) { + m_positive_event = false; if (m_mouse_over_in_previous_frame) { - m_positive_event = false; - result = true; + result = true; } } else { + m_positive_event = true; if (!m_mouse_over_in_previous_frame) { - m_positive_event = true; result = true; } } diff --git a/source/gameengine/Ketsji/KX_RaySensor.cpp b/source/gameengine/Ketsji/KX_RaySensor.cpp index 02b814105b4..e847c59bae1 100644 --- a/source/gameengine/Ketsji/KX_RaySensor.cpp +++ b/source/gameengine/Ketsji/KX_RaySensor.cpp @@ -69,7 +69,7 @@ KX_RaySensor::KX_RaySensor(class SCA_EventManager* eventmgr, void KX_RaySensor::Init() { - m_bTriggered = false; + m_bTriggered = (m_invert)?true:false; m_rayHit = false; m_hitObject = NULL; } diff --git a/source/gameengine/Ketsji/KX_TouchSensor.cpp b/source/gameengine/Ketsji/KX_TouchSensor.cpp index 56c2780871b..5311f059f03 100644 --- a/source/gameengine/Ketsji/KX_TouchSensor.cpp +++ b/source/gameengine/Ketsji/KX_TouchSensor.cpp @@ -101,7 +101,7 @@ void KX_TouchSensor::Init() { m_bCollision = false; m_bTriggered = false; - m_bLastTriggered = false; + m_bLastTriggered = (m_invert)?true:false; m_hitObject = NULL; } |