예제 #1
0
void CPhysicsObject::ApplyForceOffset(const Vector& forceVector, const Vector& worldPosition) {
	Vector local;
	WorldToLocal(&local, worldPosition);
	btVector3 force, offset;
	ConvertForceImpulseToBull(forceVector, force);
	ConvertPosToBull(local, offset);
	m_pObject->applyForce(force, offset);
}
예제 #2
0
void ConvertShadowControllerToBull(const hlshadowcontrol_params_t &in, shadowcontrol_params_t &out) {
	ConvertPosToBull(in.targetPosition, out.targetPosition);
	ConvertRotationToBull(in.targetRotation, out.targetRotation);
	out.teleportDistance = ConvertDistanceToBull(in.teleportDistance);

	ConvertForceImpulseToBull(in.maxSpeed, out.maxSpeed);
	out.maxSpeed = out.maxSpeed.absolute();
	ConvertAngularImpulseToBull(in.maxAngular, out.maxAngular);
	out.maxAngular = out.maxAngular.absolute();
	out.dampFactor = in.dampFactor;
}
예제 #3
0
void CPhysicsObject::ApplyForceCenter(const Vector &forceVector) {
	if (!IsMoveable() || !IsMotionEnabled()) {
		return;
	}
	Wake();

	// forceVector is in kg*in/s*time
	// bullet takes forces in newtons, aka kg*m/s*time

	btVector3 force;
	ConvertForceImpulseToBull(forceVector, force);
	m_pObject->applyCentralImpulse(force);
}
예제 #4
0
void CPhysicsObject::ApplyForceOffset(const Vector &forceVector, const Vector &worldPosition) {
	if (!IsMoveable() || !IsMotionEnabled()) {
		return;
	}
	Wake();

	Vector local;
	WorldToLocal(&local, worldPosition);

	btVector3 force, offset;
	ConvertForceImpulseToBull(forceVector, force);
	ConvertPosToBull(local, offset);
	m_pObject->applyImpulse(force, offset);
	Wake();
}
예제 #5
0
// Output passed to ApplyForceCenter/ApplyTorqueCenter
void CPhysicsObject::CalculateForceOffset(const Vector &forceVector, const Vector &worldPosition, Vector *centerForce, AngularImpulse *centerTorque) const {
	if (!centerForce && !centerTorque) return;

	btVector3 pos, force;
	ConvertPosToBull(worldPosition, pos);
	ConvertForceImpulseToBull(forceVector, force);

	pos = pos - m_pObject->getWorldTransform().getOrigin();

	btVector3 cross = pos.cross(force);

	if (centerForce) {
		ConvertForceImpulseToHL(force, *centerForce);
	}

	if (centerTorque) {
		ConvertAngularImpulseToHL(cross, *centerTorque);
	}
}
예제 #6
0
// Thrusters call this and pass output to AddVelocity
void CPhysicsObject::CalculateVelocityOffset(const Vector &forceVector, const Vector &worldPosition, Vector *centerVelocity, AngularImpulse *centerAngularVelocity) const {
	if (!centerVelocity && !centerAngularVelocity) return;

	btVector3 force, pos;
	ConvertForceImpulseToBull(forceVector, force);
	ConvertPosToBull(worldPosition, pos);

	pos = pos - m_pObject->getWorldTransform().getOrigin();

	btVector3 cross = pos.cross(force);

	// cross.set_pairwise_mult( &cross, core->get_inv_rot_inertia());

	// Linear velocity
	if (centerVelocity) {
		force *= m_pObject->getInvMass();
		ConvertForceImpulseToHL(force, *centerVelocity);
	}

	if (centerAngularVelocity) {
		ConvertAngularImpulseToHL(cross, *centerAngularVelocity);
	}
}
예제 #7
0
void CPhysicsObject::ApplyForceCenter(const Vector& forceVector) {
	btVector3 force;
	ConvertForceImpulseToBull(forceVector, force);
	m_pObject->applyCentralForce(force);
}