Changeset View
Changeset View
Standalone View
Standalone View
source/blender/modifiers/intern/MOD_skin.c
| Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | |||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BLI_array.h" | #include "BLI_array.h" | ||||
| #include "BLI_bitmap.h" | #include "BLI_bitmap.h" | ||||
| #include "BLI_heap_simple.h" | #include "BLI_heap_simple.h" | ||||
| #include "BLI_math.h" | #include "BLI_math.h" | ||||
| #include "BLI_math_geom.h" | |||||
| #include "BLI_stack.h" | #include "BLI_stack.h" | ||||
| #include "DNA_mesh_types.h" | #include "DNA_mesh_types.h" | ||||
| #include "DNA_meshdata_types.h" | #include "DNA_meshdata_types.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_modifier_types.h" | #include "DNA_modifier_types.h" | ||||
| #include "BKE_deform.h" | #include "BKE_deform.h" | ||||
| Show All 12 Lines | typedef struct { | ||||
| * MEdge.v1 */ | * MEdge.v1 */ | ||||
| int origin; | int origin; | ||||
| } EMat; | } EMat; | ||||
| typedef enum { | typedef enum { | ||||
| CAP_START = 1, | CAP_START = 1, | ||||
| CAP_END = 2, | CAP_END = 2, | ||||
| SEAM_FRAME = 4, | SEAM_FRAME = 4, | ||||
| ROOT = 8, | FLIP_NORMAL = 8, | ||||
| } SkinNodeFlag; | } SkinNodeFlag; | ||||
| typedef struct Frame { | typedef struct Frame { | ||||
| /* Index in the MVert array */ | /* Index in the MVert array */ | ||||
| BMVert *verts[4]; | BMVert *verts[4]; | ||||
| /* Location of each corner */ | /* Location of each corner */ | ||||
| float co[4][3]; | float co[4][3]; | ||||
| /* Indicates which corners have been merged with another | /* Indicates which corners have been merged with another | ||||
| ▲ Show 20 Lines • Show All 410 Lines • ▼ Show 20 Lines | else { | ||||
| skin_nodes[v].flag |= CAP_START; | skin_nodes[v].flag |= CAP_START; | ||||
| /* Use incoming edge for orientation */ | /* Use incoming edge for orientation */ | ||||
| copy_m3_m3(mat, emat[emap[v].indices[0]].mat); | copy_m3_m3(mat, emat[emap[v].indices[0]].mat); | ||||
| if (emat[emap[v].indices[0]].origin != v) { | if (emat[emap[v].indices[0]].origin != v) { | ||||
| negate_v3(mat[0]); | negate_v3(mat[0]); | ||||
| } | } | ||||
| Frame *frame = &skin_nodes[v].frames[0]; | |||||
| /* End frame */ | /* End frame */ | ||||
| create_frame(&skin_nodes[v].frames[0], mvert[v].co, rad, mat, 0); | create_frame(frame, mvert[v].co, rad, mat, 0); | ||||
| } | |||||
| if (nodes[v].flag & MVERT_SKIN_ROOT) { | /* The caps might need to have their normals inverted. So check if they | ||||
| skin_nodes[v].flag |= ROOT; | * need to be flipped when creating faces. */ | ||||
| float normal[3]; | |||||
| normal_quad_v3(normal, frame->co[0], frame->co[1], frame->co[2], frame->co[3]); | |||||
| if (dot_v3v3(mat[0], normal) < 0.0f) { | |||||
| skin_nodes[v].flag |= FLIP_NORMAL; | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| /* Returns 1 for seam, 0 otherwise */ | /* Returns 1 for seam, 0 otherwise */ | ||||
| static int connection_node_mat(float mat[3][3], int v, const MeshElemMap *emap, EMat *emat) | static int connection_node_mat(float mat[3][3], int v, const MeshElemMap *emap, EMat *emat) | ||||
| { | { | ||||
| float axis[3], angle, ine[3][3], oute[3][3]; | float axis[3], angle, ine[3][3], oute[3][3]; | ||||
JacquesLucke: The semantic might change when this is moved in the the else branch. | |||||
Not Done Inline ActionsI'm use sure what you mean with this comment. Can you elaborate? zeddb: I'm use sure what you mean with this comment. Can you elaborate? | |||||
Not Done Inline Actions*unsure zeddb: *unsure | |||||
Not Done Inline ActionsPreviously this code: if (nodes[v].flag & MVERT_SKIN_ROOT) skin_nodes[v].flag |= ROOT; would be executed no matter what emap[v].count == 0 is. Seems to work fine. :) JacquesLucke: Previously this code:
```
if (nodes[v].flag & MVERT_SKIN_ROOT)
skin_nodes[v].flag |= ROOT;
```… | |||||
Done Inline ActionsRight, that doesn't matter as the normal flip check only needs to be run on end frames. zeddb: Right, that doesn't matter as the normal flip check only needs to be run on end frames. | |||||
Done Inline Actionscode style JacquesLucke: code style | |||||
| EMat *e1, *e2; | EMat *e1, *e2; | ||||
| e1 = &emat[emap[v].indices[0]]; | e1 = &emat[emap[v].indices[0]]; | ||||
| e2 = &emat[emap[v].indices[1]]; | e2 = &emat[emap[v].indices[1]]; | ||||
| if (e1->origin != v && e2->origin == v) { | if (e1->origin != v && e2->origin == v) { | ||||
| copy_m3_m3(ine, e1->mat); | copy_m3_m3(ine, e1->mat); | ||||
| copy_m3_m3(oute, e2->mat); | copy_m3_m3(oute, e2->mat); | ||||
| ▲ Show 20 Lines • Show All 1,035 Lines • ▼ Show 20 Lines | if (sn->flag & SEAM_FRAME) { | ||||
| } | } | ||||
| connect_frames(so, sn->frames[0].verts, v_order); | connect_frames(so, sn->frames[0].verts, v_order); | ||||
| } | } | ||||
| else if (sn->totframe == 2) { | else if (sn->totframe == 2) { | ||||
| connect_frames(so, sn->frames[0].verts, sn->frames[1].verts); | connect_frames(so, sn->frames[0].verts, sn->frames[1].verts); | ||||
| } | } | ||||
| if (sn->flag & CAP_START) { | if (sn->flag & CAP_START) { | ||||
| if (sn->flag & ROOT) { | if (sn->flag & FLIP_NORMAL) { | ||||
| add_poly(so, | add_poly(so, | ||||
| sn->frames[0].verts[0], | sn->frames[0].verts[0], | ||||
| sn->frames[0].verts[1], | sn->frames[0].verts[1], | ||||
| sn->frames[0].verts[2], | sn->frames[0].verts[2], | ||||
| sn->frames[0].verts[3]); | sn->frames[0].verts[3]); | ||||
| } | } | ||||
| else { | else { | ||||
| add_poly(so, | add_poly(so, | ||||
| ▲ Show 20 Lines • Show All 361 Lines • Show Last 20 Lines | |||||
The semantic might change when this is moved in the the else branch.