コード例 #1
0
ファイル: Strand.cpp プロジェクト: mlsteele/FlightGame
// Private helper function
void Strand::InfluencePair(Pushable* A, Pushable* B, bool viscize) {
	float k;
	V3D<float> diffp = B->Pos - A->Pos;
	V3D<float> force;
	
	// F [varies with] k*x
	k = .012; // Spring Constant
	float x = diffp.Length() - MiniTargL();
	force = diffp.Normalized()*x*k;
	A->PushGlobal(force);
	B->PushGlobal(-force);
	
	// Viscosity
	if (viscize) {
		k = .015; // Viscosity Constant
		V3D<float> diffvel = B->Vel - A->Vel;
		force = diffvel*k;
		A->PushGlobal(force);
		B->PushGlobal(-force);
	}
}