[Bf-blender-cvs] [f38173e] testbuild: Hair test.

Lukas Tönne noreply at git.blender.org
Fri Sep 5 15:42:34 CEST 2014


Commit: f38173e58b54c87ab1b1821d63a273e3c1b83b2d
Author: Lukas Tönne
Date:   Fri Sep 5 15:43:49 2014 +0200
Branches: testbuild
https://developer.blender.org/rBf38173e58b54c87ab1b1821d63a273e3c1b83b2d

Hair test.

===================================================================

M	release/scripts/startup/bl_ui/properties_particle.py
M	release/scripts/startup/bl_ui/properties_texture.py
M	source/blender/blenkernel/BKE_cloth.h
M	source/blender/blenkernel/BKE_collision.h
M	source/blender/blenkernel/BKE_effect.h
M	source/blender/blenkernel/intern/collision.c
M	source/blender/blenkernel/intern/effect.c
M	source/blender/blenkernel/intern/implicit.c
M	source/blender/blenkernel/intern/particle.c
M	source/blender/blenkernel/intern/particle_system.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/editors/space_view3d/CMakeLists.txt
M	source/blender/editors/space_view3d/drawobject.c
A	source/blender/editors/space_view3d/drawsimdebug.c
M	source/blender/editors/space_view3d/view3d_intern.h
M	source/blender/makesdna/DNA_cloth_types.h
M	source/blender/makesdna/DNA_modifier_types.h
M	source/blender/makesdna/DNA_texture_types.h
M	source/blender/makesrna/intern/rna_cloth.c
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/makesrna/intern/rna_particle.c
M	source/blender/makesrna/intern/rna_texture.c
M	source/blender/modifiers/intern/MOD_cloth.c
M	source/blender/render/intern/source/voxeldata.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py
index 30fc3a9..492b3d5 100644
--- a/release/scripts/startup/bl_ui/properties_particle.py
+++ b/release/scripts/startup/bl_ui/properties_particle.py
@@ -278,7 +278,8 @@ class PARTICLE_PT_hair_dynamics(ParticleButtonsPanel, Panel):
         if not psys.cloth:
             return
 
-        cloth = psys.cloth.settings
+        cloth_md = psys.cloth
+        cloth = cloth_md.settings
 
         layout.enabled = psys.use_hair_dynamics and psys.point_cache.is_baked is False
 
@@ -292,6 +293,8 @@ class PARTICLE_PT_hair_dynamics(ParticleButtonsPanel, Panel):
         sub.prop(cloth, "bending_stiffness", text="Bending")
         sub.prop(cloth, "internal_friction", slider=True)
         sub.prop(cloth, "collider_friction", slider=True)
+        sub.prop(cloth, "pressure", slider=True)
+        sub.prop(cloth, "pressure_threshold", slider=True)
 
         col = split.column()
         col.label(text="Damping:")
@@ -302,6 +305,9 @@ class PARTICLE_PT_hair_dynamics(ParticleButtonsPanel, Panel):
         col.label(text="Quality:")
         col.prop(cloth, "quality", text="Steps", slider=True)
 
+        col.prop(cloth_md, "show_debug_data", text="Debug")
+
+
 
 class PARTICLE_PT_cache(ParticleButtonsPanel, Panel):
     bl_label = "Cache"
diff --git a/release/scripts/startup/bl_ui/properties_texture.py b/release/scripts/startup/bl_ui/properties_texture.py
index faf0d4c..4f5d22d 100644
--- a/release/scripts/startup/bl_ui/properties_texture.py
+++ b/release/scripts/startup/bl_ui/properties_texture.py
@@ -771,6 +771,9 @@ class TEXTURE_PT_voxeldata(TextureButtonsPanel, Panel):
         elif vd.file_format == 'SMOKE':
             layout.prop(vd, "domain_object")
             layout.prop(vd, "smoke_data_type")
+        elif vd.file_format == 'HAIR':
+            layout.prop(vd, "domain_object")
+            layout.prop(vd, "hair_data_type")
         elif vd.file_format == 'IMAGE_SEQUENCE':
             layout.template_ID(tex, "image", open="image.open")
             layout.template_image(tex, "image", tex.image_user, compact=True)
diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h
index 757d63e..df11827 100644
--- a/source/blender/blenkernel/BKE_cloth.h
+++ b/source/blender/blenkernel/BKE_cloth.h
@@ -41,7 +41,10 @@ struct Scene;
 struct MFace;
 struct DerivedMesh;
 struct ClothModifierData;
+struct CollisionModifierData;
 struct CollisionTree;
+struct VoxelData;
+struct PartDeflect;
 
 #define DO_INLINE MALWAYS_INLINE
 
