[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29513] branches/hairsim/source/blender/ blenkernel: forgot these files
Joseph Eagar
joeedh at gmail.com
Thu Jun 17 07:55:32 CEST 2010
Revision: 29513
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29513
Author: joeedh
Date: 2010-06-17 07:55:32 +0200 (Thu, 17 Jun 2010)
Log Message:
-----------
forgot these files
Added Paths:
-----------
branches/hairsim/source/blender/blenkernel/BKE_pdynamics.h
branches/hairsim/source/blender/blenkernel/BLI_pdynamics.h
branches/hairsim/source/blender/blenkernel/intern/pdynamics.c
Added: branches/hairsim/source/blender/blenkernel/BKE_pdynamics.h
===================================================================
--- branches/hairsim/source/blender/blenkernel/BKE_pdynamics.h (rev 0)
+++ branches/hairsim/source/blender/blenkernel/BKE_pdynamics.h 2010-06-17 05:55:32 UTC (rev 29513)
@@ -0,0 +1,205 @@
+#ifndef _BKE_PDYNAMICS_H
+#define _BKE_PDYNAMICS_H
+
+#include "BLI_kdopbvh.h"
+#include "BKE_utildefines.h"
+
+struct MemArena;
+struct BLI_mempool;
+struct GHash;
+
+#ifndef PD_USE_32BIT_FLOAT
+typedef double pdfloat;
+#else
+typedef float pdfloat;
+#endif
+
+#define MAX_PDEDGES_V 8
+
+typedef struct PDVertex {
+ /*NULL-terminated list of adjacent edges.
+ this should be quicker then using linked lists.
+ points into a single array inside the main solver
+ struct.*/
+ struct PDEdge **edges;
+ struct PDVertex *parents[2];
+ pdfloat parentfac[2];
+
+ pdfloat tx[3], txstart[3], txold[3], txold2[3], tv[3], tvold[3];
+ pdfloat tanforce[3], springforce[3], goalforce[3];
+ pdfloat txconst[3], txconstold[3];
+ pdfloat no[3], mass, goal;
+
+ int pinned;
+ intptr_t hash1, hash2;
+} PDVertex;
+
+typedef struct PDEdge {
+ struct PDTri *t1, *t2;
+ struct PDVertex *v1, *v2;
+ pdfloat no[3];
+} PDEdge;
+
+typedef struct PDTri {
+ PDEdge *edges[3];
+ PDVertex *verts[3];
+ pdfloat no[3], mindis, dis;
+ pdfloat cent[3], ocent[3];
+
+ int noncloth, origface;
+} PDTri;
+
+typedef struct PDMesh {
+ struct PDSolver *solver;
+
+ PDVertex *verts;
+ PDEdge *edges;
+ PDTri *tris;
+ PDTri *(*facemap)[2];
+
+ /*point array filled with a null-terminated
+ sequence of pointers for each vertex*/
+ PDEdge **v_edgelists;
+
+ int totvert, totedge, tottri;
+ struct GHash *edgehash, *trihash;
+
+ struct BVHTree *bvh_tritree, *bvh_edgetree;
+
+ pdfloat goal, friction, bending;
+ pdfloat springdamp, goaldamp, rigid_damp;
+ pdfloat internel_friction, collision_friction;
+ pdfloat airdamp, gravity[3], self_repulsion;
+ pdfloat mindis;
+
+ int do_coll; /*flag for if collisions are enabled*/
+ int do_goal;
+} PDMesh;
+
+/*main dynamics structure*/
+typedef struct PDSolver {
+ PDMesh *mesh;
+
+ ListBase constraints;
+ ListBase coll_constraints; /*temporary collision constraints*/
+
+ /*number of steps that advance time, and number of steps within those steps*/
+ int timesteps, substeps;
+
+ struct MemArena *arena;/*stores geometry, non-collision constraints (e.g springs), etc*/
+ struct MemArena *temparena;/*created and destroyed each time step*/
+} PDSolver;
+
+#define CMAXVERTS 10
+
+/*"point-based dynamics" by mueller*/
+typedef struct PDConstraint {
+ struct PDConstraint *next, *prev;
+
+ PDVertex *verts[CMAXVERTS];
+ void (*eval)(void *vself);
+ int type;
+
+ pdfloat grad[CMAXVERTS][3];
+ pdfloat k, realk; /*stiffness of constraint, at current solver iteration stiffness*/
+ pdfloat w, result;
+} PDConstraint;
+
+typedef struct PDCollConstraint {
+ PDConstraint head;
+ pdfloat mindis, friction;
+ pdfloat no[3];
+} PDCollConstraint;
+
+typedef struct PDPointConstraint {
+ PDCollConstraint coll;
+ PDVertex *v1, *v2, *v3, *p;
+ PDTri *colltri;
+ int flip;
+} PDPointConstraint;
+
+typedef struct PDBendingConstraint {
+ PDConstraint head;
+
+ PDVertex *v2, *v3;
+
+ pdfloat restlen;
+} PDBendingConstraint;
+
+typedef struct PDGoalConstraint {
+ PDConstraint head;
+
+ pdfloat restlen, t;
+ pdfloat nor[3];
+
+ PDVertex *v1;
+} PDGoalConstraint;
+
+typedef struct PDSpringConstraint {
+ PDConstraint head;
+ PDVertex *v1;
+
+ pdfloat restlen;
+ int ignore_stretch;
+} PDSpringConstraint;
+
+typedef struct PDEdgeConstraint {
+ PDCollConstraint coll;
+ PDVertex *v1, *v2, *v3, *v4;
+
+ pdfloat off[3];
+ pdfloat elen1, elen2;
+} PDEdgeConstraint;
+
+#define TRI_EPS (DBL_EPSILON)
+
+/*collision constraints*/
+#define CON_POINT 1
+#define CON_EDGE 2
+
+/*deformation constraints*/
+#define CON_SPRING 3
+#define CON_GOAL 4
+#define CON_BEND 5
+
+void run_constraint_solver(struct Object *ob, struct PDMesh *pdm, int solversteps, int totlevel, pdfloat dt);
+int pd_init_solver(struct Object *ob, struct ClothModifierData *clmd);
+int pd_free_solver(struct ClothModifierData *clmd);
+int pd_solver_step(struct Object *ob, float framenr, struct ClothModifierData *clmd, struct ListBase *effectors);
+int pd_do_substeps(Object *ob, ClothModifierData *clmd, pdfloat step, pdfloat dt, pdfloat dstep);
+int pd_set_positions(struct ClothModifierData *clmd);
+PDMesh *pd_create_from_collmodifier(Object *ob, struct CollisionModifierData *collmd);
+void pd_free_mesh(PDMesh *pdm);
+
+#ifndef PD_USE_32BIT_FLOAT
+#ifdef PD_INTERNAL
+#define add_v3_v3 add_v3_v3_d
+#define sub_v3_v3 sub_v3_v3_d
+#define add_v3_v3v3 add_v3_v3v3_d
+#define sub_v3_v3v3 sub_v3_v3v3_d
+#define addfac_v3_v3 addfac_v3_v3_d
+#define subfac_v3_v3 subfac_v3_v3_d
+#define addfac_v3_v3v3 addfac_v3_v3v3_d
+#define subfac_v3_v3v3 subfac_v3_v3v3_d
+#define mul_v3_sl mul_v3_d
+#define len_v3 len_v3_d
+#define len_v3v3 len_v3v3_d
+#define dot_v3 dot_v3_d
+#define dot_v3v3 dot_v3v3_d
+#define normalize_v3 normalize_v3_d
+#define normal_tri_v3 normal_tri_v3_d
+#define normal_quad_v3 normal_quad_v3_d
+#define cross_v3_v3v3 cross_v3_v3v3_d
+#define copy_v3_v3 copy_v3_v3_d
+#define tetra_isect tetra_isect_d
+#define line_in_tetra line_in_tetra_d
+#define line_line_isect_moving line_line_isect_moving_d
+#define isect_line_line_v3 isect_line_line_v3_d
+#define negate_v3 negate_v3_d
+#define zero_v3 zero_v3_d
+#endif
+#else
+#define mul_v3_sl mul_v3_fl
+#endif
+
+#endif /*_BKE_PDYNAMICS_H*/
\ No newline at end of file
Added: branches/hairsim/source/blender/blenkernel/BLI_pdynamics.h
===================================================================
--- branches/hairsim/source/blender/blenkernel/BLI_pdynamics.h (rev 0)
+++ branches/hairsim/source/blender/blenkernel/BLI_pdynamics.h 2010-06-17 05:55:32 UTC (rev 29513)
@@ -0,0 +1,136 @@
+#ifndef _BKE_PDYNAMICS_H
+#define _BKE_PDYNAMICS_H
+
+#include "BLI_kdopbvh.h"
+#include "BKE_utildefines.h"
+
+struct MemArena;
+struct BLI_mempool;
+struct GHash;
+
+#ifndef PD_USE_FLOAT
+typedef double pdfloat;
+#else
+typedef float pdfloat;
+#endif
+
+#define MAX_PDEDGES_V 8
+
+typedef struct PDVertex {
+ /*NULL-terminated list of adjacent edges.
+ this should be quicker then using linked lists.
+ points into a single array inside the main solver
+ struct.*/
+ struct PDEdge **edges;
+
+ pdfloat tx[3], txold[3], txold2[3], tv[3];
+ pdfloat tanforce[3], springforce[3], goalforce[3];
+ pdfloat txconst[3], txconstold[3];
+ pdfloat no[3];
+
+ int hash1, hash2;
+} PDVertex;
+
+typedef struct PDEdge {
+ struct PDTri *t1, *t2;
+ struct PDVert *v1, *v2;
+ pdfloat no[3];
+
+ int hash;
+} PDEdge;
+
+typedef struct PDTri {
+ PDEdge *edges[3];
+ PDVert *verts[3];
+ pdfloat no[3];
+ pdfloat cent[3], ocent[3];
+
+ int hash;
+} PDTri;
+
+typedef struct PDMesh {
+ PDVertex *verts;
+ PDEdge *edges;
+ PDTri *tris;
+
+ /*point array filled with a null-terminated
+ sequence of pointers for each vertex*/
+ PDEdge **vedges;
+
+ int totvert, totedge, tottri;
+ GHash *edgehash, *trihash;
+} PDMesh;
+
+/*main dynamics structure*/
+typedef struct PD_Solver {
+ PDMesh *mesh;
+
+ ListBase constraints;
+ ListBase coll_constraints; /*temporary collision constraints*/
+
+ BVHTree *bvh_tritree, *bvh_springtree;
+
+ struct MemArena *arena;/*stores geometry, non-collision constraints (e.g springs), etc*/
+ struct MemArena *temparena;/*created and destroyed each time step*/
+} PD_Solver;
+
+#define CMAXVERTS 10
+
+/*"point-based dynamics" by mueller*/
+typedef struct PD_Constraint {
+ struct PD_Constraint *next, *prev;
+
+ PDVertex *verts[CMAXVERTS];
+ void (*eval)(void *vself);
+ int type;
+
+ pdfloat grad[CMAXVERTS][3];
+ pdfloat k, realk; /*stiffness of constraint, at current solver iteration stiffness*/
+ pdfloat w, result;
+} PD_Constraint;
+
+typedef struct PD_CollConstraint {
+ PD_Constraint head;
+ pdfloat mindis, friction;
+ pdfloat no[3];
+} PD_CollConstraint;
+
+typedef struct PD_PointConstraint {
+ PD_CollConstraint coll;
+ PDVertex *v1, *v2, *v3, *p;
+ PDTri *colltri;
+ int flip;
+} PD_PointConstraint;
+
+typedef struct PD_BendingConstraint {
+ PD_Constraint head;
+
+ PDVertex *v2, *v3;
+
+ pdfloat restlen;
+} PD_BendingConstraint;
+
+typedef struct PD_GoalConstraint {
+ Constraint head;
+
+ pdfloat restlen, t;
+ pdfloat nor[3];
+} PD_GoalConstraint;
+
+typedef struct PD_SpringConstraint {
+ Constraint head;
+ PDVertex *v1;
+
+ pdfloat restlen;
+ int ignore_stretch;
+} PD_SpringConstraint;
+
+typedef struct PD_EdgeConstraint {
+ CollConstraint coll;
+ PDVertex *v1, *v2, *v3, *v4;
+
+ pdfloat off[3];
+ pdfloat sign, elen1, elen2;
+} PD_EdgeConstraint;
+
+#endif /*_BKE_PDYNAMICS_H*/
\ No newline at end of file
Added: branches/hairsim/source/blender/blenkernel/intern/pdynamics.c
===================================================================
--- branches/hairsim/source/blender/blenkernel/intern/pdynamics.c (rev 0)
+++ branches/hairsim/source/blender/blenkernel/intern/pdynamics.c 2010-06-17 05:55:32 UTC (rev 29513)
@@ -0,0 +1,2194 @@
+/* collision.c
+*
+*
+* ***** 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): none yet.
+*
+* ***** END GPL LICENSE BLOCK *****
+*/
+
+#include "MEM_guardedalloc.h"
+
+#include "BKE_cloth.h"
+
+#include "DNA_cloth_types.h"
+#include "DNA_group_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_object_types.h"
+#include "DNA_object_force.h"
+#include "DNA_scene_types.h"
+
+#include "BKE_DerivedMesh.h"
+#include "BKE_global.h"
+#include "BKE_mesh.h"
+#include "BKE_object.h"
+#include "BKE_modifier.h"
+#include "BKE_utildefines.h"
+#include "BKE_DerivedMesh.h"
+#include "BKE_collision.h"
+
+#define PD_INTERNAL
+#include "BKE_pdynamics.h"
+
+#ifdef USE_BULLET
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list