Index: code/branches/physics/src/bullet/BulletSoftBody/btSoftBody.h
===================================================================
--- code/branches/physics/src/bullet/BulletSoftBody/btSoftBody.h	(revision 1963)
+++ code/branches/physics/src/bullet/BulletSoftBody/btSoftBody.h	(revision 1972)
@@ -63,5 +63,5 @@
 		END
 	};};
-
+	
 	///eVSolver : velocities solvers
 	struct	eVSolver { enum _ {
@@ -69,5 +69,5 @@
 		END
 	};};
-
+	
 	///ePSolver : positions solvers
 	struct	ePSolver { enum _ {
@@ -78,5 +78,5 @@
 		END
 	};};
-
+	
 	///eSolverPresets
 	struct	eSolverPresets { enum _ {
@@ -86,5 +86,5 @@
 		END
 	};};
-
+	
 	///eFeature
 	struct	eFeature { enum _ {
@@ -95,12 +95,12 @@
 		END
 	};};
-
+	
 	typedef btAlignedObjectArray<eVSolver::_>	tVSolverArray;
 	typedef btAlignedObjectArray<ePSolver::_>	tPSolverArray;
-
+	
 	//
 	// Flags
 	//
-
+	
 	///fCollision
 	struct fCollision { enum _ {
@@ -108,5 +108,5 @@
 		SDF_RS	=	0x0001,	///SDF based rigid vs soft
 		CL_RS	=	0x0002, ///Cluster vs convex rigid vs soft
-
+		
 		SVSmask	=	0x00f0,	///Rigid versus soft mask		
 		VF_SS	=	0x0010,	///Vertex vs face soft vs soft handling
@@ -116,5 +116,5 @@
 		END
 	};};
-
+	
 	///fMaterial
 	struct fMaterial { enum _ {
@@ -124,9 +124,9 @@
 		END
 	};};
-
+		
 	//
 	// API Types
 	//
-
+	
 	/* sRayCast		*/ 
 	struct sRayCast
@@ -135,7 +135,7 @@
 		eFeature::_	feature;	/// feature type
 		int			index;		/// feature index
-		btScalar	fraction;		/// time of impact fraction (rayorg+(rayto-rayfrom)*fraction)
-	};
-
+		btScalar	time;		/// time of impact (rayorg+raydir*time)
+	};
+	
 	/* ImplicitFn	*/ 
 	struct	ImplicitFn
@@ -143,5 +143,5 @@
 		virtual btScalar	Eval(const btVector3& x)=0;
 	};
-
+	
 	//
 	// Internal types
@@ -181,5 +181,5 @@
 		int						m_flags;		// Flags
 	};
-
+		
 	/* Feature		*/ 
 	struct	Feature : Element
@@ -297,5 +297,5 @@
 		btScalar					m_matching;
 		bool						m_collide;
-		Cluster() : m_leaf(0),m_ndamping(0),m_ldamping(0),m_adamping(0),m_matching(0) {}
+									Cluster() : m_leaf(0),m_ndamping(0),m_ldamping(0),m_adamping(0),m_matching(0) {}
 	};
 	/* Impulse		*/ 
@@ -308,17 +308,17 @@
 		Impulse() : m_velocity(0,0,0),m_drift(0,0,0),m_asVelocity(0),m_asDrift(0)	{}
 		Impulse						operator -() const
-		{
+			{
 			Impulse i=*this;
 			i.m_velocity=-i.m_velocity;
 			i.m_drift=-i.m_drift;
 			return(i);
-		}
+			}
 		Impulse						operator*(btScalar x) const
-		{
+			{
 			Impulse i=*this;
 			i.m_velocity*=x;
 			i.m_drift*=x;
 			return(i);
-		}
+			}
 	};
 	/* Body			*/ 
@@ -327,88 +327,88 @@
 		Cluster*		m_soft;
 		btRigidBody*				m_rigid;
-		Body() : m_soft(0),m_rigid(0)				{}
-		Body(Cluster* p) : m_soft(p),m_rigid(0)	{}
-		Body(btRigidBody* p) : m_soft(0),m_rigid(p)	{}
+									Body() : m_soft(0),m_rigid(0)				{}
+									Body(Cluster* p) : m_soft(p),m_rigid(0)	{}
+									Body(btRigidBody* p) : m_soft(0),m_rigid(p)	{}
 		void						activate() const
-		{
+			{
 			if(m_rigid) m_rigid->activate();
-		}
+			}
 		const btMatrix3x3&			invWorldInertia() const
