Merge branch 'master' of https://github.com/highfidelity/hifi into avatar-debug

This commit is contained in:
Stephen Birarda 2014-03-25 14:52:28 -07:00
commit 38ad75fc9e
6 changed files with 25 additions and 36 deletions

View file

@ -3,4 +3,5 @@
Script.include("lookWithTouch.js"); Script.include("lookWithTouch.js");
Script.include("editVoxels.js"); Script.include("editVoxels.js");
Script.include("selectAudioDevice.js"); Script.include("selectAudioDevice.js");
Script.include("hydraMove.js"); Script.include("hydraMove.js");
Script.include("inspect.js");

View file

@ -9,6 +9,7 @@
// //
// //
var startedTouching = false;
var lastX = 0; var lastX = 0;
var lastY = 0; var lastY = 0;
var yawFromMouse = 0; var yawFromMouse = 0;
@ -21,12 +22,14 @@ function touchBeginEvent(event) {
} }
lastX = event.x; lastX = event.x;
lastY = event.y; lastY = event.y;
startedTouching = true;
} }
function touchEndEvent(event) { function touchEndEvent(event) {
if (wantDebugging) { if (wantDebugging) {
print("touchEndEvent event.x,y=" + event.x + ", " + event.y); print("touchEndEvent event.x,y=" + event.x + ", " + event.y);
} }
startedTouching = false;
} }
function touchUpdateEvent(event) { function touchUpdateEvent(event) {
@ -44,24 +47,26 @@ function touchUpdateEvent(event) {
} }
function update(deltaTime) { function update(deltaTime) {
// rotate body yaw for yaw received from mouse if (startedTouching) {
var newOrientation = Quat.multiply(MyAvatar.orientation, Quat.fromPitchYawRollRadians(0, yawFromMouse, 0)); // rotate body yaw for yaw received from mouse
if (wantDebugging) { var newOrientation = Quat.multiply(MyAvatar.orientation, Quat.fromPitchYawRollRadians(0, yawFromMouse, 0));
print("changing orientation" if (wantDebugging) {
+ " [old]MyAvatar.orientation="+MyAvatar.orientation.x + "," + MyAvatar.orientation.y + "," print("changing orientation"
+ MyAvatar.orientation.z + "," + MyAvatar.orientation.w + " [old]MyAvatar.orientation="+MyAvatar.orientation.x + "," + MyAvatar.orientation.y + ","
+ " newOrientation="+newOrientation.x + "," + newOrientation.y + "," + newOrientation.z + "," + newOrientation.w); + MyAvatar.orientation.z + "," + MyAvatar.orientation.w
} + " newOrientation="+newOrientation.x + "," + newOrientation.y + "," + newOrientation.z + "," + newOrientation.w);
MyAvatar.orientation = newOrientation; }
yawFromMouse = 0; MyAvatar.orientation = newOrientation;
yawFromMouse = 0;
// apply pitch from mouse // apply pitch from mouse
var newPitch = MyAvatar.headPitch + pitchFromMouse; var newPitch = MyAvatar.headPitch + pitchFromMouse;
if (wantDebugging) { if (wantDebugging) {
print("changing pitch [old]MyAvatar.headPitch="+MyAvatar.headPitch+ " newPitch="+newPitch); print("changing pitch [old]MyAvatar.headPitch="+MyAvatar.headPitch+ " newPitch="+newPitch);
}
MyAvatar.headPitch = newPitch;
pitchFromMouse = 0;
} }
MyAvatar.headPitch = newPitch;
pitchFromMouse = 0;
} }
// Map the mouse events to our functions // Map the mouse events to our functions
@ -77,10 +82,6 @@ function scriptEnding() {
Controller.releaseTouchEvents(); Controller.releaseTouchEvents();
} }
MyAvatar.bodyYaw = 0;
MyAvatar.bodyPitch = 0;
MyAvatar.bodyRoll = 0;
// would be nice to change to update // would be nice to change to update
Script.update.connect(update); Script.update.connect(update);
Script.scriptEnding.connect(scriptEnding); Script.scriptEnding.connect(scriptEnding);

View file

@ -235,7 +235,6 @@ void ScriptEngine::init() {
// let the VoxelPacketSender know how frequently we plan to call it // let the VoxelPacketSender know how frequently we plan to call it
_voxelsScriptingInterface.getVoxelPacketSender()->setProcessCallIntervalHint(SCRIPT_DATA_CALLBACK_USECS); _voxelsScriptingInterface.getVoxelPacketSender()->setProcessCallIntervalHint(SCRIPT_DATA_CALLBACK_USECS);
_particlesScriptingInterface.getParticlePacketSender()->setProcessCallIntervalHint(SCRIPT_DATA_CALLBACK_USECS); _particlesScriptingInterface.getParticlePacketSender()->setProcessCallIntervalHint(SCRIPT_DATA_CALLBACK_USECS);
} }
void ScriptEngine::registerGlobalObject(const QString& name, QObject* object) { void ScriptEngine::registerGlobalObject(const QString& name, QObject* object) {

View file

@ -413,9 +413,8 @@ void NodeList::sendSTUNRequest() {
// transaction ID (random 12-byte unsigned integer) // transaction ID (random 12-byte unsigned integer)
const uint NUM_TRANSACTION_ID_BYTES = 12; const uint NUM_TRANSACTION_ID_BYTES = 12;
unsigned char transactionID[NUM_TRANSACTION_ID_BYTES]; QUuid randomUUID = QUuid::createUuid();
loadRandomIdentifier(transactionID, NUM_TRANSACTION_ID_BYTES); memcpy(stunRequestPacket + packetIndex, randomUUID.toRfc4122().data(), NUM_TRANSACTION_ID_BYTES);
memcpy(stunRequestPacket + packetIndex, &transactionID, sizeof(transactionID));
// lookup the IP for the STUN server // lookup the IP for the STUN server
static HifiSockAddr stunSockAddr(STUN_SERVER_HOSTNAME, STUN_SERVER_PORT); static HifiSockAddr stunSockAddr(STUN_SERVER_HOSTNAME, STUN_SERVER_PORT);

View file

@ -206,15 +206,6 @@ bool isInEnvironment(const char* environment) {
} }
} }
void loadRandomIdentifier(unsigned char* identifierBuffer, int numBytes) {
// seed the the random number generator
srand(time(NULL));
for (int i = 0; i < numBytes; i++) {
identifierBuffer[i] = rand() % 256;
}
}
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
// Function: getCmdOption() // Function: getCmdOption()
// Description: Handy little function to tell you if a command line flag and option was // Description: Handy little function to tell you if a command line flag and option was

View file

@ -96,8 +96,6 @@ int getNthBit(unsigned char byte, int ordinal); /// determines the bit placement
bool isInEnvironment(const char* environment); bool isInEnvironment(const char* environment);
void loadRandomIdentifier(unsigned char* identifierBuffer, int numBytes);
const char* getCmdOption(int argc, const char * argv[],const char* option); const char* getCmdOption(int argc, const char * argv[],const char* option);
bool cmdOptionExists(int argc, const char * argv[],const char* option); bool cmdOptionExists(int argc, const char * argv[],const char* option);