Changeset View
Changeset View
Standalone View
Standalone View
source/blender/modifiers/intern/MOD_screw.c
| Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | |||||
| #include "MOD_modifiertypes.h" | #include "MOD_modifiertypes.h" | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "BLI_strict_flags.h" | #include "BLI_strict_flags.h" | ||||
| /* used for gathering edge connectivity */ | /* used for gathering edge connectivity */ | ||||
| typedef struct ScrewVertConnect { | typedef struct ScrewVertConnect { | ||||
| float dist; /* distance from the center axis */ | float dist; /* distance from the center axis */ | ||||
| float co[3]; /* loaction relative to the transformed axis */ | float co[3]; /* location relative to the transformed axis */ | ||||
| float no[3]; /* calc normal of the vertex */ | float no[3]; /* calc normal of the vertex */ | ||||
| unsigned int v[2]; /* 2 verts on either side of this one */ | unsigned int v[2]; /* 2 verts on either side of this one */ | ||||
| MEdge *e[2]; /* edges on either side, a bit of a waste since each edge ref's 2 edges */ | MEdge *e[2]; /* edges on either side, a bit of a waste since each edge ref's 2 edges */ | ||||
| char flag; | char flag; | ||||
| } ScrewVertConnect; | } ScrewVertConnect; | ||||
| typedef struct ScrewVertIter { | typedef struct ScrewVertIter { | ||||
| ScrewVertConnect *v_array; | ScrewVertConnect *v_array; | ||||
| ▲ Show 20 Lines • Show All 223 Lines • ▼ Show 20 Lines | if (ltmd->flag & MOD_SCREW_OBJECT_OFFSET) { | ||||
| } | } | ||||
| else { | else { | ||||
| screw_ofs = 0.0f; | screw_ofs = 0.0f; | ||||
| } | } | ||||
| } | } | ||||
| /* angle */ | /* angle */ | ||||
| #if 0 /* cant incluide this, not predictable enough, though quite fun. */ | #if 0 /* can't include this, not predictable enough, though quite fun. */ | ||||
| if (ltmd->flag & MOD_SCREW_OBJECT_ANGLE) { | if (ltmd->flag & MOD_SCREW_OBJECT_ANGLE) { | ||||
| float mtx3_tx[3][3]; | float mtx3_tx[3][3]; | ||||
| copy_m3_m4(mtx3_tx, mtx_tx); | copy_m3_m4(mtx3_tx, mtx_tx); | ||||
| float vec[3] = {0, 1, 0}; | float vec[3] = {0, 1, 0}; | ||||
| float cross1[3]; | float cross1[3]; | ||||
| float cross2[3]; | float cross2[3]; | ||||
| cross_v3_v3v3(cross1, vec, axis_vec); | cross_v3_v3v3(cross1, vec, axis_vec); | ||||
| ▲ Show 20 Lines • Show All 359 Lines • ▼ Show 20 Lines | else { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else if (SV_IS_VALID(vc_tmp->v[0])) { /*vertex only connected on 1 side */ | else if (SV_IS_VALID(vc_tmp->v[0])) { /*vertex only connected on 1 side */ | ||||
| /*printf("Verts on ONE side (%i %i)\n", vc_tmp->v[0], vc_tmp->v[1]);*/ | /*printf("Verts on ONE side (%i %i)\n", vc_tmp->v[0], vc_tmp->v[1]);*/ | ||||
| if (tmpf1[ltmd->axis] < vc_tmp->co[ltmd->axis]) { /* best is above */ | if (tmpf1[ltmd->axis] < vc_tmp->co[ltmd->axis]) { /* best is above */ | ||||
| ed_loop_flip = 1; | ed_loop_flip = 1; | ||||
| } | } | ||||
| else { /* best is below or even... in even case we cant know whet to do. */ | else { /* best is below or even... in even case we can't know what to do. */ | ||||
| ed_loop_flip = 0; | ed_loop_flip = 0; | ||||
| } | } | ||||
| } | } | ||||
| #if 0 | #if 0 | ||||
| else { | else { | ||||
| printf("No Connected ___\n"); | printf("No Connected ___\n"); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 119 Lines • ▼ Show 20 Lines | #endif | ||||
| cross_v3_v3v3(vc->no, tmp_vec1, tmp_vec2); | cross_v3_v3v3(vc->no, tmp_vec1, tmp_vec2); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| copy_v3_v3(vc->no, vc->co); | copy_v3_v3(vc->no, vc->co); | ||||
| } | } | ||||
| /* we wont be looping on this data again so copy normals here */ | /* we won't be looping on this data again so copy normals here */ | ||||
| if ((angle < 0.0f) != do_flip) | if ((angle < 0.0f) != do_flip) | ||||
| negate_v3(vc->no); | negate_v3(vc->no); | ||||
| normalize_v3(vc->no); | normalize_v3(vc->no); | ||||
| normal_float_to_short_v3(mvert_new[i].no, vc->no); | normal_float_to_short_v3(mvert_new[i].no, vc->no); | ||||
| /* Done with normals */ | /* Done with normals */ | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | #endif | ||||
| /* we can avoid if using vert alloc trick */ | /* we can avoid if using vert alloc trick */ | ||||
| if (vert_connect) { | if (vert_connect) { | ||||
| MEM_freeN(vert_connect); | MEM_freeN(vert_connect); | ||||
| vert_connect = NULL; | vert_connect = NULL; | ||||
| } | } | ||||
| if (close) { | if (close) { | ||||
| /* last loop of edges, previous loop dosnt account for the last set of edges */ | /* last loop of edges, previous loop doesn't account for the last set of edges */ | ||||
| const unsigned int varray_stride = (step_tot - 1) * totvert; | const unsigned int varray_stride = (step_tot - 1) * totvert; | ||||
| for (i = 0; i < totvert; i++) { | for (i = 0; i < totvert; i++) { | ||||
| med_new->v1 = i; | med_new->v1 = i; | ||||
| med_new->v2 = varray_stride + i; | med_new->v2 = varray_stride + i; | ||||
| med_new->flag = ME_EDGEDRAW | ME_EDGERENDER; | med_new->flag = ME_EDGEDRAW | ME_EDGERENDER; | ||||
| med_new++; | med_new++; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 265 Lines • Show Last 20 Lines | |||||