|
@@ -54,7 +54,6 @@ extern const char* PHYSICS_CATEGORY;
|
|
|
|
|
|
|
|
Constraint::Constraint(Context* context) :
|
|
Constraint::Constraint(Context* context) :
|
|
|
Component(context),
|
|
Component(context),
|
|
|
- constraint_(0),
|
|
|
|
|
constraintType_(CONSTRAINT_POINT),
|
|
constraintType_(CONSTRAINT_POINT),
|
|
|
position_(Vector3::ZERO),
|
|
position_(Vector3::ZERO),
|
|
|
rotation_(Quaternion::IDENTITY),
|
|
rotation_(Quaternion::IDENTITY),
|
|
@@ -167,7 +166,7 @@ void Constraint::DrawDebugGeometry(DebugRenderer* debug, bool depthTest)
|
|
|
{
|
|
{
|
|
|
physicsWorld_->SetDebugRenderer(debug);
|
|
physicsWorld_->SetDebugRenderer(debug);
|
|
|
physicsWorld_->SetDebugDepthTest(depthTest);
|
|
physicsWorld_->SetDebugDepthTest(depthTest);
|
|
|
- physicsWorld_->GetWorld()->debugDrawConstraint(constraint_);
|
|
|
|
|
|
|
+ physicsWorld_->GetWorld()->debugDrawConstraint(constraint_.Get());
|
|
|
physicsWorld_->SetDebugRenderer(0);
|
|
physicsWorld_->SetDebugRenderer(0);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -380,10 +379,9 @@ void Constraint::ReleaseConstraint()
|
|
|
otherBody_->RemoveConstraint(this);
|
|
otherBody_->RemoveConstraint(this);
|
|
|
|
|
|
|
|
if (physicsWorld_)
|
|
if (physicsWorld_)
|
|
|
- physicsWorld_->GetWorld()->removeConstraint(constraint_);
|
|
|
|
|
|
|
+ physicsWorld_->GetWorld()->removeConstraint(constraint_.Get());
|
|
|
|
|
|
|
|
- delete constraint_;
|
|
|
|
|
- constraint_ = 0;
|
|
|
|
|
|
|
+ constraint_.Reset();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -402,7 +400,7 @@ void Constraint::ApplyFrames()
|
|
|
{
|
|
{
|
|
|
case POINT2POINT_CONSTRAINT_TYPE:
|
|
case POINT2POINT_CONSTRAINT_TYPE:
|
|
|
{
|
|
{
|
|
|
- btPoint2PointConstraint* pointConstraint = static_cast<btPoint2PointConstraint*>(constraint_);
|
|
|
|
|
|
|
+ btPoint2PointConstraint* pointConstraint = static_cast<btPoint2PointConstraint*>(constraint_.Get());
|
|
|
pointConstraint->setPivotA(ToBtVector3(ownBodyScaledPosition));
|
|
pointConstraint->setPivotA(ToBtVector3(ownBodyScaledPosition));
|
|
|
pointConstraint->setPivotB(ToBtVector3(otherBodyScaledPosition));
|
|
pointConstraint->setPivotB(ToBtVector3(otherBodyScaledPosition));
|
|
|
}
|
|
}
|
|
@@ -410,7 +408,7 @@ void Constraint::ApplyFrames()
|
|
|
|
|
|
|
|
case HINGE_CONSTRAINT_TYPE:
|
|
case HINGE_CONSTRAINT_TYPE:
|
|
|
{
|
|
{
|
|
|
- btHingeConstraint* hingeConstraint = static_cast<btHingeConstraint*>(constraint_);
|
|
|
|
|
|
|
+ btHingeConstraint* hingeConstraint = static_cast<btHingeConstraint*>(constraint_.Get());
|
|
|
btTransform ownFrame(ToBtQuaternion(rotation_), ToBtVector3(ownBodyScaledPosition));
|
|
btTransform ownFrame(ToBtQuaternion(rotation_), ToBtVector3(ownBodyScaledPosition));
|
|
|
btTransform otherFrame(ToBtQuaternion(otherRotation_), ToBtVector3(otherBodyScaledPosition));
|
|
btTransform otherFrame(ToBtQuaternion(otherRotation_), ToBtVector3(otherBodyScaledPosition));
|
|
|
hingeConstraint->setFrames(ownFrame, otherFrame);
|
|
hingeConstraint->setFrames(ownFrame, otherFrame);
|
|
@@ -419,7 +417,7 @@ void Constraint::ApplyFrames()
|
|
|
|
|
|
|
|
case SLIDER_CONSTRAINT_TYPE:
|
|
case SLIDER_CONSTRAINT_TYPE:
|
|
|
{
|
|
{
|
|
|
- btSliderConstraint* sliderConstraint = static_cast<btSliderConstraint*>(constraint_);
|
|
|
|
|
|
|
+ btSliderConstraint* sliderConstraint = static_cast<btSliderConstraint*>(constraint_.Get());
|
|
|
btTransform ownFrame(ToBtQuaternion(rotation_), ToBtVector3(ownBodyScaledPosition));
|
|
btTransform ownFrame(ToBtQuaternion(rotation_), ToBtVector3(ownBodyScaledPosition));
|
|
|
btTransform otherFrame(ToBtQuaternion(otherRotation_), ToBtVector3(otherBodyScaledPosition));
|
|
btTransform otherFrame(ToBtQuaternion(otherRotation_), ToBtVector3(otherBodyScaledPosition));
|
|
|
sliderConstraint->setFrames(ownFrame, otherFrame);
|
|
sliderConstraint->setFrames(ownFrame, otherFrame);
|
|
@@ -428,7 +426,7 @@ void Constraint::ApplyFrames()
|
|
|
|
|
|
|
|
case CONETWIST_CONSTRAINT_TYPE:
|
|
case CONETWIST_CONSTRAINT_TYPE:
|
|
|
{
|
|
{
|
|
|
- btConeTwistConstraint* coneTwistConstraint = static_cast<btConeTwistConstraint*>(constraint_);
|
|
|
|
|
|
|
+ btConeTwistConstraint* coneTwistConstraint = static_cast<btConeTwistConstraint*>(constraint_.Get());
|
|
|
btTransform ownFrame(ToBtQuaternion(rotation_), ToBtVector3(ownBodyScaledPosition));
|
|
btTransform ownFrame(ToBtQuaternion(rotation_), ToBtVector3(ownBodyScaledPosition));
|
|
|
btTransform otherFrame(ToBtQuaternion(otherRotation_), ToBtVector3(otherBodyScaledPosition));
|
|
btTransform otherFrame(ToBtQuaternion(otherRotation_), ToBtVector3(otherBodyScaledPosition));
|
|
|
coneTwistConstraint->setFrames(ownFrame, otherFrame);
|
|
coneTwistConstraint->setFrames(ownFrame, otherFrame);
|
|
@@ -555,7 +553,7 @@ void Constraint::CreateConstraint()
|
|
|
|
|
|
|
|
ApplyLimits();
|
|
ApplyLimits();
|
|
|
|
|
|
|
|
- physicsWorld_->GetWorld()->addConstraint(constraint_, disableCollision_);
|
|
|
|
|
|
|
+ physicsWorld_->GetWorld()->addConstraint(constraint_.Get(), disableCollision_);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
recreateConstraint_ = false;
|
|
recreateConstraint_ = false;
|
|
@@ -572,14 +570,14 @@ void Constraint::ApplyLimits()
|
|
|
{
|
|
{
|
|
|
case HINGE_CONSTRAINT_TYPE:
|
|
case HINGE_CONSTRAINT_TYPE:
|
|
|
{
|
|
{
|
|
|
- btHingeConstraint* hingeConstraint = static_cast<btHingeConstraint*>(constraint_);
|
|
|
|
|
|
|
+ btHingeConstraint* hingeConstraint = static_cast<btHingeConstraint*>(constraint_.Get());
|
|
|
hingeConstraint->setLimit(lowLimit_.x_ * M_DEGTORAD, highLimit_.x_ * M_DEGTORAD);
|
|
hingeConstraint->setLimit(lowLimit_.x_ * M_DEGTORAD, highLimit_.x_ * M_DEGTORAD);
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
case SLIDER_CONSTRAINT_TYPE:
|
|
case SLIDER_CONSTRAINT_TYPE:
|
|
|
{
|
|
{
|
|
|
- btSliderConstraint* sliderConstraint = static_cast<btSliderConstraint*>(constraint_);
|
|
|
|
|
|
|
+ btSliderConstraint* sliderConstraint = static_cast<btSliderConstraint*>(constraint_.Get());
|
|
|
sliderConstraint->setUpperLinLimit(highLimit_.x_);
|
|
sliderConstraint->setUpperLinLimit(highLimit_.x_);
|
|
|
sliderConstraint->setUpperAngLimit(highLimit_.y_ * M_DEGTORAD);
|
|
sliderConstraint->setUpperAngLimit(highLimit_.y_ * M_DEGTORAD);
|
|
|
sliderConstraint->setLowerLinLimit(lowLimit_.x_);
|
|
sliderConstraint->setLowerLinLimit(lowLimit_.x_);
|
|
@@ -589,7 +587,7 @@ void Constraint::ApplyLimits()
|
|
|
|
|
|
|
|
case CONETWIST_CONSTRAINT_TYPE:
|
|
case CONETWIST_CONSTRAINT_TYPE:
|
|
|
{
|
|
{
|
|
|
- btConeTwistConstraint* coneTwistConstraint = static_cast<btConeTwistConstraint*>(constraint_);
|
|
|
|
|
|
|
+ btConeTwistConstraint* coneTwistConstraint = static_cast<btConeTwistConstraint*>(constraint_.Get());
|
|
|
coneTwistConstraint->setLimit(highLimit_.y_ * M_DEGTORAD, highLimit_.y_ * M_DEGTORAD, highLimit_.x_ * M_DEGTORAD);
|
|
coneTwistConstraint->setLimit(highLimit_.y_ * M_DEGTORAD, highLimit_.y_ * M_DEGTORAD, highLimit_.x_ * M_DEGTORAD);
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|