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:
-rw-r--r--source/blender/blenkernel/intern/effect.c4
-rw-r--r--source/blender/makesdna/DNA_effect_types.h4
-rw-r--r--source/blender/src/buttons_object.c18
-rw-r--r--source/blender/src/drawobject.c128
4 files changed, 137 insertions, 17 deletions
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index 699f6670a23..709f3e218a5 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -405,7 +405,7 @@ static void get_effector(float opco[], float force[], float speed[], float cur_t
while (base) {
if(base->lay & par_layer) {
ob= base->object;
- if(ob->pd && ob->pd->forcefield & 1) {
+ if(ob->pd && ob->pd->forcefield == PFIELD_FORCE) {
/* Need to set r.cfra for paths (investigate, ton) */
cur_frame = G.scene->r.cfra;
@@ -442,7 +442,7 @@ static void get_effector(float opco[], float force[], float speed[], float cur_t
force[2] += (vect_to_vert[2] * f_force );
}
- if(ob->pd && ob->pd->forcefield & 2) {
+ else if(ob->pd && ob->pd->forcefield == PFIELD_VORTEX) {
/* Need to set r.cfra for paths (investigate, ton) */
cur_frame = G.scene->r.cfra;
G.scene->r.cfra = (short)cur_time;
diff --git a/source/blender/makesdna/DNA_effect_types.h b/source/blender/makesdna/DNA_effect_types.h
index b8dc9efd959..86dd2f299c3 100644
--- a/source/blender/makesdna/DNA_effect_types.h
+++ b/source/blender/makesdna/DNA_effect_types.h
@@ -67,6 +67,10 @@
#define WAV_Y 4
#define WAV_CYCL 8
+ /* Effector Fields types */
+#define PFIELD_FORCE 1
+#define PFIELD_VORTEX 2
+#define PFIELD_MAGNET 3
typedef struct Effect {
struct Effect *next, *prev;
diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c
index c8ae5f4871b..bebc8851144 100644
--- a/source/blender/src/buttons_object.c
+++ b/source/blender/src/buttons_object.c
@@ -1261,18 +1261,20 @@ static void editing_panel_deflectors(Object *ob)
if(ob->pd) {
uiBlockBeginAlign(block);
- uiDefButS(block, TOG|BIT|0, REDRAWVIEW3D, "Force field", 10,160,200,20, &ob->pd->forcefield, 0, 0, 0, 0, "Object center attracts or repels particles");
- uiDefButS(block, TOG|BIT|1, REDRAWVIEW3D, "Vortex field", 10,140,200,20, &ob->pd->forcefield, 0, 0, 0, 0, "Particles swirl around Z-axis of the object");
- uiDefButF(block, NUM, B_DIFF, "Strength: ", 10,120,200,20, &ob->pd->f_strength, -1000, 1000, 1000, 0, "Strength of force field");
- uiDefButF(block, NUM, B_DIFF, "Fall-off: ", 10,100,200,20, &ob->pd->f_power, 0, 10, 100, 0, "Falloff power (real gravitational fallof = 2)");
+ uiDefButI(block, ROW, REDRAWVIEW3D, "None", 10,160,200,20, &ob->pd->forcefield, 1.0, 0, 0, 0, "No force");
+ uiDefButI(block, ROW, REDRAWVIEW3D, "Force field", 10,140,200,20, &ob->pd->forcefield, 1.0, PFIELD_FORCE, 0, 0, "Object center attracts or repels particles");
+ uiDefButI(block, ROW, REDRAWVIEW3D, "Vortex field", 10,120,200,20, &ob->pd->forcefield, 1.0, PFIELD_VORTEX, 0, 0, "Particles swirl around Z-axis of the object");
+
+ uiDefButF(block, NUM, B_DIFF, "Strength: ", 10,100,200,20, &ob->pd->f_strength, -1000, 1000, 1000, 0, "Strength of force field");
+ uiDefButF(block, NUM, REDRAWVIEW3D, "Fall-off: ", 10,80,200,20, &ob->pd->f_power, 0, 10, 100, 0, "Falloff power (real gravitational fallof = 2)");
/* only meshes collide now */
if(ob->type==OB_MESH) {
uiBlockBeginAlign(block);
- uiDefButS(block, TOG|BIT|0, B_DIFF, "Deflection",10,70,200,20, &ob->pd->deflect, 0, 0, 0, 0, "Deflects particles based on collision");
- uiDefButF(block, NUM, B_DIFF, "Damping: ", 10,50,200,20, &ob->pd->pdef_damp, 0.0, 1.0, 10, 0, "Amount of damping during particle collision");
- uiDefButF(block, NUM, B_DIFF, "Rnd Damping: ", 10,30,200,20, &ob->pd->pdef_rdamp, 0.0, 1.0, 10, 0, "Random variation of damping");
- uiDefButF(block, NUM, B_DIFF, "Permeability: ", 10,10,200,20, &ob->pd->pdef_perm, 0.0, 1.0, 10, 0, "Chance that the particle will pass through the mesh");
+ uiDefButS(block, TOG|BIT|0, B_DIFF, "Deflection",10,50,200,20, &ob->pd->deflect, 0, 0, 0, 0, "Deflects particles based on collision");
+ uiDefButF(block, NUM, B_DIFF, "Damping: ", 10,30,200,20, &ob->pd->pdef_damp, 0.0, 1.0, 10, 0, "Amount of damping during particle collision");
+ uiDefButF(block, NUM, B_DIFF, "Rnd Damping: ", 10,10,200,20, &ob->pd->pdef_rdamp, 0.0, 1.0, 10, 0, "Random variation of damping");
+ uiDefButF(block, NUM, B_DIFF, "Permeability: ", 10,-10,200,20, &ob->pd->pdef_perm, 0.0, 1.0, 10, 0, "Chance that the particle will pass through the mesh");
}
}
}
diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c
index 838981e9ed9..ac81473e026 100644
--- a/source/blender/src/drawobject.c
+++ b/source/blender/src/drawobject.c
@@ -3075,6 +3075,98 @@ static void tekentextcurs(void)
glEnd();
}
+void drawspiral(float *cent, float rad, float tmat[][4], int start)
+{
+ float vec[3], vx[3], vy[3];
+ int a, tot=32;
+
+ /* 32 values of sin function (still same result!) */
+ static float si[32] = {0.00000000,
+ 0.20129852,
+ 0.39435585,
+ 0.57126821,
+ 0.72479278,
+ 0.84864425,
+ 0.93775213,
+ 0.98846832,
+ 0.99871650,
+ 0.96807711,
+ 0.89780453,
+ 0.79077573,
+ 0.65137248,
+ 0.48530196,
+ 0.29936312,
+ 0.10116832,
+ -0.10116832,
+ -0.29936312,
+ -0.48530196,
+ -0.65137248,
+ -0.79077573,
+ -0.89780453,
+ -0.96807711,
+ -0.99871650,
+ -0.98846832,
+ -0.93775213,
+ -0.84864425,
+ -0.72479278,
+ -0.57126821,
+ -0.39435585,
+ -0.20129852,
+ 0.00000000};
+ /* 32 values of cos function (still same result!) */
+ static float co[32] ={1.00000000,
+ 0.97952994,
+ 0.91895781,
+ 0.82076344,
+ 0.68896691,
+ 0.52896401,
+ 0.34730525,
+ 0.15142777,
+ -0.05064916,
+ -0.25065253,
+ -0.44039415,
+ -0.61210598,
+ -0.75875812,
+ -0.87434661,
+ -0.95413925,
+ -0.99486932,
+ -0.99486932,
+ -0.95413925,
+ -0.87434661,
+ -0.75875812,
+ -0.61210598,
+ -0.44039415,
+ -0.25065253,
+ -0.05064916,
+ 0.15142777,
+ 0.34730525,
+ 0.52896401,
+ 0.68896691,
+ 0.82076344,
+ 0.91895781,
+ 0.97952994,
+ 1.00000000};
+
+ VECCOPY(vx, tmat[0]);
+ VECCOPY(vy, tmat[1]);
+ VecMulf(vx, rad);
+ VecMulf(vy, rad);
+
+ VECCOPY(vec, cent);
+
+ for(a=0; a<tot; a++) {
+ if (a+start>31)
+ start=-a + 1;
+ glBegin(GL_LINES);
+ glVertex3fv(vec);
+ vec[0]= cent[0] + *(si+a+start) * (vx[0] * (float)a/(float)tot) + *(co+a+start) * (vy[0] * (float)a/(float)tot);
+ vec[1]= cent[1] + *(si+a+start) * (vx[1] * (float)a/(float)tot) + *(co+a+start) * (vy[1] * (float)a/(float)tot);
+ vec[2]= cent[2] + *(si+a+start) * (vx[2] * (float)a/(float)tot) + *(co+a+start) * (vy[2] * (float)a/(float)tot);
+ glVertex3fv(vec);
+ glEnd();
+ }
+}
+
void drawcircball(float *cent, float rad, float tmat[][4])
{
float vec[3], vx[3], vy[3];
@@ -3220,12 +3312,34 @@ static void draw_forcefield(Object *ob)
Normalise(imat[0]);
Normalise(imat[1]);
- BIF_ThemeColorBlend(TH_WIRE, TH_BACK, 0.4);
- drawcircball(vec, 0.5, imat);
- BIF_ThemeColorBlend(TH_WIRE, TH_BACK, 0.65);
- drawcircball(vec, 1.0, imat);
- BIF_ThemeColorBlend(TH_WIRE, TH_BACK, 0.8);
- drawcircball(vec, 1.5, imat);
+ if (ob->pd->forcefield == PFIELD_FORCE) {
+ float ffall_val;
+
+ if (has_ipo_code(ob->ipo, OB_PD_FFALL))
+ ffall_val = IPO_GetFloatValue(ob->ipo, OB_PD_FFALL, G.scene->r.cfra);
+ else
+ ffall_val = ob->pd->f_power;
+
+ BIF_ThemeColorBlend(TH_WIRE, TH_BACK, 0.5);
+ drawcircball(vec, 1.0, imat);
+ BIF_ThemeColorBlend(TH_WIRE, TH_BACK, 0.9 - 0.4 / pow(1.5, (double)ffall_val));
+ drawcircball(vec, 1.5, imat);
+ BIF_ThemeColorBlend(TH_WIRE, TH_BACK, 0.9 - 0.4 / pow(2.0, (double)ffall_val));
+ drawcircball(vec, 2.0, imat);
+ }
+ else if (ob->pd->forcefield == PFIELD_VORTEX) {
+ float ffall_val;
+
+ if (has_ipo_code(ob->ipo, OB_PD_FFALL))
+ ffall_val = IPO_GetFloatValue(ob->ipo, OB_PD_FFALL, G.scene->r.cfra);
+ else
+ ffall_val = ob->pd->f_power;
+
+ BIF_ThemeColorBlend(TH_WIRE, TH_BACK, 0.7);
+ drawspiral(vec, 1.0, imat, 0);
+ drawspiral(vec, 1.0, imat, 15);
+ }
+
}
static void draw_bb_box(BoundBox *bb)
@@ -3815,7 +3929,6 @@ void draw_object(Base *base)
break;
case OB_EMPTY:
drawaxes(1.0);
- if(ob->pd && ob->pd->forcefield) draw_forcefield(ob);
break;
case OB_LAMP:
/* does a myloadmatrix */
@@ -3835,6 +3948,7 @@ void draw_object(Base *base)
default:
drawaxes(1.0);
}
+ if(ob->pd && ob->pd->forcefield) draw_forcefield(ob);
/* draw extra: after normal draw because of makeDispList */