-		{
+			{
 			static const btMatrix3x3	iwi(0,0,0,0,0,0,0,0,0);
 			if(m_rigid) return(m_rigid->getInvInertiaTensorWorld());
 			if(m_soft)	return(m_soft->m_invwi);
 			return(iwi);
-		}
+			}
 		btScalar					invMass() const
-		{
+			{
 			if(m_rigid) return(m_rigid->getInvMass());
 			if(m_soft)	return(m_soft->m_imass);
 			return(0);
-		}
+			}
 		const btTransform&			xform() const
-		{
+			{
 			static const btTransform	identity=btTransform::getIdentity();		
 			if(m_rigid) return(m_rigid->getInterpolationWorldTransform());
 			if(m_soft)	return(m_soft->m_framexform);
 			return(identity);
-		}
+			}
 		btVector3					linearVelocity() const
-		{
+			{
 			if(m_rigid) return(m_rigid->getLinearVelocity());
 			if(m_soft)	return(m_soft->m_lv);
 			return(btVector3(0,0,0));
-		}
+			}
 		btVector3					angularVelocity(const btVector3& rpos) const
-		{			
+			{			
 			if(m_rigid) return(cross(m_rigid->getAngularVelocity(),rpos));
 			if(m_soft)	return(cross(m_soft->m_av,rpos));
 			return(btVector3(0,0,0));
-		}
+			}
 		btVector3					angularVelocity() const
-		{			
+			{			
 			if(m_rigid) return(m_rigid->getAngularVelocity());
 			if(m_soft)	return(m_soft->m_av);
 			return(btVector3(0,0,0));
-		}
+			}
 		btVector3					velocity(const btVector3& rpos) const
-		{
+			{
 			return(linearVelocity()+angularVelocity(rpos));
-		}
+			}
 		void						applyVImpulse(const btVector3& impulse,const btVector3& rpos) const
-		{
+			{
 			if(m_rigid)	m_rigid->applyImpulse(impulse,rpos);
 			if(m_soft)	btSoftBody::clusterVImpulse(m_soft,rpos,impulse);
-		}
+			}
 		void						applyDImpulse(const btVector3& impulse,const btVector3& rpos) const
-		{
+			{
 			if(m_rigid)	m_rigid->applyImpulse(impulse,rpos);
 			if(m_soft)	btSoftBody::clusterDImpulse(m_soft,rpos,impulse);
-		}		
+			}		
 		void						applyImpulse(const Impulse& impulse,const btVector3& rpos) const
-		{
+			{
 			if(impulse.m_asVelocity)	applyVImpulse(impulse.m_velocity,rpos);
 			if(impulse.m_asDrift)		applyDImpulse(impulse.m_drift,rpos);
-		}
+			}
 		void						applyVAImpulse(const btVector3& impulse) const
-		{
+			{
 			if(m_rigid)	m_rigid->applyTorqueImpulse(impulse);
 			if(m_soft)	btSoftBody::clusterVAImpulse(m_soft,impulse);
-		}
+			}
 		void						applyDAImpulse(const btVector3& impulse) const
-		{
+			{
 			if(m_rigid)	m_rigid->applyTorqueImpulse(impulse);
 			if(m_soft)	btSoftBody::clusterDAImpulse(m_soft,impulse);
-		}
+			}
 		void						applyAImpulse(const Impulse& impulse) const
-		{
+			{
 			if(impulse.m_asVelocity)	applyVAImpulse(impulse.m_velocity);
 			if(impulse.m_asDrift)		applyDAImpulse(impulse.m_drift);
-		}
+			}
 		void						applyDCImpulse(const btVector3& impulse) const
-		{
+			{
 			if(m_rigid)	m_rigid->applyCentralImpulse(impulse);
 			if(m_soft)	btSoftBody::clusterDCImpulse(m_soft,impulse);
-		}
+			}
 	};
 	/* Joint		*/ 
@@ -421,10 +421,10 @@
 		};};
 		struct Specs
-		{
-			Specs() : erp(1),cfm(1),split(1) {}
+			{
+						Specs() : erp(1),cfm(1),split(1) {}
 			btScalar	erp;
 			btScalar	cfm;
 			btScalar	split;
-		};
+			};
 		Body						m_bodies[2];
 		btVector3					m_refs[2];
@@ -437,5 +437,5 @@
 		bool						m_delete;
 		virtual						~Joint() {}
