RigidBody constructor
RigidBody({})
Implementation
RigidBody({
Vec3? position,
Quat? orientation,
List<Shape>? shapes,
String? name,
this.type = RigidBodyType.static,
this.allowSleep = true,
bool isSleeping = false,
bool adjustPosition = true,
Vec3? linearVelocity,
Vec3? angularVelocity,
double? mass,
this.isTrigger = false
}){
this.position = position ?? Vec3();
this.orientation = orientation ?? Quat();
this.linearVelocity = linearVelocity ?? Vec3();
this.angularVelocity = angularVelocity ?? Vec3();
initAngularVelocity = Vec3().copy(this.angularVelocity);
initLinearVelocity = Vec3().copy(this.linearVelocity);
initPosition = Vec3().copy(this.position);
initOrientation = Quat().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(Vec3(),adjustPosition);
}
if(isDynamic){
if(isSleeping){
sleep();
}
else{
awake();
}
}
}