From 253154ce6d45daf0460b3548cf7b64a1141e4ee6 Mon Sep 17 00:00:00 2001 From: Jeffrey Ventrella Date: Wed, 7 Aug 2013 10:17:53 -0700 Subject: [PATCH 1/3] fixed mohawk physics bug --- interface/src/Application.cpp | 4 ++-- interface/src/BendyLine.cpp | 2 +- interface/src/avatar/Head.cpp | 15 +++++++++------ interface/src/avatar/Head.h | 3 ++- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 52e6c984ea..5bde58a302 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2681,7 +2681,7 @@ void Application::updateAvatar(float deltaTime) { // If I'm in paint mode, send a voxel out to VOXEL server nodes. if (_paintOn) { - + glm::vec3 avatarPos = _myAvatar.getPosition(); // For some reason, we don't want to flip X and Z here. @@ -2692,7 +2692,7 @@ void Application::updateAvatar(float deltaTime) { if (_paintingVoxel.x >= 0.0 && _paintingVoxel.x <= 1.0 && _paintingVoxel.y >= 0.0 && _paintingVoxel.y <= 1.0 && _paintingVoxel.z >= 0.0 && _paintingVoxel.z <= 1.0) { - + PACKET_TYPE message = (_destructiveAddVoxel->isChecked() ? PACKET_TYPE_SET_VOXEL_DESTRUCTIVE : PACKET_TYPE_SET_VOXEL); sendVoxelEditMessage(message, _paintingVoxel); diff --git a/interface/src/BendyLine.cpp b/interface/src/BendyLine.cpp index ef5bd5f18d..8aca07dfac 100644 --- a/interface/src/BendyLine.cpp +++ b/interface/src/BendyLine.cpp @@ -24,7 +24,7 @@ BendyLine::BendyLine(){ _gravityForce = glm::vec3(0.0f, 0.0f, 0.0f); _basePosition = glm::vec3(0.0f, 0.0f, 0.0f); - _baseDirection = glm::vec3(0.0f, 0.0f, 0.0f); + _baseDirection = glm::vec3(0.0f, 1.0f, 0.0f); _midPosition = glm::vec3(0.0f, 0.0f, 0.0f); _endPosition = glm::vec3(0.0f, 0.0f, 0.0f); _midVelocity = glm::vec3(0.0f, 0.0f, 0.0f); diff --git a/interface/src/avatar/Head.cpp b/interface/src/avatar/Head.cpp index b88802b7f1..c74f06f9f0 100644 --- a/interface/src/avatar/Head.cpp +++ b/interface/src/avatar/Head.cpp @@ -30,10 +30,12 @@ const float MINIMUM_EYE_ROTATION_DOT = 0.5f; // based on a dot product: 1.0 is const float EYEBALL_RADIUS = 0.017; const float EYELID_RADIUS = 0.019; const float EYEBALL_COLOR[3] = { 0.9f, 0.9f, 0.8f }; -const float HAIR_SPRING_FORCE = 7.0f; -const float HAIR_TORQUE_FORCE = 0.1f; -const float HAIR_GRAVITY_FORCE = 0.02f; + +const float HAIR_SPRING_FORCE = 15.0f; +const float HAIR_TORQUE_FORCE = 0.2f; +const float HAIR_GRAVITY_FORCE = 0.001f; const float HAIR_DRAG = 10.0f; + const float HAIR_LENGTH = 0.09f; const float HAIR_THICKNESS = 0.03f; const float NOSE_LENGTH = 0.025; @@ -73,9 +75,10 @@ Head::Head(Avatar* owningAvatar) : _audioAttack(0.0f), _returnSpringScale(1.0f), _bodyRotation(0.0f, 0.0f, 0.0f), + _hairInitialized(false), _renderLookatVectors(false), _mohawkTriangleFan(NULL), - _mohawkColors(NULL), + _mohawkColors(NULL), _saccade(0.0f, 0.0f, 0.0f), _saccadeTarget(0.0f, 0.0f, 0.0f), _leftEyeBlink(0.0f), @@ -128,7 +131,6 @@ void Head::reset() { } void Head::resetHairPhysics() { - //glm::vec3 up = getUpDirection(); for (int t = 0; t < NUM_HAIR_TUFTS; t ++) { for (int t = 0; t < NUM_HAIR_TUFTS; t ++) { @@ -334,7 +336,7 @@ void Head::setScale (float scale) { delete[] _mohawkColors; createMohawk(); - resetHairPhysics(); + //resetHairPhysics(); } void Head::createMohawk() { @@ -737,6 +739,7 @@ void Head::renderLookatVectors(glm::vec3 leftEyePosition, glm::vec3 rightEyePosi } void Head::updateHairPhysics(float deltaTime) { + glm::quat orientation = getOrientation(); glm::vec3 up = orientation * IDENTITY_UP; glm::vec3 front = orientation * IDENTITY_FRONT; diff --git a/interface/src/avatar/Head.h b/interface/src/avatar/Head.h index 1256b05bb7..a848e566f4 100644 --- a/interface/src/avatar/Head.h +++ b/interface/src/avatar/Head.h @@ -112,7 +112,8 @@ private: float _returnSpringScale; //strength of return springs glm::vec3 _bodyRotation; bool _renderLookatVectors; - BendyLine _hairTuft[NUM_HAIR_TUFTS]; + BendyLine _hairTuft[NUM_HAIR_TUFTS]; + bool _hairInitialized; glm::vec3* _mohawkTriangleFan; glm::vec3* _mohawkColors; glm::vec3 _saccade; From 6997d0174acf48235b50b4b560cb3dd1e3ce586c Mon Sep 17 00:00:00 2001 From: Jeffrey Ventrella Date: Wed, 7 Aug 2013 10:24:21 -0700 Subject: [PATCH 2/3] clean up in mohawk code --- interface/src/avatar/Head.cpp | 10 ++++++++-- interface/src/avatar/Head.h | 1 - 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/interface/src/avatar/Head.cpp b/interface/src/avatar/Head.cpp index 0cff0c45b7..1f6f4159f6 100644 --- a/interface/src/avatar/Head.cpp +++ b/interface/src/avatar/Head.cpp @@ -75,7 +75,6 @@ Head::Head(Avatar* owningAvatar) : _audioAttack(0.0f), _returnSpringScale(1.0f), _bodyRotation(0.0f, 0.0f, 0.0f), - _hairInitialized(false), _renderLookatVectors(false), _mohawkTriangleFan(NULL), _mohawkColors(NULL), @@ -335,10 +334,17 @@ void Head::setScale (float scale) { delete[] _mohawkTriangleFan; delete[] _mohawkColors; createMohawk(); + + if (USING_PHYSICAL_MOHAWK) { + for (int t = 0; t < NUM_HAIR_TUFTS; t ++) { - //resetHairPhysics(); + _hairTuft[t].setLength (_scale * HAIR_LENGTH ); + _hairTuft[t].setThickness(_scale * HAIR_THICKNESS); + } + } } + void Head::createMohawk() { uint16_t nodeId = UNKNOWN_NODE_ID; if (_owningAvatar->getOwningNode()) { diff --git a/interface/src/avatar/Head.h b/interface/src/avatar/Head.h index 3a6f6d4d90..60fc2864ed 100644 --- a/interface/src/avatar/Head.h +++ b/interface/src/avatar/Head.h @@ -115,7 +115,6 @@ private: glm::vec3 _bodyRotation; bool _renderLookatVectors; BendyLine _hairTuft[NUM_HAIR_TUFTS]; - bool _hairInitialized; glm::vec3* _mohawkTriangleFan; glm::vec3* _mohawkColors; glm::vec3 _saccade; From ccf3498ae5f1c8ab063e829c9f8706f36ff0c094 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Wed, 7 Aug 2013 11:11:03 -0700 Subject: [PATCH 3/3] quick fix crash in parseVoxelStats() --- interface/src/Application.cpp | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 19b889a918..1f06eef04e 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3953,24 +3953,27 @@ int Application::parseVoxelStats(unsigned char* messageData, ssize_t messageLeng // But, also identify the sender, and keep track of the contained jurisdiction root for this server Node* voxelServer = NodeList::getInstance()->nodeWithAddress(&senderAddress); - uint16_t nodeID = voxelServer->getNodeID(); - - VoxelPositionSize jurisditionDetails; - voxelDetailsForCode(_voxelSceneStats.getJurisdictionRoot(), jurisditionDetails); - // see if this is the first we've heard of this node... - if (_voxelServerJurisdictions.find(nodeID) == _voxelServerJurisdictions.end()) { - printf("stats from new voxel server... v[%f, %f, %f, %f]\n", - jurisditionDetails.x, jurisditionDetails.y, jurisditionDetails.z, jurisditionDetails.s); + // quick fix for crash... why would voxelServer be NULL? + if (voxelServer) { + uint16_t nodeID = voxelServer->getNodeID(); - // Add the jurisditionDetails object to the list of "fade outs" - VoxelFade fade(VoxelFade::FADE_OUT, NODE_ADDED_RED, NODE_ADDED_GREEN, NODE_ADDED_BLUE); - fade.voxelDetails = jurisditionDetails; - _voxelFades.push_back(fade); + VoxelPositionSize jurisditionDetails; + voxelDetailsForCode(_voxelSceneStats.getJurisdictionRoot(), jurisditionDetails); + + // see if this is the first we've heard of this node... + if (_voxelServerJurisdictions.find(nodeID) == _voxelServerJurisdictions.end()) { + printf("stats from new voxel server... v[%f, %f, %f, %f]\n", + jurisditionDetails.x, jurisditionDetails.y, jurisditionDetails.z, jurisditionDetails.s); + + // Add the jurisditionDetails object to the list of "fade outs" + VoxelFade fade(VoxelFade::FADE_OUT, NODE_ADDED_RED, NODE_ADDED_GREEN, NODE_ADDED_BLUE); + fade.voxelDetails = jurisditionDetails; + _voxelFades.push_back(fade); + } + // store jurisdiction details for later use + _voxelServerJurisdictions[nodeID] = jurisditionDetails; } - // store jurisdiction details for later use - _voxelServerJurisdictions[nodeID] = jurisditionDetails; - return statsMessageLength; }