Commit: 6681a6e83877b79de7ed48a13d59e2416ac3195e
Author: Lukas Tönne
Date:   Wed Jan 21 10:13:47 2015 +0100
Branches: gooseberry
https://developer.blender.org/rB6681a6e83877b79de7ed48a13d59e2416ac3195e

Merge branch 'master' into gooseberry

Conflicts:
        source/blender/editors/space_view3d/view3d_draw.c
        source/blender/physics/intern/BPH_mass_spring.cpp
        source/blender/physics/intern/implicit_blender.c

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



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

diff --cc source/blender/blenkernel/intern/subsurf_ccg.c
index fbe5894,45ec337..1bc6609
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@@ -2176,68 -1869,8 +2176,10 @@@ static void ccgDM_drawFacesSolid(Derive
                        }
                }
        }
 +
 +#endif
  }
  
- static void ccgdm_draw_attrib_vertex(DMVertexAttribs *attribs, int a, int 
index, int vert)
- {
-       const float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f};
-       int b;
- 
-       /* orco texture coordinates */
-       if (attribs->totorco) {
-               /*const*/ float (*array)[3] = attribs->orco.array;
-               const float *orco = (array) ? array[index] : zero;
- 
-               if (attribs->orco.gl_texco)
-                       glTexCoord3fv(orco);
-               else
-                       glVertexAttrib3fvARB(attribs->orco.gl_index, orco);
-       }
- 
-       /* uv texture coordinates */
-       for (b = 0; b < attribs->tottface; b++) {
-               const float *uv;
- 
-               if (attribs->tface[b].array) {
-                       MTFace *tf = &attribs->tface[b].array[a];
-                       uv = tf->uv[vert];
-               }
-               else {
-                       uv = zero;
-               }
- 
-               if (attribs->tface[b].gl_texco)
-                       glTexCoord2fv(uv);
-               else
-                       glVertexAttrib2fvARB(attribs->tface[b].gl_index, uv);
-       }
- 
-       /* vertex colors */
-       for (b = 0; b < attribs->totmcol; b++) {
-               GLubyte col[4];
- 
-               if (attribs->mcol[b].array) {
-                       MCol *cp = &attribs->mcol[b].array[a * 4 + vert];
-                       col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] 
= cp->a;
-               }
-               else {
-                       col[0] = 0; col[1] = 0; col[2] = 0; col[3] = 0;
-               }
- 
-               glVertexAttrib4ubvARB(attribs->mcol[b].gl_index, col);
-       }
- 
-       /* tangent for normal mapping */
-       if (attribs->tottang) {
-               /*const*/ float (*array)[4] = attribs->tang.array;
-               const float *tang = (array) ? array[a * 4 + vert] : zero;
- 
-               glVertexAttrib4fvARB(attribs->tang.gl_index, tang);
-       }
- }
- 
  /* Only used by non-editmesh types */
  static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm,
                                        DMSetMaterial setMaterial,
diff --cc source/blender/editors/space_view3d/view3d_draw.c
index d47a836,ed30c87..29d05ab
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@@ -3640,6 -3584,9 +3641,8 @@@ void view3d_main_area_draw(const bConte
  #ifdef DEBUG_DRAW
                bl_debug_draw();
  #endif
+               draw_sim_debug_data(scene, v3d, ar);
+               
 -              ED_region_pixelspace(ar);
        }
  
        /* draw viewport using external renderer */
