Really minor updates related to code I wrote for the Cast modifier:

- modifier.c: moved a check out of a loop, removed an unneeded var, made a couple cosmetic changes.

- DNA_modifier_types.h: added parentheses to cast and smooth modifier defines that used bit-shifting (like 1<<1, etc.).

Note: realized they were needed when I tried to use "flag &= ~MOD_CAST_Z" in modifier.c. Since MOD_CAST_Z is #defined as 1<<3, ~MOD_CAST_Z ended up as ~1<<3 while I wanted ~(1<<3). There are other places in that header file and others in Blender where it'd be safer to add the parentheses...

- Updated the epydoc documentation for the features added by Ben Batt to the cast modifier; fixed small typo in API_intro.py.

BTW, thanks Ben Batt (artificer) for checking, improving with a couple features and committing these modifiers :).
This commit is contained in:
Willian Padovani Germano
2007-04-30 19:20:43 +00:00
parent 469208a101
commit c40997656e
4 changed files with 24 additions and 22 deletions

View File

@@ -3637,9 +3637,11 @@ static void castModifier_sphere_do(
facm = 1.0f - fac;
flag = cmd->flag;
type = cmd->type; /* projection type: sphere or cylinder */
if (type == MOD_CAST_TYPE_CYLINDER)
flag &= ~MOD_CAST_Z;
ctrl_ob = cmd->object;
/* spherify's center is {0, 0, 0} (the ob's own center in its local
@@ -3680,7 +3682,7 @@ static void castModifier_sphere_do(
if ((ob->type == OB_MESH) && dm && defgrp_index >= 0)
dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT);
if(cmd->flag & MOD_CAST_SIZE_FROM_RADIUS) {
if(flag & MOD_CAST_SIZE_FROM_RADIUS) {
len = cmd->radius;
}
else {
@@ -3743,7 +3745,7 @@ static void castModifier_sphere_do(
tmp_co[0] = fac*vec[0]*len + facm*tmp_co[0];
if (flag & MOD_CAST_Y)
tmp_co[1] = fac*vec[1]*len + facm*tmp_co[1];
if (flag & MOD_CAST_Z && type != MOD_CAST_TYPE_CYLINDER)
if (flag & MOD_CAST_Z)
tmp_co[2] = fac*vec[2]*len + facm*tmp_co[2];
if(ctrl_ob) {
@@ -3787,7 +3789,7 @@ static void castModifier_sphere_do(
tmp_co[0] = fac*vec[0]*len + facm*tmp_co[0];
if (flag & MOD_CAST_Y)
tmp_co[1] = fac*vec[1]*len + facm*tmp_co[1];
if (flag & MOD_CAST_Z && type != MOD_CAST_TYPE_CYLINDER)
if (flag & MOD_CAST_Z)
tmp_co[2] = fac*vec[2]*len + facm*tmp_co[2];
if(ctrl_ob) {
@@ -3811,7 +3813,7 @@ static void castModifier_cuboid_do(
int i, defgrp_index = -1;
int has_radius = 0;
short flag, type;
short flag;
float fac, facm;
float min[3], max[3], bb[8][3];
float center[3] = {0.0f, 0.0f, 0.0f};
@@ -3822,8 +3824,6 @@ static void castModifier_cuboid_do(
flag = cmd->flag;
type = cmd->type; /* projection type: sphere or cylinder */
ctrl_ob = cmd->object;
/* now we check which options the user wants */
@@ -3861,12 +3861,12 @@ static void castModifier_cuboid_do(
Mat4MulVecfl(ob->imat, center);
}
if((cmd->flag & MOD_CAST_SIZE_FROM_RADIUS) && has_radius) {
if((flag & MOD_CAST_SIZE_FROM_RADIUS) && has_radius) {
for(i = 0; i < 3; i++) {
min[i] = -cmd->radius;
max[i] = cmd->radius;
}
} else if(!(cmd->flag & MOD_CAST_SIZE_FROM_RADIUS) && cmd->size > 0) {
} else if(!(flag & MOD_CAST_SIZE_FROM_RADIUS) && cmd->size > 0) {
for(i = 0; i < 3; i++) {
min[i] = -cmd->size;
max[i] = cmd->size;
@@ -3877,9 +3877,9 @@ static void castModifier_cuboid_do(
* may have changed the vertex data. */
INIT_MINMAX(min, max);
/* Cast's center is the ob's own center in its local space,by default,
* but if the user defined a control object, we use its location,
* transformed to ob's local space. */
/* Cast's center is the ob's own center in its local space,
* by default, but if the user defined a control object, we use
* its location, transformed to ob's local space. */
if (ctrl_ob) {
float vec[3];

View File

@@ -236,9 +236,9 @@ typedef struct DecimateModifierData {
} DecimateModifierData;
/* Smooth modifier flags */
#define MOD_SMOOTH_X 1<<1
#define MOD_SMOOTH_Y 1<<2
#define MOD_SMOOTH_Z 1<<3
#define MOD_SMOOTH_X (1<<1)
#define MOD_SMOOTH_Y (1<<2)
#define MOD_SMOOTH_Z (1<<3)
typedef struct SmoothModifierData {
ModifierData modifier;
@@ -249,11 +249,11 @@ typedef struct SmoothModifierData {
} SmoothModifierData;
/* Cast modifier flags */
#define MOD_CAST_X 1<<1
#define MOD_CAST_Y 1<<2
#define MOD_CAST_Z 1<<3
#define MOD_CAST_USE_OB_TRANSFORM 1<<4
#define MOD_CAST_SIZE_FROM_RADIUS 1<<5
#define MOD_CAST_X (1<<1)
#define MOD_CAST_Y (1<<2)
#define MOD_CAST_Z (1<<3)
#define MOD_CAST_USE_OB_TRANSFORM (1<<4)
#define MOD_CAST_SIZE_FROM_RADIUS (1<<5)
/* Cast modifier projection types */
#define MOD_CAST_TYPE_SPHERE 0

View File

@@ -12,7 +12,7 @@ The Blender Python API Reference
-----------
- L{Blender}
- L{bpy<Bpy>} (experemantal)
- L{bpy<Bpy>} (experimental)
Submodules:
-----------

View File

@@ -127,7 +127,9 @@ Example::
- REPEAT - Used for Smooth only (int [0, 30], default: 1)
- RADIUS - Used for Cast only (float [0.0, 100.0], default: 0.0)
- USE_OB_SCALE - Used for Cast only (bool, default: False)
- SIZE - Used for Cast only (float [0.0, 100.0], default: 0.0)
- SIZE_FROM_RADIUS - Used for Cast only (bool, default: True)
- USE_OB_TRANSFORM - Used for Cast only (bool, default: False)
"""
class ModSeq: