mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 11:50:39 +02:00
spacing fixes in Avatar class
This commit is contained in:
parent
be37237b84
commit
8370fd2d19
1 changed files with 20 additions and 23 deletions
|
@ -563,26 +563,26 @@ glm::vec3 Avatar::getBodyUpDirection() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is a workspace for testing avatar body collision detection and response
|
// This is a workspace for testing avatar body collision detection and response
|
||||||
void Avatar::updateAvatarCollisionDetectionAndResponse
|
void Avatar::updateAvatarCollisionDetectionAndResponse(glm::vec3 collisionPosition,
|
||||||
( glm::vec3 collisionPosition, float collisionGirth, float collisionHeight, glm::vec3 collisionUpVector, float deltaTime ) {
|
float collisionGirth,
|
||||||
|
float collisionHeight,
|
||||||
|
glm::vec3 collisionUpVector,
|
||||||
|
float deltaTime) {
|
||||||
|
|
||||||
float myBodyApproximateBoundingRadius = 1.0f;
|
float myBodyApproximateBoundingRadius = 1.0f;
|
||||||
glm::vec3 vectorFromMyBodyToBigSphere(_position - collisionPosition);
|
glm::vec3 vectorFromMyBodyToBigSphere(_position - collisionPosition);
|
||||||
bool jointCollision = false;
|
bool jointCollision = false;
|
||||||
|
|
||||||
float distanceToBigSphere = glm::length(vectorFromMyBodyToBigSphere);
|
float distanceToBigSphere = glm::length(vectorFromMyBodyToBigSphere);
|
||||||
if ( distanceToBigSphere < myBodyApproximateBoundingRadius + collisionGirth )
|
if ( distanceToBigSphere < myBodyApproximateBoundingRadius + collisionGirth ) {
|
||||||
{
|
for (int b = 0; b < NUM_AVATAR_BONES; b++) {
|
||||||
for (int b=0; b<NUM_AVATAR_BONES; b++)
|
|
||||||
{
|
|
||||||
glm::vec3 vectorFromJointToBigSphereCenter(_bone[b].springyPosition - collisionPosition);
|
glm::vec3 vectorFromJointToBigSphereCenter(_bone[b].springyPosition - collisionPosition);
|
||||||
float distanceToBigSphereCenter = glm::length(vectorFromJointToBigSphereCenter);
|
float distanceToBigSphereCenter = glm::length(vectorFromJointToBigSphereCenter);
|
||||||
float combinedRadius = _bone[b].radius + collisionGirth;
|
float combinedRadius = _bone[b].radius + collisionGirth;
|
||||||
if ( distanceToBigSphereCenter < combinedRadius )
|
|
||||||
{
|
if ( distanceToBigSphereCenter < combinedRadius ) {
|
||||||
jointCollision = true;
|
jointCollision = true;
|
||||||
if (distanceToBigSphereCenter > 0.0)
|
if (distanceToBigSphereCenter > 0.0) {
|
||||||
{
|
|
||||||
glm::vec3 directionVector = vectorFromJointToBigSphereCenter / distanceToBigSphereCenter;
|
glm::vec3 directionVector = vectorFromJointToBigSphereCenter / distanceToBigSphereCenter;
|
||||||
|
|
||||||
float penetration = 1.0 - (distanceToBigSphereCenter / combinedRadius);
|
float penetration = 1.0 - (distanceToBigSphereCenter / combinedRadius);
|
||||||
|
@ -1182,12 +1182,9 @@ void Avatar::renderBody() {
|
||||||
// if the hand is grasping, show it...
|
// if the hand is grasping, show it...
|
||||||
if (( _usingBodySprings ) && ( _handState == 1 )) {
|
if (( _usingBodySprings ) && ( _handState == 1 )) {
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef
|
glTranslatef(_bone[ AVATAR_BONE_RIGHT_HAND ].springyPosition.x,
|
||||||
(
|
|
||||||
_bone[ AVATAR_BONE_RIGHT_HAND ].springyPosition.x,
|
|
||||||
_bone[ AVATAR_BONE_RIGHT_HAND ].springyPosition.y,
|
_bone[ AVATAR_BONE_RIGHT_HAND ].springyPosition.y,
|
||||||
_bone[ AVATAR_BONE_RIGHT_HAND ].springyPosition.z
|
_bone[ AVATAR_BONE_RIGHT_HAND ].springyPosition.z);
|
||||||
);
|
|
||||||
glColor4f( 1.0, 1.0, 0.8, 0.3 ); glutSolidSphere( 0.020f, 10.0f, 10.0f );
|
glColor4f( 1.0, 1.0, 0.8, 0.3 ); glutSolidSphere( 0.020f, 10.0f, 10.0f );
|
||||||
glColor4f( 1.0, 1.0, 0.4, 0.2 ); glutSolidSphere( 0.025f, 10.0f, 10.0f );
|
glColor4f( 1.0, 1.0, 0.4, 0.2 ); glutSolidSphere( 0.025f, 10.0f, 10.0f );
|
||||||
glColor4f( 1.0, 1.0, 0.2, 0.1 ); glutSolidSphere( 0.030f, 10.0f, 10.0f );
|
glColor4f( 1.0, 1.0, 0.2, 0.1 ); glutSolidSphere( 0.030f, 10.0f, 10.0f );
|
||||||
|
|
Loading…
Reference in a new issue