@@ -158,6 +161,7 @@ typedef enum {
 typedef enum {
 	CLOTH_COLLSETTINGS_FLAG_ENABLED = ( 1 << 1 ), /* enables cloth - object collisions */
 	CLOTH_COLLSETTINGS_FLAG_SELF = ( 1 << 2 ), /* enables selfcollisions */
+	CLOTH_COLLSETTINGS_FLAG_POINTS = ( 1 << 3 ), /* enables point collisions (hair) */
 } CLOTH_COLLISIONSETTINGS_FLAGS;
 
 /* Spring types as defined in the paper.*/
@@ -180,8 +184,26 @@ typedef enum {
 // collision.c
 ////////////////////////////////////////////////
 
+struct CollPair;
+
+typedef struct ColliderContacts {
+	struct Object *ob;
+	struct CollisionModifierData *collmd;
+	
+	struct CollPair *collisions;
+	int totcollisions;
+} ColliderContacts;
+
 // needed for implicit.c
 int cloth_bvh_objcollision (struct Object *ob, struct ClothModifierData *clmd, float step, float dt );
+int cloth_points_objcollision(struct Object *ob, struct ClothModifierData *clmd, float step, float dt);
+
+void cloth_find_point_contacts(struct Object *ob, struct ClothModifierData *clmd, float step, float dt,
+                               ColliderContacts **r_collider_contacts, int *r_totcolliders);
+void cloth_free_contacts(ColliderContacts *collider_contacts, int totcolliders);
+
+bool cloth_points_collpair_response(struct ClothModifierData *clmd, struct CollisionModifierData *collmd, struct PartDeflect *pd,
+                                    struct CollPair *collpair, float dt, float r_impulse[3]);
 
 ////////////////////////////////////////////////
 
@@ -196,6 +218,8 @@ int implicit_free (struct ClothModifierData *clmd );
 int implicit_solver (struct Object *ob, float frame, struct ClothModifierData *clmd, struct ListBase *effectors );
 void implicit_set_positions (struct ClothModifierData *clmd );
 
+bool implicit_hair_volume_get_texture_data(struct Object *UNUSED(ob), struct ClothModifierData *clmd, struct ListBase *UNUSED(effectors), struct VoxelData *vd);
+
 /////////////////////////////////////////////////
 // cloth.c
 ////////////////////////////////////////////////
diff --git a/source/blender/blenkernel/BKE_collision.h b/source/blender/blenkernel/BKE_collision.h
index ec257a2..c0ee5dc 100644
--- a/source/blender/blenkernel/BKE_collision.h
+++ b/source/blender/blenkernel/BKE_collision.h
@@ -81,6 +81,8 @@ typedef struct CollPair {
 	float pa[3], pb[3]; // collision point p1 on face1, p2 on face2
 	int flag;
 	float time; // collision time, from 0 up to 1
+
+	/* mesh-mesh collision */
 #ifdef WITH_ELTOPO /*either ap* or bp* can be set, but not both*/
 	float bary[3];
 	int ap1, ap2, ap3, collp, bp1, bp2, bp3;
diff --git a/source/blender/blenkernel/BKE_effect.h b/source/blender/blenkernel/BKE_effect.h
index d5e54d8..04853bb 100644
--- a/source/blender/blenkernel/BKE_effect.h
+++ b/source/blender/blenkernel/BKE_effect.h
@@ -136,6 +136,36 @@ int get_effector_data(struct EffectorCache *eff, struct EffectorData *efd, struc
 /* EffectorData->flag */
 #define PE_VELOCITY_TO_IMPULSE  1
 
+/* ======== Simulation Debugging ======== */
+
+typedef struct SimDebugElement {
+	int category_hash;
+	int hash;
+	
+	int type;
+	float color[3];
+	
+	float v1[3], v2[3];
+} SimDebugElement;
+
+typedef enum eSimDebugElement_Type {
+	SIM_DEBUG_ELEM_DOT,
+	SIM_DEBUG_ELEM_LINE,
+	SIM_DEBUG_ELEM_VECTOR,
+} eSimDebugElement_Type;
+
+typedef struct SimDebugData {
+	struct GHash *gh;
+} SimDebugData;
+
+struct SimDebugData *BKE_sim_debug_data_new(void);
+void BKE_sim_debug_data_add_dot(struct SimDebugData *debug_data, const float p[3], float r, float g, float b, const char *category, int hash);
+void BKE_sim_debug_data_add_line(struct SimDebugData *debug_data, const float p1[3], const float p2[3], float r, float g, float b, const char *category, int hash);
+void BKE_sim_debug_data_add_vector(struct SimDebugData *debug_data, const float p[3], const float d[3], float r, float g, float b, const char *category, int hash);
+void BKE_sim_debug_data_remove(struct SimDebugData *debug_data, int hash);
+void BKE_sim_debug_data_clear(struct SimDebugData *debug_data);
+void BKE_sim_debug_data_clear_category(struct SimDebugData *debug_data, const char *category);
+void BKE_sim_debug_data_free(struct SimDebugData *debug_data);
 
 #endif
 
diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c
index cedd9ea..a8fea64 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -33,6 +33,7 @@
 #include "MEM_guardedalloc.h"
 
 #include "DNA_cloth_types.h"
+#include "DNA_effect_types.h"
 #include "DNA_group_types.h"
 #include "DNA_object_types.h"
 #include "DNA_object_force.h"
@@ -45,6 +46,7 @@
 #include "BLI_edgehash.h"
 
 #include "BKE_cloth.h"
+#include "BKE_effect.h"
 #include "BKE_modifier.h"
 #include "BKE_scene.h"
 
@@ -59,6 +61,41 @@
 #endif
 
 
+/* ==== hash functions for debugging ==== */
+static unsigned int hash_int_2d(unsigned int kx, unsigned int ky)
+{
+#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
+
+	unsigned int a, b, c;
+
+	a = b = c = 0xdeadbeef + (2 << 2) + 13;
+	a += kx;
+	b += ky;
+
+	c ^= b; c -= rot(b,14);
+	a ^= c; a -= rot(c,11);
+	b ^= a; b -= rot(a,25);
+	c ^= b; c -= rot(b,16);
+	a ^= c; a -= rot(c,4);
+	b ^= a; b -= rot(a,14);
+	c ^= b; c -= rot(b,24);
+
+	return c;
+
+#undef rot
+}
+
+static int hash_vertex(int type, int vertex)
+{
+	return hash_int_2d((unsigned int)type, (unsigned int)vertex);
+}
+
+static int hash_collpair(int type, CollPair *collpair)
+{
+	return hash_int_2d((unsigned int)type, hash_int_2d((unsigned int)collpair->face1, (unsigned int)collpair->face2));
+}
+/* ================ */
+
 /***********************************
 Collision modifier code start
 ***********************************/
@@ -652,8 +689,8 @@ static void cloth_bvh_objcollisions_nearcheck ( ClothModifierData * clmd, Collis
 	*collisions_index = *collisions;
 
 	for ( i = 0; i < numresult; i++ ) {
-		*collisions_index = cloth_collision ( (ModifierData *)clmd, (ModifierData *)collmd,
-		                                      overlap+i, *collisions_index, dt );
+		*collisions_index = cloth_collision((ModifierData *)clmd, (ModifierData *)collmd,
+		                                    overlap+i, *collisions_index, dt);
 	}
 }
 
@@ -913,3 +950,632 @@ int cloth_bvh_objcollision(Object *ob, ClothModifierData *clmd, float step, floa
 
 	return 1|MIN2 ( ret, 1 );
 }
+
+BLI_INLINE void max_v3_v3v3(float r[3], const float a[3], const float b[3])
+{
+	r[0] = max_ff(a[0], b[0]);
+	r[1] = max_ff(a[1], b[1]);
+	r[2] = max_ff(a[2], b[2]);
+}
+
+bool cloth_points_collpair_response(ClothModifierData *clmd, CollisionModifierData *collmd, PartDeflect *pd, CollPair *collpair, float dt, float r_impulse[3])
+{
+	bool result = false;
+	float restitution = (1.0f - clmd->coll_parms->damping) * (1.0f - pd->pdef_sbdamp);
+	Cloth *cloth1 = clmd->clothObject;
+	
+	float u1, u2, u3;
+	float v1[3], v2_old[3], v2_new[3], v_rel_old[3], v_rel_new[3];
+	float epsilon2 = BLI_bvhtree_getepsilon ( collmd->bvhtree );
+
+	float margin_distance = collpair->distance - epsilon2;
+	float mag_v_rel;
+	
+	zero_v3(r_impulse);
+	
+	if (margin_distance > 0.0f)
+		return false; /* XXX tested before already? */
+	
+	/* only handle static collisions here */
+	if ( collpair->flag & COLLISION_IN_FUTURE )
+		return false;
+	
+	/* compute barycentric coordinates */
+	collision_compute_barycentric(collpair->pb,
+	                              collmd->current_x[collpair->bp1].co,
+	                              collmd->current_x[collpair->bp2].co,
+	                              collmd->current_x[collpair->bp3].co,
+	                              &u1, &u2, &u3 );
+	
+	/* Calculat

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list