RigidBody constructor
RigidBody({})
Implementation
RigidBody({
Vector3? position,
Quaternion? orientation,
List<Shape>? shapes,
String? name,
this.type = RigidBodyType.static,
this.allowSleep = true,
bool isSleeping = false,
bool adjustPosition = true,
Vector3? linearVelocity,
Vector3? angularVelocity,
double? mass,
this.isTrigger = false
}){
this.position = position ?? Vector3.zero();
this.orientation = orientation ?? Quaternion(0,0,0,1);
this.linearVelocity = linearVelocity ?? Vector3.zero();
this.angularVelocity = angularVelocity ?? Vector3.zero();
initAngularVelocity = Vector3.copy(this.angularVelocity);
initLinearVelocity = Vector3.copy(this.linearVelocity);
initPosition = Vector3.copy(this.position);
initOrientation = Quaternion.copy(this.orientation);
//type = config.type;
if(shapes!= null && shapes.isNotEmpty){
for(int i = 0; i < shapes.length;i++){
addShape(shapes[i]);
}
}
id = RigidBody.idCounter++;
this.name = name ?? id.toString();
if(isKinematic){
allowSleep = false;
}
if(mass == null || mass == 0){
setupMass(adjustPosition);
}
else{
this.mass = mass;
type = RigidBodyType.static == type?RigidBodyType.dynamic:type;
setupInertia(Vector3.zero(),adjustPosition);
}
if(isDynamic){
if(isSleeping){
sleep();
}
else{
awake();
}
}
}