diff --cc source/blender/physics/intern/BPH_mass_spring.cpp
index 62a13a3,6cddbc6..6c70018
--- a/source/blender/physics/intern/BPH_mass_spring.cpp
+++ b/source/blender/physics/intern/BPH_mass_spring.cpp
@@@ -1,1113 -1,1017 +1,1106 @@@
 -/*
 - * ***** 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.
 - *
 - * The Original Code is Copyright (C) Blender Foundation
 - * All rights reserved.
 - *
 - * The Original Code is: all of this file.
 - *
 - * Contributor(s): Lukas Toenne
 - *
 - * ***** END GPL LICENSE BLOCK *****
 - */
 -
 -/** \file blender/physics/intern/BPH_mass_spring.cpp
 - *  \ingroup bph
 - */
 -
 -extern "C" {
 -#include "MEM_guardedalloc.h"
 -
 -#include "DNA_cloth_types.h"
 -#include "DNA_scene_types.h"
 -#include "DNA_object_force.h"
 -#include "DNA_object_types.h"
 -#include "DNA_meshdata_types.h"
 -#include "DNA_modifier_types.h"
 -
 -#include "BLI_math.h"
 -#include "BLI_linklist.h"
 -#include "BLI_utildefines.h"
 -
 -#include "BKE_cloth.h"
 -#include "BKE_collision.h"
 -#include "BKE_effect.h"
 -}
 -
 -#include "BPH_mass_spring.h"
 -#include "implicit.h"
 -
 -static float I3[3][3] = {{1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}};
 -
 -/* Number of off-diagonal non-zero matrix blocks.
 - * Basically there is one of these for each vertex-vertex interaction.
 - */
 -static int cloth_count_nondiag_blocks(Cloth *cloth)
 -{
 -      LinkNode *link;
 -      int nondiag = 0;
 -      
 -      for (link = cloth->springs; link; link = link->next) {
 -              ClothSpring *spring = (ClothSpring *)link->link;
 -              switch (spring->type) {
 -                      case CLOTH_SPRING_TYPE_BENDING_ANG:
 -                              /* angular bending combines 3 vertices */
 -                              nondiag += 3;
 -                              break;
 -                              
 -                      default:
 -                              /* all other springs depend on 2 vertices only 
*/
 -                              nondiag += 1;
 -                              break;
 -              }
 -      }
 -      
 -      return nondiag;
 -}
 -
 -int BPH_cloth_solver_init(Object *UNUSED(ob), ClothModifierData *clmd)
 -{
 -      Cloth *cloth = clmd->clothObject;
 -      ClothVertex *verts = cloth->verts;
 -      const float ZERO[3] = {0.0f, 0.0f, 0.0f};
 -      Implicit_Data *id;
 -      unsigned int i, nondiag;
 -      
 -      nondiag = cloth_count_nondiag_blocks(cloth);
 -      cloth->implicit = id = BPH_mass_spring_solver_create(cloth->numverts, 
nondiag);
 -      
 -      for (i = 0; i < cloth->numverts; i++) {
 -              BPH_mass_spring_set_vertex_mass(id, i, verts[i].mass);
 -      }
 -      
 -      for (i = 0; i < cloth->numverts; i++) {
 -              BPH_mass_spring_set_motion_state(id, i, verts[i].x, ZERO);
 -      }
 -      
 -      return 1;
 -}
 -
 -void BPH_cloth_solver_free(ClothModifierData *clmd)
 -{
 -      Cloth *cloth = clmd->clothObject;
 -      
 -      if (cloth->implicit) {
 -              BPH_mass_spring_solver_free(cloth->implicit);
 -              cloth->implicit = NULL;
 -      }
 -}
 -
 -void BKE_cloth_solver_set_positions(ClothModifierData *clmd)
 -{
 -      Cloth *cloth = clmd->clothObject;
 -      ClothVertex *verts = cloth->verts;
 -      unsigned int numverts = cloth->numverts, i;
 -      ClothHairData *cloth_hairdata = clmd->hairdata;
 -      Implicit_Data *id = cloth->implicit;
 -      
 -      for (i = 0; i < numverts; i++) {
 -              if (cloth_hairdata) {
 -                      ClothHairData *root = &cloth_hairdata[i];
 -                      BPH_mass_spring_set_rest_transform(id, i, root->rot);
 -              }
 -              else
 -                      BPH_mass_spring_set_rest_transform(id, i, I3);
 -              
 -              BPH_mass_spring_set_motion_state(id, i, verts[i].x, verts[i].v);
 -      }
 -}
 -
 -static bool collision_response(ClothModifierData *clmd, CollisionModifierData 
*collmd, CollPair *collpair, float dt, float restitution, float r_impulse[3])
 -{
 -      Cloth *cloth = clmd->clothObject;
 -      int index = collpair->ap1;
 -      bool result = false;
 -      
 -      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;
 -      
 -      /* velocity */
 -      copy_v3_v3(v1, cloth->verts[index].v);
 -      collision_get_collider_velocity(v2_old, v2_new, collmd, collpair);
 -      /* relative velocity = velocity of the cloth point relative to the 
collider */
 -      sub_v3_v3v3(v_rel_old, v1, v2_old);
 -      sub_v3_v3v3(v_rel_new, v1, v2_new);
 -      /* normal component of the relative velocity */
 -      mag_v_rel = dot_v3v3(v_rel_old, collpair->normal);
 -      
 -      /* only valid when moving toward the collider */
 -      if (mag_v_rel < -ALMOST_ZERO) {
 -              float v_nor_old, v_nor_new;
 -              float v_tan_old[3], v_tan_new[3];
 -              float bounce, repulse;
 -              
 -              /* Collision response based on
 -               * "Simulating Complex Hair with Robust Collision Handling" 
(Choe, Choi, Ko, ACM SIGGRAPH 2005)
 -               * 
http://graphics.snu.ac.kr/publications/2005-choe-HairSim/Choe_2005_SCA.pdf
 -               */
 -              
 -              v_nor_old = mag_v_rel;
 -              v_nor_new = dot_v3v3(v_rel_new, collpair->normal);
 -              
 -              madd_v3_v3v3fl(v_tan_old, v_rel_old, collpair->normal, 
-v_nor_old);
 -              madd_v3_v3v3fl(v_tan_new, v_rel_new, collpair->normal, 
-v_nor_new);
 -              
 -              bounce = -v_nor_old * restitution;
 -              
 -              repulse = -margin_distance / dt; /* base repulsion velocity in 
normal direction */
 -              /* XXX this clamping factor is quite arbitrary ...
 -               * not sure if there is a more scientific approach, but seems 
to give good results
 -               */
 -              CLAMP(repulse, 0.0f, 4.0f * bounce);
 -              
 -              if (margin_distance < -epsilon2) {
 -                      mul_v3_v3fl(r_impulse, collpair->normal, 
max_ff(repulse, bounce) - v_nor_new);
 -              }
 -              else {
 -                      bounce = 0.0f;
 -                      mul_v3_v3fl(r_impulse, collpair->normal, repulse - 
v_nor_new);
 -              }
 -              
 -              result = true;
 -      }
 -      
 -      return result;
 -}
 -
 -/* Init constraint matrix
 - * This is part of the modified CG method suggested by Baraff/Witkin in
 - * "Large Steps in Cloth Simulation" (Siggraph 1998)
 - */
 -static void cloth_setup_constraints(ClothModifierData *clmd, ColliderContacts 
*contacts, int totcolliders, float dt)
 -{
 -      Cloth *cloth = clmd->clothObject;
 -      Implicit_Data *data = cloth->implicit;
 -      ClothVertex *verts = cloth->verts;
 -      int numverts = cloth->numverts;
 -      int i, j, v;
 -      
 -      const float ZERO[3] = {0.0f, 0.0f, 0.0f};
 -      
 -      for (v = 0; v < numverts; v++) {
 -              if (verts[v].flags & CLOTH_VERT_FLAG_PINNED) {
 -                      /* pinned vertex constraints */
 -                      BPH_mass_spring_add_constraint_ndof0(data, v, ZERO); /* 
velocity is defined externally */
 -              }
 -              
 -              verts[v].impulse_count = 0;
 -      }
 -
 -      for (i = 0; i < totcolliders; ++i) {
 -              ColliderContacts *ct = &contacts[i];
 -              for (j = 0; j < ct->totcollisions; ++j) {
 -                      CollPair *collpair = &ct->collisions[j];
 -//                    float restitution = (1.0f - clmd->coll_parms->damping) 
* (1.0f - ct->ob->pd->pdef_sbdamp);
 -                      float restitution = 0.0f;
 -                      int v = collpair->face1;
 -                      float impulse[3];
 -                      
 -                      /* pinned verts handled separately */
 -                      if (verts[v].flags & CLOTH_VERT_FLAG_PINNED)
 -                              continue;
 -                      
 -                      /* XXX cheap way of avoiding instability from multiple 
collisions in the same step
 -                       * this should eventually be supported ...
 -                       */
 -                      if (verts[v].impulse_count > 0)
 -                              continue

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to