-		Joint() : m_delete(false) {}
+									Joint() : m_delete(false) {}
 		virtual void				Prepare(btScalar dt,int iterations);
 		virtual void				Solve(btScalar dt,btScalar sor)=0;
@@ -447,7 +447,7 @@
 	{
 		struct Specs : Joint::Specs
-		{
+			{
 			btVector3	position;
-		};		
+			};		
 		btVector3					m_rpos[2];
 		void						Prepare(btScalar dt,int iterations);
@@ -460,15 +460,15 @@
 	{
 		struct IControl
-		{
+			{
 			virtual void			Prepare(AJoint*)				{}
 			virtual btScalar		Speed(AJoint*,btScalar current) { return(current); }
 			static IControl*		Default()						{ static IControl def;return(&def); }
-		};
+			};
 		struct Specs : Joint::Specs
-		{
-			Specs() : icontrol(IControl::Default()) {}
+			{
+						Specs() : icontrol(IControl::Default()) {}
 			btVector3	axis;
 			IControl*	icontrol;
-		};		
+			};		
 		btVector3					m_axis[2];
 		IControl*					m_icontrol;
@@ -533,24 +533,21 @@
 		btScalar				updmrg;			// Update margin
 	};	
-	/// RayFromToCaster takes a ray from, ray to (instead of direction!)
-	struct	RayFromToCaster : btDbvt::ICollide
-	{
-		btVector3			m_rayFrom;
-		btVector3			m_rayTo;
-		btVector3			m_rayNormalizedDirection;
-		btScalar			m_mint;
-		Face*				m_face;
-		int					m_tests;
-		RayFromToCaster(const btVector3& rayFrom,const btVector3& rayTo,btScalar mxt);
+	/* RayCaster	*/ 
+	struct	RayCaster : btDbvt::ICollide
+		{
+		btVector3			o;
+		btVector3			d;
+		btScalar			mint;
+		Face*	face;
+		int					tests;
+								RayCaster(const btVector3& org,const btVector3& dir,btScalar mxt);
 		void					Process(const btDbvtNode* leaf);
-
-		static inline btScalar	rayFromToTriangle(const btVector3& rayFrom,
-			const btVector3& rayTo,
-			const btVector3& rayNormalizedDirection,
-			const btVector3& a,
-			const btVector3& b,
-			const btVector3& c,
-			btScalar maxt=SIMD_INFINITY);
-	};
+		static inline btScalar	rayTriangle(const btVector3& org,
+											const btVector3& dir,
+											const btVector3& a,
+											const btVector3& b,
+											const btVector3& c,
+											btScalar maxt=SIMD_INFINITY);
+		};
 
 	//
@@ -598,13 +595,13 @@
 	btDbvt					m_cdbvt;		// Clusters tree
 	tClusterArray			m_clusters;		// Clusters
-
+		
 	//
 	// Api
 	//
-
+	
 	/* ctor																	*/ 
 	btSoftBody(	btSoftBodyWorldInfo* worldInfo,int node_count,
-		const btVector3* x,
-		const btScalar* m);
+				const btVector3* x,
+				const btScalar* m);
 	/* dtor																	*/ 
 	virtual ~btSoftBody();
@@ -626,28 +623,28 @@
 		int node1) const;
 	bool				checkLink(	const Node* node0,
-		const Node* node1) const;
+									const Node* node1) const;
 	/* Check for existring face												*/ 
 	bool				checkFace(	int node0,
-		int node1,
-		int node2) const;
+									int node1,
+									int node2) const;
 	/* Append material														*/ 
 	Material*			appendMaterial();
 	/* Append note															*/ 
 	void				appendNote(	const char* text,
-		const btVector3& o,
-		const btVector4& c=btVector4(1,0,0,0),
-		Node* n0=0,
-		Node* n1=0,
-		Node* n2=0,
-		Node* n3=0);
+									const btVector3& o,
+									const btVector4& c=btVector4(1,0,0,0),
+									Node* n0=0,
+									Node* n1=0,
+									Node* n2=0,
+									Node* n3=0);
 	void				appendNote(	const char* text,
-		const btVector3& o,
-		Node* feature);
+									const btVector3& o,
+									Node* feature);
 	void				appendNote(	const char* text,
-		const btVector3& o,
-		Link* feature);
+									const btVector3& o,
+									Link* feature);
 	void				appendNote(	const char* text,
-		const btVector3& o,
-		Face* feature);
+									const btVector3& o,
+									Face* feature);
 	/* Append node															*/ 
 	void				appendNode(	const btVector3& x,btScalar m);
