[Bf-blender-cvs] [cb4d349] cloth-improvements: Initial implementation of angular bending springs
Commit: cb4d349803cbe27f51be2a5ccca1c68ea42ba3d9 Author: Luca Rood Date: Wed Dec 7 15:57:17 2016 -0200 Branches: cloth-improvements https://developer.blender.org/rBcb4d349803cbe27f51be2a5ccca1c68ea42ba3d9 Initial implementation of angular bending springs This implements bending resistant forces between adjacent polygons in cloth simulation. Note that derivatives are not yet included in the computations (and might not even be needed, as the simulation is already quite stable). Angular damping is not yet implemented either. === M source/blender/blenkernel/BKE_cloth.h M source/blender/blenkernel/intern/cloth.c M source/blender/physics/intern/BPH_mass_spring.cpp M source/blender/physics/intern/implicit.h M source/blender/physics/intern/implicit_blender.c === diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h index 9f8a8e4..5514958 100644 --- a/source/blender/blenkernel/BKE_cloth.h +++ b/source/blender/blenkernel/BKE_cloth.h @@ -132,8 +132,13 @@ ClothVertex; typedef struct ClothSpring { int ij; /* Pij from the paper, one end of the spring. */ int kl; /* Pkl from the paper, one end of the spring. */ - int mn; /* Something related to angular hair springs. */ - float restlen;/* The original length of the spring. */ + int mn; /* For hair springs: third vertex index; For bending springs: edge index */ + int *pa;/* array of vert indices for poly a (for bending springs) */ + int *pb;/* array of vert indices for poly b (for bending springs) */ + int la; /* length of *pa */ + int lb; /* length of *pb */ + float restlen; /* The original length of the spring */ + float restang; /* The original angle of the bending springs */ int type; /* types defined in BKE_cloth.h ("springType") */ int flags; /* defined in BKE_cloth.h, e.g. deactivated due to tearing */ float stiffness; /* stiffness factor from the vertex groups */ diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 8485004..be5747a 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -35,6 +35,7 @@ #include "DNA_object_types.h" #include "DNA_meshdata_types.h" +#include "BLI_alloca.h" #include "BLI_utildefines.h" #include "BLI_math.h" #include "BLI_edgehash.h" @@ -63,6 +64,12 @@ static void cloth_update_spring_lengths( ClothModifierData *clmd, DerivedMesh *d static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ); static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm ); +typedef struct BendSpringRef { + int set; + int index; + LinkNode **spring; +} BendSpringRef; + /** * * External interface called by modifier.c clothModifier functions. @@ -531,7 +538,12 @@ void cloth_free_modifier(ClothModifierData *clmd ) LinkNode *search = cloth->springs; while (search) { ClothSpring *spring = search->link; - + + if (spring->type == CLOTH_SPRING_TYPE_BENDING) { + MEM_freeN(spring->pa); + MEM_freeN(spring->pb); + } + MEM_freeN ( spring ); search = search->next; } @@ -598,6 +610,11 @@ void cloth_free_modifier_extern(ClothModifierData *clmd ) while (search) { ClothSpring *spring = search->link; + if (spring->type == CLOTH_SPRING_TYPE_BENDING) { + MEM_freeN(spring->pa); + MEM_freeN(spring->pb); + } + MEM_freeN ( spring ); search = search->next; } @@ -959,7 +976,7 @@ int cloth_add_spring(ClothModifierData *clmd, unsigned int indexA, unsigned int Cloth *cloth = clmd->clothObject; ClothSpring *spring = NULL; - if (cloth) { + if (cloth && spring_type != CLOTH_SPRING_TYPE_BENDING) { // TODO: look if this spring is already there spring = (ClothSpring *)MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" ); @@ -1001,7 +1018,12 @@ static void cloth_free_errorsprings(Cloth *cloth, LinkNodePair *edgelist)
[Bf-blender-cvs] [dc52667] cloth-improvements: Implement angular bending damping
Commit: dc526671c760db8c81d2fe5f99626b7a2d3dc7b3 Author: Luca Rood Date: Thu Dec 8 19:26:33 2016 -0200 Branches: cloth-improvements https://developer.blender.org/rBdc526671c760db8c81d2fe5f99626b7a2d3dc7b3 Implement angular bending damping === M release/scripts/startup/bl_ui/properties_physics_cloth.py M source/blender/physics/intern/BPH_mass_spring.cpp M source/blender/physics/intern/implicit_blender.c === diff --git a/release/scripts/startup/bl_ui/properties_physics_cloth.py b/release/scripts/startup/bl_ui/properties_physics_cloth.py index 43096d5..f57b0e0 100644 --- a/release/scripts/startup/bl_ui/properties_physics_cloth.py +++ b/release/scripts/startup/bl_ui/properties_physics_cloth.py @@ -97,6 +97,7 @@ class PHYSICS_PT_cloth(PhysicButtonsPanel, Panel): col.prop(cloth, "tension_damping", text="Tension") col.prop(cloth, "compression_damping", text="Compression") col.prop(cloth, "shear_damping", text="Shear") +col.prop(cloth, "bending_damping", text="Bending") col.prop(cloth, "air_damping", text="Air") col.prop(cloth, "vel_damping", text="Velocity") diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp b/source/blender/physics/intern/BPH_mass_spring.cpp index 36794f1..dbebc6b 100644 --- a/source/blender/physics/intern/BPH_mass_spring.cpp +++ b/source/blender/physics/intern/BPH_mass_spring.cpp @@ -453,7 +453,7 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s, kb = scaling / (20.0f * (parms->avg_spring_len + FLT_EPSILON)); // Fix for [#45084] for cloth stiffness must have cb proportional to kb - cb = kb * parms->bending_damping; + cb = kb * 0.5f; // this was multiplied by a constant parms->bending_damping, which is no longer constant /* XXX assuming same restlen for ij and jk segments here, this can be done correctly for hair later */ BPH_mass_spring_force_spring_bending_hair(data, s->ij, s->kl, s->mn, s->target, kb, cb); diff --git a/source/blender/physics/intern/implicit_blender.c b/source/blender/physics/intern/implicit_blender.c index 6a4eb70..d7b984a 100644 --- a/source/blender/physics/intern/implicit_blender.c +++ b/source/blender/physics/intern/implicit_blender.c @@ -1742,8 +1742,12 @@ bool BPH_mass_spring_force_spring_angular(Implicit_Data *data, int i, int j, int spring_angle(data, i, j, i_a, i_b, len_a, len_b, dir_a, dir_b, , vel_a, vel_b); + /* spring force */ force = stiffness * (angle - restang); + /* damping force */ + force += -damping * (dot_v3v3(vel_a, dir_a) + dot_v3v3(vel_b, dir_b)); + mul_v3_v3fl(f_a, dir_a, force / len_a); mul_v3_v3fl(f_b, dir_b, force / len_b); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [04e157e] cloth-improvements: Rename angular hair spring things to hair instead of angular
Commit: 04e157e44af540eeae65c28e5c7f87e70adf2d81 Author: Luca Rood Date: Mon Dec 5 21:39:29 2016 -0200 Branches: cloth-improvements https://developer.blender.org/rB04e157e44af540eeae65c28e5c7f87e70adf2d81 Rename angular hair spring things to hair instead of angular This is to make a clear distinction between the existing angular hair springs, and the new generic angular springs. === M source/blender/blenkernel/BKE_cloth.h M source/blender/blenkernel/intern/cloth.c M source/blender/physics/intern/BPH_mass_spring.cpp M source/blender/physics/intern/implicit.h M source/blender/physics/intern/implicit_blender.c === diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h index 1dbd41f..9f8a8e4 100644 --- a/source/blender/blenkernel/BKE_cloth.h +++ b/source/blender/blenkernel/BKE_cloth.h @@ -182,7 +182,7 @@ typedef enum { CLOTH_SPRING_TYPE_BENDING = (1 << 3), CLOTH_SPRING_TYPE_GOAL= (1 << 4), CLOTH_SPRING_TYPE_SEWING = (1 << 5), - CLOTH_SPRING_TYPE_BENDING_ANG = (1 << 6), + CLOTH_SPRING_TYPE_BENDING_HAIR = (1 << 6), } CLOTH_SPRING_TYPES; /* SPRING FLAGS */ diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 79e1d1b..8485004 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -1042,7 +1042,7 @@ static void cloth_hair_update_bending_targets(ClothModifierData *clmd) ClothHairData *hair_ij, *hair_kl; bool is_root = spring->kl != prev_mn; - if (spring->type != CLOTH_SPRING_TYPE_BENDING_ANG) { + if (spring->type != CLOTH_SPRING_TYPE_BENDING_HAIR) { continue; } @@ -1117,7 +1117,7 @@ static void cloth_hair_update_bending_rest_targets(ClothModifierData *clmd) ClothHairData *hair_ij, *hair_kl; bool is_root = spring->kl != prev_mn; - if (spring->type != CLOTH_SPRING_TYPE_BENDING_ANG) { + if (spring->type != CLOTH_SPRING_TYPE_BENDING_HAIR) { continue; } @@ -1168,7 +1168,7 @@ static void cloth_update_springs( ClothModifierData *clmd ) else if (spring->type == CLOTH_SPRING_TYPE_BENDING) { spring->stiffness = (cloth->verts[spring->kl].bend_stiff + cloth->verts[spring->ij].bend_stiff) / 2.0f; } - else if (spring->type == CLOTH_SPRING_TYPE_BENDING_ANG) { + else if (spring->type == CLOTH_SPRING_TYPE_BENDING_HAIR) { ClothVertex *v1 = >verts[spring->ij]; ClothVertex *v2 = >verts[spring->kl]; if (clmd->hairdata) { @@ -1471,7 +1471,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) spring->kl = tspring->ij; spring->mn = tspring->kl; spring->restlen = len_v3v3(cloth->verts[spring->kl].xrest, cloth->verts[spring->ij].xrest); - spring->type = CLOTH_SPRING_TYPE_BENDING_ANG; + spring->type = CLOTH_SPRING_TYPE_BENDING_HAIR; spring->stiffness = (cloth->verts[spring->kl].bend_stiff + cloth->verts[spring->ij].bend_stiff) / 2.0f; bend_springs++; diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp b/source/blender/physics/intern/BPH_mass_spring.cpp index f8152ba..37a2138 100644 --- a/source/blender/physics/intern/BPH_mass_spring.cpp +++ b/source/blender/physics/intern/BPH_mass_spring.cpp @@ -64,7 +64,7 @@ static int cloth_count_nondiag_blocks(Cloth *cloth) for (link = cloth->springs; link; link = link->next) { ClothSpring *spring = (ClothSpring *)link->link; switch (spring->type) { - case CLOTH_SPRING_TYPE_BENDING_ANG: + case CLOTH_SPRING_TYPE_BENDING_HAIR: /* angular bending combines 3 vertices */ nondiag += 3; break; @@ -441,7 +441,7 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s, BPH_mass_spring_force_spring_bending(data, s->ij, s->kl, s->restlen, kb, cb); #endif } - else if (s->type & CLOTH_SPRING_TYPE_BENDING_ANG) { + else if (s->type & CLOTH_SPRING_TYPE_BENDING_HAIR) { #ifdef CLOTH_FORCE_SPRING_BEND float kb, cb, scaling;
[Bf-blender-cvs] [1d8a08f] cloth-improvements: Add some comments about methods used for mass-spring model
Commit: 1d8a08fb9ff6202570e6f61b9f254393d9286d90 Author: Luca Rood Date: Thu Dec 8 16:27:48 2016 -0200 Branches: cloth-improvements https://developer.blender.org/rB1d8a08fb9ff6202570e6f61b9f254393d9286d90 Add some comments about methods used for mass-spring model === M source/blender/physics/intern/implicit_blender.c === diff --git a/source/blender/physics/intern/implicit_blender.c b/source/blender/physics/intern/implicit_blender.c index a2f9de3..6a4eb70 100644 --- a/source/blender/physics/intern/implicit_blender.c +++ b/source/blender/physics/intern/implicit_blender.c @@ -1605,6 +1605,7 @@ bool BPH_mass_spring_force_spring_linear(Implicit_Data *data, int i, int j, floa } /* Calculate compression forces */ + /* this is based on the Choi and Ko bending model, which works surprisingly well for compression */ else if (!no_compress) { float kb = compression; float cb = kb; /* cb equal to kb seems to work, but a factor can be added if necessary */ @@ -1729,6 +1730,7 @@ BLI_INLINE bool spring_angle(Implicit_Data *data, int i, int j, int *i_a, int *i return true; } +/* Angular springs roughly based on the bending model proposed by Baraff and Witkin in "Large Steps in Cloth Simulation" */ bool BPH_mass_spring_force_spring_angular(Implicit_Data *data, int i, int j, int *i_a, int *i_b, int len_a, int len_b, float restang, float stiffness, float damping) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [f9dad94] cloth-improvements: Implement bending springs along shear springs within polygons
Commit: f9dad94d9e291c2762d9eca1b3f50b27870df0a3 Author: Luca Rood Date: Wed Dec 7 20:41:54 2016 -0200 Branches: cloth-improvements https://developer.blender.org/rBf9dad94d9e291c2762d9eca1b3f50b27870df0a3 Implement bending springs along shear springs within polygons This adds bending springs within polygons, so that they resist changing planarity. === M source/blender/blenkernel/intern/cloth.c === diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 7830862..b356524 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -1316,35 +1316,6 @@ void cloth_parallel_transport_hair_frame(float mat[3][3], const float dir_old[3] mul_m3_m3m3(mat, rot, mat); } -BLI_INLINE bool add_shear_bend_spring(ClothModifierData *clmd, LinkNodePair *edgelist, const MLoop *mloop, const MPoly *mpoly, int i, int j, int k) -{ - Cloth *cloth = clmd->clothObject; - ClothSpring *spring = (ClothSpring *)MEM_callocN(sizeof(ClothSpring), "cloth spring"); - float shrink_factor; - - if (!spring) { - cloth_free_errorsprings(cloth, edgelist); - return 0; - } - - spring_verts_ordered_set( - spring, - mloop[mpoly[i].loopstart + j].v, - mloop[mpoly[i].loopstart + k].v); - - shrink_factor = cloth_shrink_factor(clmd, cloth->verts, spring->ij, spring->kl); - spring->restlen = len_v3v3(cloth->verts[spring->kl].xrest, cloth->verts[spring->ij].xrest) * shrink_factor; - spring->type = CLOTH_SPRING_TYPE_SHEAR; - spring->stiffness = (cloth->verts[spring->kl].shear_stiff + cloth->verts[spring->ij].shear_stiff) / 2.0f; - - BLI_linklist_append([spring->ij], spring); - BLI_linklist_append([spring->kl], spring); - - BLI_linklist_prepend(>springs, spring); - - return 1; -} - BLI_INLINE float spring_angle(ClothVertex *verts, int i, int j, int *i_a, int *i_b, int len_a, int len_b) { float co_i[3], co_j[3], co_a[3], co_b[3]; @@ -1397,6 +1368,86 @@ BLI_INLINE float spring_angle(ClothVertex *verts, int i, int j, int *i_a, int *i return atan2(sin, cos); } +/* add a shear and a bend spring between two verts within a poly */ +BLI_INLINE bool add_shear_bend_spring(ClothModifierData *clmd, LinkNodePair *edgelist, const MLoop *mloop, const MPoly *mpoly, int i, int j, int k) +{ + Cloth *cloth = clmd->clothObject; + ClothSpring *spring; + MLoop *tmp_loop; + float shrink_factor; + int x, y; + + /* shear spring */ + + spring = (ClothSpring *)MEM_callocN(sizeof(ClothSpring), "cloth spring"); + + if (!spring) { + cloth_free_errorsprings(cloth, edgelist); + return 0; + } + + spring_verts_ordered_set( + spring, + mloop[mpoly[i].loopstart + j].v, + mloop[mpoly[i].loopstart + k].v); + + shrink_factor = cloth_shrink_factor(clmd, cloth->verts, spring->ij, spring->kl); + spring->restlen = len_v3v3(cloth->verts[spring->kl].xrest, cloth->verts[spring->ij].xrest) * shrink_factor; + spring->type = CLOTH_SPRING_TYPE_SHEAR; + spring->stiffness = (cloth->verts[spring->kl].shear_stiff + cloth->verts[spring->ij].shear_stiff) / 2.0f; + + BLI_linklist_append([spring->ij], spring); + BLI_linklist_append([spring->kl], spring); + + BLI_linklist_prepend(>springs, spring); + + /* bending spring */ + + spring = MEM_callocN(sizeof(ClothSpring), "cloth spring"); + + if (!spring) { + cloth_free_errorsprings(cloth, edgelist); + return 0; + } + + spring->type = CLOTH_SPRING_TYPE_BENDING; + + spring->la = k - j + 1; + spring->lb = mpoly[i].totloop - k + j + 1; + + spring->pa = MEM_mallocN(sizeof(*spring->pa) * spring->la, "spring poly"); + spring->pb = MEM_mallocN(sizeof(*spring->pb) * spring->lb, "spring poly"); + + tmp_loop = mloop + mpoly[i].loopstart; + + for (x = 0; x < spring->la; x++) { + spring->pa[x] = tmp_loop[j + x].v; + } + + for (x = 0; x <= j; x++) { + spring->pb[x] = tmp_loop[x].v; + } + + for (y = k; y < mpoly[i].totloop; x++, y++) { + spring->pb[x] = tmp_loop[y].v; + } + + spring->ij = tmp_loop[j].v; + spring->kl = tmp_loop[k].v; + spring->mn = -1; + + shrink_factor = cloth_shrink_factor(clmd, cloth->verts, spring->ij, spring->kl); + spring->restlen = len_v3v3(cloth->verts[spring->ij].xrest, cloth->verts[spring->kl].xrest) * shrink_factor; + + spring->restang = spring_angle(cloth->verts, spring->ij, spring->kl, spring->pa, spring->pb,
[Bf-blender-cvs] [54186c5] cloth-improvements: Set better default values for the new mass-spring model
Commit: 54186c5aa982c0b7fea8ebea20c51e7732e5abbe Author: Luca Rood Date: Wed Dec 7 22:14:56 2016 -0200 Branches: cloth-improvements https://developer.blender.org/rB54186c5aa982c0b7fea8ebea20c51e7732e5abbe Set better default values for the new mass-spring model === M source/blender/blenkernel/intern/cloth.c M source/blender/physics/intern/BPH_mass_spring.cpp === diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index b356524..c017fdc 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -87,18 +87,18 @@ void cloth_init(ClothModifierData *clmd ) clmd->sim_parms->gravity[0] = 0.0; clmd->sim_parms->gravity[1] = 0.0; clmd->sim_parms->gravity[2] = -9.81; - clmd->sim_parms->tension = 15.0; - clmd->sim_parms->compression = 15.0; - clmd->sim_parms->max_tension = 15.0; - clmd->sim_parms->max_compression = 15.0; - clmd->sim_parms->shear = 5.0; - clmd->sim_parms->max_shear = 5.0; - clmd->sim_parms->bending = 0.5; - clmd->sim_parms->max_bend = 0.5; + clmd->sim_parms->tension = 50.0; + clmd->sim_parms->compression = 50.0; + clmd->sim_parms->max_tension = 50.0; + clmd->sim_parms->max_compression = 50.0; + clmd->sim_parms->shear = 0.1; + clmd->sim_parms->max_shear = 0.1; + clmd->sim_parms->bending = 0.05; + clmd->sim_parms->max_bend = 0.05; clmd->sim_parms->bending_damping = 0.5; clmd->sim_parms->tension_damp = 5.0; clmd->sim_parms->compression_damp = 5.0; - clmd->sim_parms->shear_damp = 5.0; + clmd->sim_parms->shear_damp = 1.0; clmd->sim_parms->Cvi = 1.0; clmd->sim_parms->mass = 0.3f; clmd->sim_parms->stepsPerFrame = 5; diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp b/source/blender/physics/intern/BPH_mass_spring.cpp index 9537694..36794f1 100644 --- a/source/blender/physics/intern/BPH_mass_spring.cpp +++ b/source/blender/physics/intern/BPH_mass_spring.cpp @@ -433,7 +433,7 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s, s->flags |= CLOTH_SPRING_FLAG_NEEDED; scaling = parms->bending + s->stiffness * fabsf(parms->max_bend - parms->bending); - k = scaling * s->restlen; + k = scaling * s->restlen * 0.1f; /* multiplying by 0.1, just to scale the forces to more reasonable values */ BPH_mass_spring_force_spring_angular(data, s->ij, s->kl, s->pa, s->pb, s->la, s->lb, s->restang, k, parms->bending_damping); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [ce6227b] cloth-improvements: Add cent_poly_v3 function
Commit: ce6227b6beefc2b58f900397318492bc529cd99c Author: Luca Rood Date: Sun Nov 27 00:44:48 2016 -0200 Branches: cloth-improvements https://developer.blender.org/rBce6227b6beefc2b58f900397318492bc529cd99c Add cent_poly_v3 function === M source/blender/blenlib/BLI_math_geom.h M source/blender/blenlib/intern/math_geom.c === diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h index 514b030..46e780c 100644 --- a/source/blender/blenlib/BLI_math_geom.h +++ b/source/blender/blenlib/BLI_math_geom.h @@ -46,6 +46,7 @@ extern "C" { void cent_tri_v3(float r[3], const float a[3], const float b[3], const float c[3]); void cent_quad_v3(float r[3], const float a[3], const float b[3], const float c[3], const float d[3]); +void cent_poly_v3(float cent[3], const float verts[][3], unsigned int nr); float normal_tri_v3(float r[3], const float a[3], const float b[3], const float c[3]); float normal_quad_v3(float r[3], const float a[3], const float b[3], const float c[3], const float d[3]); diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index f31d093..2610fbd 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -51,6 +51,16 @@ void cent_quad_v3(float cent[3], const float v1[3], const float v2[3], const flo cent[2] = 0.25f * (v1[2] + v2[2] + v3[2] + v4[2]); } +void cent_poly_v3(float cent[3], const float verts[][3], unsigned int nr) +{ + unsigned int i; + zero_v3(cent); + + for (i = 0; i < nr; i++) { + madd_v3_v3fl(cent, verts[i], 1.0f / (float)nr); + } +} + void cross_tri_v3(float n[3], const float v1[3], const float v2[3], const float v3[3]) { float n1[3], n2[3]; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [8a0d8dd] cloth-improvements: Implement shear springs for ngons
Commit: 8a0d8ddf270693a13aa037685d44dcc01b1d8c1e Author: Luca Rood Date: Wed Dec 7 17:20:29 2016 -0200 Branches: cloth-improvements https://developer.blender.org/rB8a0d8ddf270693a13aa037685d44dcc01b1d8c1e Implement shear springs for ngons === M source/blender/blenkernel/intern/cloth.c === diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index be5747a..7830862 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -1316,6 +1316,35 @@ void cloth_parallel_transport_hair_frame(float mat[3][3], const float dir_old[3] mul_m3_m3m3(mat, rot, mat); } +BLI_INLINE bool add_shear_bend_spring(ClothModifierData *clmd, LinkNodePair *edgelist, const MLoop *mloop, const MPoly *mpoly, int i, int j, int k) +{ + Cloth *cloth = clmd->clothObject; + ClothSpring *spring = (ClothSpring *)MEM_callocN(sizeof(ClothSpring), "cloth spring"); + float shrink_factor; + + if (!spring) { + cloth_free_errorsprings(cloth, edgelist); + return 0; + } + + spring_verts_ordered_set( + spring, + mloop[mpoly[i].loopstart + j].v, + mloop[mpoly[i].loopstart + k].v); + + shrink_factor = cloth_shrink_factor(clmd, cloth->verts, spring->ij, spring->kl); + spring->restlen = len_v3v3(cloth->verts[spring->kl].xrest, cloth->verts[spring->ij].xrest) * shrink_factor; + spring->type = CLOTH_SPRING_TYPE_SHEAR; + spring->stiffness = (cloth->verts[spring->kl].shear_stiff + cloth->verts[spring->ij].shear_stiff) / 2.0f; + + BLI_linklist_append([spring->ij], spring); + BLI_linklist_append([spring->kl], spring); + + BLI_linklist_prepend(>springs, spring); + + return 1; +} + BLI_INLINE float spring_angle(ClothVertex *verts, int i, int j, int *i_a, int *i_b, int len_a, int len_b) { float co_i[3], co_j[3], co_a[3], co_b[3]; @@ -1453,7 +1482,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) if (numpolys) { BendSpringRef *spring_ref = MEM_callocN(sizeof(*spring_ref) * numedges, "temp bend spring reference"); BendSpringRef *curr_ref; - int j; + int j, k; if (!spring_ref) { cloth_free_errorsprings(cloth, edgelist); @@ -1463,32 +1492,25 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) for (i = 0; i < numpolys; i++) { /* shear spring */ /* triangle faces already have shear springs due to structural geometry */ - /* TODO: Support ngons */ - if (mpoly[i].totloop == 4) { - for (j = 0; j != 2; j++) { - spring = (ClothSpring *)MEM_callocN(sizeof(ClothSpring), "cloth spring"); - - if (!spring) { - cloth_free_errorsprings(cloth, edgelist); - return 0; + if (mpoly[i].totloop > 3) { + for (j = 1; j < mpoly[i].totloop - 1; j++) { + if (j > 1) { + if (add_shear_bend_spring(clmd, edgelist, mloop, mpoly, i, 0, j)) + shear_springs++; + else { + cloth_free_errorsprings(cloth, edgelist); + return 0; + } } - spring_verts_ordered_set( - spring, - mloop[mpoly[i].loopstart + (j + 0)].v, - mloop[mpoly[i].loopstart + (j + 2)].v); - - shrink_factor = cloth_shrink_factor(clmd, cloth->verts, spring->ij, spring->kl); - spring->restlen = len_v3v3(cloth->verts[spring->kl].xrest, cloth->verts[spring->ij].xrest) * shrink_factor; - spring->type = CLOTH_SPRING_TYPE_SHEAR; - spring->stiffness = (cloth->verts[spring->kl].shear_stiff + cloth->verts[spring->ij].shear_stiff) / 2.0f; - - BLI_linklist_append([spring->ij], spring); -
[Bf-blender-cvs] [2bb7a13] master: Added --debug-io flag to command line
Commit: 2bb7a135aee8b3f60660cef0aa87215e8275f3bb Author: Gaia Clary Date: Fri Dec 9 17:19:59 2016 +0100 Branches: master https://developer.blender.org/rB2bb7a135aee8b3f60660cef0aa87215e8275f3bb Added --debug-io flag to command line === M source/blender/blenkernel/BKE_global.h M source/creator/creator_args.c === diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h index 5ef5a80..4bb2b95 100644 --- a/source/blender/blenkernel/BKE_global.h +++ b/source/blender/blenkernel/BKE_global.h @@ -129,10 +129,11 @@ enum { G_DEBUG_GPU_MEM = (1 << 10), /* gpu memory in status bar */ G_DEBUG_DEPSGRAPH_NO_THREADS = (1 << 11), /* single threaded depsgraph */ G_DEBUG_GPU =(1 << 12), /* gpu debug */ + G_DEBUG_IO = (1 << 13), /* IO Debugging (for Collada, ...)*/ }; #define G_DEBUG_ALL (G_DEBUG | G_DEBUG_FFMPEG | G_DEBUG_PYTHON | G_DEBUG_EVENTS | G_DEBUG_WM | G_DEBUG_JOBS | \ - G_DEBUG_FREESTYLE | G_DEBUG_DEPSGRAPH | G_DEBUG_GPU_MEM) + G_DEBUG_FREESTYLE | G_DEBUG_DEPSGRAPH | G_DEBUG_GPU_MEM | G_DEBUG_IO) /* G.fileflags */ diff --git a/source/creator/creator_args.c b/source/creator/creator_args.c index ab3410d..9f845d2 100644 --- a/source/creator/creator_args.c +++ b/source/creator/creator_args.c @@ -554,6 +554,7 @@ static int arg_handle_print_help(int UNUSED(argc), const char **UNUSED(argv), vo BLI_argsPrintArgDoc(ba, "--debug-gpumem"); BLI_argsPrintArgDoc(ba, "--debug-wm"); BLI_argsPrintArgDoc(ba, "--debug-all"); + BLI_argsPrintArgDoc(ba, "--debug-io"); printf("\n"); BLI_argsPrintArgDoc(ba, "--debug-fpe"); @@ -756,6 +757,14 @@ static int arg_handle_debug_mode_generic_set(int UNUSED(argc), const char **UNUS return 0; } +static const char arg_handle_debug_mode_io_doc[] = +"\n\tEnable debug messages for I/O (collada, ...)"; +static int arg_handle_debug_mode_io(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data)) +{ + G.debug |= G_DEBUG_IO; + return 0; +} + static const char arg_handle_debug_mode_all_doc[] = "\n\tEnable all debug messages"; static int arg_handle_debug_mode_all(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data)) @@ -1805,6 +1814,8 @@ void main_args_setup(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle) CB_EX(arg_handle_debug_mode_generic_set, wm), (void *)G_DEBUG_WM); BLI_argsAdd(ba, 1, NULL, "--debug-all", CB(arg_handle_debug_mode_all), NULL); + BLI_argsAdd(ba, 1, NULL, "--debug-io", CB(arg_handle_debug_mode_io), NULL); + BLI_argsAdd(ba, 1, NULL, "--debug-fpe", CB(arg_handle_debug_fpe_set), NULL); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [5a8b5a0] master: Land D2339 by bliblu bli
Commit: 5a8b5a0377781b5d03b39543a58175d8f4bc2bab Author: lazydodo Date: Fri Dec 9 08:28:04 2016 -0700 Branches: master https://developer.blender.org/rB5a8b5a0377781b5d03b39543a58175d8f4bc2bab Land D2339 by bliblu bli === M intern/cycles/device/device.cpp M intern/cycles/device/device.h M intern/cycles/kernel/kernel_types.h M intern/cycles/render/session.cpp M intern/cycles/render/shader.cpp === diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp index ff9387b..31c99f4 100644 --- a/intern/cycles/device/device.cpp +++ b/intern/cycles/device/device.cpp @@ -64,6 +64,8 @@ std::ostream& operator <<(std::ostream , << string_from_bool(requested_features.use_integrator_branched) << std::endl; os << "Use Patch Evaluation: " << string_from_bool(requested_features.use_patch_evaluation) << std::endl; + os << "Use Transparent Shadows: " + << string_from_bool(requested_features.use_transparent) << std::endl; return os; } diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h index 988ad10..ccee25a 100644 --- a/intern/cycles/device/device.h +++ b/intern/cycles/device/device.h @@ -117,6 +117,9 @@ public: /* Use OpenSubdiv patch evaluation */ bool use_patch_evaluation; + + /* Use Transparent shadows */ + bool use_transparent; DeviceRequestedFeatures() { @@ -133,6 +136,7 @@ public: use_volume = false; use_integrator_branched = false; use_patch_evaluation = false; + use_transparent = false; } bool modified(const DeviceRequestedFeatures& requested_features) @@ -148,7 +152,8 @@ public: use_subsurface == requested_features.use_subsurface && use_volume == requested_features.use_volume && use_integrator_branched == requested_features.use_integrator_branched && -use_patch_evaluation == requested_features.use_patch_evaluation); +use_patch_evaluation == requested_features.use_patch_evaluation && +use_transparent == requested_features.use_transparent); } /* Convert the requested features structure to a build options, @@ -189,6 +194,9 @@ public: if(!use_patch_evaluation) { build_options += " -D__NO_PATCH_EVAL__"; } + if(!use_transparent) { + build_options += " -D__NO_TRANSPARENT__"; + } return build_options; } }; diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h index a6c31d4..fd96183 100644 --- a/intern/cycles/kernel/kernel_types.h +++ b/intern/cycles/kernel/kernel_types.h @@ -192,6 +192,9 @@ CCL_NAMESPACE_BEGIN #ifdef __NO_PATCH_EVAL__ # undef __PATCH_EVAL__ #endif +#ifdef __NO_TRANSPARENT__ +# undef __TRANSPARENT_SHADOWS__ +#endif /* Random Numbers */ diff --git a/intern/cycles/render/session.cpp b/intern/cycles/render/session.cpp index 8e90224..3372104 100644 --- a/intern/cycles/render/session.cpp +++ b/intern/cycles/render/session.cpp @@ -636,6 +636,7 @@ DeviceRequestedFeatures Session::get_requested_device_features() BakeManager *bake_manager = scene->bake_manager; requested_features.use_baking = bake_manager->get_baking(); requested_features.use_integrator_branched = (scene->integrator->method == Integrator::BRANCHED_PATH); + requested_features.use_transparent &= scene->integrator->transparent_shadows; return requested_features; } diff --git a/intern/cycles/render/shader.cpp b/intern/cycles/render/shader.cpp index 06b6dd9..335edcb 100644 --- a/intern/cycles/render/shader.cpp +++ b/intern/cycles/render/shader.cpp @@ -571,6 +571,9 @@ void ShaderManager::get_requested_graph_features(ShaderGraph *graph, if(node->has_surface_bssrdf()) { requested_features->use_subsurface = true; } + if(node->has_surface_transparent()) { + requested_features->use_transparent = true; + } } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [3788eea] workspaces: Add missing CMakeLists file
Commit: 3788eeaad8c981d9924765ae107d11bdbad9c35d Author: Julian Eisel Date: Fri Dec 9 14:01:35 2016 +0100 Branches: workspaces https://developer.blender.org/rB3788eeaad8c981d9924765ae107d11bdbad9c35d Add missing CMakeLists file === A source/blender/editors/scene/CMakeLists.txt === diff --git a/source/blender/editors/scene/CMakeLists.txt b/source/blender/editors/scene/CMakeLists.txt new file mode 100644 index 000..72199ca --- /dev/null +++ b/source/blender/editors/scene/CMakeLists.txt @@ -0,0 +1,43 @@ +# * BEGIN GPL LICENSE BLOCK * +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributor(s): Jacques Beaurain. +# +# * END GPL LICENSE BLOCK * + +set(INC + ../include + ../../blenkernel + ../../blenlib + ../../blentranslation + ../../makesdna + ../../makesrna + ../../windowmanager +) + +set(INC_SYS + +) + +set(SRC + scene_edit.c +) + +if(WITH_INTERNATIONAL) + add_definitions(-DWITH_INTERNATIONAL) +endif() + +blender_add_lib(bf_editor_scene "${SRC}" "${INC}" "${INC_SYS}") ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [bdc209f] workspaces: Make WorkSpace and WorkSpaceLayout local DNA structs
Commit: bdc209faa9fd172fc83d5f7ea36cb806fcd7c2c5 Author: Julian Eisel Date: Fri Dec 9 13:52:08 2016 +0100 Branches: workspaces https://developer.blender.org/rBbdc209faa9fd172fc83d5f7ea36cb806fcd7c2c5 Make WorkSpace and WorkSpaceLayout local DNA structs Wanted to try this to avoid having (almost) global scope of DNA structs, instead, everything should be handled through BKE_workspace API. === M source/blender/blenkernel/BKE_workspace.h M source/blender/blenkernel/intern/library.c M source/blender/blenkernel/intern/workspace.c A source/blender/blenkernel/intern/workspace_dna.h M source/blender/blenloader/intern/readfile.c M source/blender/blenloader/intern/versioning_270.c M source/blender/blenloader/intern/writefile.c M source/blender/editors/include/ED_screen.h M source/blender/editors/screen/workspace_edit.c M source/blender/editors/screen/workspace_layout_edit.c M source/blender/makesdna/DNA_screen_types.h M source/blender/makesdna/intern/makesdna.c M source/blender/makesrna/intern/rna_workspace.c M source/blender/windowmanager/intern/wm_files.c === diff --git a/source/blender/blenkernel/BKE_workspace.h b/source/blender/blenkernel/BKE_workspace.h index c84ef4f..400bf29 100644 --- a/source/blender/blenkernel/BKE_workspace.h +++ b/source/blender/blenkernel/BKE_workspace.h @@ -30,34 +30,59 @@ struct bScreen; struct WorkSpace; +typedef struct WorkSpace WorkSpace; +typedef struct WorkSpaceLayout WorkSpaceLayout; + /* */ /* Create, delete, init */ -struct WorkSpace *BKE_workspace_add(Main *bmain, const char *name); -void BKE_workspace_free(struct WorkSpace *ws); +WorkSpace *BKE_workspace_add(Main *bmain, const char *name); +void BKE_workspace_free(WorkSpace *ws); -struct WorkSpaceLayout *BKE_workspace_layout_add(struct WorkSpace *workspace, struct bScreen *screen) ATTR_NONNULL(); -void BKE_workspace_layout_remove(struct WorkSpace *workspace, struct WorkSpaceLayout *layout, Main *bmain) ATTR_NONNULL(); +struct WorkSpaceLayout *BKE_workspace_layout_add(WorkSpace *workspace, struct bScreen *screen) ATTR_NONNULL(); +void BKE_workspace_layout_remove(WorkSpace *workspace, WorkSpaceLayout *layout, Main *bmain) ATTR_NONNULL(); /* */ /* General Utils */ -struct WorkSpaceLayout *BKE_workspace_layout_find( -const struct WorkSpace *ws, const struct bScreen *screen) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT; -struct WorkSpaceLayout *BKE_workspace_layout_find_exec( -const struct WorkSpace *ws, const struct bScreen *screen) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT; +#define BKE_workspace_iter(_workspace, _start_workspace) \ + for (WorkSpace *_workspace = _start_workspace; _workspace; _workspace = BKE_workspace_next_get(_workspace)) + +WorkSpaceLayout *BKE_workspace_layout_find(const WorkSpace *ws, const struct bScreen *screen) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT; +WorkSpaceLayout *BKE_workspace_layout_find_exec(const WorkSpace *ws, const struct bScreen *screen) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT; + +#define BKE_workspace_layout_iter(_layout, _start_layout) \ + for (WorkSpaceLayout *_layout = _start_layout; _layout; _layout = BKE_workspace_layout_next_get(_layout)) +#define BKE_workspace_layout_iter_backwards(_layout, _start_layout) \ + for (WorkSpaceLayout *_layout = _start_layout; _layout; _layout = BKE_workspace_layout_prev_get(_layout)) + +WorkSpaceLayout *BKE_workspace_layout_iter_circular(const WorkSpace *workspace, WorkSpaceLayout *start, +bool (*callback)(const WorkSpaceLayout *layout, void *arg), +void *arg, const bool iter_backward); /* */ /* Getters/Setters */ -struct WorkSpaceLayout *BKE_workspace_active_layout_get(const struct WorkSpace *ws) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT; -voidBKE_workspace_active_layout_set(struct WorkSpace *ws, struct WorkSpaceLayout *layout) ATTR_NONNULL(1); +struct ID *BKE_workspace_id_get(WorkSpace *workspace); +const char *BKE_workspace_name_get(const WorkSpace *workspace); +WorkSpaceLayout *BKE_workspace_active_layout_get(const struct WorkSpace *ws) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT; +void BKE_workspace_active_layout_set(WorkSpace *ws, WorkSpaceLayout *layout) ATTR_NONNULL(1); struct bScreen *BKE_workspace_active_screen_get(const struct WorkSpace *ws) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT; -voidBKE_workspace_active_screen_set(struct WorkSpace *ws, struct bScreen *screen) ATTR_NONNULL(1); +void
[Bf-blender-cvs] [1846a78] master: Depsgraph: Add missing relation for cast modifier
Commit: 1846a7884974a3cde5ce62ee1faaa8295647398d Author: Sergey Sharybin Date: Fri Dec 9 13:40:12 2016 +0100 Branches: master https://developer.blender.org/rB1846a7884974a3cde5ce62ee1faaa8295647398d Depsgraph: Add missing relation for cast modifier When control object is used we need to known our own transformation as well. === M source/blender/modifiers/intern/MOD_cast.c === diff --git a/source/blender/modifiers/intern/MOD_cast.c b/source/blender/modifiers/intern/MOD_cast.c index 33e5b36..2fe2773 100644 --- a/source/blender/modifiers/intern/MOD_cast.c +++ b/source/blender/modifiers/intern/MOD_cast.c @@ -124,12 +124,13 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, static void updateDepsgraph(ModifierData *md, struct Main *UNUSED(bmain), struct Scene *UNUSED(scene), -Object *UNUSED(ob), +Object *object, struct DepsNodeHandle *node) { CastModifierData *cmd = (CastModifierData *)md; if (cmd->object != NULL) { DEG_add_object_relation(node, cmd->object, DEG_OB_COMP_TRANSFORM, "Cast Modifier"); + DEG_add_object_relation(node, object, DEG_OB_COMP_TRANSFORM, "Cast Modifier"); } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [3bd94b9] master: Depsgraph: Bone parent should also include armature transform relation
Commit: 3bd94b9f45e921186352bed9908f5bb851714d4f Author: Sergey Sharybin Date: Fri Dec 9 13:05:39 2016 +0100 Branches: master https://developer.blender.org/rB3bd94b9f45e921186352bed9908f5bb851714d4f Depsgraph: Bone parent should also include armature transform relation It is required to have world-space bone position, which consists of armature object transform and local bone transform. === M source/blender/depsgraph/intern/builder/deg_builder_relations.cc === diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index d9a21d2..b5272d3 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -528,8 +528,20 @@ void DepsgraphRelationBuilder::build_object_parent(Object *ob) case PARBONE: /* Bone Parent */ { - ComponentKey parent_key(>parent->id, DEPSNODE_TYPE_BONE, ob->parsubstr); - add_relation(parent_key, ob_key, DEPSREL_TYPE_TRANSFORM, "Bone Parent"); + ComponentKey parent_bone_key(>parent->id, +DEPSNODE_TYPE_BONE, +ob->parsubstr); + OperationKey parent_transform_key(>parent->id, + DEPSNODE_TYPE_TRANSFORM, + DEG_OPCODE_TRANSFORM_FINAL); + add_relation(parent_bone_key, +ob_key, +DEPSREL_TYPE_TRANSFORM, +"Bone Parent"); + add_relation(parent_transform_key, +ob_key, +DEPSREL_TYPE_TRANSFORM, +"Armature Parent"); break; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs