[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15370] branches/soc-2008-jaguarandi/ source/blender: Modifications on simple modifier
André Pinto
andresusanopinto at gmail.com
Fri Jun 27 18:46:54 CEST 2008
Revision: 15370
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15370
Author: jaguarandi
Date: 2008-06-27 18:45:37 +0200 (Fri, 27 Jun 2008)
Log Message:
-----------
Modifications on simple modifier
+Added limits on bend
+button to create an empty and make child of object
+empty is now relative to object
Modified Paths:
--------------
branches/soc-2008-jaguarandi/source/blender/blenkernel/BKE_simple_deform.h
branches/soc-2008-jaguarandi/source/blender/blenkernel/intern/modifier.c
branches/soc-2008-jaguarandi/source/blender/blenkernel/intern/simple_deform.c
branches/soc-2008-jaguarandi/source/blender/makesdna/DNA_modifier_types.h
branches/soc-2008-jaguarandi/source/blender/src/buttons_editing.c
Modified: branches/soc-2008-jaguarandi/source/blender/blenkernel/BKE_simple_deform.h
===================================================================
--- branches/soc-2008-jaguarandi/source/blender/blenkernel/BKE_simple_deform.h 2008-06-27 13:02:12 UTC (rev 15369)
+++ branches/soc-2008-jaguarandi/source/blender/blenkernel/BKE_simple_deform.h 2008-06-27 16:45:37 UTC (rev 15370)
@@ -33,8 +33,7 @@
struct DerivedMesh;
struct SimpleDeformModifierData;
-/* struct DerivedMesh *simpledeformModifier_do(struct SimpleDeformModifierData *smd, struct Object *ob, struct DerivedMesh *dm, int useRenderParams, int isFinalCalc); */
-void SimpleDeformModifier_do(SimpleDeformModifierData *smd, float (*vertexCos)[3], int numVerts);
+void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object *ob, float (*vertexCos)[3], int numVerts);
#endif
Modified: branches/soc-2008-jaguarandi/source/blender/blenkernel/intern/modifier.c
===================================================================
--- branches/soc-2008-jaguarandi/source/blender/blenkernel/intern/modifier.c 2008-06-27 13:02:12 UTC (rev 15369)
+++ branches/soc-2008-jaguarandi/source/blender/blenkernel/intern/modifier.c 2008-06-27 16:45:37 UTC (rev 15370)
@@ -101,6 +101,7 @@
#include "depsgraph_private.h"
#include "BKE_bmesh.h"
#include "BKE_shrinkwrap.h"
+#include "BKE_simple_deform.h"
#include "LOD_DependKludge.h"
#include "LOD_decimation.h"
@@ -7284,9 +7285,11 @@
{
SimpleDeformModifierData *smd = (SimpleDeformModifierData*) md;
- smd->mode = 0;
+ smd->mode = MOD_SIMPLEDEFORM_MODE_TWIST;
smd->origin = 0;
- smd->factor[0] = 1.0;
+ smd->factor[0] = 0.35;
+ smd->factor[1] = -1000.0;
+ smd->factor[2] = 1000.0;
}
static void simpledeformModifier_copyData(ModifierData *md, ModifierData *target)
@@ -7301,12 +7304,12 @@
static void simpledeformModifier_deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
- SimpleDeformModifier_do((SimpleDeformModifierData*)md, vertexCos, numVerts);
+ SimpleDeformModifier_do((SimpleDeformModifierData*)md, ob, vertexCos, numVerts);
}
static void simpledeformModifier_deformVertsEM(ModifierData *md, Object *ob, EditMesh *editData, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
- SimpleDeformModifier_do((SimpleDeformModifierData*)md, vertexCos, numVerts);
+ SimpleDeformModifier_do((SimpleDeformModifierData*)md, ob, vertexCos, numVerts);
}
static void simpledeformModifier_foreachObjectLink(ModifierData *md, Object *ob, void (*walk)(void *userData, Object *ob, Object **obpoin), void *userData)
Modified: branches/soc-2008-jaguarandi/source/blender/blenkernel/intern/simple_deform.c
===================================================================
--- branches/soc-2008-jaguarandi/source/blender/blenkernel/intern/simple_deform.c 2008-06-27 13:02:12 UTC (rev 15369)
+++ branches/soc-2008-jaguarandi/source/blender/blenkernel/intern/simple_deform.c 2008-06-27 16:45:37 UTC (rev 15370)
@@ -38,16 +38,26 @@
#include <math.h>
-static void simpleDeform_tapper(const float factor, float *co)
+
+
+static void simpleDeform_tapperXY(const float factor, float *co)
{
float x = co[0], y = co[1], z = co[2];
co[0] = x*(1.0f + z*factor);
+ co[1] = y*(1.0f + z*factor);
+ co[2] = z;
+}
+
+static void simpleDeform_tapperX(const float factor, float *co)
+{
+ float x = co[0], y = co[1], z = co[2];
+
+ co[0] = x*(1.0f + z*factor);
co[1] = y;
co[2] = z;
}
-
static void simpleDeform_twist(const float factor, float *co)
{
float x = co[0], y = co[1], z = co[2];
@@ -59,41 +69,51 @@
co[0] = x*cost - y*sint;
co[1] = x*sint + y*cost;
co[2] = z;
+
}
-static void simpleDeform_bend(const float factor, float *co)
+static void simpleDeform_bend(const float factor, const float axis_limit[2], float *co)
{
float x = co[0], y = co[1], z = co[2];
float x0 = 0.0f;
- float theta = (x - x0)*factor;
- float sint = sin(theta);
- float cost = cos(theta);
+ float theta = x*factor, sint, cost;
- co[0] = -sint*(y-1.0f/factor) + x0;
- co[1] = cost*(y-1.0f/factor) + 1.0f/factor;
- co[2] = z;
-}
+ if(x > axis_limit[1])
+ {
+ x0 = axis_limit[1] - x;
+ x = axis_limit[1];
+ }
+ else if(x < axis_limit[0])
+ {
+ x0 = axis_limit[0] - x;
+ x = axis_limit[0];
+ }
-static void simpleDeform_shear(const float factor, float *co)
-{
- float x = co[0], y = co[1], z = co[2];
+ theta = x*factor;
+ sint = sin(theta);
+ cost = cos(theta);
- co[0] = x + factor;
- co[1] = y;
- co[2] = z;
+ co[0] = -y*sint - cost*x0;
+ co[1] = y*cost - sint*x0;
+ co[2] = z;
}
/* simple deform modifier */
-void SimpleDeformModifier_do(SimpleDeformModifierData *smd, float (*vertexCos)[3], int numVerts)
+void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object *ob, float (*vertexCos)[3], int numVerts)
{
float (*ob2mod)[4] = NULL, (*mod2ob)[4] = NULL;
+ float tmp[2][4][4];
+
if(smd->origin)
{
- Mat4Invert(smd->origin->imat, smd->origin->obmat); //inverse is outdated
+ //inverse is outdated
+ Mat4Invert(smd->origin->imat, smd->origin->obmat);
- ob2mod = smd->origin->imat;
- mod2ob = smd->origin->obmat;
+ ob2mod = tmp[0];
+ mod2ob = tmp[1];
+ Mat4MulSerie(ob2mod, smd->origin->imat, ob->obmat, 0, 0, 0, 0, 0, 0);
+ Mat4Invert(mod2ob, ob2mod);
}
@@ -104,10 +124,10 @@
switch(smd->mode)
{
- case 0: simpleDeform_tapper (smd->factor[0], *vertexCos); break;
- case 1: simpleDeform_twist (smd->factor[0], *vertexCos); break;
- case 2: simpleDeform_bend (smd->factor[0], *vertexCos); break;
- case 3: simpleDeform_shear (smd->factor[0], *vertexCos); break;
+ case MOD_SIMPLEDEFORM_MODE_TWIST: simpleDeform_twist(smd->factor[0], *vertexCos); break;
+ case MOD_SIMPLEDEFORM_MODE_BEND: simpleDeform_bend(smd->factor[0], smd->factor+1, *vertexCos); break;
+ case MOD_SIMPLEDEFORM_MODE_TAPER_X: simpleDeform_tapperX (smd->factor[0], *vertexCos); break;
+ case MOD_SIMPLEDEFORM_MODE_TAPER_XY: simpleDeform_tapperXY(smd->factor[0], *vertexCos); break;
}
if(mod2ob)
Modified: branches/soc-2008-jaguarandi/source/blender/makesdna/DNA_modifier_types.h
===================================================================
--- branches/soc-2008-jaguarandi/source/blender/makesdna/DNA_modifier_types.h 2008-06-27 13:02:12 UTC (rev 15369)
+++ branches/soc-2008-jaguarandi/source/blender/makesdna/DNA_modifier_types.h 2008-06-27 16:45:37 UTC (rev 15370)
@@ -529,4 +529,9 @@
} SimpleDeformModifierData;
+#define MOD_SIMPLEDEFORM_MODE_TWIST 1
+#define MOD_SIMPLEDEFORM_MODE_BEND 2
+#define MOD_SIMPLEDEFORM_MODE_TAPER_X 3
+#define MOD_SIMPLEDEFORM_MODE_TAPER_XY 4
+
#endif
Modified: branches/soc-2008-jaguarandi/source/blender/src/buttons_editing.c
===================================================================
--- branches/soc-2008-jaguarandi/source/blender/src/buttons_editing.c 2008-06-27 13:02:12 UTC (rev 15369)
+++ branches/soc-2008-jaguarandi/source/blender/src/buttons_editing.c 2008-06-27 16:45:37 UTC (rev 15370)
@@ -1664,6 +1664,33 @@
}
return 0;
}
+
+static void modifier_link_new_empty(void *pp_empty, void *p_parent)
+{
+ Object **empty = (Object**)pp_empty;
+ Object *parent = (Object*) p_parent;
+
+ /* Add object but witouth chaing layers and or changing active object */
+ Base *base= BASACT, *newbase;
+
+ (*empty) = add_object(OB_EMPTY);
+
+ newbase= BASACT;
+ newbase->lay= base->lay;
+ (*empty)->lay= newbase->lay;
+
+ /* restore, add_object sets active */
+ BASACT= base;
+
+ /* Makes parent relation and positions empty on center of object */
+ (*empty)->partype= PAROBJECT;
+ (*empty)->parent = parent;
+ Mat4CpyMat4( (*empty)->obmat, parent->obmat );
+ Mat4Invert( (*empty)->parentinv, parent->obmat);
+ apply_obmat( (*empty) );
+ DAG_scene_sort(G.scene);
+}
+
static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco, int *yco, int index, int cageIndex, int lastCageIndex)
{
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
@@ -1830,8 +1857,11 @@
ShrinkwrapModifierData *smd = (ShrinkwrapModifierData*) md;
height = 86;
if (smd->shrinkType == MOD_SHRINKWRAP_NORMAL)
- height += 19*7;
+ height += 19*5;
} else if (md->type==eModifierType_SimpleDeform) {
+ SimpleDeformModifierData *smd = (SimpleDeformModifierData*) md;
+ height += 19*3;
+ if(smd->mode == MOD_SIMPLEDEFORM_MODE_BEND)
height += 19*2;
}
/* roundbox 4 free variables: corner-rounding, nop, roundbox type, shade */
@@ -2460,12 +2490,15 @@
uiDefButS(block, MENU, B_MODIFIER_RECALC, shrinktypemenu, lx,(cy-=19),buttonWidth,19, &smd->shrinkType, 0, 0, 0, 0, "Selects type of shrinkwrap algorithm for target position.");
if (smd->shrinkType == MOD_SHRINKWRAP_NORMAL){
- uiDefButBitS(block, TOG, MOD_SHRINKWRAP_ALLOW_DEFAULT_NORMAL, B_MODIFIER_RECALC, "Default normal", lx,(cy-=19),buttonWidth,19, &smd->shrinkOpts, 0, 0, 0, 0, "Allows vertices to move in the normal direction");
- uiDefButBitS(block, TOG, MOD_SHRINKWRAP_ALLOW_INVERTED_NORMAL, B_MODIFIER_RECALC, "Invert normal", lx,(cy-=19),buttonWidth,19, &smd->shrinkOpts, 0, 0, 0, 0, "Allows vertices to move in the inverse direction of their normal");
+
+ uiDefButBitS(block, TOG, MOD_SHRINKWRAP_ALLOW_DEFAULT_NORMAL, B_MODIFIER_RECALC, "Default normal", lx,(cy-=19),buttonWidth/2,19, &smd->shrinkOpts, 0, 0, 0, 0, "Allows vertices to move in the normal direction");
+ uiDefButBitS(block, TOG, MOD_SHRINKWRAP_ALLOW_INVERTED_NORMAL, B_MODIFIER_RECALC, "Invert normal", lx + buttonWidth/2,cy,buttonWidth/2,19, &smd->shrinkOpts, 0, 0, 0, 0, "Allows vertices to move in the inverse direction of their normal");
+
uiDefButBitS(block, TOG, MOD_SHRINKWRAP_REMOVE_UNPROJECTED_FACES, B_MODIFIER_RECALC, "Remove faces", lx,(cy-=19),buttonWidth,19, &smd->shrinkOpts, 0, 0, 0, 0, "Remove faces where all vertices haven't been projected");
- uiDefButBitS(block, TOG, MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE, B_MODIFIER_RECALC, "Cull frontfaces", lx,(cy-=19),buttonWidth,19, &smd->shrinkOpts, 0, 0, 0, 0, "Controls whether a vertex can be projected to a front face on target");
- uiDefButBitS(block, TOG, MOD_SHRINKWRAP_CULL_TARGET_BACKFACE, B_MODIFIER_RECALC, "Cull backfaces", lx,(cy-=19),buttonWidth,19, &smd->shrinkOpts, 0, 0, 0, 0, "Controls whether a vertex can be projected to a back face on target");
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list