@@ -655,20 +652,20 @@
 	void				appendLink(int model=-1,Material* mat=0);
 	void				appendLink(	int node0,
-		int node1,
-		Material* mat=0,
-		bool bcheckexist=false);
+									int node1,
+									Material* mat=0,
+									bool bcheckexist=false);
 	void				appendLink(	Node* node0,
-		Node* node1,
-		Material* mat=0,
-		bool bcheckexist=false);
+									Node* node1,
+									Material* mat=0,
+									bool bcheckexist=false);
 	/* Append face															*/ 
 	void				appendFace(int model=-1,Material* mat=0);
 	void				appendFace(	int node0,
-		int node1,
-		int node2,
-		Material* mat=0);
+									int node1,
+									int node2,
+									Material* mat=0);
 	/* Append anchor														*/ 
 	void				appendAnchor(	int node,
-		btRigidBody* body);
+										btRigidBody* body);
 	/* Append linear joint													*/ 
 	void				appendLinearJoint(const LJoint::Specs& specs,Cluster* body0,Body body1);
@@ -683,5 +680,5 @@
 	/* Add force (or gravity) to a node of the body							*/ 
 	void				addForce(		const btVector3& force,
-		int node);
+										int node);
 	/* Add velocity to the entire body										*/ 
 	void				addVelocity(	const btVector3& velocity);
@@ -692,8 +689,8 @@
 	/* Add velocity to a node of the body									*/ 
 	void				addVelocity(	const btVector3& velocity,
-		int node);
+										int node);
 	/* Set mass																*/ 
 	void				setMass(		int node,
-		btScalar mass);
+										btScalar mass);
 	/* Get mass																*/ 
 	btScalar			getMass(		int node) const;
@@ -702,5 +699,5 @@
 	/* Set total mass (weighted by previous masses)							*/ 
 	void				setTotalMass(	btScalar mass,
-		bool fromfaces=false);
+										bool fromfaces=false);
 	/* Set total density													*/ 
 	void				setTotalDensity(btScalar density);
@@ -715,5 +712,5 @@
 	/* Set current state as pose											*/ 
 	void				setPose(		bool bvolume,
-		bool bframe);
+										bool bframe);
 	/* Return the volume													*/ 
 	btScalar			getVolume() const;
@@ -735,5 +732,5 @@
 	/* Generate bending constraints based on distance in the adjency graph	*/ 
 	int					generateBendingConstraints(	int distance,
-		Material* mat=0);
+													Material* mat=0);
 	/* Randomize constraints to reduce solver bias							*/ 
 	void				randomizeConstraints();
@@ -748,9 +745,9 @@
 	bool				cutLink(int node0,int node1,btScalar position);
 	bool				cutLink(const Node* node0,const Node* node1,btScalar position);
-
-	///Ray casting using rayFrom and rayTo in worldspace, (not direction!)
-	bool				rayTest(const btVector3& rayFrom,
-		const btVector3& rayTo,
-		sRayCast& results);
+	/* Ray casting															*/ 
+	bool				rayCast(const btVector3& org,
+								const btVector3& dir,
+								sRayCast& results,
+								btScalar maxtime=SIMD_INFINITY);
 	/* Solver presets														*/ 
 	void				setSolver(eSolverPresets::_ preset);
@@ -770,9 +767,9 @@
 	void				defaultCollisionHandler(btCollisionObject* pco);
 	void				defaultCollisionHandler(btSoftBody* psb);
-
+		
 	//
 	// Cast
 	//
-
+		
 	static const btSoftBody*	upcast(const btCollisionObject* colObj)
 	{
@@ -802,7 +799,6 @@
 	void				pointersToIndices();
 	void				indicesToPointers(const int* map=0);
-
-	int					rayTest(const btVector3& rayFrom,const btVector3& rayTo,
-		btScalar& mint,eFeature::_& feature,int& index,bool bcountonly) const;
+	int					rayCast(const btVector3& org,const btVector3& dir,
+								btScalar& mint,eFeature::_& feature,int& index,bool bcountonly) const;
 	void				initializeFaceTree();
 	btVector3			evaluateCom() const;
@@ -827,5 +823,5 @@
 	static psolver_t	getSolver(ePSolver::_ solver);
 	static vsolver_t	getSolver(eVSolver::_ solver);
-
+	
 };
 
