float CPhysicsObject::GetSphereRadius()
{
	if ( m_collideType != COLLIDE_BALL )
		return 0;

	return ConvertDistanceToHL( m_pObject->to_ball()->get_radius() );
}
float CPhysicsObject::GetSphereRadius() const {
	btCollisionShape *shape = m_pObject->getCollisionShape();
	if (shape->getShapeType() != SPHERE_SHAPE_PROXYTYPE)
		return 0;

	btSphereShape *sphere = (btSphereShape *)shape;
	return ConvertDistanceToHL(sphere->getRadius());
}
void CPhysicsObject::GetSleepThresholds(float *linVel, float *angVel) const {
	if (linVel) {
		*linVel = ConvertDistanceToHL(m_pObject->getLinearSleepingThreshold());
	}

	if (angVel) {
		*angVel = RAD2DEG(m_pObject->getAngularSleepingThreshold());
	}
}
void ConvertShadowControllerToHL( const shadowcontrol_params_t &in, hlshadowcontrol_params_t &out )
{
	ConvertPositionToHL( in.targetPosition, out.targetPosition );
	ConvertRotationToHL( in.targetRotation, out.targetRotation );
	out.teleportDistance = ConvertDistanceToHL( in.teleportDistance );

	ConvertForceImpulseToHL( in.maxSpeed, out.maxSpeed);
	VectorAbs( out.maxSpeed, out.maxSpeed );
	ConvertAngularImpulseToHL( in.maxAngular, out.maxAngular );
	VectorAbs( out.maxAngular, out.maxAngular );
	out.dampFactor = in.dampFactor;
}
Beispiel #5
0
CTraceIVP::CTraceIVP( const IVP_Compact_Surface *pSurface, const Vector &origin, const QAngle &angles, CPhysicsTrace &traceapi )
					 : m_traceapi(traceapi)
{
	m_pSurface = pSurface;
	m_pLedge = NULL;

	ConvertRotationToIVP( angles, m_matrix );
	ConvertPositionToIVP( origin, m_matrix.vv );
	// UNDONE: Move this offset calculation into the tracing routines
	// I didn't do this now because it seems to require changes to most of the
	// transform routines - and this would cause bugs.
	
	float centerOffset = VectorLength( m_pSurface->mass_center.k );
	m_radius = ConvertDistanceToHL( m_pSurface->upper_limit_radius + centerOffset );
}
    virtual void event_post_collision( IVP_Event_Collision *pEvent )
	{
		// didn't call preCollision, so don't call postCollision
		if ( !m_event.isCollision && !m_event.isShadowCollision )
			return;

		IVP_Contact_Situation *contact = pEvent->contact_situation;

		float collisionSpeed = contact->speed.dot_product(&contact->surf_normal);
		m_event.collisionSpeed = ConvertDistanceToHL( fabs(collisionSpeed) );
		CPhysicsCollisionData data(contact);
		m_event.pInternalData = &data;

		m_pCallback->PostCollision( &m_event );
	}
void CPhysicsSpring::WriteToTemplate( vphysics_save_cphysicsspring_t &params )
{
	params.constant = m_pSpring->get_constant();
	params.naturalLength = ConvertDistanceToHL( m_pSpring->get_spring_length_zero_force() );
	params.damping = m_pSpring->get_damp_factor();
	params.relativeDamping = m_pSpring->get_rel_pos_damp();

	const IVP_Anchor *anchor0 = m_pSpring->get_actuator_anchor(0);
	ConvertPositionToHL( anchor0->object_pos, params.startPosition );
	const IVP_Anchor *anchor1 = m_pSpring->get_actuator_anchor(1);
	ConvertPositionToHL( anchor1->object_pos, params.endPosition );
	params.useLocalPositions = true;

	params.onlyStretch = m_pSpring->get_only_stretch() ? true : false;
	params.pObjStart = m_pObjStart;
	params.pObjEnd = m_pObjEnd;
}
float CShadowController::GetTeleportDistance() {
	return ConvertDistanceToHL(m_shadow.teleportDistance);
}