19 TypeHandle LinearCylinderVortexForce::_type_handle;
26 PN_stdfloat a,
bool md) :
28 _radius(radius), _length(length), _coef(coef) {
37 _radius = copy._radius;
38 _length = copy._length;
60 LVector3 LinearCylinderVortexForce::
65 LVector3 force_vec(0.0f, 0.0f, 0.0f);
71 if (point[2] < 0.0f || point[2] > _length)
75 PN_stdfloat x_squared = point[0] * point[0];
76 PN_stdfloat y_squared = point[1] * point[1];
77 PN_stdfloat dist_squared = x_squared + y_squared;
78 PN_stdfloat radius_squared = _radius * _radius;
82 if (dist_squared > radius_squared)
85 if IS_NEARLY_ZERO(dist_squared)
88 PN_stdfloat r = csqrt(dist_squared);
93 LVector3 tangential = point;
95 tangential.normalize();
96 tangential = tangential.cross(LVector3(0,0,1));
98 LVector3 centripetal = -point;
99 centripetal[2] = 0.0f;
100 centripetal.normalize();
102 LVector3 combined = tangential + centripetal;
103 combined.normalize();
108 centripetal = combined * _coef * po->
get_velocity().length();
120 output(std::ostream &out)
const {
122 out<<
"LinearCylinderVortexForce";
132 out.width(
indent); out<<
""; out<<
"LinearCylinderVortexForce:\n";