_linearVelocity(0, 0, 0),
_angularVelocity(0, 0, 0),
_referenceTime(0),
+ _startTime(0),
_endTime(0),
_id(0)
{
_linearVelocity = transform._linearVelocity;
_angularVelocity = transform._angularVelocity;
_referenceTime = transform._referenceTime;
+ _startTime = transform._startTime;
_endTime = transform._endTime;
_id = transform._id;
invalidateParentBound();
SGSphered sphere(BVHGroup::computeBoundingSphere());
if (sphere.empty())
return sphere;
- SGVec3d centerStart = _toWorldReference.xformPt(sphere.getCenter());
+ SGMatrixd toWorldStart = getToWorldTransform(_startTime);
+ SGVec3d centerStart = toWorldStart.xformPt(sphere.getCenter());
SGMatrixd toWorldEnd = getToWorldTransform(_endTime);
SGVec3d centerEnd = toWorldEnd.xformPt(sphere.getCenter());
double rad = 0.5*length(centerStart - centerEnd) + sphere.getRadius();
const double& getReferenceTime() const
{ return _referenceTime; }
+ void setStartTime(const double& startTime)
+ { _startTime = startTime; }
+ const double& getStartTime() const
+ { return _startTime; }
+
void setEndTime(const double& endTime)
{ _endTime = endTime; }
const double& getEndTime() const
SGMatrixd getToWorldTransform(const double& t) const
{
- double dt = t - _referenceTime;
- if (0 == dt)
+ if (t == _referenceTime)
return _toWorldReference;
+ double dt = t - _referenceTime;
SGMatrixd matrix(_toWorldReference);
matrix.postMultRotate(SGQuatd::fromAngleAxis(dt*_angularVelocity));
matrix.postMultTranslate(dt*_linearVelocity);
}
SGMatrixd getToLocalTransform(const double& t) const
{
- double dt = _referenceTime - t;
- if (0 == dt)
+ if (t == _referenceTime)
return _toLocalReference;
+ double dt = _referenceTime - t;
SGMatrixd matrix(_toLocalReference);
matrix.preMultRotate(SGQuatd::fromAngleAxis(dt*_angularVelocity));
matrix.preMultTranslate(dt*_linearVelocity);
SGVec3d _angularVelocity;
double _referenceTime;
+ double _startTime;
double _endTime;
Id _id;
return;
SGSphered sphere = _sphere;
- _sphere = transform.sphereToLocal(sphere, transform.getReferenceTime());
+ _sphere = transform.sphereToLocal(sphere, transform.getStartTime());
_sphere.expandBy(transform.sphereToLocal(sphere, transform.getEndTime()));
NodeList parentNodeList;