Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Want <cwant@ualberta.ca>2003-04-24 04:48:43 +0400
committerChris Want <cwant@ualberta.ca>2003-04-24 04:48:43 +0400
commitc95692df7ca0b2d4746e2e7a597b69a6f30c1676 (patch)
tree413150ab3b6d1b3f82e1a41ea1a78b171edd4330 /source/blender/blenkernel
parent788fa67bdf4a17c2128f15bc1f2fde7d58dd54bb (diff)
Support for auto-skinning when parenting a mesh to an armature.
Applies to bones that do not have a boneclass of unskinnable (set per bone in editmode in the button window).
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_armature.h1
-rw-r--r--source/blender/blenkernel/BKE_subsurf.h1
-rw-r--r--source/blender/blenkernel/intern/armature.c3
-rw-r--r--source/blender/blenkernel/intern/subsurf.c41
4 files changed, 44 insertions, 2 deletions
diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h
index 7fabacd48ee..1f9725a4f41 100644
--- a/source/blender/blenkernel/BKE_armature.h
+++ b/source/blender/blenkernel/BKE_armature.h
@@ -77,6 +77,7 @@ struct Bone *get_named_bone (struct bArmature *arm, const char *name);
struct Bone *get_indexed_bone (struct bArmature *arm, int index);
void make_displists_by_armature (struct Object *ob);
void calc_bone_deform (struct Bone *bone, float weight, float *vec, float *co, float *contrib);
+float dist_to_bone (float vec[3], float b1[3], float b2[3]);
void where_is_armature_time (struct Object *ob, float ctime);
void where_is_armature (struct Object *ob);
diff --git a/source/blender/blenkernel/BKE_subsurf.h b/source/blender/blenkernel/BKE_subsurf.h
index 2ce3a8b66ed..8025c89dc0e 100644
--- a/source/blender/blenkernel/BKE_subsurf.h
+++ b/source/blender/blenkernel/BKE_subsurf.h
@@ -39,6 +39,7 @@ void subsurf_to_mesh(struct Object *oldob, struct Mesh *newme);
void subsurf_make_mesh(struct Object *ob, short subdiv);
void subsurf_make_editmesh(struct Object *ob);
struct DispList* subsurf_mesh_to_displist(struct Mesh *me, struct DispList *dl, short subdiv);
+void subsurf_calculate_limit_positions(Mesh *me, float (*positions_r)[3]);
#endif
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index b4ef397b64b..5fb87e58ecc 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -73,7 +73,6 @@
/* Function prototypes */
static void apply_pose_bonechildren (Bone* bone, bPose* pose, int doit);
-static float dist_to_bone (float vec[3], float b1[3], float b2[3]);
static Bone *get_named_bone_bonechildren (Bone *bone, const char *name);
static Bone *get_indexed_bone_bonechildren (Bone *bone, int *index);
/*void make_bone_parent_matrix (Bone* bone);*/
@@ -568,7 +567,7 @@ static int verify_boneptr_children (Bone *cBone, Bone *tBone)
}
-static float dist_to_bone (float vec[3], float b1[3], float b2[3])
+float dist_to_bone (float vec[3], float b1[3], float b2[3])
{
/* float dist=0; */
float bdelta[3];
diff --git a/source/blender/blenkernel/intern/subsurf.c b/source/blender/blenkernel/intern/subsurf.c
index 064db5368ea..dd7bfc3dafd 100644
--- a/source/blender/blenkernel/intern/subsurf.c
+++ b/source/blender/blenkernel/intern/subsurf.c
@@ -901,3 +901,44 @@ DispList* subsurf_mesh_to_displist(Mesh *me, DispList *dl, short subdiv)
return subsurf_subdivide_to_displist(hme, subdiv);
}
+
+void subsurf_calculate_limit_positions(Mesh *me, float (*positions_r)[3])
+{
+ /* Finds the subsurf limit positions for the verts in a mesh
+ * and puts them in an array of floats. Please note that the
+ * calculated vert positions is incorrect for the verts
+ * on the boundary of the mesh.
+ */
+ HyperMesh *hme= hypermesh_from_mesh(me, NULL);
+ HyperMesh *nme= hypermesh_new();
+ float edge_sum[3], face_sum[3];
+ HyperVert *hv;
+ LinkNode *l;
+ int i;
+
+ hypermesh_subdivide(hme, nme);
+
+ for (i= me->totvert-1,hv=hme->verts; i>=0; i--,hv=hv->next) {
+ int N= 0;
+
+ edge_sum[0]= edge_sum[1]= edge_sum[2]= 0.0;
+ face_sum[0]= face_sum[1]= face_sum[2]= 0.0;
+
+ for (N=0,l=hv->edges; l; N++,l= l->next) {
+ Vec3Add(edge_sum, ((HyperEdge*) l->link)->ep->co);
+ }
+ for (l=hv->faces; l; l= l->next) {
+ Vec3Add(face_sum, ((HyperFace*) l->link)->mid->co);
+ }
+
+ positions_r[i][0] =
+ (hv->nmv->co[0]*N*N + edge_sum[0]*4 + face_sum[0])/(N*(N+5));
+ positions_r[i][1] =
+ (hv->nmv->co[1]*N*N + edge_sum[1]*4 + face_sum[1])/(N*(N+5));
+ positions_r[i][2] =
+ (hv->nmv->co[2]*N*N + edge_sum[2]*4 + face_sum[2])/(N*(N+5));
+ }
+
+ hypermesh_free(nme);
+ hypermesh_free(hme);
+}