diff --git a/.gitignore b/.gitignore index eb2f3ec303..c296a918af 100644 --- a/.gitignore +++ b/.gitignore @@ -42,5 +42,9 @@ interface/external/visage/* interface/resources/visage/* !interface/resources/visage/tracker.cfg +# Ignore Faceplus +interface/external/faceplus/* +!interface/external/faceplus/readme.txt + # Ignore interfaceCache for Linux users interface/interfaceCache/ diff --git a/LICENSE b/LICENSE index 1ecd0026f5..93c9a953d4 100644 --- a/LICENSE +++ b/LICENSE @@ -1 +1,13 @@ -All rights reserved. © High Fidelity, Inc. 2013 \ No newline at end of file +Copyright 2014 High Fidelity, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. \ No newline at end of file diff --git a/animation-server/src/AnimationServer.cpp b/animation-server/src/AnimationServer.cpp index 1f0828ec17..6a4d1ea76d 100644 --- a/animation-server/src/AnimationServer.cpp +++ b/animation-server/src/AnimationServer.cpp @@ -1,9 +1,12 @@ // // AnimationServer.cpp -// hifi +// animation-server/src // // Created by Stephen Birarda on 12/5/2013. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/animation-server/src/AnimationServer.h b/animation-server/src/AnimationServer.h index cda5f8fb24..58f05c32c5 100644 --- a/animation-server/src/AnimationServer.h +++ b/animation-server/src/AnimationServer.h @@ -1,13 +1,16 @@ // // AnimationServer.h -// hifi +// animation-server/src // // Created by Stephen Birarda on 12/5/2013. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__AnimationServer__ -#define __hifi__AnimationServer__ +#ifndef hifi_AnimationServer_h +#define hifi_AnimationServer_h #include @@ -21,4 +24,4 @@ private slots: }; -#endif /* defined(__hifi__AnimationServer__) */ +#endif // hifi_AnimationServer_h diff --git a/animation-server/src/main.cpp b/animation-server/src/main.cpp index 3cdb7f04be..8acf3b8db2 100644 --- a/animation-server/src/main.cpp +++ b/animation-server/src/main.cpp @@ -1,9 +1,12 @@ // // main.cpp -// Animation Server +// animation-server/src // -// Created by Brad Hefta-Gaub on 05/16/2013 -// Copyright (c) 2012 High Fidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 05/16/2013. +// Copyright 2012 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "AnimationServer.h" diff --git a/assignment-client/src/Agent.cpp b/assignment-client/src/Agent.cpp index b5199e87e8..f376c4e981 100644 --- a/assignment-client/src/Agent.cpp +++ b/assignment-client/src/Agent.cpp @@ -1,9 +1,12 @@ // // Agent.cpp -// hifi +// assignment-client/src // // Created by Stephen Birarda on 7/1/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/assignment-client/src/Agent.h b/assignment-client/src/Agent.h index 9e5f31213c..2dcd7e3107 100644 --- a/assignment-client/src/Agent.h +++ b/assignment-client/src/Agent.h @@ -1,13 +1,16 @@ // // Agent.h -// hifi +// assignment-client/src // // Created by Stephen Birarda on 7/1/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__Agent__ -#define __hifi__Agent__ +#ifndef hifi_Agent_h +#define hifi_Agent_h #include @@ -64,4 +67,4 @@ private: MixedAudioRingBuffer _receivedAudioBuffer; }; -#endif /* defined(__hifi__Agent__) */ +#endif // hifi_Agent_h diff --git a/assignment-client/src/AssignmentClient.cpp b/assignment-client/src/AssignmentClient.cpp index aa20f2ff29..9d9bfa3113 100644 --- a/assignment-client/src/AssignmentClient.cpp +++ b/assignment-client/src/AssignmentClient.cpp @@ -1,9 +1,12 @@ // // AssignmentClient.cpp -// hifi +// assignment-client/src // // Created by Stephen Birarda on 11/25/2013. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/assignment-client/src/AssignmentClient.h b/assignment-client/src/AssignmentClient.h index c267c6238b..1ad8cca244 100644 --- a/assignment-client/src/AssignmentClient.h +++ b/assignment-client/src/AssignmentClient.h @@ -1,13 +1,16 @@ // // AssignmentClient.h -// hifi +// assignment-client/src // // Created by Stephen Birarda on 11/25/2013. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__AssignmentClient__ -#define __hifi__AssignmentClient__ +#ifndef hifi_AssignmentClient_h +#define hifi_AssignmentClient_h #include @@ -27,4 +30,4 @@ private: SharedAssignmentPointer _currentAssignment; }; -#endif /* defined(__hifi__AssignmentClient__) */ +#endif // hifi_AssignmentClient_h diff --git a/assignment-client/src/AssignmentClientMonitor.cpp b/assignment-client/src/AssignmentClientMonitor.cpp index 64c9b31147..af09ff1535 100644 --- a/assignment-client/src/AssignmentClientMonitor.cpp +++ b/assignment-client/src/AssignmentClientMonitor.cpp @@ -1,9 +1,12 @@ // // AssignmentClientMonitor.cpp -// hifi +// assignment-client/src // // Created by Stephen Birarda on 1/10/2014. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include @@ -53,4 +56,4 @@ void AssignmentClientMonitor::spawnChildClient() { void AssignmentClientMonitor::childProcessFinished(int exitCode, QProcess::ExitStatus exitStatus) { qDebug("Replacing dead child assignment client with a new one"); spawnChildClient(); -} \ No newline at end of file +} diff --git a/assignment-client/src/AssignmentClientMonitor.h b/assignment-client/src/AssignmentClientMonitor.h index 259a6d6db7..1df08a345e 100644 --- a/assignment-client/src/AssignmentClientMonitor.h +++ b/assignment-client/src/AssignmentClientMonitor.h @@ -1,13 +1,16 @@ // // AssignmentClientMonitor.h -// hifi +// assignment-client/src // // Created by Stephen Birarda on 1/10/2014. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__AssignmentClientMonitor__ -#define __hifi__AssignmentClientMonitor__ +#ifndef hifi_AssignmentClientMonitor_h +#define hifi_AssignmentClientMonitor_h #include #include @@ -28,4 +31,4 @@ private: QStringList _childArguments; }; -#endif /* defined(__hifi__AssignmentClientMonitor__) */ +#endif // hifi_AssignmentClientMonitor_h diff --git a/assignment-client/src/AssignmentFactory.cpp b/assignment-client/src/AssignmentFactory.cpp index cde5666ab9..cdf5c591e1 100644 --- a/assignment-client/src/AssignmentFactory.cpp +++ b/assignment-client/src/AssignmentFactory.cpp @@ -1,9 +1,12 @@ // // AssignmentFactory.cpp -// hifi +// assignment-client/src // // Created by Stephen Birarda on 9/17/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/assignment-client/src/AssignmentFactory.h b/assignment-client/src/AssignmentFactory.h index 9eff29a468..9c197f5747 100644 --- a/assignment-client/src/AssignmentFactory.h +++ b/assignment-client/src/AssignmentFactory.h @@ -1,13 +1,16 @@ // // AssignmentFactory.h -// hifi +// assignment-client/src // // Created by Stephen Birarda on 9/17/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__AssignmentFactory__ -#define __hifi__AssignmentFactory__ +#ifndef hifi_AssignmentFactory_h +#define hifi_AssignmentFactory_h #include @@ -16,4 +19,4 @@ public: static ThreadedAssignment* unpackAssignment(const QByteArray& packet); }; -#endif /* defined(__hifi__AssignmentFactory__) */ +#endif // hifi_AssignmentFactory_h diff --git a/assignment-client/src/AssignmentThread.cpp b/assignment-client/src/AssignmentThread.cpp index dfe093aa7b..848fa7afae 100644 --- a/assignment-client/src/AssignmentThread.cpp +++ b/assignment-client/src/AssignmentThread.cpp @@ -1,9 +1,12 @@ // // AssignmentThread.cpp -// hifi +// assignment-client/src // -// Created by Stephen Birarda on 2014-03-28. -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Created by Stephen Birarda on 2014. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "AssignmentThread.h" @@ -13,4 +16,4 @@ AssignmentThread::AssignmentThread(const SharedAssignmentPointer& assignment, QO _assignment(assignment) { -} \ No newline at end of file +} diff --git a/assignment-client/src/AssignmentThread.h b/assignment-client/src/AssignmentThread.h index b55ac10676..848c4614ba 100644 --- a/assignment-client/src/AssignmentThread.h +++ b/assignment-client/src/AssignmentThread.h @@ -1,13 +1,16 @@ // // AssignmentThread.h -// hifi +// assignment-client/src // -// Created by Stephen Birarda on 2014-03-28. -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Created by Stephen Birarda on 2014. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__AssignmentThread__ -#define __hifi__AssignmentThread__ +#ifndef hifi_AssignmentThread_h +#define hifi_AssignmentThread_h #include @@ -20,4 +23,4 @@ private: SharedAssignmentPointer _assignment; }; -#endif /* defined(__hifi__AssignmentThread__) */ +#endif // hifi_AssignmentThread_h diff --git a/assignment-client/src/audio/AudioMixer.cpp b/assignment-client/src/audio/AudioMixer.cpp index f183abade9..35b522ff2f 100644 --- a/assignment-client/src/audio/AudioMixer.cpp +++ b/assignment-client/src/audio/AudioMixer.cpp @@ -1,9 +1,12 @@ // // AudioMixer.cpp -// hifi +// assignment-client/src/audio // // Created by Stephen Birarda on 8/22/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/assignment-client/src/audio/AudioMixer.h b/assignment-client/src/audio/AudioMixer.h index 0ca241c5ed..659227dffb 100644 --- a/assignment-client/src/audio/AudioMixer.h +++ b/assignment-client/src/audio/AudioMixer.h @@ -1,13 +1,16 @@ // // AudioMixer.h -// hifi +// assignment-client/src/audio // // Created by Stephen Birarda on 8/22/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__AudioMixer__ -#define __hifi__AudioMixer__ +#ifndef hifi_AudioMixer_h +#define hifi_AudioMixer_h #include @@ -50,4 +53,4 @@ private: int _sumMixes; }; -#endif /* defined(__hifi__AudioMixer__) */ +#endif // hifi_AudioMixer_h diff --git a/assignment-client/src/audio/AudioMixerClientData.cpp b/assignment-client/src/audio/AudioMixerClientData.cpp index 4a9f1f84de..85b8dde690 100644 --- a/assignment-client/src/audio/AudioMixerClientData.cpp +++ b/assignment-client/src/audio/AudioMixerClientData.cpp @@ -1,9 +1,12 @@ // // AudioMixerClientData.cpp -// hifi +// assignment-client/src/audio // // Created by Stephen Birarda on 10/18/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/assignment-client/src/audio/AudioMixerClientData.h b/assignment-client/src/audio/AudioMixerClientData.h index 7f44390ec5..a5f03ebd15 100644 --- a/assignment-client/src/audio/AudioMixerClientData.h +++ b/assignment-client/src/audio/AudioMixerClientData.h @@ -1,13 +1,16 @@ // // AudioMixerClientData.h -// hifi +// assignment-client/src/audio // // Created by Stephen Birarda on 10/18/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__AudioMixerClientData__ -#define __hifi__AudioMixerClientData__ +#ifndef hifi_AudioMixerClientData_h +#define hifi_AudioMixerClientData_h #include @@ -31,4 +34,4 @@ private: std::vector _ringBuffers; }; -#endif /* defined(__hifi__AudioMixerClientData__) */ +#endif // hifi_AudioMixerClientData_h diff --git a/assignment-client/src/audio/AvatarAudioRingBuffer.cpp b/assignment-client/src/audio/AvatarAudioRingBuffer.cpp index 4b1907efb8..9a7c2839d8 100644 --- a/assignment-client/src/audio/AvatarAudioRingBuffer.cpp +++ b/assignment-client/src/audio/AvatarAudioRingBuffer.cpp @@ -1,9 +1,12 @@ // // AvatarAudioRingBuffer.cpp -// hifi +// assignment-client/src/audio // // Created by Stephen Birarda on 6/5/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include @@ -18,4 +21,4 @@ AvatarAudioRingBuffer::AvatarAudioRingBuffer() : int AvatarAudioRingBuffer::parseData(const QByteArray& packet) { _shouldLoopbackForNode = (packetTypeForPacket(packet) == PacketTypeMicrophoneAudioWithEcho); return PositionalAudioRingBuffer::parseData(packet); -} \ No newline at end of file +} diff --git a/assignment-client/src/audio/AvatarAudioRingBuffer.h b/assignment-client/src/audio/AvatarAudioRingBuffer.h index 0d4f28467b..1e61a82f68 100644 --- a/assignment-client/src/audio/AvatarAudioRingBuffer.h +++ b/assignment-client/src/audio/AvatarAudioRingBuffer.h @@ -1,13 +1,16 @@ // // AvatarAudioRingBuffer.h -// hifi +// assignment-client/src/audio // // Created by Stephen Birarda on 6/5/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__AvatarAudioRingBuffer__ -#define __hifi__AvatarAudioRingBuffer__ +#ifndef hifi_AvatarAudioRingBuffer_h +#define hifi_AvatarAudioRingBuffer_h #include @@ -24,4 +27,4 @@ private: AvatarAudioRingBuffer& operator= (const AvatarAudioRingBuffer&); }; -#endif /* defined(__hifi__AvatarAudioRingBuffer__) */ +#endif // hifi_AvatarAudioRingBuffer_h diff --git a/assignment-client/src/avatars/AvatarMixer.cpp b/assignment-client/src/avatars/AvatarMixer.cpp index c4c0dcda24..93f38e3608 100644 --- a/assignment-client/src/avatars/AvatarMixer.cpp +++ b/assignment-client/src/avatars/AvatarMixer.cpp @@ -1,14 +1,13 @@ // // AvatarMixer.cpp -// hifi +// assignment-client/src/avatars // // Created by Stephen Birarda on 9/5/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // -// Original avatar-mixer main created by Leonardo Murillo on 03/25/13. +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -// The avatar mixer receives head, hand and positional data from all connected -// nodes, and broadcasts that data back to them, every BROADCAST_INTERVAL ms. #include #include diff --git a/assignment-client/src/avatars/AvatarMixer.h b/assignment-client/src/avatars/AvatarMixer.h index c9a145d2da..a69019427b 100644 --- a/assignment-client/src/avatars/AvatarMixer.h +++ b/assignment-client/src/avatars/AvatarMixer.h @@ -1,13 +1,19 @@ // // AvatarMixer.h -// hifi +// assignment-client/src/avatars // // Created by Stephen Birarda on 9/5/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// The avatar mixer receives head, hand and positional data from all connected +// nodes, and broadcasts that data back to them, every BROADCAST_INTERVAL ms. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__AvatarMixer__ -#define __hifi__AvatarMixer__ +#ifndef hifi_AvatarMixer_h +#define hifi_AvatarMixer_h #include @@ -43,4 +49,4 @@ private: int _sumIdentityPackets; }; -#endif /* defined(__hifi__AvatarMixer__) */ +#endif // hifi_AvatarMixer_h diff --git a/assignment-client/src/avatars/AvatarMixerClientData.cpp b/assignment-client/src/avatars/AvatarMixerClientData.cpp index d1449e956e..9289d640f5 100644 --- a/assignment-client/src/avatars/AvatarMixerClientData.cpp +++ b/assignment-client/src/avatars/AvatarMixerClientData.cpp @@ -1,9 +1,12 @@ // // AvatarMixerClientData.cpp -// hifi +// assignment-client/src/avatars // // Created by Stephen Birarda on 2/4/2014. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "AvatarMixerClientData.h" diff --git a/assignment-client/src/avatars/AvatarMixerClientData.h b/assignment-client/src/avatars/AvatarMixerClientData.h index bc0a54f06b..18c29c4b0f 100644 --- a/assignment-client/src/avatars/AvatarMixerClientData.h +++ b/assignment-client/src/avatars/AvatarMixerClientData.h @@ -1,13 +1,16 @@ // // AvatarMixerClientData.h -// hifi +// assignment-client/src/avatars // // Created by Stephen Birarda on 2/4/2014. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__AvatarMixerClientData__ -#define __hifi__AvatarMixerClientData__ +#ifndef hifi_AvatarMixerClientData_h +#define hifi_AvatarMixerClientData_h #include @@ -37,4 +40,4 @@ private: quint64 _identityChangeTimestamp; }; -#endif /* defined(__hifi__AvatarMixerClientData__) */ +#endif // hifi_AvatarMixerClientData_h diff --git a/assignment-client/src/main.cpp b/assignment-client/src/main.cpp index 0151f93319..24d19ddef6 100644 --- a/assignment-client/src/main.cpp +++ b/assignment-client/src/main.cpp @@ -1,9 +1,12 @@ // // main.cpp -// assignment-client +// assignment-client/src // // Created by Stephen Birarda on 8/22/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include @@ -37,4 +40,4 @@ int main(int argc, char* argv[]) { AssignmentClient client(argc, argv); return client.exec(); } -} \ No newline at end of file +} diff --git a/assignment-client/src/metavoxels/MetavoxelServer.cpp b/assignment-client/src/metavoxels/MetavoxelServer.cpp index 98c91d44e7..3bf1632074 100644 --- a/assignment-client/src/metavoxels/MetavoxelServer.cpp +++ b/assignment-client/src/metavoxels/MetavoxelServer.cpp @@ -1,9 +1,12 @@ // // MetavoxelServer.cpp -// hifi +// assignment-client/src/metavoxels // // Created by Andrzej Kapolka on 12/18/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include @@ -95,6 +98,8 @@ MetavoxelSession::MetavoxelSession(MetavoxelServer* server, const SharedNodePoin connect(&_sequencer, SIGNAL(readyToRead(Bitstream&)), SLOT(readPacket(Bitstream&))); connect(&_sequencer, SIGNAL(sendAcknowledged(int)), SLOT(clearSendRecordsBefore(int))); connect(&_sequencer, SIGNAL(receivedHighPriorityMessage(const QVariant&)), SLOT(handleMessage(const QVariant&))); + connect(_sequencer.getReliableInputChannel(), SIGNAL(receivedMessage(const QVariant&)), + SLOT(handleMessage(const QVariant&))); // insert the baseline send record SendRecord record = { 0 }; diff --git a/assignment-client/src/metavoxels/MetavoxelServer.h b/assignment-client/src/metavoxels/MetavoxelServer.h index d178127ac7..b01bb9b412 100644 --- a/assignment-client/src/metavoxels/MetavoxelServer.h +++ b/assignment-client/src/metavoxels/MetavoxelServer.h @@ -1,13 +1,16 @@ // // MetavoxelServer.h -// hifi +// assignment-client/src/metavoxels // // Created by Andrzej Kapolka on 12/18/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__MetavoxelServer__ -#define __hifi__MetavoxelServer__ +#ifndef hifi_MetavoxelServer_h +#define hifi_MetavoxelServer_h #include #include @@ -92,4 +95,4 @@ private: QList _sendRecords; }; -#endif /* defined(__hifi__MetavoxelServer__) */ +#endif // hifi_MetavoxelServer_h diff --git a/assignment-client/src/octree/OctreeInboundPacketProcessor.cpp b/assignment-client/src/octree/OctreeInboundPacketProcessor.cpp index 5e8de3a1b3..41158bf339 100644 --- a/assignment-client/src/octree/OctreeInboundPacketProcessor.cpp +++ b/assignment-client/src/octree/OctreeInboundPacketProcessor.cpp @@ -1,11 +1,12 @@ // // OctreeInboundPacketProcessor.cpp -// voxel-server +// assignment-client/src/octree // -// Created by Brad Hefta-Gaub on 8/21/13 -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 8/21/13. +// Copyright 2013 High Fidelity, Inc. // -// Threaded or non-threaded network packet processor for the voxel-server +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/assignment-client/src/octree/OctreeInboundPacketProcessor.h b/assignment-client/src/octree/OctreeInboundPacketProcessor.h index e2ec1b5c50..f637a9e7c9 100644 --- a/assignment-client/src/octree/OctreeInboundPacketProcessor.h +++ b/assignment-client/src/octree/OctreeInboundPacketProcessor.h @@ -1,15 +1,18 @@ // // OctreeInboundPacketProcessor.h -// voxel-server +// assignment-client/src/octree // -// Created by Brad Hefta-Gaub on 8/21/13 -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 8/21/13. +// Copyright 2013 High Fidelity, Inc. // -// Threaded or non-threaded network packet processor for the voxel-server +// Threaded or non-threaded network packet processor for the voxel-server +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __octree_server__OctreeInboundPacketProcessor__ -#define __octree_server__OctreeInboundPacketProcessor__ +#ifndef hifi_OctreeInboundPacketProcessor_h +#define hifi_OctreeInboundPacketProcessor_h #include @@ -80,4 +83,4 @@ private: NodeToSenderStatsMap _singleSenderStats; }; -#endif // __octree_server__OctreeInboundPacketProcessor__ +#endif // hifi_OctreeInboundPacketProcessor_h diff --git a/assignment-client/src/octree/OctreeQueryNode.cpp b/assignment-client/src/octree/OctreeQueryNode.cpp index 984ce42631..00526cc967 100644 --- a/assignment-client/src/octree/OctreeQueryNode.cpp +++ b/assignment-client/src/octree/OctreeQueryNode.cpp @@ -1,9 +1,12 @@ // // OctreeQueryNode.cpp -// hifi +// assignment-client/src/octree // // Created by Stephen Birarda on 3/21/13. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "PacketHeaders.h" diff --git a/assignment-client/src/octree/OctreeQueryNode.h b/assignment-client/src/octree/OctreeQueryNode.h index 17d6f6337c..aa445db8a6 100644 --- a/assignment-client/src/octree/OctreeQueryNode.h +++ b/assignment-client/src/octree/OctreeQueryNode.h @@ -1,13 +1,16 @@ // // OctreeQueryNode.h -// hifi +// assignment-client/src/octree // // Created by Brad Hefta-Gaub on 12/4/13. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__OctreeQueryNode__ -#define __hifi__OctreeQueryNode__ +#ifndef hifi_OctreeQueryNode_h +#define hifi_OctreeQueryNode_h #include #include @@ -135,4 +138,4 @@ private: bool _isShuttingDown; }; -#endif /* defined(__hifi__OctreeQueryNode__) */ +#endif // hifi_OctreeQueryNode_h diff --git a/assignment-client/src/octree/OctreeSendThread.cpp b/assignment-client/src/octree/OctreeSendThread.cpp index 4105b21eb8..0a53160b8f 100644 --- a/assignment-client/src/octree/OctreeSendThread.cpp +++ b/assignment-client/src/octree/OctreeSendThread.cpp @@ -1,8 +1,12 @@ // // OctreeSendThread.cpp +// assignment-client/src/octree // -// Created by Brad Hefta-Gaub on 8/21/13 -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 8/21/13. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/assignment-client/src/octree/OctreeSendThread.h b/assignment-client/src/octree/OctreeSendThread.h index 4b1b6d8c92..95205af32f 100644 --- a/assignment-client/src/octree/OctreeSendThread.h +++ b/assignment-client/src/octree/OctreeSendThread.h @@ -1,14 +1,18 @@ // // OctreeSendThread.h +// assignment-client/src/octree // -// Created by Brad Hefta-Gaub on 8/21/13 -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 8/21/13. +// Copyright 2013 High Fidelity, Inc. // // Threaded or non-threaded object for sending voxels to a client // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// -#ifndef __octree_server__OctreeSendThread__ -#define __octree_server__OctreeSendThread__ +#ifndef hifi_OctreeSendThread_h +#define hifi_OctreeSendThread_h #include #include @@ -51,4 +55,4 @@ private: bool _isShuttingDown; }; -#endif // __octree_server__OctreeSendThread__ +#endif // hifi_OctreeSendThread_h diff --git a/assignment-client/src/octree/OctreeServer.cpp b/assignment-client/src/octree/OctreeServer.cpp index fd3f9e6cb7..2e8a354c6a 100644 --- a/assignment-client/src/octree/OctreeServer.cpp +++ b/assignment-client/src/octree/OctreeServer.cpp @@ -1,9 +1,12 @@ // // OctreeServer.cpp -// hifi +// assignment-client/src/octree // // Created by Brad Hefta-Gaub on 9/16/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/assignment-client/src/octree/OctreeServer.h b/assignment-client/src/octree/OctreeServer.h index 63d43b6634..d02764bc59 100644 --- a/assignment-client/src/octree/OctreeServer.h +++ b/assignment-client/src/octree/OctreeServer.h @@ -1,14 +1,16 @@ // // OctreeServer.h -// voxel-server +// assignment-client/src/octree // -// Created by Brad Hefta-Gaub on 8/21/13 -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 8/21/13. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __octree_server__OctreeServer__ -#define __octree_server__OctreeServer__ +#ifndef hifi_OctreeServer_h +#define hifi_OctreeServer_h #include #include @@ -217,4 +219,4 @@ protected: static QMutex _threadsDidCallWriteDatagramMutex; }; -#endif // __octree_server__OctreeServer__ +#endif // hifi_OctreeServer_h diff --git a/assignment-client/src/octree/OctreeServerConsts.h b/assignment-client/src/octree/OctreeServerConsts.h index fae03a73ca..a10c81494c 100644 --- a/assignment-client/src/octree/OctreeServerConsts.h +++ b/assignment-client/src/octree/OctreeServerConsts.h @@ -1,13 +1,16 @@ +// // OctreeServerConsts.h -// octree-server +// assignment-client/src/octree // -// Created by Brad Hefta-Gaub on 12/4/13 -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 12/4/13. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __octree_server__OctreeServerConsts__ -#define __octree_server__OctreeServerConsts__ +#ifndef hifi_OctreeServerConsts_h +#define hifi_OctreeServerConsts_h #include #include // for MAX_PACKET_SIZE @@ -18,4 +21,4 @@ const int INTERVALS_PER_SECOND = 60; const int OCTREE_SEND_INTERVAL_USECS = (1000 * 1000)/INTERVALS_PER_SECOND; const int SENDING_TIME_TO_SPARE = 5 * 1000; // usec of sending interval to spare for calculating voxels -#endif // __octree_server__OctreeServerConsts__ +#endif // hifi_OctreeServerConsts_h diff --git a/assignment-client/src/particles/ParticleNodeData.h b/assignment-client/src/particles/ParticleNodeData.h index 450767613e..340ce4844f 100644 --- a/assignment-client/src/particles/ParticleNodeData.h +++ b/assignment-client/src/particles/ParticleNodeData.h @@ -1,14 +1,16 @@ // // ParticleNodeData.h -// hifi +// assignment-client/src/particles // -// Created by Brad Hefta-Gaub on 12/4/13 -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 12/4/13. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__ParticleNodeData__ -#define __hifi__ParticleNodeData__ +#ifndef hifi_ParticleNodeData_h +#define hifi_ParticleNodeData_h #include @@ -29,4 +31,4 @@ private: quint64 _lastDeletedParticlesSentAt; }; -#endif /* defined(__hifi__ParticleNodeData__) */ +#endif // hifi_ParticleNodeData_h diff --git a/assignment-client/src/particles/ParticleServer.cpp b/assignment-client/src/particles/ParticleServer.cpp index 1785ef46d6..649ee0cff9 100644 --- a/assignment-client/src/particles/ParticleServer.cpp +++ b/assignment-client/src/particles/ParticleServer.cpp @@ -1,9 +1,12 @@ // // ParticleServer.cpp -// hifi +// assignment-client/src/particles // -// Created by Brad Hefta-Gaub on 12/4/13 -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 12/4/13. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/assignment-client/src/particles/ParticleServer.h b/assignment-client/src/particles/ParticleServer.h index 4e6a896475..495fc02c68 100644 --- a/assignment-client/src/particles/ParticleServer.h +++ b/assignment-client/src/particles/ParticleServer.h @@ -1,14 +1,16 @@ // // ParticleServer.h -// particle-server +// assignment-client/src/particles // -// Created by Brad Hefta-Gaub on 12/2/13 -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 12/2/13. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __particle_server__ParticleServer__ -#define __particle_server__ParticleServer__ +#ifndef hifi_ParticleServer_h +#define hifi_ParticleServer_h #include "../octree/OctreeServer.h" @@ -45,4 +47,4 @@ public slots: private: }; -#endif // __particle_server__ParticleServer__ +#endif // hifi_ParticleServer_h diff --git a/assignment-client/src/particles/ParticleServerConsts.h b/assignment-client/src/particles/ParticleServerConsts.h index 5ac2a1534b..49df2a181e 100644 --- a/assignment-client/src/particles/ParticleServerConsts.h +++ b/assignment-client/src/particles/ParticleServerConsts.h @@ -1,16 +1,19 @@ +// // ParticleServerConsts.h -// particle-server +// assignment-client/src/particles // -// Created by Brad Hefta-Gaub on 8/21/13 -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 8/21/13. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __particle_server__ParticleServerConsts__ -#define __particle_server__ParticleServerConsts__ +#ifndef hifi_ParticleServerConsts_h +#define hifi_ParticleServerConsts_h extern const char* PARTICLE_SERVER_NAME; extern const char* PARTICLE_SERVER_LOGGING_TARGET_NAME; extern const char* LOCAL_PARTICLES_PERSIST_FILE; -#endif // __particle_server__ParticleServerConsts__ +#endif // hifi_ParticleServerConsts_h diff --git a/assignment-client/src/voxels/VoxelNodeData.h b/assignment-client/src/voxels/VoxelNodeData.h index c24bfad6ce..86d241852d 100644 --- a/assignment-client/src/voxels/VoxelNodeData.h +++ b/assignment-client/src/voxels/VoxelNodeData.h @@ -1,13 +1,16 @@ // // VoxelNodeData.h -// hifi +// assignment-client/src/voxels // // Created by Stephen Birarda on 3/21/13. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__VoxelNodeData__ -#define __hifi__VoxelNodeData__ +#ifndef hifi_VoxelNodeData_h +#define hifi_VoxelNodeData_h #include @@ -19,4 +22,4 @@ public: virtual PacketType getMyPacketType() const { return PacketTypeVoxelData; } }; -#endif /* defined(__hifi__VoxelNodeData__) */ +#endif // hifi_VoxelNodeData_h diff --git a/assignment-client/src/voxels/VoxelServer.cpp b/assignment-client/src/voxels/VoxelServer.cpp index 771c91570f..7747b8336b 100644 --- a/assignment-client/src/voxels/VoxelServer.cpp +++ b/assignment-client/src/voxels/VoxelServer.cpp @@ -1,9 +1,12 @@ // // VoxelServer.cpp -// hifi +// assignment-client/src/voxels // // Created by Brad Hefta-Gaub on 9/16/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/assignment-client/src/voxels/VoxelServer.h b/assignment-client/src/voxels/VoxelServer.h index 2e97736963..e81c16fc38 100644 --- a/assignment-client/src/voxels/VoxelServer.h +++ b/assignment-client/src/voxels/VoxelServer.h @@ -1,14 +1,16 @@ // // VoxelServer.h -// voxel-server +// assignment-client/src/voxels // -// Created by Brad Hefta-Gaub on 8/21/13 -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 8/21/13. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __voxel_server__VoxelServer__ -#define __voxel_server__VoxelServer__ +#ifndef hifi_VoxelServer_h +#define hifi_VoxelServer_h #include #include @@ -53,4 +55,4 @@ private: unsigned char _tempOutputBuffer[MAX_PACKET_SIZE]; }; -#endif // __voxel_server__VoxelServer__ +#endif // hifi_VoxelServer_h diff --git a/assignment-client/src/voxels/VoxelServerConsts.h b/assignment-client/src/voxels/VoxelServerConsts.h index ce6fd86a32..5764e7d4cf 100644 --- a/assignment-client/src/voxels/VoxelServerConsts.h +++ b/assignment-client/src/voxels/VoxelServerConsts.h @@ -1,13 +1,16 @@ +// // VoxelServerConsts.h -// voxel-server +// assignment-client/src/voxels // -// Created by Brad Hefta-Gaub on 8/21/13 -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 8/21/13. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __voxel_server__VoxelServerConsts__ -#define __voxel_server__VoxelServerConsts__ +#ifndef hifi_VoxelServerConsts_h +#define hifi_VoxelServerConsts_h extern const char* VOXEL_SERVER_NAME; extern const char* VOXEL_SERVER_LOGGING_TARGET_NAME; @@ -15,4 +18,4 @@ extern const char* LOCAL_VOXELS_PERSIST_FILE; const int ENVIRONMENT_SEND_INTERVAL_USECS = 1000000; -#endif // __voxel_server__VoxelServerConsts__ +#endif // hifi_VoxelServerConsts_h diff --git a/cmake/macros/AutoMTC.cmake b/cmake/macros/AutoMTC.cmake index 6619419b59..1682b9cd56 100644 --- a/cmake/macros/AutoMTC.cmake +++ b/cmake/macros/AutoMTC.cmake @@ -1,3 +1,13 @@ +# +# AutoMTC.cmake +# +# Created by Andrzej Kapolka on 12/31/13. +# Copyright 2013 High Fidelity, Inc. +# +# Distributed under the Apache License, Version 2.0. +# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +# + macro(AUTO_MTC TARGET ROOT_DIR) if (NOT TARGET mtc) add_subdirectory("${ROOT_DIR}/tools/mtc" "${ROOT_DIR}/tools/mtc") @@ -8,6 +18,4 @@ macro(AUTO_MTC TARGET ROOT_DIR) file(GLOB INCLUDE_FILES src/*.h) add_custom_command(OUTPUT ${AUTOMTC_SRC} COMMAND mtc -o ${AUTOMTC_SRC} ${INCLUDE_FILES} DEPENDS mtc ${INCLUDE_FILES}) -endmacro() - - +endmacro() \ No newline at end of file diff --git a/cmake/macros/IncludeGLM.cmake b/cmake/macros/IncludeGLM.cmake index 7f5fe039c6..a31324993e 100644 --- a/cmake/macros/IncludeGLM.cmake +++ b/cmake/macros/IncludeGLM.cmake @@ -1,3 +1,12 @@ +# +# IncludeGLM.cmake +# +# Copyright 2013 High Fidelity, Inc. +# +# Distributed under the Apache License, Version 2.0. +# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +# + macro(INCLUDE_GLM TARGET ROOT_DIR) find_package(GLM REQUIRED) diff --git a/cmake/macros/LinkHifiLibrary.cmake b/cmake/macros/LinkHifiLibrary.cmake index 02ebc983c2..6300e50c34 100644 --- a/cmake/macros/LinkHifiLibrary.cmake +++ b/cmake/macros/LinkHifiLibrary.cmake @@ -1,3 +1,12 @@ +# +# LinkHifiLibrary.cmake +# +# Copyright 2013 High Fidelity, Inc. +# +# Distributed under the Apache License, Version 2.0. +# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +# + macro(LINK_HIFI_LIBRARY LIBRARY TARGET ROOT_DIR) if (NOT TARGET ${LIBRARY}) diff --git a/cmake/macros/SetupHifiLibrary.cmake b/cmake/macros/SetupHifiLibrary.cmake index 19428b6723..ff4ae3b4f3 100644 --- a/cmake/macros/SetupHifiLibrary.cmake +++ b/cmake/macros/SetupHifiLibrary.cmake @@ -1,3 +1,12 @@ +# +# SetupHifiLibrary.cmake +# +# Copyright 2013 High Fidelity, Inc. +# +# Distributed under the Apache License, Version 2.0. +# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +# + macro(SETUP_HIFI_LIBRARY TARGET) project(${TARGET}) diff --git a/cmake/macros/SetupHifiProject.cmake b/cmake/macros/SetupHifiProject.cmake index a707626254..50cd3a4150 100644 --- a/cmake/macros/SetupHifiProject.cmake +++ b/cmake/macros/SetupHifiProject.cmake @@ -1,3 +1,12 @@ +# +# SetupHifiProject.cmake +# +# Copyright 2013 High Fidelity, Inc. +# +# Distributed under the Apache License, Version 2.0. +# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +# + macro(SETUP_HIFI_PROJECT TARGET INCLUDE_QT) project(${TARGET}) diff --git a/cmake/modules/FindFaceplus.cmake b/cmake/modules/FindFaceplus.cmake new file mode 100644 index 0000000000..2a2083d6e4 --- /dev/null +++ b/cmake/modules/FindFaceplus.cmake @@ -0,0 +1,42 @@ +# Try to find the Faceplus library +# +# You must provide a FACEPLUS_ROOT_DIR which contains lib and include directories +# +# Once done this will define +# +# FACEPLUS_FOUND - system found Faceplus +# FACEPLUS_INCLUDE_DIRS - the Faceplus include directory +# FACEPLUS_LIBRARIES - Link this to use Faceplus +# +# Created on 4/8/2014 by Andrzej Kapolka +# Copyright (c) 2014 High Fidelity +# + +if (FACEPLUS_LIBRARIES AND FACEPLUS_INCLUDE_DIRS) + # in cache already + set(FACEPLUS_FOUND TRUE) +else (FACEPLUS_LIBRARIES AND FACEPLUS_INCLUDE_DIRS) + find_path(FACEPLUS_INCLUDE_DIRS faceplus.h ${FACEPLUS_ROOT_DIR}/include) + + if (WIN32) + find_library(FACEPLUS_LIBRARIES faceplus.lib ${FACEPLUS_ROOT_DIR}/win32/) + endif (WIN32) + + if (FACEPLUS_INCLUDE_DIRS AND FACEPLUS_LIBRARIES) + set(FACEPLUS_FOUND TRUE) + endif (FACEPLUS_INCLUDE_DIRS AND FACEPLUS_LIBRARIES) + + if (FACEPLUS_FOUND) + if (NOT FACEPLUS_FIND_QUIETLY) + message(STATUS "Found Faceplus... ${FACEPLUS_LIBRARIES}") + endif (NOT FACEPLUS_FIND_QUIETLY) + else () + if (FACEPLUS_FIND_REQUIRED) + message(FATAL_ERROR "Could not find Faceplus") + endif (FACEPLUS_FIND_REQUIRED) + endif () + + # show the FACEPLUS_INCLUDE_DIRS and FACEPLUS_LIBRARIES variables only in the advanced view + mark_as_advanced(FACEPLUS_INCLUDE_DIRS FACEPLUS_LIBRARIES) + +endif (FACEPLUS_LIBRARIES AND FACEPLUS_INCLUDE_DIRS) diff --git a/cmake/modules/FindFaceshift.cmake b/cmake/modules/FindFaceshift.cmake index c89cbbab6f..faf556e06c 100644 --- a/cmake/modules/FindFaceshift.cmake +++ b/cmake/modules/FindFaceshift.cmake @@ -1,3 +1,6 @@ +# +# FindFaceshift.cmake +# # Try to find the Faceshift networking library # # You must provide a FACESHIFT_ROOT_DIR which contains lib and include directories @@ -9,8 +12,11 @@ # FACESHIFT_LIBRARIES - Link this to use Faceshift # # Created on 8/30/2013 by Andrzej Kapolka -# Copyright (c) 2013 High Fidelity +# Copyright 2013 High Fidelity, Inc. # +# Distributed under the Apache License, Version 2.0. +# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +# if (FACESHIFT_LIBRARIES AND FACESHIFT_INCLUDE_DIRS) # in cache already diff --git a/cmake/modules/FindGLEW.cmake b/cmake/modules/FindGLEW.cmake index 684acca762..b621756885 100644 --- a/cmake/modules/FindGLEW.cmake +++ b/cmake/modules/FindGLEW.cmake @@ -1,16 +1,22 @@ # -# Try to find GLEW library and include path. -# Once done this will define -# -# GLEW_FOUND -# GLEW_INCLUDE_DIRS -# GLEW_LIBRARY +# FindGLEW.cmake # - -# Created on 2/6/2014 by Stephen Birarda +# Try to find GLEW library and include path. +# Once done this will define # -# Adapted from FindGLEW.cmake available in the nvidia-texture-tools repository -# (https://code.google.com/p/nvidia-texture-tools/source/browse/trunk/cmake/FindGLEW.cmake?r=96) +# GLEW_FOUND +# GLEW_INCLUDE_DIRS +# GLEW_LIBRARY +# +# Created on 2/6/2014 by Stephen Birarda +# Copyright 2014 High Fidelity, Inc. +# +# Adapted from FindGLEW.cmake available in the nvidia-texture-tools repository +# (https://code.google.com/p/nvidia-texture-tools/source/browse/trunk/cmake/FindGLEW.cmake?r=96) +# +# Distributed under the Apache License, Version 2.0. +# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +# if (GLEW_INCLUDE_DIRS AND GLEW_LIBRARY) set(GLEW_FOUND TRUE) @@ -20,7 +26,7 @@ else () find_path(GLEW_INCLUDE_DIRS GL/glew.h PATH_SUFFIXES include HINTS ${WIN_GLEW_SEARCH_DIRS}) - find_library(GLEW_LIBRARY glew32s PATH_SUFFIXES "lib/Release/Win32" HINTS ${WIN_GLEW_SEARCH_DIRS}) + find_library(GLEW_LIBRARY glew32s PATH_SUFFIXES "lib/Release/Win32" "lib" HINTS ${WIN_GLEW_SEARCH_DIRS}) endif () include(FindPackageHandleStandardArgs) diff --git a/cmake/modules/FindGLUT.cmake b/cmake/modules/FindGLUT.cmake index 173f5a24ae..280a6ac6db 100644 --- a/cmake/modules/FindGLUT.cmake +++ b/cmake/modules/FindGLUT.cmake @@ -1,15 +1,23 @@ -# Try to find GLUT library and include path. -# Once done this will define +# +# FindGLUT.cmake +# +# Try to find GLUT library and include path. +# Once done this will define # -# GLUT_FOUND -# GLUT_INCLUDE_DIR -# GLUT_LIBRARIES -# GLUT_DLL_PATH - Optionally defined for Win32, if not in path +# GLUT_FOUND +# GLUT_INCLUDE_DIR +# GLUT_LIBRARIES +# GLUT_DLL_PATH - Optionally defined for Win32, if not in path # # Created on 2/6/2014 by Stephen Birarda +# Copyright 2014 High Fidelity, Inc. +# +# Adapted from FindGLUT.cmake available in tlorach's OpenGLText Repository +# https://raw.github.com/tlorach/OpenGLText/master/cmake/FindGLUT.cmake +# +# Distributed under the Apache License, Version 2.0. +# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -# Adapted from FindGLUT.cmake available in tlorach's OpenGLText Repository -# https://raw.github.com/tlorach/OpenGLText/master/cmake/FindGLUT.cmake if (GLUT_INCLUDE_DIR AND GLUT_LIBRARIES) set(GLUT_FOUND TRUE) diff --git a/cmake/modules/FindLibOVR.cmake b/cmake/modules/FindLibOVR.cmake index 47b7d27015..c07b4c14c1 100644 --- a/cmake/modules/FindLibOVR.cmake +++ b/cmake/modules/FindLibOVR.cmake @@ -1,4 +1,7 @@ -# - Try to find the LibOVR library to use the Oculus +# +# FindLibOVR.cmake +# +# Try to find the LibOVR library to use the Oculus # # You must provide a LIBOVR_ROOT_DIR which contains Lib and Include directories # @@ -9,8 +12,11 @@ # LIBOVR_LIBRARIES - Link this to use LibOVR # # Created on 5/9/2013 by Stephen Birarda -# Copyright (c) 2013 High Fidelity +# Copyright 2013 High Fidelity, Inc. # +# Distributed under the Apache License, Version 2.0. +# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +# if (LIBOVR_LIBRARIES AND LIBOVR_INCLUDE_DIRS) # in cache already diff --git a/cmake/modules/FindQt5LinguistToolsMacros.cmake b/cmake/modules/FindQt5LinguistToolsMacros.cmake index cd2d1eb74f..bd9d55cb16 100644 --- a/cmake/modules/FindQt5LinguistToolsMacros.cmake +++ b/cmake/modules/FindQt5LinguistToolsMacros.cmake @@ -30,8 +30,6 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #============================================================================= - - function(QT5_CREATE_TRANSLATION_CUSTOM _qm_files) set(options) set(oneValueArgs) diff --git a/cmake/modules/FindQxmpp.cmake b/cmake/modules/FindQxmpp.cmake index 415b184a65..d5f23143f6 100644 --- a/cmake/modules/FindQxmpp.cmake +++ b/cmake/modules/FindQxmpp.cmake @@ -1,3 +1,6 @@ +# +# FindQxmpp.cmake +# # Try to find the qxmpp library # # You can provide a QXMPP_ROOT_DIR which contains lib and include directories @@ -9,8 +12,11 @@ # QXMPP_LIBRARIES - Link this to use qxmpp # # Created on 3/10/2014 by Stephen Birarda -# Copyright (c) 2014 High Fidelity +# Copyright 2014 High Fidelity, Inc. # +# Distributed under the Apache License, Version 2.0. +# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +# if (QXMPP_LIBRARIES AND QXMPP_INCLUDE_DIRS) # in cache already diff --git a/cmake/modules/FindSixense.cmake b/cmake/modules/FindSixense.cmake index 1585095ba8..02b6e3fc21 100644 --- a/cmake/modules/FindSixense.cmake +++ b/cmake/modules/FindSixense.cmake @@ -1,3 +1,6 @@ +# +# FindSixense.cmake +# # Try to find the Sixense controller library # # You must provide a SIXENSE_ROOT_DIR which contains lib and include directories @@ -9,8 +12,11 @@ # SIXENSE_LIBRARIES - Link this to use Sixense # # Created on 11/15/2013 by Andrzej Kapolka -# Copyright (c) 2013 High Fidelity +# Copyright 2013 High Fidelity, Inc. # +# Distributed under the Apache License, Version 2.0. +# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +# if (SIXENSE_LIBRARIES AND SIXENSE_INCLUDE_DIRS) # in cache already diff --git a/cmake/modules/FindVisage.cmake b/cmake/modules/FindVisage.cmake index aa7f0f9faf..0aa57f6508 100644 --- a/cmake/modules/FindVisage.cmake +++ b/cmake/modules/FindVisage.cmake @@ -1,3 +1,6 @@ +# +# FindVisage.cmake +# # Try to find the Visage controller library # # You must provide a VISAGE_ROOT_DIR which contains lib and include directories @@ -9,8 +12,11 @@ # VISAGE_LIBRARIES - Link this to use Visage # # Created on 2/11/2014 by Andrzej Kapolka -# Copyright (c) 2014 High Fidelity +# Copyright 2014 High Fidelity, Inc. # +# Distributed under the Apache License, Version 2.0. +# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +# if (VISAGE_LIBRARIES AND VISAGE_INCLUDE_DIRS) # in cache already diff --git a/domain-server/resources/web/index.shtml b/domain-server/resources/web/index.shtml index bba4dc4d22..afd0af1679 100644 --- a/domain-server/resources/web/index.shtml +++ b/domain-server/resources/web/index.shtml @@ -12,6 +12,7 @@ Pool Public Local + Uptime (s) Kill? diff --git a/domain-server/resources/web/js/tables.js b/domain-server/resources/web/js/tables.js index 18e67ac6e7..a4884486c3 100644 --- a/domain-server/resources/web/js/tables.js +++ b/domain-server/resources/web/js/tables.js @@ -2,16 +2,47 @@ $(document).ready(function(){ // setup a function to grab the assignments function getNodesAndAssignments() { $.getJSON("nodes.json", function(json){ + + json.nodes.sort(function(a, b){ + if (a.type === b.type) { + if (a.wake_timestamp < b.wake_timestamp) { + return 1; + } else if (a.wake_timestamp > b.wake_timestamp) { + return -1; + } else { + return 0; + } + } + + if (a.type === "agent" && b.type !== "agent") { + return 1; + } else if (b.type === "agent" && a.type !== "agent") { + return -1; + } + + if (a.type > b.type) { + return 1; + } + + if (a.type < b.type) { + return -1; + } + }); + nodesTableBody = ""; - $.each(json.nodes, function (uuid, data) { + $.each(json.nodes, function(index, data) { nodesTableBody += ""; nodesTableBody += "" + data.type + ""; - nodesTableBody += "" + uuid + ""; + nodesTableBody += "" + data.uuid + ""; nodesTableBody += "" + (data.pool ? data.pool : "") + ""; nodesTableBody += "" + data.public.ip + ":" + data.public.port + ""; nodesTableBody += "" + data.local.ip + ":" + data.local.port + ""; - nodesTableBody += ""; + + var uptimeSeconds = (Date.now() - data.wake_timestamp) / 1000; + nodesTableBody += "" + uptimeSeconds.toLocaleString() + ""; + + nodesTableBody += ""; nodesTableBody += ""; }); diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index 035e6c9a20..05d1fcd534 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -1,9 +1,12 @@ // // DomainServer.cpp -// hifi +// domain-server/src // // Created by Stephen Birarda on 9/26/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include @@ -622,10 +625,12 @@ QJsonObject DomainServer::jsonForSocket(const HifiSockAddr& socket) { return socketJSON; } +const char JSON_KEY_UUID[] = "uuid"; const char JSON_KEY_TYPE[] = "type"; const char JSON_KEY_PUBLIC_SOCKET[] = "public"; const char JSON_KEY_LOCAL_SOCKET[] = "local"; const char JSON_KEY_POOL[] = "pool"; +const char JSON_KEY_WAKE_TIMESTAMP[] = "wake_timestamp"; QJsonObject DomainServer::jsonObjectForNode(const SharedNodePointer& node) { QJsonObject nodeJson; @@ -635,6 +640,9 @@ QJsonObject DomainServer::jsonObjectForNode(const SharedNodePointer& node) { nodeTypeName = nodeTypeName.toLower(); nodeTypeName.replace(' ', '-'); + // add the node UUID + nodeJson[JSON_KEY_UUID] = uuidStringWithoutCurlyBraces(node->getUUID()); + // add the node type nodeJson[JSON_KEY_TYPE] = nodeTypeName; @@ -642,6 +650,9 @@ QJsonObject DomainServer::jsonObjectForNode(const SharedNodePointer& node) { nodeJson[JSON_KEY_PUBLIC_SOCKET] = jsonForSocket(node->getPublicSocket()); nodeJson[JSON_KEY_LOCAL_SOCKET] = jsonForSocket(node->getLocalSocket()); + // add the node uptime in our list + nodeJson[JSON_KEY_WAKE_TIMESTAMP] = QString::number(node->getWakeTimestamp()); + // if the node has pool information, add it SharedAssignmentPointer matchingAssignment = _staticAssignmentHash.value(node->getUUID()); if (matchingAssignment) { @@ -707,18 +718,17 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url } else if (url.path() == QString("%1.json").arg(URI_NODES)) { // setup the JSON QJsonObject rootJSON; - QJsonObject nodesJSON; + QJsonArray nodesJSONArray; // enumerate the NodeList to find the assigned nodes NodeList* nodeList = NodeList::getInstance(); foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { // add the node using the UUID as the key - QString uuidString = uuidStringWithoutCurlyBraces(node->getUUID()); - nodesJSON[uuidString] = jsonObjectForNode(node); + nodesJSONArray.append(jsonObjectForNode(node)); } - rootJSON["nodes"] = nodesJSON; + rootJSON["nodes"] = nodesJSONArray; // print out the created JSON QJsonDocument nodesDocument(rootJSON); diff --git a/domain-server/src/DomainServer.h b/domain-server/src/DomainServer.h index 597be7f50d..c2f0eee995 100644 --- a/domain-server/src/DomainServer.h +++ b/domain-server/src/DomainServer.h @@ -1,13 +1,16 @@ // // DomainServer.h -// hifi +// domain-server/src // // Created by Stephen Birarda on 9/26/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__DomainServer__ -#define __hifi__DomainServer__ +#ifndef hifi_DomainServer_h +#define hifi_DomainServer_h #include #include @@ -86,4 +89,4 @@ private slots: void readAvailableDatagrams(); }; -#endif /* defined(__hifi__DomainServer__) */ +#endif // hifi_DomainServer_h diff --git a/domain-server/src/DomainServerNodeData.cpp b/domain-server/src/DomainServerNodeData.cpp index f1e08e3bc4..9e118faff6 100644 --- a/domain-server/src/DomainServerNodeData.cpp +++ b/domain-server/src/DomainServerNodeData.cpp @@ -1,9 +1,12 @@ // // DomainServerNodeData.cpp -// hifi +// domain-server/src // // Created by Stephen Birarda on 2/6/2014. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include @@ -45,4 +48,4 @@ QJsonObject DomainServerNodeData::mergeJSONStatsFromNewObject(const QJsonObject& } return destinationObject; -} \ No newline at end of file +} diff --git a/domain-server/src/DomainServerNodeData.h b/domain-server/src/DomainServerNodeData.h index 20531839f4..3b73ec17d2 100644 --- a/domain-server/src/DomainServerNodeData.h +++ b/domain-server/src/DomainServerNodeData.h @@ -1,13 +1,16 @@ // // DomainServerNodeData.h -// hifi +// domain-server/src // // Created by Stephen Birarda on 2/6/2014. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__DomainServerNodeData__ -#define __hifi__DomainServerNodeData__ +#ifndef hifi_DomainServerNodeData_h +#define hifi_DomainServerNodeData_h #include #include @@ -35,4 +38,4 @@ private: QJsonObject _statsJSONObject; }; -#endif /* defined(__hifi__DomainServerNodeData__) */ +#endif // hifi_DomainServerNodeData_h diff --git a/domain-server/src/main.cpp b/domain-server/src/main.cpp index 970d1dad70..2c8c3bd4c4 100644 --- a/domain-server/src/main.cpp +++ b/domain-server/src/main.cpp @@ -1,9 +1,9 @@ // // main.cpp -// Domain Server +// domain-server/src // // Created by Philip Rosedale on 11/20/12. -// Copyright (c) 2012 High Fidelity, Inc. All rights reserved. +// Copyright 2012 High Fidelity, Inc. // // The Domain Server keeps a list of nodes that have connected to it, and echoes that list of // nodes out to nodes when they check in. @@ -11,6 +11,9 @@ // The connection is stateless... the domain server will set you inactive if it does not hear from // you in LOGOFF_CHECK_INTERVAL milliseconds, meaning your info will not be sent to other users. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// #include diff --git a/examples/addVoxelOnMouseClickExample.js b/examples/addVoxelOnMouseClickExample.js index 244a017ae4..4fa175577c 100644 --- a/examples/addVoxelOnMouseClickExample.js +++ b/examples/addVoxelOnMouseClickExample.js @@ -1,13 +1,15 @@ // // addVoxelOnMouseClickExample.js -// hifi +// examples // // Created by Brad Hefta-Gaub on 2/6/14. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. // // This is an example script that demonstrates use of the Camera and Voxels class to implement // clicking on a voxel and adding a new voxel on the clicked on face // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // function mousePressEvent(event) { diff --git a/examples/audioBall.js b/examples/audioBall.js index 0889d9eb31..2a77a0999f 100644 --- a/examples/audioBall.js +++ b/examples/audioBall.js @@ -1,14 +1,17 @@ // // audioBall.js -// hifi +// examples // // Created by Athanasios Gaitatzes on 2/10/14. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. // // This script creates a particle in front of the user that stays in front of // the user's avatar as they move, and animates it's radius and color // in response to the audio intensity. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// var sound = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Animals/mexicanWhipoorwill.raw"); var CHANCE_OF_PLAYING_SOUND = 0.01; diff --git a/examples/audioDeviceExample.js b/examples/audioDeviceExample.js index 1ee00a1582..959b21f848 100644 --- a/examples/audioDeviceExample.js +++ b/examples/audioDeviceExample.js @@ -1,13 +1,15 @@ // // audioDeviceExample.js -// hifi +// examples // // Created by Brad Hefta-Gaub on 3/22/14 -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // // This is an example script that demonstrates use of the Menu object // - +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// var outputDevices = AudioDevice.getOutputDevices(); var defaultOutputDevice = AudioDevice.getDefaultOutputDevice(); diff --git a/examples/avatarCollision.js b/examples/avatarCollision.js new file mode 100644 index 0000000000..5ade894365 --- /dev/null +++ b/examples/avatarCollision.js @@ -0,0 +1,68 @@ +// +// avatarCollision.js +// examples +// +// Created by Andrew Meadows on 2014-04-09 +// Copyright 2014 High Fidelity, Inc. +// +// Play a sound on collisions with your avatar +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +var SOUND_TRIGGER_CLEAR = 1000; // milliseconds +var SOUND_TRIGGER_DELAY = 200; // milliseconds +var soundExpiry = 0; +var DateObj = new Date(); +var audioOptions = new AudioInjectionOptions(); +audioOptions.volume = 0.5; +audioOptions.position = { x: 0, y: 0, z: 0 }; + +var hitSounds = new Array(); +hitSounds[0] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit1.raw"); +hitSounds[1] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit2.raw"); +hitSounds[2] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit3.raw"); +hitSounds[3] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit4.raw"); +hitSounds[4] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit5.raw"); +hitSounds[5] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit6.raw"); +hitSounds[6] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit7.raw"); +hitSounds[7] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit8.raw"); +hitSounds[8] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit9.raw"); +hitSounds[9] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit10.raw"); +hitSounds[10] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit11.raw"); +hitSounds[11] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit12.raw"); +hitSounds[12] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit13.raw"); +hitSounds[13] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit14.raw"); +hitSounds[14] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit15.raw"); +hitSounds[15] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit16.raw"); +hitSounds[16] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit17.raw"); +hitSounds[17] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit18.raw"); +hitSounds[18] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit19.raw"); +hitSounds[19] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit20.raw"); +hitSounds[20] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit21.raw"); +hitSounds[21] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit22.raw"); + +function playHitSound(mySessionID, theirSessionID, collision) { + var now = new Date(); + var msec = now.getTime(); + if (msec > soundExpiry) { + // this is a new contact --> play a new sound + var soundIndex = Math.floor((Math.random() * hitSounds.length) % hitSounds.length); + audioOptions.position = collision.contactPoint; + Audio.playSound(hitSounds[soundIndex], audioOptions); + + // bump the expiry + soundExpiry = msec + SOUND_TRIGGER_CLEAR; + + // log the collision info + Uuid.print("my sessionID = ", mySessionID); + Uuid.print(" their sessionID = ", theirSessionID); + Vec3.print(" penetration = ", collision.penetration); + Vec3.print(" contactPoint = ", collision.contactPoint); + } else { + // this is a recurring contact --> continue to delay sound trigger + soundExpiry = msec + SOUND_TRIGGER_DELAY; + } +} +MyAvatar.collisionWithAvatar.connect(playHitSound); diff --git a/examples/bot.js b/examples/bot.js index ccbc24bc3d..f7a0429c53 100644 --- a/examples/bot.js +++ b/examples/bot.js @@ -1,13 +1,15 @@ // // bot.js -// hifi +// examples // // Created by Stephen Birarda on 2/20/14. // Modified by Philip on 3/3/14 -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. // // This is an example script that demonstrates an NPC avatar. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // function getRandomFloat(min, max) { diff --git a/examples/cameraExample.js b/examples/cameraExample.js index 6e3c51a348..332cc0fbca 100644 --- a/examples/cameraExample.js +++ b/examples/cameraExample.js @@ -1,12 +1,14 @@ // // cameraExample.js -// hifi +// examples // // Created by Brad Hefta-Gaub on 2/6/14. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. // // This is an example script that demonstrates use of the Camera class // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // var damping = 0.9; diff --git a/examples/clap.js b/examples/clap.js index ef8b61f05a..a0efcfab7b 100644 --- a/examples/clap.js +++ b/examples/clap.js @@ -1,6 +1,14 @@ // +// cameraExample.js +// examples +// +// Copyright 2014 High Fidelity, Inc. +// // This sample script watches your hydra hands and makes clapping sound when they come close together fast // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// function length(v) { return Math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z); diff --git a/examples/clipboardExample.js b/examples/clipboardExample.js index 4972505dfe..e6db44054f 100644 --- a/examples/clipboardExample.js +++ b/examples/clipboardExample.js @@ -1,12 +1,14 @@ // // clipboardExample.js -// hifi +// examples // // Created by Brad Hefta-Gaub on 1/28/14. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. // // This is an example script that demonstrates use of the Clipboard class // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // var selectedVoxel = { x: 0, y: 0, z: 0, s: 0 }; diff --git a/examples/collidingParticles.js b/examples/collidingParticles.js index 2d2cf4fecc..1f1899c8f2 100644 --- a/examples/collidingParticles.js +++ b/examples/collidingParticles.js @@ -1,14 +1,16 @@ // // collidingParticles.js -// hifi +// examples // // Created by Brad Hefta-Gaub on 12/31/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // // This is an example script that creates a couple particles, and sends them on a collision course. // One of the particles has a script that when it collides with another particle, it swaps colors with that particle. // The other particle has a script that when it collides with another particle it set's it's script to a suicide script. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // var currentIteration = 0; @@ -30,9 +32,10 @@ var gravity = { var damping = 0.1; var scriptA = " " + - " function collisionWithParticle(other, penetration) { " + + " function collisionWithParticle(other, collision) { " + " print('collisionWithParticle(other.getID()=' + other.getID() + ')...'); " + - " Vec3.print('penetration=', penetration); " + + " Vec3.print('penetration=', collision.penetration); " + + " Vec3.print('contactPoint=', collision.contactPoint); " + " print('myID=' + Particle.getID() + '\\n'); " + " var colorBlack = { red: 0, green: 0, blue: 0 };" + " var otherColor = other.getColor();" + @@ -46,9 +49,10 @@ var scriptA = " " + " "; var scriptB = " " + - " function collisionWithParticle(other, penetration) { " + + " function collisionWithParticle(other, collision) { " + " print('collisionWithParticle(other.getID()=' + other.getID() + ')...'); " + - " Vec3.print('penetration=', penetration); " + + " Vec3.print('penetration=', collision.penetration); " + + " Vec3.print('contactPoint=', collision.contactPoint); " + " print('myID=' + Particle.getID() + '\\n'); " + " Particle.setScript('Particle.setShouldDie(true);'); " + " } " + diff --git a/examples/controllerExample.js b/examples/controllerExample.js index ebb013913e..66a9e40c56 100644 --- a/examples/controllerExample.js +++ b/examples/controllerExample.js @@ -1,12 +1,14 @@ // // controllerExample.js -// hifi +// examples // // Created by Brad Hefta-Gaub on 1/28/14. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. // // This is an example script that demonstrates use of the Controller class // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // // initialize our triggers diff --git a/examples/count.js b/examples/count.js index e04bc2c94b..2a8699ac55 100644 --- a/examples/count.js +++ b/examples/count.js @@ -1,12 +1,16 @@ // // count.js -// hifi +// examples // // Created by Brad Hefta-Gaub on 12/31/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // // This is an example script that runs in a loop and displays a counter to the log // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// +// var count = 0; diff --git a/examples/crazylegs.js b/examples/crazylegs.js index 099387e000..6311aea6e4 100644 --- a/examples/crazylegs.js +++ b/examples/crazylegs.js @@ -1,9 +1,12 @@ // // crazylegs.js -// hifi +// examples // // Created by Andrzej Kapolka on 3/6/14. -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // var FREQUENCY = 5.0; @@ -12,9 +15,12 @@ var AMPLITUDE = 45.0; var cumulativeTime = 0.0; -print("Joint List:"); +print("# Joint list start"); var jointList = MyAvatar.getJointNames(); -print(jointList); +for (var i = 0; i < jointList.length; i++) { + print("jointIndex = " + jointList[i] + " = " + i); +} +print("# Joint list end"); Script.update.connect(function(deltaTime) { cumulativeTime += deltaTime; diff --git a/examples/defaultScripts.js b/examples/defaultScripts.js index 722b21844f..b3f9649883 100644 --- a/examples/defaultScripts.js +++ b/examples/defaultScripts.js @@ -1,5 +1,13 @@ +// // defaultScripts.js -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// examples +// +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + Script.include("lookWithTouch.js"); Script.include("editVoxels.js"); Script.include("selectAudioDevice.js"); diff --git a/examples/drumStick.js b/examples/drumStick.js index 9b0a8ccbca..e9ac54f814 100644 --- a/examples/drumStick.js +++ b/examples/drumStick.js @@ -1,6 +1,14 @@ // +// drumStick.js +// examples +// +// Copyright 2014 High Fidelity, Inc. +// // This example musical instrument script plays 'air drums' when you move your hands downward // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// function length(v) { return Math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z); diff --git a/examples/editParticleExample.js b/examples/editParticleExample.js index b632e0229b..54c94d0ef3 100644 --- a/examples/editParticleExample.js +++ b/examples/editParticleExample.js @@ -1,12 +1,15 @@ // // editParticleExample.js -// hifi +// examples // // Created by Brad Hefta-Gaub on 12/31/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. // // This is an example script that demonstrates creating and editing a particle // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// var count = 0; var moveUntil = 2000; diff --git a/examples/editVoxels.js b/examples/editVoxels.js index 4922caf0d8..31e8da8e74 100644 --- a/examples/editVoxels.js +++ b/examples/editVoxels.js @@ -1,9 +1,9 @@ // // editVoxels.js -// hifi +// examples // // Created by Philip Rosedale on February 8, 2014 -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. // // Captures mouse clicks and edits voxels accordingly. // @@ -15,6 +15,9 @@ // // Click and drag to create more new voxels in the same direction // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// var windowDimensions = Controller.getViewportDimensions(); @@ -32,6 +35,7 @@ var MIN_PASTE_VOXEL_SCALE = .256; var zFightingSizeAdjust = 0.002; // used to adjust preview voxels to prevent z fighting var previewLineWidth = 1.5; +var inspectJsIsRunning = false; var isAdding = false; var isExtruding = false; var extrudeDirection = { x: 0, y: 0, z: 0 }; @@ -62,9 +66,9 @@ var whichColor = -1; // Starting color is 'Copy' mode // Create sounds for adding, deleting, recoloring voxels var addSound1 = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Voxels/voxel+create+2.raw"); -var addSound2 = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Voxels/voxel+create+3.raw"); -var addSound3 = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Voxels/voxel+create+4.raw"); +var addSound2 = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Voxels/voxel+create+4.raw"); +var addSound3 = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Voxels/voxel+create+3.raw"); var deleteSound = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Voxels/voxel+delete+2.raw"); var changeColorSound = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Voxels/voxel+edit+2.raw"); var clickSound = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Switches+and+sliders/toggle+switch+-+medium.raw"); @@ -727,6 +731,9 @@ function trackKeyPressEvent(event) { trackAsEyedropper = true; moveTools(); } + if (event.text == "ALT") { + inspectJsIsRunning = true; + } showPreviewGuides(); } @@ -739,6 +746,10 @@ function trackKeyReleaseEvent(event) { showPreviewGuides(); Audio.playSound(clickSound, audioOptions); } + + if (event.text == "ALT") { + inspectJsIsRunning = false; + } if (editToolsOn) { if (event.text == "ESC") { @@ -777,11 +788,13 @@ function trackKeyReleaseEvent(event) { } function mousePressEvent(event) { - // if our tools are off, then don't do anything if (!editToolsOn) { return; } + if (inspectJsIsRunning) { + return; + } var clickedOnSomething = false; var clickedOverlay = Overlays.getOverlayAtPoint({x: event.x, y: event.y}); @@ -911,7 +924,6 @@ function mousePressEvent(event) { } voxelDetails = calculateVoxelFromIntersection(intersection,"add"); - Voxels.eraseVoxel(voxelDetails.x, voxelDetails.y, voxelDetails.z, voxelDetails.s); Voxels.setVoxel(voxelDetails.x, voxelDetails.y, voxelDetails.z, voxelDetails.s, newColor.red, newColor.green, newColor.blue); lastVoxelPosition = { x: voxelDetails.x, y: voxelDetails.y, z: voxelDetails.z }; @@ -1061,7 +1073,9 @@ function mouseMoveEvent(event) { if (!editToolsOn) { return; } - + if (inspectJsIsRunning) { + return; + } if (isMovingSlider) { thumbX = (event.x - thumbClickOffsetX) - sliderX; @@ -1121,7 +1135,10 @@ function mouseReleaseEvent(event) { if (!editToolsOn) { return; } - + if (inspectJsIsRunning) { + return; + } + if (isMovingSlider) { isMovingSlider = false; } @@ -1214,24 +1231,6 @@ function moveTools() { } -function touchBeginEvent(event) { - if (!editToolsOn) { - return; - } -} - -function touchUpdateEvent(event) { - if (!editToolsOn) { - return; - } -} - -function touchEndEvent(event) { - if (!editToolsOn) { - return; - } -} - var lastFingerAddVoxel = { x: -1, y: -1, z: -1}; // off of the build-able area var lastFingerDeleteVoxel = { x: -1, y: -1, z: -1}; // off of the build-able area @@ -1332,9 +1331,6 @@ Controller.mouseReleaseEvent.connect(mouseReleaseEvent); Controller.mouseMoveEvent.connect(mouseMoveEvent); Controller.keyPressEvent.connect(keyPressEvent); Controller.keyReleaseEvent.connect(keyReleaseEvent); -Controller.touchBeginEvent.connect(touchBeginEvent); -Controller.touchUpdateEvent.connect(touchUpdateEvent); -Controller.touchEndEvent.connect(touchEndEvent); Controller.captureKeyEvents({ text: "+" }); Controller.captureKeyEvents({ text: "-" }); diff --git a/examples/findParticleExample.js b/examples/findParticleExample.js index 4a0e9b832a..635e30f344 100644 --- a/examples/findParticleExample.js +++ b/examples/findParticleExample.js @@ -1,12 +1,15 @@ // // findParticleExample.js -// hifi +// examples // // Created by Brad Hefta-Gaub on 1/24/14. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. // // This is an example script that demonstrates "finding" particles // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// var iteration = 0; diff --git a/examples/flockingBirds.js b/examples/flockingBirds.js index 12b402ab40..17c60d88aa 100644 --- a/examples/flockingBirds.js +++ b/examples/flockingBirds.js @@ -1,9 +1,9 @@ // // flockingBirds.js -// hifi +// examples // // Created by Brad Hefta-Gaub on 3/4/14. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. // // This is an example script that generates particles that act like flocking birds // @@ -13,12 +13,16 @@ // go back to gliding // birds don't like to be below a certain altitude // if they are below that altitude they will keep thrusting up, until they get ove - +// // flocking // try to align your velocity with velocity of other birds // try to fly toward center of flock // but dont get too close // +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// var birdsInFlock = 40; diff --git a/examples/fountain.js b/examples/fountain.js index 8816dab09a..ab1b82cb76 100644 --- a/examples/fountain.js +++ b/examples/fountain.js @@ -1,4 +1,12 @@ - +// +// fountain.js +// examples +// +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// function vLength(v) { return Math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z); diff --git a/examples/gameoflife.js b/examples/gameoflife.js index c0122c604a..3fcbfa8138 100644 --- a/examples/gameoflife.js +++ b/examples/gameoflife.js @@ -1,6 +1,14 @@ -// Add your JavaScript for assignment below this line - -// The following is an example of Conway's Game of Life (http://en.wikipedia.org/wiki/Conway's_Game_of_Life) +// +// gameoflife.js +// examples +// +// Copyright 2014 High Fidelity, Inc. +// +// The following is an example of Conway's Game of Life (http://en.wikipedia.org/wiki/Conway's_Game_of_Life) +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// var NUMBER_OF_CELLS_EACH_DIMENSION = 64; var NUMBER_OF_CELLS = NUMBER_OF_CELLS_EACH_DIMENSION * NUMBER_OF_CELLS_EACH_DIMENSION; diff --git a/examples/globalCollisionsExample.js b/examples/globalCollisionsExample.js index 266823f564..11d90cd15b 100644 --- a/examples/globalCollisionsExample.js +++ b/examples/globalCollisionsExample.js @@ -1,29 +1,33 @@ // // globalCollisionsExample.js -// hifi +// examples // // Created by Brad Hefta-Gaub on 1/29/14. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. // // This is an example script that demonstrates use of the Controller class // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // print("hello..."); -function particleCollisionWithVoxel(particle, voxel, penetration) { +function particleCollisionWithVoxel(particle, voxel, collision) { print("particleCollisionWithVoxel().."); print(" particle.getID()=" + particle.id); print(" voxel color...=" + voxel.red + ", " + voxel.green + ", " + voxel.blue); - Vec3.print('penetration=', penetration); + Vec3.print('penetration=', collision.penetration); + Vec3.print('contactPoint=', collision.contactPoint); } -function particleCollisionWithParticle(particleA, particleB, penetration) { +function particleCollisionWithParticle(particleA, particleB, collision) { print("particleCollisionWithParticle().."); print(" particleA.getID()=" + particleA.id); print(" particleB.getID()=" + particleB.id); - Vec3.print('penetration=', penetration); + Vec3.print('penetration=', collision.penetration); + Vec3.print('contactPoint=', collision.contactPoint); } Particles.particleCollisionWithVoxel.connect(particleCollisionWithVoxel); diff --git a/examples/gun.js b/examples/gun.js index e358e6b391..8cf6c9f654 100644 --- a/examples/gun.js +++ b/examples/gun.js @@ -1,18 +1,19 @@ // // gun.js -// hifi +// examples // // Created by Brad Hefta-Gaub on 12/31/13. // Modified by Philip on 3/3/14 -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // // This is an example script that turns the hydra controllers and mouse into a particle gun. // It reads the controller, watches for trigger pulls, and launches particles. // When particles collide with voxels they blow little holes out of the voxels. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // - function getRandomFloat(min, max) { return Math.random() * (max - min) + min; } @@ -145,24 +146,21 @@ function shootTarget() { -function particleCollisionWithVoxel(particle, voxel, penetration) { +function particleCollisionWithVoxel(particle, voxel, collision) { var HOLE_SIZE = 0.125; var particleProperties = Particles.getParticleProperties(particle); var position = particleProperties.position; Particles.deleteParticle(particle); // Make a hole in this voxel - Vec3.print("penetration", penetration); - Vec3.print("position", position); - var pointOfEntry = Vec3.subtract(position, penetration); - Vec3.print("pointOfEntry", pointOfEntry); - Voxels.eraseVoxel(pointOfEntry.x, pointOfEntry.y, pointOfEntry.z, HOLE_SIZE); + Vec3.print("penetration", collision.penetration); + Vec3.print("contactPoint", collision.contactPoint); + Voxels.eraseVoxel(contactPoint.x, contactPoint.y, contactPoint.z, HOLE_SIZE); Voxels.eraseVoxel(position.x, position.y, position.z, HOLE_SIZE); - //audioOptions.position = position; audioOptions.position = Vec3.sum(Camera.getPosition(), Quat.getFront(Camera.getOrientation())); Audio.playSound(impactSound, audioOptions); } -function particleCollisionWithParticle(particle1, particle2) { +function particleCollisionWithParticle(particle1, particle2, collision) { score++; if (showScore) { Overlays.editOverlay(text, { text: "Score: " + score } ); @@ -174,9 +172,11 @@ function particleCollisionWithParticle(particle1, particle2) { var endTime = new Date(); var msecs = endTime.valueOf() - shotTime.valueOf(); print("hit, msecs = " + msecs); + Vec3.print("penetration = ", collision.penetration); + Vec3.print("contactPoint = ", collision.contactPoint); Particles.deleteParticle(particle1); Particles.deleteParticle(particle2); - audioOptions.position = newPosition; + // play the sound near the camera so the shooter can hear it audioOptions.position = Vec3.sum(Camera.getPosition(), Quat.getFront(Camera.getOrientation())); Audio.playSound(targetHitSound, audioOptions); } diff --git a/examples/hideAvatarExample.js b/examples/hideAvatarExample.js index 7a0ece76eb..66d85becf1 100644 --- a/examples/hideAvatarExample.js +++ b/examples/hideAvatarExample.js @@ -1,12 +1,14 @@ // // hideAvatarExample.js -// hifi +// examples // // Created by Brad Hefta-Gaub on 1/28/14. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. // // This is an example script that demonstrates how to enable or disable local rendering of your own avatar // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // function keyReleaseEvent(event) { diff --git a/examples/hydraMove.js b/examples/hydraMove.js index 6268a38ba3..b73f990446 100644 --- a/examples/hydraMove.js +++ b/examples/hydraMove.js @@ -1,13 +1,15 @@ // // hydraMove.js -// hifi +// examples // // Created by Brad Hefta-Gaub on 2/10/14. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. // // This is an example script that demonstrates use of the Controller and MyAvatar classes to implement // avatar flying through the hydra/controller joysticks // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // var damping = 0.9; diff --git a/examples/includeExample.js b/examples/includeExample.js index 489928d759..50a1234772 100644 --- a/examples/includeExample.js +++ b/examples/includeExample.js @@ -1,12 +1,15 @@ // // includeExample.js -// hifi +// examples // // Created by Brad Hefta-Gaub on 3/24/14 -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // // This is an example script that demonstrates use of the Script.include() feature // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// // You can include scripts from URLs Script.include("http://public.highfidelity.io/scripts/lookWithTouch.js"); diff --git a/examples/inspect.js b/examples/inspect.js index 2443eadf9b..28db1e7735 100644 --- a/examples/inspect.js +++ b/examples/inspect.js @@ -1,9 +1,9 @@ // // inspect.js -// hifi +// examples // // Created by Clément Brisset on March 20, 2014 -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. // // Allows you to inspect non moving objects (Voxels or Avatars) using Atl, Control (Command on Mac) and Shift // @@ -13,6 +13,9 @@ // Once you are in a mode left click on the object to inspect and hold the click // Dragging the mouse will move your camera according to the mode you are in. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// var PI = 3.14 // No need for something more precise diff --git a/examples/localVoxelsExample.js b/examples/localVoxelsExample.js index 7d9007f590..d64138b214 100644 --- a/examples/localVoxelsExample.js +++ b/examples/localVoxelsExample.js @@ -1,3 +1,12 @@ +// +// localVoxelsExample.js +// examples +// +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// var TREE_SCALE = 16384; var tree = LocalVoxels("tree"); diff --git a/examples/lookAtExample.js b/examples/lookAtExample.js index 46e0863231..1cf8aabb96 100644 --- a/examples/lookAtExample.js +++ b/examples/lookAtExample.js @@ -1,9 +1,9 @@ // // lookAtExample.js -// hifi +// examples // // Created by Brad Hefta-Gaub on 2/6/14. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. // // This is an example script that demonstrates use of the Camera class's lookAt(), keepLookingAt(), and stopLookingAt() // features. @@ -12,6 +12,8 @@ // on the face of the voxel that you clicked. Click again and it will stop looking at that point. While in this fixed mode // you can use the arrow keys to change the position of the camera. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // var lookingAtSomething = false; diff --git a/examples/lookWithMouse.js b/examples/lookWithMouse.js index ef8f11ec16..256a3ea67c 100644 --- a/examples/lookWithMouse.js +++ b/examples/lookWithMouse.js @@ -1,12 +1,14 @@ // // lookWithMouse.js -// hifi +// examples // // Created by Brad Hefta-Gaub on 1/28/14. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. // // This is an example script that demonstrates use of the Controller class // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // var alwaysLook = true; // if you want the mouse look to happen only when you click, change this to false diff --git a/examples/lookWithTouch.js b/examples/lookWithTouch.js index 4406b4567e..68b29c305b 100644 --- a/examples/lookWithTouch.js +++ b/examples/lookWithTouch.js @@ -1,12 +1,14 @@ // // lookWithTouch.js -// hifi +// examples // // Created by Brad Hefta-Gaub on 1/28/14. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. // // This is an example script that demonstrates use of the Controller class // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // var startedTouching = false; diff --git a/examples/menuExample.js b/examples/menuExample.js index 874d95ec31..00c6418269 100644 --- a/examples/menuExample.js +++ b/examples/menuExample.js @@ -1,12 +1,15 @@ // // menuExample.js -// hifi +// examples // // Created by Brad Hefta-Gaub on 2/24/14 -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // // This is an example script that demonstrates use of the Menu object // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// function setupMenus() { diff --git a/examples/movingVoxel.js b/examples/movingVoxel.js index 0ddce48334..c55957cd04 100644 --- a/examples/movingVoxel.js +++ b/examples/movingVoxel.js @@ -1,6 +1,14 @@ // +// movingVoxel.js +// examples +// +// Copyright 2014 High Fidelity, Inc. +// // This sample script creates a voxel moving back and forth in a line // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// var position = { x: 0, y: 0, z: 0 }; var oldPosition = { x: 0, y: 0, z:0 }; diff --git a/examples/multitouchExample.js b/examples/multitouchExample.js index 51bbcc2c20..9d27b7ae2a 100644 --- a/examples/multitouchExample.js +++ b/examples/multitouchExample.js @@ -1,9 +1,9 @@ // // multitouchExample.js -// hifi +// examples // // Created by Brad Hefta-Gaub on 2/9/14. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. // // This is an example script that demonstrates use of the Controller class's multi-touch features // @@ -11,6 +11,9 @@ // * Four finger rotate gesture will rotate your avatar. // * Three finger swipe up/down will adjust the pitch of your avatars head. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// var lastX = 0; var lastY = 0; diff --git a/examples/overlaysExample.js b/examples/overlaysExample.js index 60f924338f..d0b3870803 100644 --- a/examples/overlaysExample.js +++ b/examples/overlaysExample.js @@ -1,12 +1,14 @@ // // overlaysExample.js -// hifi +// examples // // Created by Brad Hefta-Gaub on 2/14/14. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. // // This is an example script that demonstrates use of the Overlays class // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // diff --git a/examples/paintGun.js b/examples/paintGun.js index 6b6e78b43e..b5bb2a49da 100644 --- a/examples/paintGun.js +++ b/examples/paintGun.js @@ -1,9 +1,12 @@ // // paintGun.js -// hifi +// examples // // Created by Brad Hefta-Gaub on 12/31/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // // initialize our triggers @@ -62,9 +65,10 @@ function checkController(deltaTime) { // This is the script for the particles that this gun shoots. var script = - " function collisionWithVoxel(voxel, penetration) { " + + " function collisionWithVoxel(voxel, collision) { " + " print('collisionWithVoxel(voxel)... '); " + - " Vec3.print('penetration=', penetration); " + + " Vec3.print('penetration=', collision.penetration); " + + " Vec3.print('contactPoint=', collision.contactPoint); " + " print('myID=' + Particle.getID() + '\\n'); " + " var voxelColor = { red: voxel.red, green: voxel.green, blue: voxel.blue };" + " var voxelAt = { x: voxel.x, y: voxel.y, z: voxel.z };" + diff --git a/examples/particleBird.js b/examples/particleBird.js index 5cd068bd60..5241b3550b 100644 --- a/examples/particleBird.js +++ b/examples/particleBird.js @@ -1,9 +1,14 @@ // // particleBird.js -// hifi +// examples +// +// Copyright 2014 High Fidelity, Inc. // // This sample script moves a voxel around like a bird and sometimes makes tweeting noises // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// function vLength(v) { return Math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z); diff --git a/examples/particleModelExample.js b/examples/particleModelExample.js index c43956cd3e..b489e704c9 100644 --- a/examples/particleModelExample.js +++ b/examples/particleModelExample.js @@ -1,12 +1,15 @@ // // particleModelExample.js -// hifi +// examples // // Created by Brad Hefta-Gaub on 1/28/14. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. // // This is an example script that demonstrates creating and editing a particle // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// var count = 0; var stopAfter = 100; diff --git a/examples/playSound.js b/examples/playSound.js index 18857826ea..fb589bc9e3 100644 --- a/examples/playSound.js +++ b/examples/playSound.js @@ -1,6 +1,12 @@ // +// playSound.js +// examples +// +// Copyright 2014 High Fidelity, Inc. // This sample script loads a sound file and plays it at the 'fingertip' of the // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // First, load the clap sound from a URL var clap = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Animals/bushtit_1.raw"); diff --git a/examples/rayPickExample.js b/examples/rayPickExample.js index 9c34cca1de..c09a7b1e57 100644 --- a/examples/rayPickExample.js +++ b/examples/rayPickExample.js @@ -1,12 +1,14 @@ // // rayPickExample.js -// hifi +// examples // // Created by Brad Hefta-Gaub on 2/6/14. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. // // This is an example script that demonstrates use of the Camera class // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // function mouseMoveEvent(event) { diff --git a/examples/ribbon.js b/examples/ribbon.js index a6e1edfa4a..dd3d46fbfc 100644 --- a/examples/ribbon.js +++ b/examples/ribbon.js @@ -1,9 +1,12 @@ // // ribbon.js -// hifi +// examples // // Created by Andrzej Kapolka on 2/24/14. -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // function vectorMultiply(vector, scalar) { diff --git a/examples/rideAlongWithAParticleExample.js b/examples/rideAlongWithAParticleExample.js index 1148b96b4d..552f6fb7fe 100644 --- a/examples/rideAlongWithAParticleExample.js +++ b/examples/rideAlongWithAParticleExample.js @@ -1,12 +1,15 @@ // // rideAlongWithAParticleExample.js -// hifi +// examples // // Created by Brad Hefta-Gaub on 1/24/14. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. // // This is an example script that demonstrates "finding" particles // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// var iteration = 0; var lengthOfRide = 2000; // in iterations diff --git a/examples/seeingVoxelsExample.js b/examples/seeingVoxelsExample.js index 0cfe54d89e..35e2f95dd7 100644 --- a/examples/seeingVoxelsExample.js +++ b/examples/seeingVoxelsExample.js @@ -1,11 +1,12 @@ // // seeingVoxelsExample.js -// hifi +// examples // // Created by Brad Hefta-Gaub on 2/26/14 -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. // -// This is an example script +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // var count = 0; diff --git a/examples/selectAudioDevice.js b/examples/selectAudioDevice.js index 958ca7babf..23606f774c 100644 --- a/examples/selectAudioDevice.js +++ b/examples/selectAudioDevice.js @@ -1,12 +1,15 @@ // // audioDeviceExample.js -// hifi +// examples // // Created by Brad Hefta-Gaub on 3/22/14 -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // // This is an example script that demonstrates use of the Menu object // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// if (typeof String.prototype.startsWith != 'function') { String.prototype.startsWith = function (str){ diff --git a/examples/settingsExample.js b/examples/settingsExample.js index 0dcc5482b6..bef347ff07 100644 --- a/examples/settingsExample.js +++ b/examples/settingsExample.js @@ -1,15 +1,15 @@ // // settingsExample.js -// hifi +// examples // // Created by Brad Hefta-Gaub on 3/22/14 -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // // This is an example script that demonstrates use of the Menu object // - - - +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// print("mySetting: " + Settings.getValue("mySetting")); Settings.setValue("mySetting", "spam"); diff --git a/examples/spaceInvadersExample.js b/examples/spaceInvadersExample.js index 61ff93fc8f..5b25fa1236 100644 --- a/examples/spaceInvadersExample.js +++ b/examples/spaceInvadersExample.js @@ -1,12 +1,15 @@ // // spaceInvadersExample.js -// hifi +// examples // // Created by Brad Hefta-Gaub on 1/30/14. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. // // This is an example script that demonstrates a simple space invaders style of game // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// var iteration = 0; @@ -392,9 +395,10 @@ function deleteIfInvader(possibleInvaderParticle) { } } -function particleCollisionWithParticle(particleA, particleB, penetration) { +function particleCollisionWithParticle(particleA, particleB, collision) { print("particleCollisionWithParticle() a.id="+particleA.id + " b.id=" + particleB.id); - Vec3.print('particleCollisionWithParticle() penetration=', penetration); + Vec3.print('particleCollisionWithParticle() penetration=', collision.penetration); + Vec3.print('particleCollisionWithParticle() contactPoint=', collision.contactPoint); if (missileFired) { myMissile = Particles.identifyParticle(myMissile); if (myMissile.id == particleA.id) { diff --git a/examples/timer.js b/examples/timer.js index c7ad0290ab..b3af1d902c 100644 --- a/examples/timer.js +++ b/examples/timer.js @@ -1,3 +1,13 @@ +// +// timer.js +// examples +// +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + var one_timer = Script.setTimeout(function() { print("One time timer fired!"); }, 10000); var multiple_timer = Script.setInterval(function() { print("Repeating timer fired!"); }, 1000); diff --git a/examples/toyball.js b/examples/toyball.js index 36f1aa11e5..de68e97357 100644 --- a/examples/toyball.js +++ b/examples/toyball.js @@ -1,9 +1,9 @@ // // toyball.js -// hifi +// examples // // Created by Brad Hefta-Gaub on 1/20/14. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. // // This is an example script that turns the hydra controllers into a toy ball catch and throw game. // It reads the controller, watches for button presses and trigger pulls, and launches particles. @@ -11,6 +11,8 @@ // The particles it creates have a script that when they collide with Voxels, the // particle will change it's color to match the voxel it hits. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // // maybe we should make these constants... diff --git a/examples/voxelDrumming.js b/examples/voxelDrumming.js index 178c6734d8..7f3495dea7 100644 --- a/examples/voxelDrumming.js +++ b/examples/voxelDrumming.js @@ -1,14 +1,17 @@ // // voxelDrumming.js -// hifi +// examples // // Created by Brad Hefta-Gaub on 2/14/14. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. // // This is an example script that demonstrates use of the Overlays, Controller, and Audio classes // // It adds Hydra controller "fingertip on voxels" drumming // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// Menu.addMenuItem({ menuName: "Developer > Hand Options", diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index f991212a6e..4e58d898af 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -12,6 +12,7 @@ project(${TARGET_NAME}) # setup for find modules set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules/") +set(FACEPLUS_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/faceplus") set(FACESHIFT_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/faceshift") set(LIBOVR_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/oculus") set(SIXENSE_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/Sixense") @@ -73,17 +74,13 @@ file (GLOB_RECURSE QT_UI_FILES ui/*.ui) # have qt5 wrap them and generate the appropriate header files qt5_wrap_ui(QT_UI_HEADERS "${QT_UI_FILES}") -# grab the resource files in resources -file (GLOB_RECURSE QT_RESOURCE_FILES resources/*.qrc) -# have qt5 wrap them and generate the appropriate source files -qt5_add_resources(QT_RESOURCES "${QT_RESOURCE_FILES}") - # add them to the interface source files set(INTERFACE_SRCS ${INTERFACE_SRCS} "${QT_UI_HEADERS}" "${QT_RESOURCES}") -set(QM ${TARGET_NAME}_en.qm) -set(TS ${TARGET_NAME}_en.ts) -qt5_create_translation_custom(${QM} ${INTERFACE_SRCS} ${QT_UI_FILES} ${TS}) +# translation disabled until we strip out the line numbers +# set(QM ${TARGET_NAME}_en.qm) +# set(TS ${TARGET_NAME}_en.ts) +# qt5_create_translation_custom(${QM} ${INTERFACE_SRCS} ${QT_UI_FILES} ${TS}) if (APPLE) # configure CMake to use a custom Info.plist @@ -129,6 +126,7 @@ link_hifi_library(audio ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(script-engine ${TARGET_NAME} "${ROOT_DIR}") # find any optional libraries +find_package(Faceplus) find_package(Faceshift) find_package(LibOVR) find_package(Sixense) @@ -162,6 +160,13 @@ if (VISAGE_FOUND AND NOT DISABLE_VISAGE) target_link_libraries(${TARGET_NAME} "${VISAGE_LIBRARIES}") endif (VISAGE_FOUND AND NOT DISABLE_VISAGE) +# and with Faceplus library, also for webcam feature tracking +if (FACEPLUS_FOUND AND NOT DISABLE_FACEPLUS) + add_definitions(-DHAVE_FACEPLUS) + include_directories(SYSTEM "${FACEPLUS_INCLUDE_DIRS}") + target_link_libraries(${TARGET_NAME} "${FACEPLUS_LIBRARIES}") +endif (FACEPLUS_FOUND AND NOT DISABLE_FACEPLUS) + # and with LibOVR for Oculus Rift if (LIBOVR_FOUND AND NOT DISABLE_LIBOVR) add_definitions(-DHAVE_LIBOVR) diff --git a/interface/InterfaceConfig.h.in b/interface/InterfaceConfig.h.in index 0b570f622f..b2b1881d67 100644 --- a/interface/InterfaceConfig.h.in +++ b/interface/InterfaceConfig.h.in @@ -1,9 +1,12 @@ // // InterfaceConfig.h -// interface +// interface/src // // Created by Stephen Birarda on 2/8/13. -// Copyright (c) 2013 High Fidelity, Inc.. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #ifndef interface__InterfaceConfig__ diff --git a/interface/InterfaceVersion.h.in b/interface/InterfaceVersion.h.in index 60e51b4ab6..2f902de41c 100644 --- a/interface/InterfaceVersion.h.in +++ b/interface/InterfaceVersion.h.in @@ -1,9 +1,14 @@ // // InterfaceVersion.h -// Declaration of version and build data +// interface/src // // Created by Leonardo Murillo on 12/16/13. -// Copyright (c) 2013 High Fidelity, Inc.. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Declaration of version and build data +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // const QString BUILD_VERSION = "@BUILD_SEQ@"; diff --git a/interface/external/faceplus/readme.txt b/interface/external/faceplus/readme.txt new file mode 100644 index 0000000000..e98f8becdc --- /dev/null +++ b/interface/external/faceplus/readme.txt @@ -0,0 +1,11 @@ + +Instructions for adding the Faceplus driver to Interface +Andrzej Kapolka, April 8, 2014 + +1. Copy the Faceplus sdk folders (include, win32) into the interface/external/faceplus folder. + This readme.txt should be there as well. + +2. Copy the Faceplus DLLs from the win32 folder into your path. + +3. Delete your build directory, run cmake and build, and you should be all set. + diff --git a/interface/interface_en.ts b/interface/interface_en.ts index 8a8a877a32..48b395339e 100644 --- a/interface/interface_en.ts +++ b/interface/interface_en.ts @@ -4,22 +4,22 @@ Application - + Export Voxels - + Sparse Voxel Octree Files (*.svo) - + Open Script - + JavaScript Files (*.js) @@ -27,25 +27,25 @@ ChatWindow - - + + Chat - - + + Connecting to XMPP... - - + + online now: - + day %n day @@ -53,7 +53,7 @@ - + hour %n hour @@ -61,7 +61,7 @@ - + minute %n minute @@ -76,7 +76,7 @@ - + %1 online now: @@ -113,22 +113,135 @@ Menu - + Open .ini config file - - + + Text files (*.ini) - + Save .ini config file + + PreferencesDialog + + + + Cancel + + + + + + Save all changes + + + + + + + + Avatar + + + + + + <html><head/><body><p>Avatar display name <span style=" color:#909090;">(optional)</span></p></body></html> + + + + + + Not showing a name + + + + + + Head + + + + + + Body + + + + + + Advanced Tuning + + + + + + It's not recomended that you play with these settings unless you've looked into exactly what they do. + + + + + + Vertical field of view + + + + + + Lean scale (applies to Faceshift users) + + + + + + Avatar scale <span style=" color:#909090;">(default is 1.0)</span> + + + + + + Pupil dillation + + + + + + Audio Jitter Buffer Samples (0 for automatic) + + + + + + Faceshift eye detection + + + + + + Voxels + + + + + + Maximum voxels + + + + + + Max voxels sent each second + + + QObject diff --git a/interface/resources/images/audio-box.svg b/interface/resources/images/audio-box.svg new file mode 100644 index 0000000000..0c0db4f51f --- /dev/null +++ b/interface/resources/images/audio-box.svg @@ -0,0 +1,12 @@ + + + Slice 1 + Created with Sketch (http://www.bohemiancoding.com/sketch) + + + + + + + + \ No newline at end of file diff --git a/interface/resources/images/body.png b/interface/resources/images/body.png deleted file mode 100644 index dda65bad07..0000000000 Binary files a/interface/resources/images/body.png and /dev/null differ diff --git a/interface/resources/images/close.png b/interface/resources/images/close.png deleted file mode 100644 index 8090e3d3d0..0000000000 Binary files a/interface/resources/images/close.png and /dev/null differ diff --git a/interface/resources/images/close.svg b/interface/resources/images/close.svg index 8fe4bf4bdb..0cae08c590 100644 --- a/interface/resources/images/close.svg +++ b/interface/resources/images/close.svg @@ -1,14 +1,12 @@ - - - - - - - - - - + + + Slice 1 + Created with Sketch (http://www.bohemiancoding.com/sketch) + + + + + + + + \ No newline at end of file diff --git a/interface/resources/images/head.png b/interface/resources/images/head.png deleted file mode 100644 index d21b453bee..0000000000 Binary files a/interface/resources/images/head.png and /dev/null differ diff --git a/interface/resources/images/kill-script.svg b/interface/resources/images/kill-script.svg new file mode 100644 index 0000000000..d98fc4555a --- /dev/null +++ b/interface/resources/images/kill-script.svg @@ -0,0 +1,7 @@ + + + + + + diff --git a/interface/resources/images/mic-mute.svg b/interface/resources/images/mic-mute.svg new file mode 100644 index 0000000000..39dd811df4 --- /dev/null +++ b/interface/resources/images/mic-mute.svg @@ -0,0 +1,115 @@ + + + +image/svg+xml + + + + + + + + Mic + Created with Sketch (http://www.bohemiancoding.com/sketch) + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/interface/resources/images/mic.svg b/interface/resources/images/mic.svg index a6dee50740..3329f19647 100644 --- a/interface/resources/images/mic.svg +++ b/interface/resources/images/mic.svg @@ -1,20 +1,105 @@ - - Mic - Created with Sketch (http://www.bohemiancoding.com/sketch) - - - - - - - - - - - - - - - + + +image/svg+xml + + + + + + + + Mic + Created with Sketch (http://www.bohemiancoding.com/sketch) + + + + + + + + + + + + + + \ No newline at end of file diff --git a/interface/resources/images/minus.svg b/interface/resources/images/minus.svg new file mode 100644 index 0000000000..463b24aa4c --- /dev/null +++ b/interface/resources/images/minus.svg @@ -0,0 +1,11 @@ + + + Slice 1 + Created with Sketch (http://www.bohemiancoding.com/sketch) + + + + + + + \ No newline at end of file diff --git a/interface/resources/images/mute.svg b/interface/resources/images/mute.svg deleted file mode 100644 index 1f1b238463..0000000000 --- a/interface/resources/images/mute.svg +++ /dev/null @@ -1,20 +0,0 @@ - - - mute - Created with Sketch (http://www.bohemiancoding.com/sketch) - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/interface/resources/images/pin.svg b/interface/resources/images/pin.svg new file mode 100644 index 0000000000..ec968a1ec1 --- /dev/null +++ b/interface/resources/images/pin.svg @@ -0,0 +1,98 @@ + + + + + + image/svg+xml + + Slice 1 + + + + + Slice 1 + Created with Sketch (http://www.bohemiancoding.com/sketch) + + + + + + + + diff --git a/interface/resources/images/pinned.svg b/interface/resources/images/pinned.svg new file mode 100644 index 0000000000..bda6f0e747 --- /dev/null +++ b/interface/resources/images/pinned.svg @@ -0,0 +1,106 @@ + + + + + + image/svg+xml + + Slice 1 + + + + + Slice 1 + Created with Sketch (http://www.bohemiancoding.com/sketch) + + + + + + + + + diff --git a/interface/resources/images/plus.svg b/interface/resources/images/plus.svg new file mode 100644 index 0000000000..6efaa31abc --- /dev/null +++ b/interface/resources/images/plus.svg @@ -0,0 +1,12 @@ + + + Slice 1 + Created with Sketch (http://www.bohemiancoding.com/sketch) + + + + + + + + \ No newline at end of file diff --git a/interface/resources/images/reload.svg b/interface/resources/images/reload.svg new file mode 100644 index 0000000000..a596f03301 --- /dev/null +++ b/interface/resources/images/reload.svg @@ -0,0 +1,24 @@ + + + + + + + + + + + diff --git a/interface/resources/images/stop.svg b/interface/resources/images/stop.svg new file mode 100644 index 0000000000..ea22bb592a --- /dev/null +++ b/interface/resources/images/stop.svg @@ -0,0 +1,7 @@ + + + + + + diff --git a/interface/resources/resources.qrc b/interface/resources/resources.qrc deleted file mode 100644 index 372fa8b1d4..0000000000 --- a/interface/resources/resources.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - images/close.svg - - diff --git a/interface/resources/shaders/ambient_occlusion.frag b/interface/resources/shaders/ambient_occlusion.frag index 6e9ed82d95..512922ca43 100644 --- a/interface/resources/shaders/ambient_occlusion.frag +++ b/interface/resources/shaders/ambient_occlusion.frag @@ -5,7 +5,10 @@ // fragment shader // // Created by Andrzej Kapolka on 7/5/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // // the depth texture diff --git a/interface/resources/shaders/ambient_occlusion.vert b/interface/resources/shaders/ambient_occlusion.vert index ca6af718bd..a95a0cda7d 100644 --- a/interface/resources/shaders/ambient_occlusion.vert +++ b/interface/resources/shaders/ambient_occlusion.vert @@ -5,7 +5,10 @@ // vertex shader // // Created by Andrzej Kapolka on 8/16/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // void main(void) { diff --git a/interface/resources/shaders/diffuse.frag b/interface/resources/shaders/diffuse.frag index ebf11dace2..bc88b6598d 100644 --- a/interface/resources/shaders/diffuse.frag +++ b/interface/resources/shaders/diffuse.frag @@ -5,7 +5,10 @@ // fragment shader // // Created by Andrzej Kapolka on 8/14/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // // the texture containing the original color diff --git a/interface/resources/shaders/glow_add.frag b/interface/resources/shaders/glow_add.frag index 0947292109..e8a1b504ea 100644 --- a/interface/resources/shaders/glow_add.frag +++ b/interface/resources/shaders/glow_add.frag @@ -5,7 +5,10 @@ // fragment shader // // Created by Andrzej Kapolka on 8/14/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // // the texture containing the original color diff --git a/interface/resources/shaders/glow_add_separate.frag b/interface/resources/shaders/glow_add_separate.frag index 7b7f538a03..e798a3b11f 100644 --- a/interface/resources/shaders/glow_add_separate.frag +++ b/interface/resources/shaders/glow_add_separate.frag @@ -5,7 +5,10 @@ // fragment shader // // Created by Andrzej Kapolka on 8/14/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // // the texture containing the original color diff --git a/interface/resources/shaders/grid.frag b/interface/resources/shaders/grid.frag index b9e3baccd4..17ad0fed5c 100644 --- a/interface/resources/shaders/grid.frag +++ b/interface/resources/shaders/grid.frag @@ -5,7 +5,10 @@ // fragment shader // // Created by Andrzej Kapolka on 1/21/14. -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // void main(void) { diff --git a/interface/resources/shaders/horizontal_blur.frag b/interface/resources/shaders/horizontal_blur.frag index 695de1a538..916fe4b52d 100644 --- a/interface/resources/shaders/horizontal_blur.frag +++ b/interface/resources/shaders/horizontal_blur.frag @@ -5,7 +5,10 @@ // fragment shader // // Created by Andrzej Kapolka on 8/8/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // // the texture containing the original color diff --git a/interface/resources/shaders/metavoxel_point.vert b/interface/resources/shaders/metavoxel_point.vert index b0472088c0..fa585be099 100644 --- a/interface/resources/shaders/metavoxel_point.vert +++ b/interface/resources/shaders/metavoxel_point.vert @@ -5,7 +5,10 @@ // vertex shader // // Created by Andrzej Kapolka on 12/12/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // uniform float pointScale; diff --git a/interface/resources/shaders/model.frag b/interface/resources/shaders/model.frag index e035f9bfe9..29579d07ac 100644 --- a/interface/resources/shaders/model.frag +++ b/interface/resources/shaders/model.frag @@ -5,7 +5,10 @@ // fragment shader // // Created by Andrzej Kapolka on 10/14/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // // the diffuse texture diff --git a/interface/resources/shaders/model.vert b/interface/resources/shaders/model.vert index d07a657d25..904e3c2a8b 100644 --- a/interface/resources/shaders/model.vert +++ b/interface/resources/shaders/model.vert @@ -5,7 +5,10 @@ // vertex shader // // Created by Andrzej Kapolka on 10/14/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // // the interpolated normal diff --git a/interface/resources/shaders/model_normal_map.frag b/interface/resources/shaders/model_normal_map.frag index 9a0e964500..2a4af2073a 100644 --- a/interface/resources/shaders/model_normal_map.frag +++ b/interface/resources/shaders/model_normal_map.frag @@ -5,7 +5,10 @@ // fragment shader // // Created by Andrzej Kapolka on 10/29/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // // the diffuse texture diff --git a/interface/resources/shaders/model_normal_map.vert b/interface/resources/shaders/model_normal_map.vert index c367a30e06..3607501acf 100644 --- a/interface/resources/shaders/model_normal_map.vert +++ b/interface/resources/shaders/model_normal_map.vert @@ -5,7 +5,10 @@ // vertex shader // // Created by Andrzej Kapolka on 10/14/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // // the tangent vector diff --git a/interface/resources/shaders/model_shadow.frag b/interface/resources/shaders/model_shadow.frag index bcb597b13c..50a4d3895d 100644 --- a/interface/resources/shaders/model_shadow.frag +++ b/interface/resources/shaders/model_shadow.frag @@ -5,7 +5,10 @@ // fragment shader // // Created by Andrzej Kapolka on 3/24/14. -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // void main(void) { diff --git a/interface/resources/shaders/model_shadow.vert b/interface/resources/shaders/model_shadow.vert index ae7e871887..a18f5fcd5d 100644 --- a/interface/resources/shaders/model_shadow.vert +++ b/interface/resources/shaders/model_shadow.vert @@ -5,7 +5,10 @@ // vertex shader // // Created by Andrzej Kapolka on 3/24/14. -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // void main(void) { diff --git a/interface/resources/shaders/occlusion_blur.frag b/interface/resources/shaders/occlusion_blur.frag index 5b86aec68d..ab4b656e71 100644 --- a/interface/resources/shaders/occlusion_blur.frag +++ b/interface/resources/shaders/occlusion_blur.frag @@ -5,7 +5,10 @@ // fragment shader // // Created by Andrzej Kapolka on 8/16/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // // the original texture diff --git a/interface/resources/shaders/oculus.frag b/interface/resources/shaders/oculus.frag index 3e7d1a4c3e..f2b066a974 100644 --- a/interface/resources/shaders/oculus.frag +++ b/interface/resources/shaders/oculus.frag @@ -5,11 +5,14 @@ // fragment shader // // Created by Andrzej Kapolka on 11/26/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // -// this shader is an adaptation (HLSL -> GLSL, removed conditional) of the one in the Oculus sample -// code (Samples/OculusRoomTiny/RenderTiny_D3D1X_Device.cpp), which is under the Apache license -// (http://www.apache.org/licenses/LICENSE-2.0) +// this shader is an adaptation (HLSL -> GLSL, removed conditional) of the one in the Oculus sample +// code (Samples/OculusRoomTiny/RenderTiny_D3D1X_Device.cpp), which is under the Apache license +// (http://www.apache.org/licenses/LICENSE-2.0) +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // uniform sampler2D texture; diff --git a/interface/resources/shaders/passthrough.vert b/interface/resources/shaders/passthrough.vert index f3d5c5b504..bb0a18eefa 100644 --- a/interface/resources/shaders/passthrough.vert +++ b/interface/resources/shaders/passthrough.vert @@ -1,4 +1,15 @@ #version 120 + +// +// passthrough.vert +// vertex shader +// +// Copyright 2013 High Fidelity, Inc. +// +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// attribute float voxelSizeIn; varying float voxelSize; diff --git a/interface/resources/shaders/perlin_modulate.frag b/interface/resources/shaders/perlin_modulate.frag index 8ead57c238..8693b14e1b 100644 --- a/interface/resources/shaders/perlin_modulate.frag +++ b/interface/resources/shaders/perlin_modulate.frag @@ -5,7 +5,10 @@ // fragment shader // // Created by Andrzej Kapolka on 5/15/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // // the texture containing our permutations and normals diff --git a/interface/resources/shaders/perlin_modulate.vert b/interface/resources/shaders/perlin_modulate.vert index 5cf87fc5fd..428615017a 100644 --- a/interface/resources/shaders/perlin_modulate.vert +++ b/interface/resources/shaders/perlin_modulate.vert @@ -5,7 +5,10 @@ // vertex shader // // Created by Andrzej Kapolka on 5/15/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // // the position in model space diff --git a/interface/resources/shaders/point_size.vert b/interface/resources/shaders/point_size.vert index 9c93385768..88c56bf0c4 100644 --- a/interface/resources/shaders/point_size.vert +++ b/interface/resources/shaders/point_size.vert @@ -1,4 +1,14 @@ #version 120 + +// +// point_size.vert +// vertex shader +// +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// attribute float voxelSizeIn; varying float voxelSize; diff --git a/interface/resources/shaders/shadow_map.frag b/interface/resources/shaders/shadow_map.frag index b683ed5af2..70c459ecf8 100644 --- a/interface/resources/shaders/shadow_map.frag +++ b/interface/resources/shaders/shadow_map.frag @@ -5,7 +5,10 @@ // fragment shader // // Created by Andrzej Kapolka on 11/21/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // uniform sampler2DShadow shadowMap; diff --git a/interface/resources/shaders/shadow_map.vert b/interface/resources/shaders/shadow_map.vert index 6809ca6e2b..abe5f99b44 100644 --- a/interface/resources/shaders/shadow_map.vert +++ b/interface/resources/shaders/shadow_map.vert @@ -5,7 +5,10 @@ // vertex shader // // Created by Andrzej Kapolka on 3/27/14. -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // varying vec4 shadowColor; diff --git a/interface/resources/shaders/skin_model.vert b/interface/resources/shaders/skin_model.vert index 57e3928241..12320ba9a9 100644 --- a/interface/resources/shaders/skin_model.vert +++ b/interface/resources/shaders/skin_model.vert @@ -5,7 +5,10 @@ // vertex shader // // Created by Andrzej Kapolka on 10/14/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // const int MAX_CLUSTERS = 128; diff --git a/interface/resources/shaders/skin_model_normal_map.vert b/interface/resources/shaders/skin_model_normal_map.vert index 97e21dae73..872cbe2fc3 100644 --- a/interface/resources/shaders/skin_model_normal_map.vert +++ b/interface/resources/shaders/skin_model_normal_map.vert @@ -5,7 +5,10 @@ // vertex shader // // Created by Andrzej Kapolka on 10/29/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // const int MAX_CLUSTERS = 128; diff --git a/interface/resources/shaders/skin_model_shadow.vert b/interface/resources/shaders/skin_model_shadow.vert index b9ef05ad8a..6d9d5ebbf5 100644 --- a/interface/resources/shaders/skin_model_shadow.vert +++ b/interface/resources/shaders/skin_model_shadow.vert @@ -5,7 +5,10 @@ // vertex shader // // Created by Andrzej Kapolka on 3/24/14. -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // const int MAX_CLUSTERS = 128; diff --git a/interface/resources/shaders/vertical_blur.frag b/interface/resources/shaders/vertical_blur.frag index 96ab95ea9e..1b8c447cc7 100644 --- a/interface/resources/shaders/vertical_blur.frag +++ b/interface/resources/shaders/vertical_blur.frag @@ -5,7 +5,10 @@ // fragment shader // // Created by Andrzej Kapolka on 8/14/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // // the texture containing the horizontally blurred color diff --git a/interface/resources/shaders/vertical_blur_add.frag b/interface/resources/shaders/vertical_blur_add.frag index 5cda2622b4..919e9d1268 100644 --- a/interface/resources/shaders/vertical_blur_add.frag +++ b/interface/resources/shaders/vertical_blur_add.frag @@ -5,7 +5,10 @@ // fragment shader // // Created by Andrzej Kapolka on 8/8/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // // the texture containing the original color diff --git a/interface/resources/shaders/voxel.geom b/interface/resources/shaders/voxel.geom index ca8f729542..4c850ed608 100644 --- a/interface/resources/shaders/voxel.geom +++ b/interface/resources/shaders/voxel.geom @@ -1,6 +1,16 @@ #version 120 #extension GL_ARB_geometry_shader4 : enable +// +// voxel.geom +// geometry shader +// +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + // // VOXEL GEOMETRY SHADER // diff --git a/interface/resources/styles/avatar.svg b/interface/resources/styles/avatar.svg new file mode 100644 index 0000000000..f9382edee4 --- /dev/null +++ b/interface/resources/styles/avatar.svg @@ -0,0 +1,27 @@ + + + + + + + + diff --git a/interface/resources/styles/close.svg b/interface/resources/styles/close.svg new file mode 100644 index 0000000000..8fe4bf4bdb --- /dev/null +++ b/interface/resources/styles/close.svg @@ -0,0 +1,14 @@ + + + + + + + + + + diff --git a/interface/resources/styles/down.svg b/interface/resources/styles/down.svg new file mode 100644 index 0000000000..983ccd9597 --- /dev/null +++ b/interface/resources/styles/down.svg @@ -0,0 +1,9 @@ + + + + + + diff --git a/interface/resources/styles/global.qss b/interface/resources/styles/global.qss new file mode 100644 index 0000000000..2554f3b2c9 --- /dev/null +++ b/interface/resources/styles/global.qss @@ -0,0 +1,113 @@ +* { + padding: 0; + margin: 0; +} + +FramelessDialog { + font-family: Helvetica, Arial, sans-serif; + font-size: 16px; +} + +QLineEdit { + background-color: rgba(255, 255, 255, 1); + border-style: solid; + border-width: 1px; + border-color: #ccc; + padding: 8px; + font-size: 16px; + color: rgb(51, 51, 51); +} + +QLabel p { + color: #0e7077; + font-size: 23px; +} + +QPushButton { + border-width: 0; + border-radius: 9px; + font-family: Arial; + font-size: 18px; + color: #ffffff; + padding: 10px 0px; +} + +QSpinBox, QDoubleSpinBox { + padding: 5px; + border-width: 1; + font-size: 16px; + color: rgb(51, 51, 51); +} + +QDoubleSpinBox::up-arrow, +QSpinBox::up-arrow { + background-image: url(styles/up.svg); + background-repeat: no-repeat; + background-position: center center; +} + +QDoubleSpinBox::down-arrow, +QSpinBox::down-arrow { + background-image: url(styles/down.svg); + background-repeat: no-repeat; + background-position: center center; +} + +QDoubleSpinBox::up-button, +QSpinBox::up-button, +QDoubleSpinBox::down-button, +QSpinBox::down-button { + width: 26px; + height: 13px; + + background-color: #f2f2f2; + border-color: #ccc; + border-style: solid; + border-width: 1px; +} + +QDoubleSpinBox::up-button, +QSpinBox::up-button { + + margin-top:2px; + border-top-left-radius: 4px; + border-top-right-radius: 4px; +} + +QDoubleSpinBox::down-button, +QSpinBox::down-button { + margin-bottom:3px; + border-bottom-left-radius: 4px; + border-bottom-right-radius: 4px; +} + +QSlider { + width: 125px; + height: 18px; +} + +QSlider::groove:horizontal { + border: none; + background-image: url(styles/slider-bg.svg); + background-repeat: no-repeat; + background-position: center center; +} + +QSlider::handle:horizontal { + width: 18px; + height: 18px; + background-image: url(styles/slider-handle.svg); + background-repeat: no-repeat; + background-position: center center; +} + +QPushButton#closeButton { + border-color: #ccc; + border-style: solid; + border-width: 1px; + border-radius: 0; + background-color: #fff; + background-image: url(styles/close.svg); + background-repeat: no-repeat; + background-position: center center; +} diff --git a/interface/resources/styles/preferences.qss b/interface/resources/styles/preferences.qss new file mode 100644 index 0000000000..643fd13a77 --- /dev/null +++ b/interface/resources/styles/preferences.qss @@ -0,0 +1,21 @@ +QLabel#avatarLabel { + background-image: url(styles/avatar.svg); + background-repeat: no-repeat; + background-position: left center; +} + +QLabel#advancedTuningLabel { + background-image: url(styles/wrench.svg); + background-repeat: no-repeat; + background-position: left center; +} + +QPushButton#buttonBrowseHead, +QPushButton#buttonBrowseBody { + background-image: url(styles/search.svg); + background-repeat: no-repeat; + background-position: center center; + background-color: #fff; + border-radius: 0; + padding: 0; +} diff --git a/interface/resources/styles/slider-bg.svg b/interface/resources/styles/slider-bg.svg new file mode 100644 index 0000000000..36c6478026 --- /dev/null +++ b/interface/resources/styles/slider-bg.svg @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/interface/resources/styles/slider-handle.svg b/interface/resources/styles/slider-handle.svg new file mode 100644 index 0000000000..5d87e8599c --- /dev/null +++ b/interface/resources/styles/slider-handle.svg @@ -0,0 +1,10 @@ + + + + + + + + + diff --git a/interface/resources/styles/up.svg b/interface/resources/styles/up.svg new file mode 100644 index 0000000000..d122c4801e --- /dev/null +++ b/interface/resources/styles/up.svg @@ -0,0 +1,9 @@ + + + + + + diff --git a/interface/resources/styles/wrench.svg b/interface/resources/styles/wrench.svg new file mode 100644 index 0000000000..5019f92b18 --- /dev/null +++ b/interface/resources/styles/wrench.svg @@ -0,0 +1,9 @@ + + + + + + diff --git a/interface/src/AbstractLoggerInterface.h b/interface/src/AbstractLoggerInterface.h index cedab1fad2..f6cf136a71 100644 --- a/interface/src/AbstractLoggerInterface.h +++ b/interface/src/AbstractLoggerInterface.h @@ -1,13 +1,16 @@ // // AbstractLoggerInterface.h -// interface +// interface/src // // Created by Stojce Slavkovski on 12/22/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__AbstractLoggerInterface__ -#define __interface__AbstractLoggerInterface__ +#ifndef hifi_AbstractLoggerInterface_h +#define hifi_AbstractLoggerInterface_h #include #include @@ -32,4 +35,4 @@ private: bool _extraDebugging; }; -#endif /* defined(__interface__AbstractLoggerInterface__) */ +#endif // hifi_AbstractLoggerInterface_h diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index e3e59bbab6..e109cbebd5 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1,9 +1,13 @@ // // Application.cpp -// interface +// interface/src // // Created by Andrzej Kapolka on 5/10/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// #ifdef WIN32 #include @@ -49,7 +53,7 @@ #include #include #include -#include +#include #include #include @@ -63,7 +67,7 @@ #include #include #include -#include +#include #include "Application.h" #include "InterfaceVersion.h" @@ -81,6 +85,7 @@ #include "ui/InfoView.h" #include "ui/Snapshot.h" #include "ui/TextRenderer.h" +#include "ui/Stats.h" using namespace std; @@ -107,18 +112,14 @@ const float MIRROR_REARVIEW_DISTANCE = 0.65f; const float MIRROR_REARVIEW_BODY_DISTANCE = 2.3f; const float MIRROR_FIELD_OF_VIEW = 30.0f; -const QString CHECK_VERSION_URL = "http://highfidelity.io/latestVersion.xml"; +const QString CHECK_VERSION_URL = "https://highfidelity.io/latestVersion.xml"; const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/hifi.skipversion"; -const int STATS_PELS_PER_LINE = 20; - -const QString CUSTOM_URL_SCHEME = "hifi:"; - void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) { if (message.size() > 0) { QString dateString = QDateTime::currentDateTime().toTimeSpec(Qt::LocalTime).toString(Qt::ISODate); QString formattedMessage = QString("[%1] %2\n").arg(dateString).arg(message); - + fprintf(stdout, "%s", qPrintable(formattedMessage)); Application::getInstance()->getLogger()->addMessage(qPrintable(formattedMessage)); } @@ -137,7 +138,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : QApplication(argc, argv), _window(new QMainWindow(desktop())), _glWidget(new GLCanvas()), - _statsExpanded(false), _nodeThread(new QThread(this)), _datagramProcessor(), _frameCount(0), @@ -150,9 +150,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : _viewFrustum(), _lastQueriedViewFrustum(), _lastQueriedTime(usecTimestampNow()), - _audioScope(256, 200, true), - _trailingAudioLoudness(0.f), _mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)), + _cameraPushback(0.0f), _mouseX(0), _mouseY(0), _lastMouseMove(usecTimestampNow()), @@ -162,36 +161,34 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : _touchAvgY(0.0f), _isTouchPressed(false), _mousePressed(false), - _audio(&_audioScope, STARTUP_JITTER_SAMPLES), + _audio(STARTUP_JITTER_SAMPLES), _enableProcessVoxelsThread(true), _voxelProcessor(), _voxelHideShowThread(&_voxels), _packetsPerSecond(0), _bytesPerSecond(0), - _recentMaxPackets(0), - _resetRecentMaxPacketsSoon(true), _previousScriptLocation(), _logger(new FileLogger(this)) { // read the ApplicationInfo.ini file for Name/Version/Domain information QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat); - + // set the associated application properties applicationInfo.beginGroup("INFO"); - + qDebug() << "[VERSION] Build sequence: " << qPrintable(applicationVersion()); - + setApplicationName(applicationInfo.value("name").toString()); setApplicationVersion(BUILD_VERSION); setOrganizationName(applicationInfo.value("organizationName").toString()); setOrganizationDomain(applicationInfo.value("organizationDomain").toString()); - + QSettings::setDefaultFormat(QSettings::IniFormat); - + _myAvatar = _avatarManager.getMyAvatar(); _applicationStartupTime = startup_time; - + QFontDatabase::addApplicationFont(Application::resourcesPath() + "styles/Inconsolata.otf"); _window->setWindowTitle("Interface"); @@ -206,19 +203,19 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : if (portStr) { listenPort = atoi(portStr); } - + // start the nodeThread so its event loop is running _nodeThread->start(); - + // make sure the node thread is given highest priority _nodeThread->setPriority(QThread::TimeCriticalPriority); - + // put the NodeList and datagram processing on the node thread NodeList* nodeList = NodeList::createInstance(NodeType::Agent, listenPort); - + nodeList->moveToThread(_nodeThread); _datagramProcessor.moveToThread(_nodeThread); - + // connect the DataProcessor processDatagrams slot to the QUDPSocket readyRead() signal connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), &_datagramProcessor, SLOT(processDatagrams())); @@ -239,21 +236,23 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : connect(nodeList, SIGNAL(nodeAdded(SharedNodePointer)), &_voxels, SLOT(nodeAdded(SharedNodePointer))); connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), &_voxels, SLOT(nodeKilled(SharedNodePointer))); connect(nodeList, &NodeList::uuidChanged, this, &Application::updateWindowTitle); + connect(nodeList, SIGNAL(uuidChanged(const QUuid&)), _myAvatar, SLOT(setSessionUUID(const QUuid&))); connect(nodeList, &NodeList::limitOfSilentDomainCheckInsReached, nodeList, &NodeList::reset); - + // connect to appropriate slots on AccountManager AccountManager& accountManager = AccountManager::getInstance(); connect(&accountManager, &AccountManager::authRequired, Menu::getInstance(), &Menu::loginForCurrentDomain); connect(&accountManager, &AccountManager::usernameChanged, this, &Application::updateWindowTitle); - + // set the account manager's root URL and trigger a login request if we don't have the access token accountManager.setAuthURL(DEFAULT_NODE_AUTH_URL); - + // once the event loop has started, check and signal for an access token QMetaObject::invokeMethod(&accountManager, "checkAndSignalForAccessToken", Qt::QueuedConnection); _settings = new QSettings(this); - + _numChangedSettings = 0; + // Check to see if the user passed in a command line option for loading a local // Voxel File. _voxelsFilename = getCmdOption(argc, constArgv, "-i"); @@ -267,7 +266,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : nodeList->addSetOfNodeTypesToNodeInterestSet(NodeSet() << NodeType::AudioMixer << NodeType::AvatarMixer << NodeType::VoxelServer << NodeType::ParticleServer << NodeType::MetavoxelServer); - + // connect to the packet sent signal of the _voxelEditSender and the _particleEditSender connect(&_voxelEditSender, &VoxelEditPacketSender::packetSent, this, &Application::packetSent); connect(&_particleEditSender, &ParticleEditPacketSender::packetSent, this, &Application::packetSent); @@ -277,7 +276,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : connect(silentNodeTimer, SIGNAL(timeout()), nodeList, SLOT(removeSilentNodes())); silentNodeTimer->moveToThread(_nodeThread); silentNodeTimer->start(NODE_SILENCE_THRESHOLD_USECS / 1000); - + // send the identity packet for our avatar each second to our avatar mixer QTimer* identityPacketTimer = new QTimer(); connect(identityPacketTimer, &QTimer::timeout, _myAvatar, &MyAvatar::sendIdentityPacket); @@ -325,14 +324,18 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : // Set the sixense filtering _sixenseManager.setFilter(Menu::getInstance()->isOptionChecked(MenuOption::FilterSixense)); - + checkVersion(); - + _overlays.init(_glWidget); // do this before scripts load - + LocalVoxelsList::getInstance()->addPersistantTree(DOMAIN_TREE_NAME, _voxels.getTree()); LocalVoxelsList::getInstance()->addPersistantTree(CLIPBOARD_TREE_NAME, &_clipboard); + _window->addDockWidget(Qt::NoDockWidgetArea, _runningScriptsWidget = new RunningScriptsWidget()); + _runningScriptsWidget->setRunningScripts(getRunningScripts()); + connect(_runningScriptsWidget, &RunningScriptsWidget::stopScriptName, this, &Application::stopScript); + // check first run... QVariant firstRunValue = _settings->value("firstRun",QVariant(true)); if (firstRunValue.isValid() && firstRunValue.toBool()) { @@ -341,44 +344,44 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : clearScriptsBeforeRunning(); loadScript("http://public.highfidelity.io/scripts/defaultScripts.js"); + QMutexLocker locker(&_settingsMutex); _settings->setValue("firstRun",QVariant(false)); } else { // do this as late as possible so that all required subsystems are inialized loadScripts(); + + QMutexLocker locker(&_settingsMutex); + _previousScriptLocation = _settings->value("LastScriptLocation", QVariant("")).toString(); } } Application::~Application() { qInstallMessageHandler(NULL); - + // make sure we don't call the idle timer any more delete idleTimer; - Menu::getInstance()->saveSettings(); - _rearMirrorTools->saveSettings(_settings); - _sharedVoxelSystem.changeTree(new VoxelTree); - if (_voxelImporter) { - _voxelImporter->saveSettings(_settings); - delete _voxelImporter; - } - _settings->sync(); + saveSettings(); + + delete _voxelImporter; + // let the avatar mixer know we're out MyAvatar::sendKillAvatar(); - + // ask the datagram processing thread to quit and wait until it is done _nodeThread->quit(); _nodeThread->wait(); - + // stop the audio process QMetaObject::invokeMethod(&_audio, "stop"); - + // ask the audio thread to quit and wait until it is done _audio.thread()->quit(); _audio.thread()->wait(); - + _voxelProcessor.terminate(); _voxelHideShowThread.terminate(); _voxelEditSender.terminate(); @@ -391,41 +394,52 @@ Application::~Application() { Menu::getInstance()->deleteLater(); _myAvatar = NULL; - + delete _glWidget; - + AccountManager::getInstance().destroy(); } +void Application::saveSettings() { + Menu::getInstance()->saveSettings(); + _rearMirrorTools->saveSettings(_settings); + + if (_voxelImporter) { + _voxelImporter->saveSettings(_settings); + } + _settings->sync(); + _numChangedSettings = 0; +} + + void Application::restoreSizeAndPosition() { - QSettings* settings = new QSettings(this); QRect available = desktop()->availableGeometry(); - settings->beginGroup("Window"); + QMutexLocker locker(&_settingsMutex); + _settings->beginGroup("Window"); - int x = (int)loadSetting(settings, "x", 0); - int y = (int)loadSetting(settings, "y", 0); + int x = (int)loadSetting(_settings, "x", 0); + int y = (int)loadSetting(_settings, "y", 0); _window->move(x, y); - int width = (int)loadSetting(settings, "width", available.width()); - int height = (int)loadSetting(settings, "height", available.height()); + int width = (int)loadSetting(_settings, "width", available.width()); + int height = (int)loadSetting(_settings, "height", available.height()); _window->resize(width, height); - settings->endGroup(); + _settings->endGroup(); } void Application::storeSizeAndPosition() { - QSettings* settings = new QSettings(this); + QMutexLocker locker(&_settingsMutex); + _settings->beginGroup("Window"); - settings->beginGroup("Window"); + _settings->setValue("width", _window->rect().width()); + _settings->setValue("height", _window->rect().height()); - settings->setValue("width", _window->rect().width()); - settings->setValue("height", _window->rect().height()); + _settings->setValue("x", _window->pos().x()); + _settings->setValue("y", _window->pos().y()); - settings->setValue("x", _window->pos().x()); - settings->setValue("y", _window->pos().y()); - - settings->endGroup(); + _settings->endGroup(); } void Application::initializeGL() { @@ -508,18 +522,55 @@ void Application::paintGL() { glEnable(GL_LINE_SMOOTH); + float pushback = 0.0f; + float pushbackFocalLength = 0.0f; if (OculusManager::isConnected()) { _myCamera.setUpShift(0.0f); _myCamera.setDistance(0.0f); _myCamera.setTightness(0.0f); // Camera is directly connected to head without smoothing _myCamera.setTargetPosition(_myAvatar->getHead()->calculateAverageEyePosition()); - _myCamera.setTargetRotation(_myAvatar->getHead()->getOrientation()); + _myCamera.setTargetRotation(_myAvatar->getHead()->getCameraOrientation()); } else if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) { _myCamera.setTightness(0.0f); // In first person, camera follows (untweaked) head exactly without delay _myCamera.setTargetPosition(_myAvatar->getHead()->calculateAverageEyePosition()); _myCamera.setTargetRotation(_myAvatar->getHead()->getCameraOrientation()); + glm::vec3 planeNormal = _myCamera.getTargetRotation() * IDENTITY_FRONT; + const float BASE_PUSHBACK_RADIUS = 0.25f; + float pushbackRadius = _myCamera.getNearClip() + _myAvatar->getScale() * BASE_PUSHBACK_RADIUS; + glm::vec4 plane(planeNormal, -glm::dot(planeNormal, _myCamera.getTargetPosition()) - pushbackRadius); + + // push camera out of any intersecting avatars + foreach (const AvatarSharedPointer& avatarData, _avatarManager.getAvatarHash()) { + Avatar* avatar = static_cast(avatarData.data()); + if (avatar->isMyAvatar()) { + continue; + } + if (glm::distance(avatar->getPosition(), _myCamera.getTargetPosition()) > + avatar->getBoundingRadius() + pushbackRadius) { + continue; + } + float angle = angleBetween(avatar->getPosition() - _myCamera.getTargetPosition(), planeNormal); + if (angle > PI_OVER_TWO) { + continue; + } + float scale = 1.0f - angle / PI_OVER_TWO; + scale = qMin(1.0f, scale * 2.5f); + static CollisionList collisions(64); + collisions.clear(); + if (!avatar->findPlaneCollisions(plane, collisions)) { + continue; + } + for (int i = 0; i < collisions.size(); i++) { + pushback = qMax(pushback, glm::length(collisions.getCollision(i)->_penetration) * scale); + } + } + const float MAX_PUSHBACK = 0.35f; + pushback = qMin(pushback, MAX_PUSHBACK * _myAvatar->getScale()); + const float BASE_PUSHBACK_FOCAL_LENGTH = 0.5f; + pushbackFocalLength = BASE_PUSHBACK_FOCAL_LENGTH * _myAvatar->getScale(); + } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) { _myCamera.setTightness(0.0f); // Camera is directly connected to head without smoothing _myCamera.setTargetPosition(_myAvatar->getUprightHeadPosition()); @@ -527,10 +578,35 @@ void Application::paintGL() { } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { _myCamera.setTightness(0.0f); - float headHeight = _myAvatar->getHead()->calculateAverageEyePosition().y - _myAvatar->getPosition().y; + glm::vec3 eyePosition = _myAvatar->getHead()->calculateAverageEyePosition(); + float headHeight = eyePosition.y - _myAvatar->getPosition().y; _myCamera.setDistance(MIRROR_FULLSCREEN_DISTANCE * _myAvatar->getScale()); _myCamera.setTargetPosition(_myAvatar->getPosition() + glm::vec3(0, headHeight, 0)); _myCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI, 0.0f))); + + // if the head would intersect the near clip plane, we must push the camera out + glm::vec3 relativePosition = glm::inverse(_myCamera.getTargetRotation()) * + (eyePosition - _myCamera.getTargetPosition()); + const float BASE_PUSHBACK_RADIUS = 0.2f; + float pushbackRadius = _myCamera.getNearClip() + _myAvatar->getScale() * BASE_PUSHBACK_RADIUS; + pushback = relativePosition.z + pushbackRadius - _myCamera.getDistance(); + pushbackFocalLength = _myCamera.getDistance(); + } + + // handle pushback, if any + if (pushbackFocalLength > 0.0f) { + const float PUSHBACK_DECAY = 0.5f; + _cameraPushback = qMax(pushback, _cameraPushback * PUSHBACK_DECAY); + if (_cameraPushback > EPSILON) { + _myCamera.setTargetPosition(_myCamera.getTargetPosition() + + _myCamera.getTargetRotation() * glm::vec3(0.0f, 0.0f, _cameraPushback)); + float enlargement = pushbackFocalLength / (pushbackFocalLength + _cameraPushback); + _myCamera.setFieldOfView(glm::degrees(2.0f * atanf(enlargement * tanf( + glm::radians(Menu::getInstance()->getFieldOfView() * 0.5f))))); + } else { + _myCamera.setFieldOfView(Menu::getInstance()->getFieldOfView()); + } + updateProjectionMatrix(_myCamera, true); } // Update camera position @@ -585,7 +661,7 @@ void Application::paintGL() { if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { renderRearViewMirror(_mirrorViewRect); - + } else if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) { _rearMirrorTools->render(true); } @@ -615,6 +691,14 @@ void Application::resizeGL(int width, int height) { updateProjectionMatrix(); glLoadIdentity(); + + // update Stats width + int horizontalOffset = 0; + if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { + // mirror is enabled, let's set horizontal offset to give stats some margin + horizontalOffset += MIRROR_VIEW_WIDTH + MIRROR_VIEW_LEFT_PADDING * 2; + } + Stats::getInstance()->resetWidth(width, horizontalOffset); } void Application::updateProjectionMatrix() { @@ -658,10 +742,10 @@ void Application::controlledBroadcastToNodes(const QByteArray& packet, const Nod if (type == NodeType::VoxelServer && !Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) { continue; } - + // Perform the broadcast for one type int nReceivingNodes = NodeList::getInstance()->broadcastToNodes(packet, NodeSet() << type); - + // Feed number of bytes to corresponding channel of the bandwidth meter, if any (done otherwise) BandwidthMeter::ChannelIndex channel; switch (type) { @@ -680,32 +764,15 @@ void Application::controlledBroadcastToNodes(const QByteArray& packet, const Nod } bool Application::event(QEvent* event) { - + // handle custom URL if (event->type() == QEvent::FileOpen) { QFileOpenEvent* fileEvent = static_cast(event); - if (!fileEvent->url().isEmpty() && fileEvent->url().toLocalFile().startsWith(CUSTOM_URL_SCHEME)) { - QString destination = fileEvent->url().toLocalFile().remove(CUSTOM_URL_SCHEME); - QStringList urlParts = destination.split('/', QString::SkipEmptyParts); - - if (urlParts.count() > 1) { - // if url has 2 or more parts, the first one is domain name - Menu::getInstance()->goToDomain(urlParts[0]); - - // location coordinates - Menu::getInstance()->goToDestination(urlParts[1]); - if (urlParts.count() > 2) { - - // location orientation - Menu::getInstance()->goToOrientation(urlParts[2]); - } - } else if (urlParts.count() == 1) { - - // location coordinates - Menu::getInstance()->goToDestination(urlParts[0]); - } + bool isHifiSchemeURL = !fileEvent->url().isEmpty() && fileEvent->url().toLocalFile().startsWith(CUSTOM_URL_SCHEME); + if (isHifiSchemeURL) { + Menu::getInstance()->goTo(fileEvent->url().toString()); } - + return false; } return QApplication::event(event); @@ -716,7 +783,7 @@ void Application::keyPressEvent(QKeyEvent* event) { _keysPressed.insert(event->key()); _controllerScriptingInterface.emitKeyPressEvent(event); // send events to any registered scripts - + // if one of our scripts have asked to capture this event, then stop processing it if (_controllerScriptingInterface.isKeyCaptured(event)) { return; @@ -739,9 +806,6 @@ void Application::keyPressEvent(QKeyEvent* event) { case Qt::Key_Period: Menu::getInstance()->handleViewFrustumOffsetKeyModifier(event->key()); break; - case Qt::Key_Apostrophe: - _audioScope.inputPaused = !_audioScope.inputPaused; - break; case Qt::Key_L: if (isShifted) { Menu::getInstance()->triggerOption(MenuOption::LodTools); @@ -1074,8 +1138,12 @@ void Application::mouseReleaseEvent(QMouseEvent* event) { _mousePressed = false; checkBandwidthMeterClick(); if (Menu::getInstance()->isOptionChecked(MenuOption::Stats)) { - checkStatsClick(); - } + int horizontalOffset = 0; + if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { + horizontalOffset = MIRROR_VIEW_WIDTH; + } + Stats::getInstance()->checkClick(_mouseX, _mouseY, _mouseDragStartedX, _mouseDragStartedY, horizontalOffset); + } } } } @@ -1124,7 +1192,7 @@ void Application::touchBeginEvent(QTouchEvent* event) { if (_controllerScriptingInterface.isTouchCaptured()) { return; } - + // put any application specific touch behavior below here.. _lastTouchAvgX = _touchAvgX; _lastTouchAvgY = _touchAvgY; @@ -1167,13 +1235,13 @@ void Application::dropEvent(QDropEvent *event) { break; } } - + SnapshotMetaData* snapshotData = Snapshot::parseSnapshotData(snapshotPath); if (snapshotData) { if (!snapshotData->getDomain().isEmpty()) { Menu::getInstance()->goToDomain(snapshotData->getDomain()); } - + _myAvatar->setPosition(snapshotData->getLocation()); _myAvatar->setOrientation(snapshotData->getOrientation()); } else { @@ -1201,19 +1269,17 @@ void Application::timer() { } _fps = (float)_frameCount / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f); - + _packetsPerSecond = (float) _datagramProcessor.getPacketCount() / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f); _bytesPerSecond = (float) _datagramProcessor.getByteCount() / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f); _frameCount = 0; - + _datagramProcessor.resetCounters(); gettimeofday(&_timerStart, NULL); // ask the node list to check in with the domain server NodeList::getInstance()->sendDomainServerCheckIn(); - - } void Application::idle() { @@ -1250,14 +1316,17 @@ void Application::idle() { _idleLoopMeasuredJitter = _idleLoopStdev.getStDev(); _idleLoopStdev.reset(); } - + if (Menu::getInstance()->isOptionChecked(MenuOption::BuckyBalls)) { _buckyBalls.simulate(timeSinceLastUpdate / 1000.f, Application::getInstance()->getAvatar()->getHandData()); } - + // After finishing all of the above work, restart the idle timer, allowing 2ms to process events. idleTimer->start(2); } + if (_numChangedSettings > 0) { + saveSettings(); + } } } @@ -1338,6 +1407,12 @@ glm::vec3 Application::getMouseVoxelWorldCoordinates(const VoxelDetail& mouseVox (mouseVoxel.z + mouseVoxel.s / 2.f) * TREE_SCALE); } +FaceTracker* Application::getActiveFaceTracker() { + return _faceshift.isActive() ? static_cast(&_faceshift) : + (_faceplus.isActive() ? static_cast(&_faceplus) : + (_visage.isActive() ? static_cast(&_visage) : NULL)); +} + struct SendVoxelsOperationArgs { const unsigned char* newBaseOctCode; }; @@ -1386,7 +1461,7 @@ void Application::exportVoxels(const VoxelDetail& sourceVoxel) { tr("Sparse Voxel Octree Files (*.svo)")); QByteArray fileNameAscii = fileNameString.toLocal8Bit(); const char* fileName = fileNameAscii.data(); - + VoxelTreeElement* selectedNode = _voxels.getTree()->getVoxelAt(sourceVoxel.x, sourceVoxel.y, sourceVoxel.z, sourceVoxel.s); if (selectedNode) { VoxelTree exportTree; @@ -1400,12 +1475,12 @@ void Application::exportVoxels(const VoxelDetail& sourceVoxel) { void Application::importVoxels() { _importSucceded = false; - + if (!_voxelImporter) { _voxelImporter = new VoxelImporter(_window); _voxelImporter->loadSettings(_settings); } - + if (!_voxelImporter->exec()) { qDebug() << "[DEBUG] Import succeeded." << endl; _importSucceded = true; @@ -1419,7 +1494,7 @@ void Application::importVoxels() { // restore the main window's active state _window->activateWindow(); - + emit importDone(); } @@ -1475,7 +1550,7 @@ void Application::pasteVoxels(const VoxelDetail& sourceVoxel) { } pasteVoxelsToOctalCode(octalCodeDestination); - + if (calculatedOctCode) { delete[] calculatedOctCode; } @@ -1512,9 +1587,9 @@ void Application::init() { // Cleanup of the original shared tree _sharedVoxelSystem.init(); - + _voxelImporter = new VoxelImporter(_window); - + _environment.init(); _glowEffect.init(); @@ -1556,11 +1631,12 @@ void Application::init() { _audio.setJitterBufferSamples(Menu::getInstance()->getAudioJitterBufferSamples()); } qDebug("Loaded settings"); - - // initialize Visage and Faceshift after loading the menu settings + + // initialize our face trackers after loading the menu settings _faceshift.init(); + _faceplus.init(); _visage.init(); - + // fire off an immediate domain-server check in now that settings are loaded NodeList::getInstance()->sendDomainServerCheckIn(); @@ -1579,32 +1655,34 @@ void Application::init() { _particleCollisionSystem.init(&_particleEditSender, _particles.getTree(), _voxels.getTree(), &_audio, &_avatarManager); // connect the _particleCollisionSystem to our script engine's ParticleScriptingInterface - connect(&_particleCollisionSystem, - SIGNAL(particleCollisionWithVoxel(const ParticleID&, const VoxelDetail&, const glm::vec3&)), - ScriptEngine::getParticlesScriptingInterface(), - SLOT(forwardParticleCollisionWithVoxel(const ParticleID&, const VoxelDetail&, const glm::vec3&))); + connect(&_particleCollisionSystem, + SIGNAL(particleCollisionWithVoxel(const ParticleID&, const VoxelDetail&, const CollisionInfo&)), + ScriptEngine::getParticlesScriptingInterface(), + SIGNAL(particleCollisionWithVoxels(const ParticleID&, const VoxelDetail&, const CollisionInfo&))); + + connect(&_particleCollisionSystem, + SIGNAL(particleCollisionWithParticle(const ParticleID&, const ParticleID&, const CollisionInfo&)), + ScriptEngine::getParticlesScriptingInterface(), + SIGNAL(particleCollisionWithParticle(const ParticleID&, const ParticleID&, const CollisionInfo&))); - connect(&_particleCollisionSystem, - SIGNAL(particleCollisionWithParticle(const ParticleID&, const ParticleID&, const glm::vec3&)), - ScriptEngine::getParticlesScriptingInterface(), - SLOT(forwardParticleCollisionWithParticle(const ParticleID&, const ParticleID&, const glm::vec3&))); - _audio.init(_glWidget); _rearMirrorTools = new RearMirrorTools(_glWidget, _mirrorViewRect, _settings); - + connect(_rearMirrorTools, SIGNAL(closeView()), SLOT(closeMirrorView())); connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView())); connect(_rearMirrorTools, SIGNAL(shrinkView()), SLOT(shrinkMirrorView())); connect(_rearMirrorTools, SIGNAL(resetView()), SLOT(resetSensors())); - // set up our audio reflector _audioReflector.setMyAvatar(getAvatar()); _audioReflector.setVoxels(_voxels.getTree()); _audioReflector.setAudio(getAudio()); connect(getAudio(), &Audio::processInboundAudio, &_audioReflector, &AudioReflector::processInboundAudio,Qt::DirectConnection); connect(getAudio(), &Audio::processLocalAudio, &_audioReflector, &AudioReflector::processLocalAudio,Qt::DirectConnection); + + // save settings when avatar changes + connect(_myAvatar, SIGNAL(transformChanged()), this, SLOT(bumpSettings())); } void Application::closeMirrorView() { @@ -1723,26 +1801,18 @@ void Application::updateMyAvatarLookAtPosition() { float distance = TREE_SCALE; if (_myAvatar->getLookAtTargetAvatar() && _myAvatar != _myAvatar->getLookAtTargetAvatar()) { distance = glm::distance(_mouseRayOrigin, - static_cast(_myAvatar->getLookAtTargetAvatar())->getHead()->calculateAverageEyePosition()); + static_cast(_myAvatar->getLookAtTargetAvatar())->getHead()->calculateAverageEyePosition()); } const float FIXED_MIN_EYE_DISTANCE = 0.3f; float minEyeDistance = FIXED_MIN_EYE_DISTANCE + (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON ? 0.0f : glm::distance(_mouseRayOrigin, _myAvatar->getHead()->calculateAverageEyePosition())); lookAtSpot = _mouseRayOrigin + _mouseRayDirection * qMax(minEyeDistance, distance); } - bool trackerActive = false; - float eyePitch, eyeYaw; - if (_faceshift.isActive()) { - eyePitch = _faceshift.getEstimatedEyePitch(); - eyeYaw = _faceshift.getEstimatedEyeYaw(); - trackerActive = true; + FaceTracker* tracker = getActiveFaceTracker(); + if (tracker) { + float eyePitch = tracker->getEstimatedEyePitch(); + float eyeYaw = tracker->getEstimatedEyeYaw(); - } else if (_visage.isActive()) { - eyePitch = _visage.getEstimatedEyePitch(); - eyeYaw = _visage.getEstimatedEyeYaw(); - trackerActive = true; - } - if (trackerActive) { // deflect using Faceshift gaze data glm::vec3 origin = _myAvatar->getHead()->calculateAverageEyePosition(); float pitchSign = (_myCamera.getMode() == CAMERA_MODE_MIRROR) ? -1.0f : 1.0f; @@ -1828,15 +1898,15 @@ void Application::updateCamera(float deltaTime) { bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); PerformanceWarning warn(showWarnings, "Application::updateCamera()"); - if (!OculusManager::isConnected() && !TV3DManager::isConnected()) { - if (Menu::getInstance()->isOptionChecked(MenuOption::OffAxisProjection)) { - float xSign = _myCamera.getMode() == CAMERA_MODE_MIRROR ? 1.0f : -1.0f; - if (_faceshift.isActive()) { - const float EYE_OFFSET_SCALE = 0.025f; - glm::vec3 position = _faceshift.getHeadTranslation() * EYE_OFFSET_SCALE; - _myCamera.setEyeOffsetPosition(glm::vec3(position.x * xSign, position.y, -position.z)); - updateProjectionMatrix(); - } + if (!OculusManager::isConnected() && !TV3DManager::isConnected() && + Menu::getInstance()->isOptionChecked(MenuOption::OffAxisProjection)) { + FaceTracker* tracker = getActiveFaceTracker(); + if (tracker) { + const float EYE_OFFSET_SCALE = 0.025f; + glm::vec3 position = tracker->getHeadTranslation() * EYE_OFFSET_SCALE; + float xSign = (_myCamera.getMode() == CAMERA_MODE_MIRROR) ? 1.0f : -1.0f; + _myCamera.setEyeOffsetPosition(glm::vec3(position.x * xSign, position.y, -position.z)); + updateProjectionMatrix(); } } } @@ -1909,9 +1979,9 @@ void Application::update(float deltaTime) { _particles.update(); // update the particles... _particleCollisionSystem.update(); // collide the particles... - + _overlays.update(deltaTime); - + // let external parties know we're updating emit simulating(deltaTime); } @@ -1935,7 +2005,7 @@ void Application::updateMyAvatar(float deltaTime) { // actually need to calculate the view frustum planes to send these details // to the server. loadViewFrustum(_myCamera, _viewFrustum); - + // Update my voxel servers with my current voxel query... quint64 now = usecTimestampNow(); quint64 sinceLastQuery = now - _lastQueriedTime; @@ -2211,7 +2281,7 @@ void Application::updateShadowMap() { } center = inverseRotation * center; glm::vec3 minima(center.x - radius, center.y - radius, center.z - radius); - glm::vec3 maxima(center.x + radius, center.y + radius, center.z + radius); + glm::vec3 maxima(center.x + radius, center.y + radius, center.z + radius); // stretch out our extents in z so that we get all of the avatars minima.z -= _viewFrustum.getFarClip() * 0.5f; @@ -2232,7 +2302,7 @@ void Application::updateShadowMap() { _shadowViewFrustum.setEyeOffsetPosition(glm::vec3()); _shadowViewFrustum.setEyeOffsetOrientation(glm::quat()); _shadowViewFrustum.calculate(); - + glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); @@ -2245,8 +2315,7 @@ void Application::updateShadowMap() { glRotatef(glm::degrees(glm::angle(inverseRotation)), axis.x, axis.y, axis.z); // store view matrix without translation, which we'll use for precision-sensitive objects - glGetFloatv(GL_MODELVIEW_MATRIX, (GLfloat*)&_untranslatedViewMatrix); - _viewMatrixTranslation = glm::vec3(); + updateUntranslatedViewMatrix(); _avatarManager.renderAvatars(Avatar::SHADOW_RENDER_MODE); _particles.render(); @@ -2287,19 +2356,19 @@ void Application::setupWorldLight() { QImage Application::renderAvatarBillboard() { _textureCache.getPrimaryFramebufferObject()->bind(); - + glDisable(GL_BLEND); const int BILLBOARD_SIZE = 64; renderRearViewMirror(QRect(0, _glWidget->height() - BILLBOARD_SIZE, BILLBOARD_SIZE, BILLBOARD_SIZE), true); - + QImage image(BILLBOARD_SIZE, BILLBOARD_SIZE, QImage::Format_ARGB32); glReadPixels(0, 0, BILLBOARD_SIZE, BILLBOARD_SIZE, GL_BGRA, GL_UNSIGNED_BYTE, image.bits()); - + glEnable(GL_BLEND); - + _textureCache.getPrimaryFramebufferObject()->release(); - + return image; } @@ -2331,8 +2400,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { glRotatef(-glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z); // store view matrix without translation, which we'll use for precision-sensitive objects - glGetFloatv(GL_MODELVIEW_MATRIX, (GLfloat*)&_untranslatedViewMatrix); - _viewMatrixTranslation = -whichCamera.getPosition(); + updateUntranslatedViewMatrix(-whichCamera.getPosition()); glTranslatef(_viewMatrixTranslation.x, _viewMatrixTranslation.y, _viewMatrixTranslation.z); @@ -2403,7 +2471,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { "Application::displaySide() ... metavoxels..."); _metavoxels.render(); } - + if (Menu::getInstance()->isOptionChecked(MenuOption::BuckyBalls)) { PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::displaySide() ... bucky balls..."); @@ -2416,7 +2484,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { "Application::displaySide() ... particles..."); _particles.render(); } - + // render the ambient occlusion effect if enabled if (Menu::getInstance()->isOptionChecked(MenuOption::AmbientOcclusion)) { PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), @@ -2460,12 +2528,17 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { // give external parties a change to hook in emit renderingInWorldInterface(); - + // render JS/scriptable overlays _overlays.render3D(); } } +void Application::updateUntranslatedViewMatrix(const glm::vec3& viewMatrixTranslation) { + glGetFloatv(GL_MODELVIEW_MATRIX, (GLfloat*)&_untranslatedViewMatrix); + _viewMatrixTranslation = viewMatrixTranslation; +} + void Application::loadTranslatedViewMatrix(const glm::vec3& translation) { glLoadMatrixf((const GLfloat*)&_untranslatedViewMatrix); glTranslatef(translation.x + _viewMatrixTranslation.x, translation.y + _viewMatrixTranslation.y, @@ -2509,34 +2582,24 @@ void Application::displayOverlay() { renderCollisionOverlay(_glWidget->width(), _glWidget->height(), _audio.getCollisionSoundMagnitude()); } } - - // Audio Scope - const int AUDIO_SCOPE_Y_OFFSET = 135; - if (Menu::getInstance()->isOptionChecked(MenuOption::Stats)) { - if (Menu::getInstance()->isOptionChecked(MenuOption::Oscilloscope)) { - int oscilloscopeTop = _glWidget->height() - AUDIO_SCOPE_Y_OFFSET; - _audioScope.render(MIRROR_VIEW_LEFT_PADDING, oscilloscopeTop); - } - } - + // Audio VU Meter and Mute Icon const int MUTE_ICON_SIZE = 24; const int AUDIO_METER_INSET = 2; - const int AUDIO_METER_WIDTH = MIRROR_VIEW_WIDTH - MUTE_ICON_SIZE - AUDIO_METER_INSET; + const int MUTE_ICON_PADDING = 10; + const int AUDIO_METER_WIDTH = MIRROR_VIEW_WIDTH - MUTE_ICON_SIZE - AUDIO_METER_INSET - MUTE_ICON_PADDING; const int AUDIO_METER_SCALE_WIDTH = AUDIO_METER_WIDTH - 2 * AUDIO_METER_INSET; const int AUDIO_METER_HEIGHT = 8; - const int AUDIO_METER_Y_GAP = 8; - const int AUDIO_METER_X = MIRROR_VIEW_LEFT_PADDING + MUTE_ICON_SIZE + AUDIO_METER_INSET; - + const int AUDIO_METER_GAP = 5; + const int AUDIO_METER_X = MIRROR_VIEW_LEFT_PADDING + MUTE_ICON_SIZE + AUDIO_METER_INSET + AUDIO_METER_GAP; + int audioMeterY; if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { - audioMeterY = MIRROR_VIEW_HEIGHT + AUDIO_METER_Y_GAP; + audioMeterY = MIRROR_VIEW_HEIGHT + AUDIO_METER_GAP + MUTE_ICON_PADDING; } else { - audioMeterY = AUDIO_METER_Y_GAP; + audioMeterY = AUDIO_METER_GAP + MUTE_ICON_PADDING; } - _audio.renderMuteIcon(MIRROR_VIEW_LEFT_PADDING, audioMeterY); - - + const float AUDIO_METER_BLUE[] = {0.0, 0.0, 1.0}; const float AUDIO_METER_GREEN[] = {0.0, 1.0, 0.0}; const float AUDIO_METER_RED[] = {1.0, 0.0, 0.0}; @@ -2563,19 +2626,34 @@ void Application::displayOverlay() { } bool isClipping = ((_audio.getTimeSinceLastClip() > 0.f) && (_audio.getTimeSinceLastClip() < CLIPPING_INDICATOR_TIME)); + + if ((_audio.getTimeSinceLastClip() > 0.f) && (_audio.getTimeSinceLastClip() < CLIPPING_INDICATOR_TIME)) { + const float MAX_MAGNITUDE = 0.7f; + float magnitude = MAX_MAGNITUDE * (1 - _audio.getTimeSinceLastClip() / CLIPPING_INDICATOR_TIME); + renderCollisionOverlay(_glWidget->width(), _glWidget->height(), magnitude, 1.0f); + } + + _audio.renderToolBox(MIRROR_VIEW_LEFT_PADDING + AUDIO_METER_GAP, + audioMeterY, + Menu::getInstance()->isOptionChecked(MenuOption::Mirror)); glBegin(GL_QUADS); if (isClipping) { glColor3f(1, 0, 0); } else { - glColor3f(0, 0, 0); + glColor3f(0.475f, 0.475f, 0.475f); } + + audioMeterY += AUDIO_METER_HEIGHT; + + glColor3f(0, 0, 0); // Draw audio meter background Quad glVertex2i(AUDIO_METER_X, audioMeterY); glVertex2i(AUDIO_METER_X + AUDIO_METER_WIDTH, audioMeterY); glVertex2i(AUDIO_METER_X + AUDIO_METER_WIDTH, audioMeterY + AUDIO_METER_HEIGHT); glVertex2i(AUDIO_METER_X, audioMeterY + AUDIO_METER_HEIGHT); + if (audioLevel > AUDIO_RED_START) { if (!isClipping) { glColor3fv(AUDIO_METER_RED); @@ -2615,6 +2693,7 @@ void Application::displayOverlay() { glVertex2i(AUDIO_METER_X + AUDIO_METER_INSET, audioMeterY + AUDIO_METER_HEIGHT - AUDIO_METER_INSET); glEnd(); + if (Menu::getInstance()->isOptionChecked(MenuOption::HeadMouse)) { _myAvatar->renderHeadMouse(); } @@ -2624,11 +2703,17 @@ void Application::displayOverlay() { glPointSize(1.0f); if (Menu::getInstance()->isOptionChecked(MenuOption::Stats)) { + int horizontalOffset = 0; + if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { + // mirror is enabled, let's set horizontal offset to give stats some margin + horizontalOffset += MIRROR_VIEW_WIDTH + MIRROR_VIEW_LEFT_PADDING * 2; + } + int voxelPacketsToProcess = _voxelProcessor.packetsToProcessCount(); // Onscreen text about position, servers, etc - displayStats(); + Stats::getInstance()->display(WHITE_TEXT, horizontalOffset, _fps, _packetsPerSecond, _bytesPerSecond, voxelPacketsToProcess); // Bandwidth meter if (Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth)) { - displayStatsBackground(0x33333399, _glWidget->width() - 296, _glWidget->height() - 68, 296, 68); + Stats::drawBackground(0x33333399, _glWidget->width() - 296, _glWidget->height() - 68, 296, 68); _bandwidthMeter.render(_glWidget->width(), _glWidget->height()); } } @@ -2638,8 +2723,8 @@ void Application::displayOverlay() { char frameTimer[10]; quint64 mSecsNow = floor(usecTimestampNow() / 1000.0 + 0.5); sprintf(frameTimer, "%d\n", (int)(mSecsNow % 1000)); - int timerBottom = - (Menu::getInstance()->isOptionChecked(MenuOption::Stats) && + int timerBottom = + (Menu::getInstance()->isOptionChecked(MenuOption::Stats) && Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth)) ? 80 : 20; drawText(_glWidget->width() - 100, _glWidget->height() - timerBottom, 0.30f, 1.0f, 0.f, frameTimer, WHITE_TEXT); @@ -2650,456 +2735,6 @@ void Application::displayOverlay() { glPopMatrix(); } -// translucent background box that makes stats more readable -void Application::displayStatsBackground(unsigned int rgba, int x, int y, int width, int height) { - glBegin(GL_QUADS); - glColor4f(((rgba >> 24) & 0xff) / 255.0f, - ((rgba >> 16) & 0xff) / 255.0f, - ((rgba >> 8) & 0xff) / 255.0f, - (rgba & 0xff) / 255.0f); - glVertex3f(x, y, 0); - glVertex3f(x + width, y, 0); - glVertex3f(x + width, y + height, 0); - glVertex3f(x , y + height, 0); - glEnd(); - glColor4f(1, 1, 1, 1); -} - -// display expanded or contracted stats - -void Application::displayStats() { - unsigned int backgroundColor = 0x33333399; - int verticalOffset = 0, horizontalOffset = 0, lines = 0; - bool mirrorEnabled = Menu::getInstance()->isOptionChecked(MenuOption::Mirror); - - QLocale locale(QLocale::English); - std::stringstream voxelStats; - - glPointSize(1.0f); - - // we need to take one avatar out so we don't include ourselves - int totalAvatars = _avatarManager.size() - 1; - int totalServers = NodeList::getInstance()->size(); - - if (mirrorEnabled) { - horizontalOffset += MIRROR_VIEW_WIDTH + MIRROR_VIEW_LEFT_PADDING * 2; - } - - lines = _statsExpanded ? 5 : 3; - displayStatsBackground(backgroundColor, horizontalOffset, 0, 165, lines * STATS_PELS_PER_LINE + 10); - horizontalOffset += 5; - - char serverNodes[30]; - sprintf(serverNodes, "Servers: %d", totalServers); - char avatarNodes[30]; - sprintf(avatarNodes, "Avatars: %d", totalAvatars); - char framesPerSecond[30]; - sprintf(framesPerSecond, "Framerate: %3.0f FPS", _fps); - - verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, serverNodes, WHITE_TEXT); - verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, avatarNodes, WHITE_TEXT); - verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, framesPerSecond, WHITE_TEXT); - - if (_statsExpanded) { - char packetsPerSecond[30]; - sprintf(packetsPerSecond, "Pkts/sec: %d", _packetsPerSecond); - char averageMegabitsPerSecond[30]; - sprintf(averageMegabitsPerSecond, "Mbps: %3.2f", (float)_bytesPerSecond * 8.f / 1000000.f); - - verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, packetsPerSecond, WHITE_TEXT); - verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, averageMegabitsPerSecond, WHITE_TEXT); - } - - verticalOffset = 0; - horizontalOffset += 161; - - if (Menu::getInstance()->isOptionChecked(MenuOption::TestPing)) { - int pingAudio = 0, pingAvatar = 0, pingVoxel = 0, pingVoxelMax = 0; - - NodeList* nodeList = NodeList::getInstance(); - SharedNodePointer audioMixerNode = nodeList->soloNodeOfType(NodeType::AudioMixer); - SharedNodePointer avatarMixerNode = nodeList->soloNodeOfType(NodeType::AvatarMixer); - - pingAudio = audioMixerNode ? audioMixerNode->getPingMs() : 0; - pingAvatar = avatarMixerNode ? avatarMixerNode->getPingMs() : 0; - - // Now handle voxel servers, since there could be more than one, we average their ping times - unsigned long totalPingVoxel = 0; - int voxelServerCount = 0; - - foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { - if (node->getType() == NodeType::VoxelServer) { - totalPingVoxel += node->getPingMs(); - voxelServerCount++; - if (pingVoxelMax < node->getPingMs()) { - pingVoxelMax = node->getPingMs(); - } - } - } - - if (voxelServerCount) { - pingVoxel = totalPingVoxel/voxelServerCount; - } - - lines = _statsExpanded ? 4 : 3; - displayStatsBackground(backgroundColor, horizontalOffset, 0, 175, lines * STATS_PELS_PER_LINE + 10); - horizontalOffset += 5; - - char audioJitter[30]; - sprintf(audioJitter, - "Buffer msecs %.1f", - (float) (_audio.getNetworkBufferLengthSamplesPerChannel() + (float) _audio.getJitterBufferSamples()) / - (float)_audio.getNetworkSampleRate() * 1000.f); - drawText(30, _glWidget->height() - 22, 0.10f, 0.f, 2.f, audioJitter, WHITE_TEXT); - - - char audioPing[30]; - sprintf(audioPing, "Audio ping: %d", pingAudio); - - - char avatarPing[30]; - sprintf(avatarPing, "Avatar ping: %d", pingAvatar); - char voxelAvgPing[30]; - sprintf(voxelAvgPing, "Voxel avg ping: %d", pingVoxel); - - verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, audioPing, WHITE_TEXT); - verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, avatarPing, WHITE_TEXT); - verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, voxelAvgPing, WHITE_TEXT); - - if (_statsExpanded) { - char voxelMaxPing[30]; - sprintf(voxelMaxPing, "Voxel max ping: %d", pingVoxelMax); - - verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, voxelMaxPing, WHITE_TEXT); - } - - verticalOffset = 0; - horizontalOffset += 171; - } - - glm::vec3 avatarPos = _myAvatar->getPosition(); - - lines = _statsExpanded ? 8 : 3; - displayStatsBackground(backgroundColor, horizontalOffset, 0, _glWidget->width() - (mirrorEnabled ? 301 : 411) - horizontalOffset, lines * STATS_PELS_PER_LINE + 10); - horizontalOffset += 5; - - char avatarPosition[200]; - if (mirrorEnabled) { - // shorthand formatting - sprintf(avatarPosition, "Pos: %.0f,%.0f,%.0f", avatarPos.x, avatarPos.y, avatarPos.z); - } else { - // longhand way - sprintf(avatarPosition, "Position: %.1f, %.1f, %.1f", avatarPos.x, avatarPos.y, avatarPos.z); - } - char avatarVelocity[30]; - sprintf(avatarVelocity, "Velocity: %.1f", glm::length(_myAvatar->getVelocity())); - char avatarBodyYaw[30]; - sprintf(avatarBodyYaw, "Yaw: %.1f", _myAvatar->getBodyYaw()); - char avatarMixerStats[200]; - - verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, avatarPosition, WHITE_TEXT); - verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, avatarVelocity, WHITE_TEXT); - verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, avatarBodyYaw, WHITE_TEXT); - - if (_statsExpanded) { - SharedNodePointer avatarMixer = NodeList::getInstance()->soloNodeOfType(NodeType::AvatarMixer); - if (avatarMixer) { - sprintf(avatarMixerStats, "Avatar Mixer: %.f kbps, %.f pps", - roundf(avatarMixer->getAverageKilobitsPerSecond()), - roundf(avatarMixer->getAveragePacketsPerSecond())); - } else { - sprintf(avatarMixerStats, "No Avatar Mixer"); - } - - verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, avatarMixerStats, WHITE_TEXT); - - stringstream downloadStats; - downloadStats << "Downloads: "; - foreach (Resource* resource, ResourceCache::getLoadingRequests()) { - const float MAXIMUM_PERCENTAGE = 100.0f; - downloadStats << roundf(resource->getProgress() * MAXIMUM_PERCENTAGE) << "% "; - } - downloadStats << "(" << ResourceCache::getPendingRequestCount() << " pending)"; - - verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, downloadStats.str().c_str(), WHITE_TEXT); - - if (Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessing)) { - // add some reflection stats - char reflectionsStatus[128]; - - sprintf(reflectionsStatus, "Reflections: %d, Original: %s, Ears: %s, Source: %s", - _audioReflector.getReflections(), - (Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingIncudeOriginal) - ? "with" : "without"), - (Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingSeparateEars) - ? "two" : "one"), - (Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingStereoSource) - ? "stereo" : "mono") - ); - - verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, reflectionsStatus, WHITE_TEXT); - - float preDelay = Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingPreDelay) ? - _audioReflector.getPreDelay() : 0.0f; - - sprintf(reflectionsStatus, "Delay: pre: %f, average %f, max %f, min %f, speed: %f", - preDelay, - _audioReflector.getAverageDelayMsecs(), - _audioReflector.getMaxDelayMsecs(), - _audioReflector.getMinDelayMsecs(), - _audioReflector.getSoundMsPerMeter()); - - verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, reflectionsStatus, WHITE_TEXT); - - sprintf(reflectionsStatus, "Attenuation: average %f, max %f, min %f, distance scale: %f", - _audioReflector.getAverageAttenuation(), - _audioReflector.getMaxAttenuation(), - _audioReflector.getMinAttenuation(), - _audioReflector.getDistanceAttenuationScalingFactor()); - - verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, reflectionsStatus, WHITE_TEXT); - } - - } - - verticalOffset = 0; - horizontalOffset = _glWidget->width() - (mirrorEnabled ? 300 : 410); - - lines = _statsExpanded ? 12 : 3; - displayStatsBackground(backgroundColor, horizontalOffset, 0, _glWidget->width() - horizontalOffset, lines * STATS_PELS_PER_LINE + 10); - horizontalOffset += 5; - - if (_statsExpanded) { - // Local Voxel Memory Usage - voxelStats.str(""); - voxelStats << "Voxels Memory Nodes: " << VoxelTreeElement::getTotalMemoryUsage() / 1000000.f << "MB"; - verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), WHITE_TEXT); - - voxelStats.str(""); - voxelStats << - "Geometry RAM: " << _voxels.getVoxelMemoryUsageRAM() / 1000000.f << "MB / " << - "VBO: " << _voxels.getVoxelMemoryUsageVBO() / 1000000.f << "MB"; - if (_voxels.hasVoxelMemoryUsageGPU()) { - voxelStats << " / GPU: " << _voxels.getVoxelMemoryUsageGPU() / 1000000.f << "MB"; - } - verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), WHITE_TEXT); - - // Voxel Rendering - voxelStats.str(""); - voxelStats.precision(4); - voxelStats << "Voxel Rendering Slots Max: " << _voxels.getMaxVoxels() / 1000.f << "K"; - verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), WHITE_TEXT); - } - - voxelStats.str(""); - voxelStats.precision(4); - voxelStats << "Drawn: " << _voxels.getVoxelsWritten() / 1000.f << "K " << - "Abandoned: " << _voxels.getAbandonedVoxels() / 1000.f << "K "; - verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), WHITE_TEXT); - - // iterate all the current voxel stats, and list their sending modes, and total voxel counts - std::stringstream sendingMode(""); - sendingMode << "Octree Sending Mode: ["; - int serverCount = 0; - int movingServerCount = 0; - unsigned long totalNodes = 0; - unsigned long totalInternal = 0; - unsigned long totalLeaves = 0; - for(NodeToOctreeSceneStatsIterator i = _octreeServerSceneStats.begin(); i != _octreeServerSceneStats.end(); i++) { - //const QUuid& uuid = i->first; - OctreeSceneStats& stats = i->second; - serverCount++; - if (_statsExpanded) { - if (serverCount > 1) { - sendingMode << ","; - } - if (stats.isMoving()) { - sendingMode << "M"; - movingServerCount++; - } else { - sendingMode << "S"; - } - } - - // calculate server node totals - totalNodes += stats.getTotalElements(); - if (_statsExpanded) { - totalInternal += stats.getTotalInternal(); - totalLeaves += stats.getTotalLeaves(); - } - } - if (_statsExpanded) { - if (serverCount == 0) { - sendingMode << "---"; - } - sendingMode << "] " << serverCount << " servers"; - if (movingServerCount > 0) { - sendingMode << " "; - } else { - sendingMode << " "; - } - verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)sendingMode.str().c_str(), WHITE_TEXT); - } - - // Incoming packets - int voxelPacketsToProcess = _voxelProcessor.packetsToProcessCount(); - if (_statsExpanded) { - voxelStats.str(""); - QString packetsString = locale.toString((int)voxelPacketsToProcess); - QString maxString = locale.toString((int)_recentMaxPackets); - voxelStats << "Voxel Packets to Process: " << qPrintable(packetsString) - << " [Recent Max: " << qPrintable(maxString) << "]"; - verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), WHITE_TEXT); - } - - if (_resetRecentMaxPacketsSoon && voxelPacketsToProcess > 0) { - _recentMaxPackets = 0; - _resetRecentMaxPacketsSoon = false; - } - if (voxelPacketsToProcess == 0) { - _resetRecentMaxPacketsSoon = true; - } else { - if (voxelPacketsToProcess > _recentMaxPackets) { - _recentMaxPackets = voxelPacketsToProcess; - } - } - - verticalOffset += (_statsExpanded ? STATS_PELS_PER_LINE : 0); - - QString serversTotalString = locale.toString((uint)totalNodes); // consider adding: .rightJustified(10, ' '); - - // Server Voxels - voxelStats.str(""); - voxelStats << "Server voxels: " << qPrintable(serversTotalString); - verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), WHITE_TEXT); - - if (_statsExpanded) { - QString serversInternalString = locale.toString((uint)totalInternal); - QString serversLeavesString = locale.toString((uint)totalLeaves); - - voxelStats.str(""); - voxelStats << - "Internal: " << qPrintable(serversInternalString) << " " << - "Leaves: " << qPrintable(serversLeavesString) << ""; - verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), WHITE_TEXT); - } - - unsigned long localTotal = VoxelTreeElement::getNodeCount(); - QString localTotalString = locale.toString((uint)localTotal); // consider adding: .rightJustified(10, ' '); - - // Local Voxels - voxelStats.str(""); - voxelStats << "Local voxels: " << qPrintable(localTotalString); - verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), WHITE_TEXT); - - if (_statsExpanded) { - unsigned long localInternal = VoxelTreeElement::getInternalNodeCount(); - unsigned long localLeaves = VoxelTreeElement::getLeafNodeCount(); - QString localInternalString = locale.toString((uint)localInternal); - QString localLeavesString = locale.toString((uint)localLeaves); - - voxelStats.str(""); - voxelStats << - "Internal: " << qPrintable(localInternalString) << " " << - "Leaves: " << qPrintable(localLeavesString) << ""; - verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0, 2, (char*)voxelStats.str().c_str(), WHITE_TEXT); - } - - // LOD Details - if (_statsExpanded) { - voxelStats.str(""); - QString displayLODDetails = Menu::getInstance()->getLODFeedbackText(); - voxelStats << "LOD: You can see " << qPrintable(displayLODDetails.trimmed()); - verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), WHITE_TEXT); - } -} - -// called on mouse click release -// check for clicks over stats in order to expand or contract them -void Application::checkStatsClick() { - if (0 != glm::compMax(glm::abs(glm::ivec2(_mouseX - _mouseDragStartedX, _mouseY - _mouseDragStartedY)))) { - // not worried about dragging on stats - return; - } - - int statsHeight = 0, statsWidth = 0, statsX = 0, statsY = 0, lines = 0; - - if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { - statsX += MIRROR_VIEW_WIDTH; - } - - // top-left stats click - lines = _statsExpanded ? 5 : 3; - statsHeight = lines * STATS_PELS_PER_LINE + 10; - statsWidth = 165; - if (_mouseX > statsX && _mouseX < statsX + statsWidth && _mouseY > statsY && _mouseY < statsY + statsHeight) { - toggleStatsExpanded(); - return; - } - - // ping stats click - lines = _statsExpanded ? 4 : 3; - statsX += statsWidth; - statsHeight = lines * STATS_PELS_PER_LINE + 10; - statsWidth = 175; - if (_mouseX > statsX && _mouseX < statsX + statsWidth && _mouseY > statsY && _mouseY < statsY + statsHeight) { - toggleStatsExpanded(); - return; - } - - // top-center stats panel click - lines = _statsExpanded ? 4 : 3; - statsX += statsWidth; - statsHeight = lines * STATS_PELS_PER_LINE + 10; - statsWidth = _glWidget->width() - 411 - statsX; - if (_mouseX > statsX && _mouseX < statsX + statsWidth && _mouseY > statsY && _mouseY < statsY + statsHeight) { - toggleStatsExpanded(); - return; - } - - // top-right stats click - lines = _statsExpanded ? 11 : 3; - statsX = _glWidget->width() - 410; - statsHeight = lines * STATS_PELS_PER_LINE + 10; - statsWidth = _glWidget->width() - statsX; - if (_mouseX > statsX && _mouseX < statsX + statsWidth && _mouseY > statsY && _mouseY < statsY + statsHeight) { - toggleStatsExpanded(); - return; - } -} - -void Application::toggleStatsExpanded() { - _statsExpanded = !_statsExpanded; -} - glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) { float horizontalScale = _glWidget->width() / 2.0f; float verticalScale = _glWidget->height() / 2.0f; @@ -3132,12 +2767,12 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { _mirrorCamera.setFieldOfView(BILLBOARD_FIELD_OF_VIEW); // degees _mirrorCamera.setDistance(BILLBOARD_DISTANCE * _myAvatar->getScale()); _mirrorCamera.setTargetPosition(_myAvatar->getPosition()); - + } else if (_rearMirrorTools->getZoomLevel() == BODY) { _mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees _mirrorCamera.setDistance(MIRROR_REARVIEW_BODY_DISTANCE * _myAvatar->getScale()); _mirrorCamera.setTargetPosition(_myAvatar->getChestPosition()); - + } else { // HEAD zoom level _mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees _mirrorCamera.setDistance(MIRROR_REARVIEW_DISTANCE * _myAvatar->getScale()); @@ -3152,7 +2787,7 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { } } _mirrorCamera.setAspectRatio((float)region.width() / region.height()); - + _mirrorCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI, 0.0f))); _mirrorCamera.update(1.0f/_fps); @@ -3197,7 +2832,7 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { if (!billboard) { _rearMirrorTools->render(false); } - + // reset Viewport and projection matrix glViewport(0, 0, _glWidget->width(), _glWidget->height()); glDisable(GL_SCISSOR_TEST); @@ -3417,14 +3052,14 @@ void Application::setMenuShortcutsEnabled(bool enabled) { } void Application::updateWindowTitle(){ - + QString buildVersion = " (build " + applicationVersion() + ")"; NodeList* nodeList = NodeList::getInstance(); - + QString username = AccountManager::getInstance().getUsername(); QString title = QString() + (!username.isEmpty() ? username + " " : QString()) + nodeList->getSessionUUID().toString() + " @ " + nodeList->getDomainInfo().getHostname() + buildVersion; - + qDebug("Application title set to: %s", title.toStdString().c_str()); _window->setWindowTitle(title); } @@ -3439,7 +3074,7 @@ void Application::domainChanged(const QString& domainHostname) { _voxelServerJurisdictions.clear(); _octreeServerSceneStats.clear(); _particleServerJurisdictions.clear(); - + // reset the particle renderer _particles.clear(); @@ -3449,12 +3084,12 @@ void Application::domainChanged(const QString& domainHostname) { void Application::connectedToDomain(const QString& hostname) { AccountManager& accountManager = AccountManager::getInstance(); - + if (accountManager.isLoggedIn()) { // update our domain-server with the data-server we're logged in with - + QString domainPutJsonString = "{\"address\":{\"domain\":\"" + hostname + "\"}}"; - + accountManager.authenticatedRequest("/api/v1/users/address", QNetworkAccessManager::PutOperation, JSONCallbackParameters(), domainPutJsonString.toUtf8()); } @@ -3617,72 +3252,106 @@ void Application::packetSent(quint64 length) { void Application::loadScripts() { // loads all saved scripts - QSettings* settings = new QSettings(this); - int size = settings->beginReadArray("Settings"); - + int size = lockSettings()->beginReadArray("Settings"); + unlockSettings(); for (int i = 0; i < size; ++i){ - settings->setArrayIndex(i); - QString string = settings->value("script").toString(); - loadScript(string); + lockSettings()->setArrayIndex(i); + QString string = _settings->value("script").toString(); + unlockSettings(); + if (!string.isEmpty()) { + loadScript(string); + } } - settings->endArray(); + QMutexLocker locker(&_settingsMutex); + _settings->endArray(); } void Application::clearScriptsBeforeRunning() { // clears all scripts from the settings - QSettings* settings = new QSettings(this); - settings->beginWriteArray("Settings"); - settings->endArray(); + QMutexLocker locker(&_settingsMutex); + _settings->remove("Settings"); } void Application::saveScripts() { // saves all current running scripts - QSettings* settings = new QSettings(this); - settings->beginWriteArray("Settings"); - for (int i = 0; i < _activeScripts.size(); ++i){ - settings->setArrayIndex(i); - settings->setValue("script", _activeScripts.at(i)); + QMutexLocker locker(&_settingsMutex); + _settings->beginWriteArray("Settings"); + for (int i = 0; i < getRunningScripts().size(); ++i){ + _settings->setArrayIndex(i); + _settings->setValue("script", getRunningScripts().at(i)); } - - settings->endArray(); + _settings->endArray(); } void Application::stopAllScripts() { // stops all current running scripts - QList scriptActions = Menu::getInstance()->getActiveScriptsMenu()->actions(); - foreach (QAction* scriptAction, scriptActions) { - scriptAction->activate(QAction::Trigger); - qDebug() << "stopping script..." << scriptAction->text(); + for (int i = 0; i < _scriptEnginesHash.size(); ++i) { + _scriptEnginesHash.values().at(i)->stop(); + qDebug() << "stopping script..." << getRunningScripts().at(i); } - _activeScripts.clear(); + _scriptEnginesHash.clear(); + _runningScriptsWidget->setRunningScripts(getRunningScripts()); +} + +void Application::stopScript(const QString &scriptName) +{ + _scriptEnginesHash.value(scriptName)->stop(); + qDebug() << "stopping script..." << scriptName; + _scriptEnginesHash.remove(scriptName); + _runningScriptsWidget->setRunningScripts(getRunningScripts()); } void Application::reloadAllScripts() { // remember all the current scripts so we can reload them - QStringList reloadList = _activeScripts; + QStringList reloadList = getRunningScripts(); // reloads all current running scripts - QList scriptActions = Menu::getInstance()->getActiveScriptsMenu()->actions(); - foreach (QAction* scriptAction, scriptActions) { - scriptAction->activate(QAction::Trigger); - qDebug() << "stopping script..." << scriptAction->text(); - } + stopAllScripts(); - // NOTE: we don't need to clear the _activeScripts list because that is handled on script shutdown. - foreach (QString scriptName, reloadList){ qDebug() << "reloading script..." << scriptName; loadScript(scriptName); } } -void Application::uploadFST(bool isHead) { - FstReader reader(isHead); - if (reader.zip()) { - reader.send(); +void Application::toggleRunningScriptsWidget() +{ + if (!_runningScriptsWidget->toggleViewAction()->isChecked()) { + _runningScriptsWidget->move(_window->geometry().topLeft().x(), _window->geometry().topLeft().y()); + _runningScriptsWidget->resize(0, _window->height()); + _runningScriptsWidget->toggleViewAction()->trigger(); + _runningScriptsWidget->grabKeyboard(); + + QPropertyAnimation* slideAnimation = new QPropertyAnimation(_runningScriptsWidget, "geometry", _runningScriptsWidget); + slideAnimation->setStartValue(_runningScriptsWidget->geometry()); + slideAnimation->setEndValue(QRect(_window->geometry().topLeft().x(), _window->geometry().topLeft().y(), + 310, _runningScriptsWidget->height())); + slideAnimation->setDuration(250); + slideAnimation->start(QAbstractAnimation::DeleteWhenStopped); + } else { + _runningScriptsWidget->releaseKeyboard(); + + QPropertyAnimation* slideAnimation = new QPropertyAnimation(_runningScriptsWidget, "geometry", _runningScriptsWidget); + slideAnimation->setStartValue(_runningScriptsWidget->geometry()); + slideAnimation->setEndValue(QRect(_window->geometry().topLeft().x(), _window->geometry().topLeft().y(), + 0, _runningScriptsWidget->height())); + slideAnimation->setDuration(250); + slideAnimation->start(QAbstractAnimation::DeleteWhenStopped); + + QTimer::singleShot(260, _runningScriptsWidget->toggleViewAction(), SLOT(trigger())); } } +void Application::uploadFST(bool isHead) { + ModelUploader* uploader = new ModelUploader(isHead); + QThread* thread = new QThread(); + thread->connect(uploader, SIGNAL(destroyed()), SLOT(quit())); + thread->connect(thread, SIGNAL(finished()), SLOT(deleteLater())); + uploader->connect(thread, SIGNAL(started()), SLOT(send())); + + thread->start(); +} + void Application::uploadHead() { uploadFST(true); } @@ -3691,37 +3360,26 @@ void Application::uploadSkeleton() { uploadFST(false); } -void Application::removeScriptName(const QString& fileNameString) { - _activeScripts.removeOne(fileNameString); -} - -void Application::cleanupScriptMenuItem(const QString& scriptMenuName) { - Menu::getInstance()->removeAction(Menu::getInstance()->getActiveScriptsMenu(), scriptMenuName); -} - void Application::loadScript(const QString& scriptName) { // start the script on a new thread... - bool wantMenuItems = true; // tells the ScriptEngine object to add menu items for itself - ScriptEngine* scriptEngine = new ScriptEngine(QUrl(scriptName), wantMenuItems, &_controllerScriptingInterface); + ScriptEngine* scriptEngine = new ScriptEngine(QUrl(scriptName), &_controllerScriptingInterface); + _scriptEnginesHash.insert(scriptName, scriptEngine); if (!scriptEngine->hasScript()) { qDebug() << "Application::loadScript(), script failed to load..."; return; } - _activeScripts.append(scriptName); - - // add a stop menu item - Menu::getInstance()->addActionToQMenuAndActionHash(Menu::getInstance()->getActiveScriptsMenu(), - scriptEngine->getScriptMenuName(), 0, scriptEngine, SLOT(stop())); + _runningScriptsWidget->setRunningScripts(getRunningScripts()); // setup the packet senders and jurisdiction listeners of the script engine's scripting interfaces so // we can use the same ones from the application. scriptEngine->getVoxelsScriptingInterface()->setPacketSender(&_voxelEditSender); scriptEngine->getVoxelsScriptingInterface()->setVoxelTree(_voxels.getTree()); + scriptEngine->getVoxelsScriptingInterface()->setUndoStack(&_undoStack); scriptEngine->getParticlesScriptingInterface()->setPacketSender(&_particleEditSender); scriptEngine->getParticlesScriptingInterface()->setParticleTree(_particles.getTree()); - + // hook our avatar object into this script engine scriptEngine->setAvatarData(_myAvatar, "MyAvatar"); // leave it as a MyAvatar class to expose thrust features @@ -3747,8 +3405,6 @@ void Application::loadScript(const QString& scriptName) { // when the thread is terminated, add both scriptEngine and thread to the deleteLater queue connect(scriptEngine, SIGNAL(finished(const QString&)), scriptEngine, SLOT(deleteLater())); connect(workerThread, SIGNAL(finished()), workerThread, SLOT(deleteLater())); - connect(scriptEngine, SIGNAL(finished(const QString&)), this, SLOT(removeScriptName(const QString&))); - connect(scriptEngine, SIGNAL(cleanupMenuItem(const QString&)), this, SLOT(cleanupScriptMenuItem(const QString&))); // when the application is about to quit, stop our script engine so it unwinds properly connect(this, SIGNAL(aboutToQuit()), scriptEngine, SLOT(stop())); @@ -3767,18 +3423,23 @@ void Application::loadDialog() { if (_previousScriptLocation.isEmpty()) { QString desktopLocation = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); +// Temporary fix to Qt bug: http://stackoverflow.com/questions/16194475 +#ifdef __APPLE__ suggestedName = desktopLocation.append("/script.js"); +#endif } else { suggestedName = _previousScriptLocation; } - QString fileNameString = QFileDialog::getOpenFileName(_glWidget, tr("Open Script"), suggestedName, + QString fileNameString = QFileDialog::getOpenFileName(_glWidget, tr("Open Script"), suggestedName, tr("JavaScript Files (*.js)")); if (!fileNameString.isEmpty()) { _previousScriptLocation = fileNameString; + QMutexLocker locker(&_settingsMutex); + _settings->setValue("LastScriptLocation", _previousScriptLocation); + + loadScript(fileNameString); } - - loadScript(fileNameString); } void Application::loadScriptURLDialog() { @@ -3788,7 +3449,7 @@ void Application::loadScriptURLDialog() { scriptURLDialog.setLabelText("Script:"); scriptURLDialog.setWindowFlags(Qt::Sheet); const float DIALOG_RATIO_OF_WINDOW = 0.30f; - scriptURLDialog.resize(scriptURLDialog.parentWidget()->size().width() * DIALOG_RATIO_OF_WINDOW, + scriptURLDialog.resize(scriptURLDialog.parentWidget()->size().width() * DIALOG_RATIO_OF_WINDOW, scriptURLDialog.size().height()); int dialogReturn = scriptURLDialog.exec(); @@ -3826,29 +3487,29 @@ void Application::checkVersion() { } void Application::parseVersionXml() { - + #ifdef Q_OS_WIN32 QString operatingSystem("win"); #endif - + #ifdef Q_OS_MAC QString operatingSystem("mac"); #endif - + #ifdef Q_OS_LINUX QString operatingSystem("ubuntu"); #endif - + QString releaseDate; QString releaseNotes; QString latestVersion; QUrl downloadUrl; QObject* sender = QObject::sender(); - + QXmlStreamReader xml(qobject_cast(sender)); while (!xml.atEnd() && !xml.hasError()) { QXmlStreamReader::TokenType token = xml.readNext(); - + if (token == QXmlStreamReader::StartElement) { if (xml.name() == "ReleaseDate") { xml.readNext(); diff --git a/interface/src/Application.h b/interface/src/Application.h index 50275d96d2..2656ff47ce 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -1,26 +1,31 @@ // // Application.h -// interface +// interface/src // // Created by Andrzej Kapolka on 5/10/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__Application__ -#define __interface__Application__ +#ifndef hifi_Application_h +#define hifi_Application_h #include #include #include #include +#include #include -#include -#include #include -#include -#include #include +#include +#include +#include +#include +#include #include #include @@ -48,6 +53,7 @@ #include "avatar/Avatar.h" #include "avatar/AvatarManager.h" #include "avatar/MyAvatar.h" +#include "devices/Faceplus.h" #include "devices/Faceshift.h" #include "devices/SixenseManager.h" #include "devices/Visage.h" @@ -66,6 +72,7 @@ #include "ui/LogDialog.h" #include "ui/UpdateDialog.h" #include "ui/overlays/Overlays.h" +#include "ui/RunningScriptsWidget.h" #include "voxels/VoxelFade.h" #include "voxels/VoxelHideShowThread.h" #include "voxels/VoxelImporter.h" @@ -94,6 +101,7 @@ static const float NODE_KILLED_GREEN = 0.0f; static const float NODE_KILLED_BLUE = 0.0f; static const QString SNAPSHOT_EXTENSION = ".jpg"; +static const QString CUSTOM_URL_SCHEME = "hifi:"; static const float BILLBOARD_FIELD_OF_VIEW = 30.0f; // degrees static const float BILLBOARD_DISTANCE = 5.0f; // meters @@ -113,7 +121,7 @@ public: ~Application(); void restoreSizeAndPosition(); - void loadScript(const QString& fileNameString); + void loadScript(const QString& fileNameString); void loadScripts(); void storeSizeAndPosition(); void clearScriptsBeforeRunning(); @@ -137,9 +145,9 @@ public: void wheelEvent(QWheelEvent* event); void dropEvent(QDropEvent *event); - + bool event(QEvent* event); - + void makeVoxel(glm::vec3 position, float scale, unsigned char red, @@ -155,6 +163,7 @@ public: bool isThrottleRendering() const { return _glWidget->isThrottleRendering(); } MyAvatar* getAvatar() { return _myAvatar; } Audio* getAudio() { return &_audio; } + const AudioReflector* getAudioReflector() const { return &_audioReflector; } Camera* getCamera() { return &_myCamera; } ViewFrustum* getViewFrustum() { return &_viewFrustum; } ViewFrustum* getShadowViewFrustum() { return &_shadowViewFrustum; } @@ -170,14 +179,19 @@ public: bool isMouseHidden() const { return _mouseHidden; } const glm::vec3& getMouseRayOrigin() const { return _mouseRayOrigin; } const glm::vec3& getMouseRayDirection() const { return _mouseRayDirection; } + Faceplus* getFaceplus() { return &_faceplus; } Faceshift* getFaceshift() { return &_faceshift; } Visage* getVisage() { return &_visage; } + FaceTracker* getActiveFaceTracker(); SixenseManager* getSixenseManager() { return &_sixenseManager; } BandwidthMeter* getBandwidthMeter() { return &_bandwidthMeter; } + QUndoStack* getUndoStack() { return &_undoStack; } /// if you need to access the application settings, use lockSettings()/unlockSettings() QSettings* lockSettings() { _settingsMutex.lock(); return _settings; } void unlockSettings() { _settingsMutex.unlock(); } + + void saveSettings(); QMainWindow* getWindow() { return _window; } NodeToOctreeSceneStats* getOcteeSceneStats() { return &_octreeServerSceneStats; } @@ -201,6 +215,10 @@ public: void displaySide(Camera& whichCamera, bool selfAvatarOnly = false); + /// Stores the current modelview matrix as the untranslated view matrix to use for transforms and the supplied vector as + /// the view matrix translation. + void updateUntranslatedViewMatrix(const glm::vec3& viewMatrixTranslation = glm::vec3()); + /// Loads a view matrix that incorporates the specified model translation without the precision issues that can /// result from matrix multiplication at high translation magnitudes. void loadTranslatedViewMatrix(const glm::vec3& translation); @@ -227,6 +245,8 @@ public: void skipVersion(QString latestVersion); + QStringList getRunningScripts() { return _scriptEnginesHash.keys(); } + signals: /// Fired when we're simulating; allows external parties to hook in. @@ -234,10 +254,10 @@ signals: /// Fired when we're rendering in-world interface elements; allows external parties to hook in. void renderingInWorldInterface(); - + /// Fired when the import window is closed void importDone(); - + public slots: void domainChanged(const QString& domainHostname); void updateWindowTitle(); @@ -260,33 +280,34 @@ public slots: void toggleLogDialog(); void initAvatarAndViewFrustum(); void stopAllScripts(); + void stopScript(const QString& scriptName); void reloadAllScripts(); - + void toggleRunningScriptsWidget(); + void uploadFST(bool isHead); void uploadHead(); void uploadSkeleton(); + void bumpSettings() { ++_numChangedSettings; } + private slots: void timer(); void idle(); - + void connectedToDomain(const QString& hostname); void setFullscreen(bool fullscreen); void setEnable3DTVMode(bool enable3DTVMode); void cameraMenuChanged(); - + glm::vec2 getScaledScreenPoint(glm::vec2 projectedPoint); void closeMirrorView(); void restoreMirrorView(); void shrinkMirrorView(); void resetSensors(); - - void parseVersionXml(); - void removeScriptName(const QString& fileNameString); - void cleanupScriptMenuItem(const QString& scriptMenuName); + void parseVersionXml(); private: void resetCamerasOnResizeGL(Camera& camera, int width, int height); @@ -304,6 +325,7 @@ private: // Various helper functions called during update() void updateLOD(); void updateMouseRay(); + void updateFaceplus(); void updateFaceshift(); void updateVisage(); void updateMyAvatarLookAtPosition(); @@ -330,10 +352,6 @@ private: void updateShadowMap(); void displayOverlay(); - void displayStatsBackground(unsigned int rgba, int x, int y, int width, int height); - void displayStats(); - void checkStatsClick(); - void toggleStatsExpanded(); void renderRearViewMirror(const QRect& region, bool billboard = false); void renderViewFrustum(ViewFrustum& viewFrustum); @@ -354,16 +372,18 @@ private: QMainWindow* _window; GLCanvas* _glWidget; // our GLCanvas has a couple extra features - bool _statsExpanded; BandwidthMeter _bandwidthMeter; - + QThread* _nodeThread; DatagramProcessor _datagramProcessor; QNetworkAccessManager* _networkAccessManager; QMutex _settingsMutex; QSettings* _settings; + int _numChangedSettings; + QUndoStack _undoStack; + glm::vec3 _gravity; // Frame Rate Measurement @@ -375,7 +395,7 @@ private: timeval _lastTimeUpdated; bool _justStarted; Stars _stars; - + BuckyBalls _buckyBalls; VoxelSystem _voxels; @@ -398,7 +418,6 @@ private: ViewFrustum _shadowViewFrustum; quint64 _lastQueriedTime; - Oscilloscope _audioScope; float _trailingAudioLoudness; OctreeQuery _octreeQuery; // NodeData derived class for querying voxels from voxel server @@ -406,11 +425,11 @@ private: AvatarManager _avatarManager; MyAvatar* _myAvatar; // TODO: move this and relevant code to AvatarManager (or MyAvatar as the case may be) + Faceplus _faceplus; Faceshift _faceshift; Visage _visage; - + SixenseManager _sixenseManager; - QStringList _activeScripts; Camera _myCamera; // My view onto the world Camera _viewFrustumOffsetCamera; // The camera we use to sometimes show the view frustum from an offset mode @@ -418,6 +437,7 @@ private: QRect _mirrorViewRect; RearMirrorTools* _rearMirrorTools; + float _cameraPushback; glm::mat4 _untranslatedViewMatrix; glm::vec3 _viewMatrixTranslation; glm::mat4 _projectionMatrix; @@ -468,9 +488,6 @@ private: int _packetsPerSecond; int _bytesPerSecond; - int _recentMaxPackets; // recent max incoming voxel packets to process - bool _resetRecentMaxPacketsSoon; - StDev _idleLoopStdev; float _idleLoopMeasuredJitter; @@ -494,11 +511,13 @@ private: void displayUpdateDialog(); bool shouldSkipVersion(QString latestVersion); void takeSnapshot(); - + TouchEvent _lastTouchEvent; - + Overlays _overlays; AudioReflector _audioReflector; + RunningScriptsWidget* _runningScriptsWidget; + QHash _scriptEnginesHash; }; -#endif /* defined(__interface__Application__) */ +#endif // hifi_Application_h diff --git a/interface/src/Audio.cpp b/interface/src/Audio.cpp index f7bb3f78c9..77b9fbb16b 100644 --- a/interface/src/Audio.cpp +++ b/interface/src/Audio.cpp @@ -1,9 +1,12 @@ // // Audio.cpp -// interface +// interface/src // // Created by Stephen Birarda on 1/22/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include @@ -15,6 +18,15 @@ #include #endif +#ifdef WIN32 +#define WIN32_LEAN_AND_MEAN +#include +#include +#include +#include +#include +#endif + #include #include #include @@ -39,7 +51,7 @@ static const int NUMBER_OF_NOISE_SAMPLE_FRAMES = 300; // Mute icon configration static const int MUTE_ICON_SIZE = 24; -Audio::Audio(Oscilloscope* scope, int16_t initialJitterBufferSamples, QObject* parent) : +Audio::Audio(int16_t initialJitterBufferSamples, QObject* parent) : AbstractAudioInterface(parent), _audioInput(NULL), _desiredInputFormat(), @@ -56,7 +68,6 @@ Audio::Audio(Oscilloscope* scope, int16_t initialJitterBufferSamples, QObject* p _proceduralOutputDevice(NULL), _inputRingBuffer(0), _ringBuffer(NETWORK_BUFFER_LENGTH_BYTES_PER_CHANNEL), - _scope(scope), _averagedLatency(0.0), _measuredJitter(0), _jitterBufferSamples(initialJitterBufferSamples), @@ -91,7 +102,8 @@ Audio::Audio(Oscilloscope* scope, int16_t initialJitterBufferSamples, QObject* p void Audio::init(QGLWidget *parent) { _micTextureId = parent->bindTexture(QImage(Application::resourcesPath() + "images/mic.svg")); - _muteTextureId = parent->bindTexture(QImage(Application::resourcesPath() + "images/mute.svg")); + _muteTextureId = parent->bindTexture(QImage(Application::resourcesPath() + "images/mic-mute.svg")); + _boxTextureId = parent->bindTexture(QImage(Application::resourcesPath() + "images/audio-box.svg")); } void Audio::reset() { @@ -152,24 +164,56 @@ QAudioDeviceInfo defaultAudioDeviceForMode(QAudio::Mode mode) { #endif #ifdef WIN32 QString deviceName; - if (mode == QAudio::AudioInput) { - WAVEINCAPS wic; - // first use WAVE_MAPPER to get the default devices manufacturer ID - waveInGetDevCaps(WAVE_MAPPER, &wic, sizeof(wic)); - //Use the received manufacturer id to get the device's real name - waveInGetDevCaps(wic.wMid, &wic, sizeof(wic)); - qDebug() << "input device:" << wic.szPname; - deviceName = wic.szPname; + //Check for Windows Vista or higher, IMMDeviceEnumerator doesn't work below that. + OSVERSIONINFO osvi; + ZeroMemory(&osvi, sizeof(OSVERSIONINFO)); + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + GetVersionEx(&osvi); + const DWORD VISTA_MAJOR_VERSION = 6; + if (osvi.dwMajorVersion < VISTA_MAJOR_VERSION) {// lower then vista + if (mode == QAudio::AudioInput) { + WAVEINCAPS wic; + // first use WAVE_MAPPER to get the default devices manufacturer ID + waveInGetDevCaps(WAVE_MAPPER, &wic, sizeof(wic)); + //Use the received manufacturer id to get the device's real name + waveInGetDevCaps(wic.wMid, &wic, sizeof(wic)); + qDebug() << "input device:" << wic.szPname; + deviceName = wic.szPname; + } else { + WAVEOUTCAPS woc; + // first use WAVE_MAPPER to get the default devices manufacturer ID + waveOutGetDevCaps(WAVE_MAPPER, &woc, sizeof(woc)); + //Use the received manufacturer id to get the device's real name + waveOutGetDevCaps(woc.wMid, &woc, sizeof(woc)); + qDebug() << "output device:" << woc.szPname; + deviceName = woc.szPname; + } } else { - WAVEOUTCAPS woc; - // first use WAVE_MAPPER to get the default devices manufacturer ID - waveOutGetDevCaps(WAVE_MAPPER, &woc, sizeof(woc)); - //Use the received manufacturer id to get the device's real name - waveOutGetDevCaps(woc.wMid, &woc, sizeof(woc)); - qDebug() << "output device:" << woc.szPname; - deviceName = woc.szPname; + HRESULT hr = S_OK; + CoInitialize(NULL); + IMMDeviceEnumerator* pMMDeviceEnumerator = NULL; + CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, CLSCTX_ALL, __uuidof(IMMDeviceEnumerator), (void**)&pMMDeviceEnumerator); + IMMDevice* pEndpoint; + pMMDeviceEnumerator->GetDefaultAudioEndpoint(mode == QAudio::AudioOutput ? eRender : eCapture, eMultimedia, &pEndpoint); + IPropertyStore* pPropertyStore; + pEndpoint->OpenPropertyStore(STGM_READ, &pPropertyStore); + pEndpoint->Release(); + pEndpoint = NULL; + PROPVARIANT pv; + PropVariantInit(&pv); + hr = pPropertyStore->GetValue(PKEY_Device_FriendlyName, &pv); + pPropertyStore->Release(); + pPropertyStore = NULL; + //QAudio devices seems to only take the 31 first characters of the Friendly Device Name. + const DWORD QT_WIN_MAX_AUDIO_DEVICENAME_LEN = 31; + deviceName = QString::fromWCharArray((wchar_t*)pv.pwszVal).left(QT_WIN_MAX_AUDIO_DEVICENAME_LEN); + qDebug() << (mode == QAudio::AudioOutput ? "output" : "input") << " device:" << deviceName; + PropVariantClear(&pv); + pMMDeviceEnumerator->Release(); + pMMDeviceEnumerator = NULL; + CoUninitialize(); } - qDebug() << "DEBUG [" << deviceName << "] [" << getNamedAudioDeviceForMode(mode, deviceName).deviceName() << "]"; + qDebug() << "DEBUG [" << deviceName << "] [" << getNamedAudioDeviceForMode(mode, deviceName).deviceName() << "]"; return getNamedAudioDeviceForMode(mode, deviceName); #endif @@ -521,12 +565,6 @@ void Audio::handleAudioInput() { _lastInputLoudness = 0; } } - - // add input data just written to the scope - QMetaObject::invokeMethod(_scope, "addSamples", Qt::QueuedConnection, - Q_ARG(QByteArray, QByteArray((char*) monoAudioSamples, - NETWORK_BUFFER_LENGTH_BYTES_PER_CHANNEL)), - Q_ARG(bool, false), Q_ARG(bool, true)); } else { // our input loudness is 0, since we're muted _lastInputLoudness = 0; @@ -801,11 +839,6 @@ void Audio::processReceivedAudio(AudioRingBuffer& ringBuffer) { if (_outputDevice) { _outputDevice->write(outputBuffer); - - // add output (@speakers) data just written to the scope - QMetaObject::invokeMethod(_scope, "addSamples", Qt::QueuedConnection, - Q_ARG(QByteArray, QByteArray((char*) ringBufferSamples, numNetworkOutputSamples)), - Q_ARG(bool, true), Q_ARG(bool, false)); } delete[] ringBufferSamples; } @@ -979,13 +1012,52 @@ void Audio::handleAudioByteArray(const QByteArray& audioByteArray) { // or send to the mixer and use delayed loopback } -void Audio::renderMuteIcon(int x, int y) { +void Audio::renderToolBox(int x, int y, bool boxed) { - _iconBounds = QRect(x, y, MUTE_ICON_SIZE, MUTE_ICON_SIZE); glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, _micTextureId); - glColor3f(.93f, .93f, .93f); + if (boxed) { + + bool isClipping = ((getTimeSinceLastClip() > 0.f) && (getTimeSinceLastClip() < 1.f)); + const int BOX_LEFT_PADDING = 5; + const int BOX_TOP_PADDING = 10; + const int BOX_WIDTH = 266; + const int BOX_HEIGHT = 44; + + QRect boxBounds = QRect(x - BOX_LEFT_PADDING, y - BOX_TOP_PADDING, BOX_WIDTH, BOX_HEIGHT); + + glBindTexture(GL_TEXTURE_2D, _boxTextureId); + + if (isClipping) { + glColor3f(1.f,0.f,0.f); + } else { + glColor3f(.41f,.41f,.41f); + } + glBegin(GL_QUADS); + + glTexCoord2f(1, 1); + glVertex2f(boxBounds.left(), boxBounds.top()); + + glTexCoord2f(0, 1); + glVertex2f(boxBounds.right(), boxBounds.top()); + + glTexCoord2f(0, 0); + glVertex2f(boxBounds.right(), boxBounds.bottom()); + + glTexCoord2f(1, 0); + glVertex2f(boxBounds.left(), boxBounds.bottom()); + + glEnd(); + } + + _iconBounds = QRect(x, y, MUTE_ICON_SIZE, MUTE_ICON_SIZE); + if (!_muted) { + glBindTexture(GL_TEXTURE_2D, _micTextureId); + } else { + glBindTexture(GL_TEXTURE_2D, _muteTextureId); + } + + glColor3f(1,1,1); glBegin(GL_QUADS); glTexCoord2f(1, 1); @@ -1002,25 +1074,6 @@ void Audio::renderMuteIcon(int x, int y) { glEnd(); - if (_muted) { - glBindTexture(GL_TEXTURE_2D, _muteTextureId); - glBegin(GL_QUADS); - - glTexCoord2f(1, 1); - glVertex2f(_iconBounds.left(), _iconBounds.top()); - - glTexCoord2f(0, 1); - glVertex2f(_iconBounds.right(), _iconBounds.top()); - - glTexCoord2f(0, 0); - glVertex2f(_iconBounds.right(), _iconBounds.bottom()); - - glTexCoord2f(1, 0); - glVertex2f(_iconBounds.left(), _iconBounds.bottom()); - - glEnd(); - } - glDisable(GL_TEXTURE_2D); } diff --git a/interface/src/Audio.h b/interface/src/Audio.h index e449d8f6c7..bac8d48ccf 100644 --- a/interface/src/Audio.h +++ b/interface/src/Audio.h @@ -1,13 +1,16 @@ // // Audio.h -// interface +// interface/src // // Created by Stephen Birarda on 1/22/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__Audio__ -#define __interface__Audio__ +#ifndef hifi_Audio_h +#define hifi_Audio_h #ifdef _WIN32 #define WANT_TIMEVAL @@ -31,9 +34,6 @@ #include #include -#include "ui/Oscilloscope.h" - - static const int NUM_AUDIO_CHANNELS = 2; class QAudioInput; @@ -44,7 +44,7 @@ class Audio : public AbstractAudioInterface { Q_OBJECT public: // setup for audio I/O - Audio(Oscilloscope* scope, int16_t initialJitterBufferSamples, QObject* parent = 0); + Audio(int16_t initialJitterBufferSamples, QObject* parent = 0); float getLastInputLoudness() const { return glm::max(_lastInputLoudness - _noiseGateMeasuredFloor, 0.f); } float getTimeSinceLastClip() const { return _timeSinceLastClip; } @@ -69,7 +69,7 @@ public: void init(QGLWidget *parent = 0); bool mousePressEvent(int x, int y); - void renderMuteIcon(int x, int y); + void renderToolBox(int x, int y, bool boxed); int getNetworkSampleRate() { return SAMPLE_RATE; } int getNetworkBufferLengthSamplesPerChannel() { return NETWORK_BUFFER_LENGTH_SAMPLES_PER_CHANNEL; } @@ -129,7 +129,6 @@ private: QString _inputAudioDeviceName; QString _outputAudioDeviceName; - Oscilloscope* _scope; StDev _stdev; timeval _lastReceiveTime; float _averagedLatency; @@ -167,6 +166,7 @@ private: bool _localEcho; GLuint _micTextureId; GLuint _muteTextureId; + GLuint _boxTextureId; QRect _iconBounds; // Audio callback in class context. @@ -203,4 +203,4 @@ private: }; -#endif /* defined(__interface__audio__) */ +#endif // hifi_Audio_h diff --git a/interface/src/BuckyBalls.cpp b/interface/src/BuckyBalls.cpp index 8e489db74b..e1ec41dca1 100644 --- a/interface/src/BuckyBalls.cpp +++ b/interface/src/BuckyBalls.cpp @@ -1,9 +1,12 @@ // // BuckyBalls.cpp -// hifi +// interface/src // // Created by Philip on 1/2/14. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "BuckyBalls.h" diff --git a/interface/src/BuckyBalls.h b/interface/src/BuckyBalls.h index 705f85517f..f7690408d3 100644 --- a/interface/src/BuckyBalls.h +++ b/interface/src/BuckyBalls.h @@ -1,13 +1,16 @@ // // BuckyBalls.h -// hifi +// interface/src // // Created by Philip on 1/2/14. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__BuckyBalls__ -#define __hifi__BuckyBalls__ +#ifndef hifi_BuckyBalls_h +#define hifi_BuckyBalls_h #include @@ -44,4 +47,4 @@ private: }; -#endif /* defined(__hifi__BuckyBalls__) */ +#endif // hifi_BuckyBalls_h diff --git a/interface/src/Camera.cpp b/interface/src/Camera.cpp index 252b3be685..2ef32dac5f 100644 --- a/interface/src/Camera.cpp +++ b/interface/src/Camera.cpp @@ -1,8 +1,12 @@ // // Camera.cpp -// interface +// interface/src +// +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. #include diff --git a/interface/src/Camera.h b/interface/src/Camera.h index 9973fd246e..5e189c1111 100644 --- a/interface/src/Camera.h +++ b/interface/src/Camera.h @@ -1,12 +1,15 @@ // // Camera.h -// interface +// interface/src // -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__camera__ -#define __interface__camera__ +#ifndef hifi_Camera_h +#define hifi_Camera_h #include #include @@ -54,6 +57,7 @@ public: const glm::quat& getRotation() const { return _rotation; } CameraMode getMode() const { return _mode; } float getModeShiftPeriod() const { return _modeShiftPeriod; } + float getDistance() const { return _distance; } const glm::vec3& getTargetPosition() const { return _targetPosition; } const glm::quat& getTargetRotation() const { return _targetRotation; } float getFieldOfView() const { return _fieldOfView; } @@ -150,4 +154,4 @@ private: Camera* _camera; ViewFrustum* _viewFrustum; }; -#endif +#endif // hifi_Camera_h diff --git a/interface/src/DatagramProcessor.cpp b/interface/src/DatagramProcessor.cpp index 50e84db7b5..92260ad9dc 100644 --- a/interface/src/DatagramProcessor.cpp +++ b/interface/src/DatagramProcessor.cpp @@ -1,9 +1,12 @@ // // DatagramProcessor.cpp -// hifi +// interface/src // // Created by Stephen Birarda on 1/23/2014. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/interface/src/DatagramProcessor.h b/interface/src/DatagramProcessor.h index 722e5a9d41..7d337ec02b 100644 --- a/interface/src/DatagramProcessor.h +++ b/interface/src/DatagramProcessor.h @@ -1,13 +1,16 @@ // // DatagramProcessor.h -// hifi +// interface/src // // Created by Stephen Birarda on 1/23/2014. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__DatagramProcessor__ -#define __hifi__DatagramProcessor__ +#ifndef hifi_DatagramProcessor_h +#define hifi_DatagramProcessor_h #include @@ -28,4 +31,4 @@ private: int _byteCount; }; -#endif /* defined(__hifi__DatagramProcessor__) */ +#endif // hifi_DatagramProcessor_h diff --git a/interface/src/Environment.cpp b/interface/src/Environment.cpp index 096b8770fb..1ba2f0501c 100644 --- a/interface/src/Environment.cpp +++ b/interface/src/Environment.cpp @@ -1,9 +1,13 @@ // // Environment.cpp -// interface +// interface/src // // Created by Andrzej Kapolka on 5/6/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// #include "InterfaceConfig.h" diff --git a/interface/src/Environment.h b/interface/src/Environment.h index 1c9ee578c3..525f3b7eb4 100644 --- a/interface/src/Environment.h +++ b/interface/src/Environment.h @@ -1,13 +1,16 @@ // // Environment.h -// interface +// interface/src // // Created by Andrzej Kapolka on 5/6/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__Environment__ -#define __interface__Environment__ +#ifndef hifi_Environment_h +#define hifi_Environment_h #include #include @@ -75,4 +78,4 @@ private: QMutex _mutex; }; -#endif /* defined(__interface__Environment__) */ +#endif // hifi_Environment_h diff --git a/interface/src/FileLogger.cpp b/interface/src/FileLogger.cpp index 81c626a46e..c4e75b21b2 100644 --- a/interface/src/FileLogger.cpp +++ b/interface/src/FileLogger.cpp @@ -1,9 +1,12 @@ // // FileLogger.cpp -// hifi +// interface/src // // Created by Stojce Slavkovski on 12/22/13. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "FileLogger.h" diff --git a/interface/src/FileLogger.h b/interface/src/FileLogger.h index 35cafa4db7..5da86044ab 100644 --- a/interface/src/FileLogger.h +++ b/interface/src/FileLogger.h @@ -1,9 +1,12 @@ // // FileLogger.h -// hifi +// interface/src // // Created by Stojce Slavkovski on 12/22/13. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #ifndef hifi_FileLogger_h @@ -29,4 +32,4 @@ private: }; -#endif +#endif // hifi_FileLogger_h diff --git a/interface/src/GLCanvas.cpp b/interface/src/GLCanvas.cpp index 513dcfe40c..9f1bf303fa 100644 --- a/interface/src/GLCanvas.cpp +++ b/interface/src/GLCanvas.cpp @@ -1,9 +1,12 @@ // // GLCanvas.cpp -// hifi +// interface/src // // Created by Stephen Birarda on 8/14/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "Application.h" diff --git a/interface/src/GLCanvas.h b/interface/src/GLCanvas.h index f7f7fb7c20..73b70de19e 100644 --- a/interface/src/GLCanvas.h +++ b/interface/src/GLCanvas.h @@ -1,13 +1,16 @@ // // GLCanvas.h -// hifi +// interface/src // // Created by Stephen Birarda on 8/14/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__GLCanvas__ -#define __hifi__GLCanvas__ +#ifndef hifi_GLCanvas_h +#define hifi_GLCanvas_h #include #include @@ -49,4 +52,4 @@ private slots: void throttleRender(); }; -#endif /* defined(__hifi__GLCanvas__) */ +#endif // hifi_GLCanvas_h diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 1bdbabec44..eb23d227bf 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -1,9 +1,12 @@ // // Menu.cpp -// hifi +// interface/src // // Created by Stephen Birarda on 8/12/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include @@ -29,7 +32,6 @@ #include #include #include -#include #include "Application.h" #include "Menu.h" @@ -37,7 +39,7 @@ #include "Util.h" #include "ui/InfoView.h" #include "ui/MetavoxelEditor.h" -#include "ui/ModelBrowser.h" +#include "ui/ModelsBrowser.h" Menu* Menu::_instance = NULL; @@ -84,10 +86,11 @@ Menu::Menu() : _lastAvatarDetailDrop(usecTimestampNow()), _fpsAverage(FIVE_SECONDS_OF_FRAMES), _fastFPSAverage(ONE_SECOND_OF_FRAMES), - _loginAction(NULL) + _loginAction(NULL), + _preferencesDialog(NULL) { Application *appInstance = Application::getInstance(); - + QMenu* fileMenu = addMenu("File"); #ifdef Q_OS_MAC @@ -100,23 +103,24 @@ Menu::Menu() : #endif AccountManager& accountManager = AccountManager::getInstance(); - + _loginAction = addActionToQMenuAndActionHash(fileMenu, MenuOption::Logout); - + // call our toggle login function now so the menu option is setup properly toggleLoginMenuItem(); - + // connect to the appropriate slots of the AccountManager so that we can change the Login/Logout menu item connect(&accountManager, &AccountManager::accessTokenChanged, this, &Menu::toggleLoginMenuItem); connect(&accountManager, &AccountManager::logoutComplete, this, &Menu::toggleLoginMenuItem); addDisabledActionAndSeparator(fileMenu, "Scripts"); addActionToQMenuAndActionHash(fileMenu, MenuOption::LoadScript, Qt::CTRL | Qt::Key_O, appInstance, SLOT(loadDialog())); - addActionToQMenuAndActionHash(fileMenu, MenuOption::LoadScriptURL, + addActionToQMenuAndActionHash(fileMenu, MenuOption::LoadScriptURL, Qt::CTRL | Qt::SHIFT | Qt::Key_O, appInstance, SLOT(loadScriptURLDialog())); addActionToQMenuAndActionHash(fileMenu, MenuOption::StopAllScripts, 0, appInstance, SLOT(stopAllScripts())); addActionToQMenuAndActionHash(fileMenu, MenuOption::ReloadAllScripts, 0, appInstance, SLOT(reloadAllScripts())); - _activeScriptsMenu = fileMenu->addMenu("Running Scripts"); + addActionToQMenuAndActionHash(fileMenu, MenuOption::RunningScripts, Qt::CTRL | Qt::Key_J, + appInstance, SLOT(toggleRunningScriptsWidget())); addDisabledActionAndSeparator(fileMenu, "Go"); addActionToQMenuAndActionHash(fileMenu, @@ -148,7 +152,6 @@ Menu::Menu() : addDisabledActionAndSeparator(fileMenu, "Upload Avatar Model"); addActionToQMenuAndActionHash(fileMenu, MenuOption::UploadHead, 0, Application::getInstance(), SLOT(uploadHead())); addActionToQMenuAndActionHash(fileMenu, MenuOption::UploadSkeleton, 0, Application::getInstance(), SLOT(uploadSkeleton())); - addDisabledActionAndSeparator(fileMenu, "Settings"); addActionToQMenuAndActionHash(fileMenu, MenuOption::SettingsImport, 0, this, SLOT(importSettings())); addActionToQMenuAndActionHash(fileMenu, MenuOption::SettingsExport, 0, this, SLOT(exportSettings())); @@ -162,6 +165,15 @@ Menu::Menu() : QMenu* editMenu = addMenu("Edit"); + + QUndoStack* undoStack = Application::getInstance()->getUndoStack(); + QAction* undoAction = undoStack->createUndoAction(editMenu); + undoAction->setShortcut(Qt::CTRL | Qt::Key_Z); + addActionToQMenuAndActionHash(editMenu, undoAction); + + QAction* redoAction = undoStack->createRedoAction(editMenu); + redoAction->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_Z); + addActionToQMenuAndActionHash(editMenu, redoAction); addActionToQMenuAndActionHash(editMenu, MenuOption::Preferences, @@ -173,26 +185,25 @@ Menu::Menu() : addDisabledActionAndSeparator(editMenu, "Physics"); addCheckableActionToQMenuAndActionHash(editMenu, MenuOption::Gravity, Qt::SHIFT | Qt::Key_G, false); - - + + addAvatarCollisionSubMenu(editMenu); QMenu* toolsMenu = addMenu("Tools"); addActionToQMenuAndActionHash(toolsMenu, MenuOption::MetavoxelEditor, 0, this, SLOT(showMetavoxelEditor())); +#ifdef HAVE_QXMPP _chatAction = addActionToQMenuAndActionHash(toolsMenu, MenuOption::Chat, - Qt::Key_Return, + 0, this, SLOT(showChat())); -#ifdef HAVE_QXMPP + const QXmppClient& xmppClient = XmppClient::getInstance().getXMPPClient(); toggleChat(); connect(&xmppClient, SIGNAL(connected()), this, SLOT(toggleChat())); connect(&xmppClient, SIGNAL(disconnected()), this, SLOT(toggleChat())); -#else - _chatAction->setEnabled(false); #endif QMenu* viewMenu = addMenu("View"); @@ -208,7 +219,7 @@ Menu::Menu() : addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::Mirror, Qt::SHIFT | Qt::Key_H, true); addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::FullscreenMirror, Qt::Key_H, false, appInstance, SLOT(cameraMenuChanged())); - + addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::Enable3DTVMode, 0, false, appInstance, @@ -242,7 +253,6 @@ Menu::Menu() : addDisabledActionAndSeparator(viewMenu, "Stats"); addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::Stats, Qt::Key_Slash); addActionToQMenuAndActionHash(viewMenu, MenuOption::Log, Qt::CTRL | Qt::Key_L, appInstance, SLOT(toggleLogDialog())); - addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::Oscilloscope, 0, false); addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::Bandwidth, 0, true); addActionToQMenuAndActionHash(viewMenu, MenuOption::BandwidthDetails, 0, this, SLOT(bandwidthDetails())); addActionToQMenuAndActionHash(viewMenu, MenuOption::OctreeStats, 0, this, SLOT(octreeStatsDetails())); @@ -283,8 +293,9 @@ Menu::Menu() : QMenu* avatarOptionsMenu = developerMenu->addMenu("Avatar Options"); addCheckableActionToQMenuAndActionHash(avatarOptionsMenu, MenuOption::Avatars, 0, true); - addCheckableActionToQMenuAndActionHash(avatarOptionsMenu, MenuOption::RenderSkeletonCollisionProxies); - addCheckableActionToQMenuAndActionHash(avatarOptionsMenu, MenuOption::RenderHeadCollisionProxies); + addCheckableActionToQMenuAndActionHash(avatarOptionsMenu, MenuOption::RenderSkeletonCollisionShapes); + addCheckableActionToQMenuAndActionHash(avatarOptionsMenu, MenuOption::RenderHeadCollisionShapes); + addCheckableActionToQMenuAndActionHash(avatarOptionsMenu, MenuOption::RenderBoundingCollisionShapes); addCheckableActionToQMenuAndActionHash(avatarOptionsMenu, MenuOption::LookAtVectors, 0, false); addCheckableActionToQMenuAndActionHash(avatarOptionsMenu, @@ -293,6 +304,11 @@ Menu::Menu() : true, appInstance->getFaceshift(), SLOT(setTCPEnabled(bool))); +#ifdef HAVE_FACEPLUS + addCheckableActionToQMenuAndActionHash(avatarOptionsMenu, MenuOption::Faceplus, 0, true, + appInstance->getFaceplus(), SLOT(updateEnabled())); +#endif + #ifdef HAVE_VISAGE addCheckableActionToQMenuAndActionHash(avatarOptionsMenu, MenuOption::Visage, 0, true, appInstance->getVisage(), SLOT(updateEnabled())); @@ -334,16 +350,16 @@ Menu::Menu() : addCheckableActionToQMenuAndActionHash(renderDebugMenu, MenuOption::PipelineWarnings); addCheckableActionToQMenuAndActionHash(renderDebugMenu, MenuOption::SuppressShortTimings); - addCheckableActionToQMenuAndActionHash(renderDebugMenu, - MenuOption::CullSharedFaces, - Qt::CTRL | Qt::SHIFT | Qt::Key_C, + addCheckableActionToQMenuAndActionHash(renderDebugMenu, + MenuOption::CullSharedFaces, + Qt::CTRL | Qt::SHIFT | Qt::Key_C, false, appInstance->getVoxels(), SLOT(cullSharedFaces())); - addCheckableActionToQMenuAndActionHash(renderDebugMenu, - MenuOption::ShowCulledSharedFaces, - Qt::CTRL | Qt::SHIFT | Qt::Key_X, + addCheckableActionToQMenuAndActionHash(renderDebugMenu, + MenuOption::ShowCulledSharedFaces, + Qt::CTRL | Qt::SHIFT | Qt::Key_X, false, appInstance->getVoxels(), SLOT(showCulledSharedFaces())); @@ -400,14 +416,13 @@ Menu::Menu() : Qt::CTRL | Qt::SHIFT | Qt::Key_F, false); - addActionToQMenuAndActionHash(developerMenu, MenuOption::PasteToVoxel, Qt::CTRL | Qt::SHIFT | Qt::Key_V, this, SLOT(pasteToVoxel())); connect(appInstance->getAudio(), SIGNAL(muteToggled()), this, SLOT(audioMuteToggled())); - + #ifndef Q_OS_MAC QMenu* helpMenu = addMenu("Help"); QAction* helpAction = helpMenu->addAction(MenuOption::AboutApp); @@ -611,7 +626,7 @@ void Menu::addDisabledActionAndSeparator(QMenu* destinationMenu, const QString& QAction* separatorText = new QAction(actionName,destinationMenu); separatorText->setEnabled(false); destinationMenu->insertAction(actionBefore, separatorText); - + } else { destinationMenu->addSeparator(); (destinationMenu->addAction(actionName))->setEnabled(false); @@ -655,6 +670,41 @@ QAction* Menu::addActionToQMenuAndActionHash(QMenu* destinationMenu, return action; } +QAction* Menu::addActionToQMenuAndActionHash(QMenu* destinationMenu, + QAction* action, + const QString& actionName, + const QKeySequence& shortcut, + QAction::MenuRole role, + int menuItemLocation) { + QAction* actionBefore = NULL; + + if (menuItemLocation >= 0 && destinationMenu->actions().size() > menuItemLocation) { + actionBefore = destinationMenu->actions()[menuItemLocation]; + } + + if (!actionName.isEmpty()) { + action->setText(actionName); + } + + if (shortcut != 0) { + action->setShortcut(shortcut); + } + + if (role != QAction::NoRole) { + action->setMenuRole(role); + } + + if (!actionBefore) { + destinationMenu->addAction(action); + } else { + destinationMenu->insertAction(actionBefore, action); + } + + _actionHash.insert(action->text(), action); + + return action; +} + QAction* Menu::addCheckableActionToQMenuAndActionHash(QMenu* destinationMenu, const QString& actionName, const QKeySequence& shortcut, @@ -663,10 +713,11 @@ QAction* Menu::addCheckableActionToQMenuAndActionHash(QMenu* destinationMenu, const char* member, int menuItemLocation) { - QAction* action = addActionToQMenuAndActionHash(destinationMenu, actionName, shortcut, receiver, member, + QAction* action = addActionToQMenuAndActionHash(destinationMenu, actionName, shortcut, receiver, member, QAction::NoRole, menuItemLocation); action->setCheckable(true); action->setChecked(checked); + connect(action, SIGNAL(changed()), Application::getInstance(), SLOT(bumpSettings())); return action; } @@ -691,7 +742,12 @@ bool Menu::isOptionChecked(const QString& menuOption) { } void Menu::triggerOption(const QString& menuOption) { - _actionHash.value(menuOption)->trigger(); + QAction* action = _actionHash.value(menuOption); + if (action) { + action->trigger(); + } else { + qDebug() << "NULL Action for menuOption '" << menuOption << "'"; + } } QAction* Menu::getActionForOption(const QString& menuOption) { @@ -717,197 +773,53 @@ const float DIALOG_RATIO_OF_WINDOW = 0.30f; void Menu::loginForCurrentDomain() { QDialog loginDialog(Application::getInstance()->getWindow()); loginDialog.setWindowTitle("Login"); - + QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom); loginDialog.setLayout(layout); loginDialog.setWindowFlags(Qt::Sheet); - + QFormLayout* form = new QFormLayout(); layout->addLayout(form, 1); - + QLineEdit* loginLineEdit = new QLineEdit(); loginLineEdit->setMinimumWidth(QLINE_MINIMUM_WIDTH); form->addRow("Login:", loginLineEdit); - + QLineEdit* passwordLineEdit = new QLineEdit(); passwordLineEdit->setMinimumWidth(QLINE_MINIMUM_WIDTH); passwordLineEdit->setEchoMode(QLineEdit::Password); form->addRow("Password:", passwordLineEdit); - + QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); loginDialog.connect(buttons, SIGNAL(accepted()), SLOT(accept())); loginDialog.connect(buttons, SIGNAL(rejected()), SLOT(reject())); layout->addWidget(buttons); - + int dialogReturn = loginDialog.exec(); - + if (dialogReturn == QDialog::Accepted && !loginLineEdit->text().isEmpty() && !passwordLineEdit->text().isEmpty()) { // attempt to get an access token given this username and password AccountManager::getInstance().requestAccessToken(loginLineEdit->text(), passwordLineEdit->text()); } - + sendFakeEnterEvent(); } void Menu::editPreferences() { - Application* applicationInstance = Application::getInstance(); - ModelBrowser headBrowser(Head); - ModelBrowser skeletonBrowser(Skeleton); - - const QString BROWSE_BUTTON_TEXT = "Browse"; - - QDialog dialog(applicationInstance->getWindow()); - dialog.setWindowTitle("Interface Preferences"); - - QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom); - dialog.setLayout(layout); - - QFormLayout* form = new QFormLayout(); - layout->addLayout(form, 1); - - - QHBoxLayout headModelLayout; - QString faceURLString = applicationInstance->getAvatar()->getHead()->getFaceModel().getURL().toString(); - QLineEdit headURLEdit(faceURLString); - QPushButton headBrowseButton(BROWSE_BUTTON_TEXT); - connect(&headBrowseButton, SIGNAL(clicked()), &headBrowser, SLOT(browse())); - connect(&headBrowser, SIGNAL(selected(QString)), &headURLEdit, SLOT(setText(QString))); - headURLEdit.setMinimumWidth(QLINE_MINIMUM_WIDTH); - headURLEdit.setPlaceholderText(DEFAULT_HEAD_MODEL_URL.toString()); - headModelLayout.addWidget(&headURLEdit); - headModelLayout.addWidget(&headBrowseButton); - form->addRow("Head URL:", &headModelLayout); - - QHBoxLayout skeletonModelLayout; - QString skeletonURLString = applicationInstance->getAvatar()->getSkeletonModel().getURL().toString(); - QLineEdit skeletonURLEdit(skeletonURLString); - QPushButton SkeletonBrowseButton(BROWSE_BUTTON_TEXT); - connect(&SkeletonBrowseButton, SIGNAL(clicked()), &skeletonBrowser, SLOT(browse())); - connect(&skeletonBrowser, SIGNAL(selected(QString)), &skeletonURLEdit, SLOT(setText(QString))); - skeletonURLEdit.setMinimumWidth(QLINE_MINIMUM_WIDTH); - skeletonURLEdit.setPlaceholderText(DEFAULT_BODY_MODEL_URL.toString()); - skeletonModelLayout.addWidget(&skeletonURLEdit); - skeletonModelLayout.addWidget(&SkeletonBrowseButton); - form->addRow("Skeleton URL:", &skeletonModelLayout); - - - QString displayNameString = applicationInstance->getAvatar()->getDisplayName(); - QLineEdit* displayNameEdit = new QLineEdit(displayNameString); - displayNameEdit->setMinimumWidth(QLINE_MINIMUM_WIDTH); - form->addRow("Display name:", displayNameEdit); - - QSlider* pupilDilation = new QSlider(Qt::Horizontal); - pupilDilation->setValue(applicationInstance->getAvatar()->getHead()->getPupilDilation() * pupilDilation->maximum()); - form->addRow("Pupil Dilation:", pupilDilation); - - QSlider* faceshiftEyeDeflection = new QSlider(Qt::Horizontal); - faceshiftEyeDeflection->setValue(_faceshiftEyeDeflection * faceshiftEyeDeflection->maximum()); - form->addRow("Faceshift Eye Deflection:", faceshiftEyeDeflection); - - QSpinBox* fieldOfView = new QSpinBox(); - fieldOfView->setMaximum(180.f); - fieldOfView->setMinimum(1.f); - fieldOfView->setValue(_fieldOfView); - form->addRow("Vertical Field of View (Degrees):", fieldOfView); - - QDoubleSpinBox* leanScale = new QDoubleSpinBox(); - leanScale->setValue(applicationInstance->getAvatar()->getLeanScale()); - form->addRow("Lean Scale:", leanScale); - - QDoubleSpinBox* avatarScale = new QDoubleSpinBox(); - avatarScale->setValue(applicationInstance->getAvatar()->getScale()); - form->addRow("Avatar Scale:", avatarScale); - - QSpinBox* audioJitterBufferSamples = new QSpinBox(); - audioJitterBufferSamples->setMaximum(10000); - audioJitterBufferSamples->setMinimum(-10000); - audioJitterBufferSamples->setValue(_audioJitterBufferSamples); - form->addRow("Audio Jitter Buffer Samples (0 for automatic):", audioJitterBufferSamples); - - QSpinBox* maxVoxels = new QSpinBox(); - const int MAX_MAX_VOXELS = 5000000; - const int MIN_MAX_VOXELS = 0; - const int STEP_MAX_VOXELS = 50000; - maxVoxels->setMaximum(MAX_MAX_VOXELS); - maxVoxels->setMinimum(MIN_MAX_VOXELS); - maxVoxels->setSingleStep(STEP_MAX_VOXELS); - maxVoxels->setValue(_maxVoxels); - form->addRow("Maximum Voxels:", maxVoxels); - - QSpinBox* maxVoxelsPPS = new QSpinBox(); - const int MAX_MAX_VOXELS_PPS = 6000; - const int MIN_MAX_VOXELS_PPS = 60; - const int STEP_MAX_VOXELS_PPS = 10; - maxVoxelsPPS->setMaximum(MAX_MAX_VOXELS_PPS); - maxVoxelsPPS->setMinimum(MIN_MAX_VOXELS_PPS); - maxVoxelsPPS->setSingleStep(STEP_MAX_VOXELS_PPS); - maxVoxelsPPS->setValue(_maxVoxelPacketsPerSecond); - form->addRow("Maximum Voxels Packets Per Second:", maxVoxelsPPS); - - QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); - dialog.connect(buttons, SIGNAL(accepted()), SLOT(accept())); - dialog.connect(buttons, SIGNAL(rejected()), SLOT(reject())); - layout->addWidget(buttons); - - int ret = dialog.exec(); - if (ret == QDialog::Accepted) { - bool shouldDispatchIdentityPacket = false; - - if (headURLEdit.text() != faceURLString && !headURLEdit.text().isEmpty()) { - // change the faceModelURL in the profile, it will also update this user's BlendFace - applicationInstance->getAvatar()->setFaceModelURL(QUrl(headURLEdit.text())); - shouldDispatchIdentityPacket = true; - } - - if (skeletonURLEdit.text() != skeletonURLString && !skeletonURLEdit.text().isEmpty()) { - // change the skeletonModelURL in the profile, it will also update this user's Body - applicationInstance->getAvatar()->setSkeletonModelURL(QUrl(skeletonURLEdit.text())); - shouldDispatchIdentityPacket = true; - } - - QString displayNameStr(displayNameEdit->text()); - - if (displayNameStr != displayNameString) { - applicationInstance->getAvatar()->setDisplayName(displayNameStr); - shouldDispatchIdentityPacket = true; - } - - if (shouldDispatchIdentityPacket) { - applicationInstance->getAvatar()->sendIdentityPacket(); - } - - applicationInstance->getAvatar()->getHead()->setPupilDilation(pupilDilation->value() / (float)pupilDilation->maximum()); - - _maxVoxels = maxVoxels->value(); - applicationInstance->getVoxels()->setMaxVoxels(_maxVoxels); - - _maxVoxelPacketsPerSecond = maxVoxelsPPS->value(); - - applicationInstance->getAvatar()->setLeanScale(leanScale->value()); - applicationInstance->getAvatar()->setClampedTargetScale(avatarScale->value()); - - _audioJitterBufferSamples = audioJitterBufferSamples->value(); - - if (_audioJitterBufferSamples != 0) { - applicationInstance->getAudio()->setJitterBufferSamples(_audioJitterBufferSamples); - } - - _fieldOfView = fieldOfView->value(); - applicationInstance->resizeGL(applicationInstance->getGLWidget()->width(), applicationInstance->getGLWidget()->height()); - - _faceshiftEyeDeflection = faceshiftEyeDeflection->value() / (float)faceshiftEyeDeflection->maximum(); + if (!_preferencesDialog) { + _preferencesDialog = new PreferencesDialog(Application::getInstance()->getWindow()); + _preferencesDialog->show(); + } else { + _preferencesDialog->close(); } - QMetaObject::invokeMethod(applicationInstance->getAudio(), "reset", Qt::QueuedConnection); - - sendFakeEnterEvent(); } void Menu::goToDomain(const QString newDomain) { if (NodeList::getInstance()->getDomainInfo().getHostname() != newDomain) { - + // send a node kill request, indicating to other clients that they should play the "disappeared" effect Application::getInstance()->getAvatar()->sendKillAvatar(); - + // give our nodeList the new domain-server hostname NodeList::getInstance()->getDomainInfo().setHostname(newDomain); } @@ -937,7 +849,7 @@ void Menu::goToDomainDialog() { // the user input a new hostname, use that newHostname = domainDialog.textValue(); } - + goToDomain(newHostname); } @@ -952,19 +864,58 @@ bool Menu::goToDestination(QString destination) { return LocationManager::getInstance().goToDestination(destination); } +void Menu::goTo(QString destination) { + LocationManager::getInstance().goTo(destination); +} + void Menu::goTo() { - + QInputDialog gotoDialog(Application::getInstance()->getWindow()); gotoDialog.setWindowTitle("Go to"); - gotoDialog.setLabelText("Destination:"); + gotoDialog.setLabelText("Destination or URL:\n @user, #place, hifi://domain/location/orientation"); QString destination = QString(); + gotoDialog.setTextValue(destination); gotoDialog.setWindowFlags(Qt::Sheet); gotoDialog.resize(gotoDialog.parentWidget()->size().width() * DIALOG_RATIO_OF_WINDOW, gotoDialog.size().height()); - + int dialogReturn = gotoDialog.exec(); if (dialogReturn == QDialog::Accepted && !gotoDialog.textValue().isEmpty()) { - goToUser(gotoDialog.textValue()); + QString desiredDestination = gotoDialog.textValue(); + + if (desiredDestination.startsWith(CUSTOM_URL_SCHEME + "//")) { + QStringList urlParts = desiredDestination.remove(0, CUSTOM_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts); + + if (urlParts.count() > 1) { + // if url has 2 or more parts, the first one is domain name + QString domain = urlParts[0]; + + // second part is either a destination coordinate or + // a place name + QString destination = urlParts[1]; + + // any third part is an avatar orientation. + QString orientation = urlParts.count() > 2 ? urlParts[2] : QString(); + + goToDomain(domain); + + // goto either @user, #place, or x-xx,y-yy,z-zz + // style co-ordinate. + goTo(destination); + + if (!orientation.isEmpty()) { + // location orientation + goToOrientation(orientation); + } + } else if (urlParts.count() == 1) { + // location coordinates or place name + QString destination = urlParts[0]; + goTo(destination); + } + + } else { + goToUser(gotoDialog.textValue()); + } } sendFakeEnterEvent(); } @@ -1000,7 +951,6 @@ void Menu::goToLocation() { QString currentLocation = QString("%1, %2, %3").arg(QString::number(avatarPos.x), QString::number(avatarPos.y), QString::number(avatarPos.z)); - QInputDialog coordinateDialog(Application::getInstance()->getWindow()); coordinateDialog.setWindowTitle("Go to Location"); coordinateDialog.setLabelText("Coordinate as x,y,z:"); @@ -1110,7 +1060,7 @@ void Menu::toggleLoginMenuItem() { AccountManager& accountManager = AccountManager::getInstance(); disconnect(_loginAction, 0, 0, 0); - + if (accountManager.isLoggedIn()) { // change the menu item to logout _loginAction->setText("Logout " + accountManager.getUsername()); @@ -1118,7 +1068,7 @@ void Menu::toggleLoginMenuItem() { } else { // change the menu item to login _loginAction->setText("Login"); - + connect(_loginAction, &QAction::triggered, this, &Menu::loginForCurrentDomain); } } @@ -1142,14 +1092,9 @@ void Menu::showMetavoxelEditor() { } void Menu::showChat() { - if (!_chatAction->isEnabled()) { - // Don't do anything if chat is disabled (No - // QXMPP library or xmpp is disconnected). - return; - } QMainWindow* mainWindow = Application::getInstance()->getWindow(); if (!_chatWindow) { - mainWindow->addDockWidget(Qt::NoDockWidgetArea, _chatWindow = new ChatWindow()); + mainWindow->addDockWidget(Qt::RightDockWidgetArea, _chatWindow = new ChatWindow()); } if (!_chatWindow->toggleViewAction()->isChecked()) { int width = _chatWindow->width(); @@ -1225,7 +1170,7 @@ QString Menu::getLODFeedbackText() { } break; } - // distance feedback + // distance feedback float voxelSizeScale = getVoxelSizeScale(); float relativeToDefault = voxelSizeScale / DEFAULT_OCTREE_SIZE_SCALE; QString result; @@ -1240,7 +1185,7 @@ QString Menu::getLODFeedbackText() { } void Menu::autoAdjustLOD(float currentFPS) { - // NOTE: our first ~100 samples at app startup are completely all over the place, and we don't + // NOTE: our first ~100 samples at app startup are completely all over the place, and we don't // really want to count them in our average, so we will ignore the real frame rates and stuff // our moving average with simulated good data const int IGNORE_THESE_SAMPLES = 100; @@ -1252,30 +1197,32 @@ void Menu::autoAdjustLOD(float currentFPS) { _fastFPSAverage.updateAverage(currentFPS); quint64 now = usecTimestampNow(); - + + const float ADJUST_AVATAR_LOD_DOWN_FPS = 30.0f; const quint64 ADJUST_AVATAR_LOD_DOWN_DELAY = 1000 * 1000; - if (_fastFPSAverage.getAverage() < ADJUST_LOD_DOWN_FPS) { + if (_fastFPSAverage.getAverage() < ADJUST_AVATAR_LOD_DOWN_FPS) { if (now - _lastAvatarDetailDrop > ADJUST_AVATAR_LOD_DOWN_DELAY) { // attempt to lower the detail in proportion to the fps difference - float targetFps = (ADJUST_LOD_DOWN_FPS + ADJUST_LOD_UP_FPS) * 0.5f; + float targetFps = (ADJUST_AVATAR_LOD_DOWN_FPS + ADJUST_LOD_UP_FPS) * 0.5f; float averageFps = _fastFPSAverage.getAverage(); const float MAXIMUM_MULTIPLIER_SCALE = 2.0f; - _avatarLODDistanceMultiplier *= (averageFps < EPSILON) ? MAXIMUM_MULTIPLIER_SCALE : - qMin(MAXIMUM_MULTIPLIER_SCALE, targetFps / averageFps); + const float MAXIMUM_DISTANCE_MULTIPLIER = 15.0f; + _avatarLODDistanceMultiplier = qMin(MAXIMUM_DISTANCE_MULTIPLIER, _avatarLODDistanceMultiplier * + (averageFps < EPSILON ? MAXIMUM_MULTIPLIER_SCALE : qMin(MAXIMUM_MULTIPLIER_SCALE, targetFps / averageFps))); _lastAvatarDetailDrop = now; } } else if (_fastFPSAverage.getAverage() > ADJUST_LOD_UP_FPS) { // let the detail level creep slowly upwards - const float DISTANCE_DECREASE_RATE = 0.02f; + const float DISTANCE_DECREASE_RATE = 0.05f; const float MINIMUM_DISTANCE_MULTIPLIER = 0.1f; _avatarLODDistanceMultiplier = qMax(MINIMUM_DISTANCE_MULTIPLIER, _avatarLODDistanceMultiplier - DISTANCE_DECREASE_RATE); } - + bool changed = false; quint64 elapsed = now - _lastAdjust; - if (elapsed > ADJUST_LOD_DOWN_DELAY && _fpsAverage.getAverage() < ADJUST_LOD_DOWN_FPS + if (elapsed > ADJUST_LOD_DOWN_DELAY && _fpsAverage.getAverage() < ADJUST_LOD_DOWN_FPS && _voxelSizeScale > ADJUST_LOD_MIN_SIZE_SCALE) { _voxelSizeScale *= ADJUST_LOD_DOWN_BY; @@ -1288,7 +1235,7 @@ void Menu::autoAdjustLOD(float currentFPS) { << "_voxelSizeScale=" << _voxelSizeScale; } - if (elapsed > ADJUST_LOD_UP_DELAY && _fpsAverage.getAverage() > ADJUST_LOD_UP_FPS + if (elapsed > ADJUST_LOD_UP_DELAY && _fpsAverage.getAverage() > ADJUST_LOD_UP_FPS && _voxelSizeScale < ADJUST_LOD_MAX_SIZE_SCALE) { _voxelSizeScale *= ADJUST_LOD_UP_BY; if (_voxelSizeScale > ADJUST_LOD_MAX_SIZE_SCALE) { @@ -1299,7 +1246,7 @@ void Menu::autoAdjustLOD(float currentFPS) { qDebug() << "adjusting LOD up... average fps for last approximately 5 seconds=" << _fpsAverage.getAverage() << "_voxelSizeScale=" << _voxelSizeScale; } - + if (changed) { if (_lodToolsDialog) { _lodToolsDialog->reloadSliders(); @@ -1377,13 +1324,13 @@ void Menu::addAvatarCollisionSubMenu(QMenu* overMenu) { Application* appInstance = Application::getInstance(); QObject* avatar = appInstance->getAvatar(); - addCheckableActionToQMenuAndActionHash(subMenu, MenuOption::CollideWithEnvironment, + addCheckableActionToQMenuAndActionHash(subMenu, MenuOption::CollideWithEnvironment, 0, false, avatar, SLOT(updateCollisionFlags())); - addCheckableActionToQMenuAndActionHash(subMenu, MenuOption::CollideWithAvatars, + addCheckableActionToQMenuAndActionHash(subMenu, MenuOption::CollideWithAvatars, 0, true, avatar, SLOT(updateCollisionFlags())); - addCheckableActionToQMenuAndActionHash(subMenu, MenuOption::CollideWithVoxels, + addCheckableActionToQMenuAndActionHash(subMenu, MenuOption::CollideWithVoxels, 0, false, avatar, SLOT(updateCollisionFlags())); - addCheckableActionToQMenuAndActionHash(subMenu, MenuOption::CollideWithParticles, + addCheckableActionToQMenuAndActionHash(subMenu, MenuOption::CollideWithParticles, 0, true, avatar, SLOT(updateCollisionFlags())); } @@ -1392,9 +1339,9 @@ QAction* Menu::getActionFromName(const QString& menuName, QMenu* menu) { if (menu) { menuActions = menu->actions(); } else { - menuActions = actions(); + menuActions = actions(); } - + foreach (QAction* menuAction, menuActions) { if (menuName == menuAction->text()) { return menuAction; @@ -1501,7 +1448,7 @@ QMenu* Menu::addMenu(const QString& menuName) { void Menu::removeMenu(const QString& menuName) { QAction* action = getMenuAction(menuName); - + // only proceed if the menu actually exists if (action) { QString finalMenuPart; @@ -1553,7 +1500,7 @@ void Menu::addMenuItem(const MenuItemProperties& properties) { if (!properties.shortcutKeySequence.isEmpty()) { shortcut = new QShortcut(properties.shortcutKeySequence, this); } - + // check for positioning requests int requestedPosition = properties.position; if (requestedPosition == UNSPECIFIED_POSITION && !properties.beforeItem.isEmpty()) { @@ -1567,13 +1514,13 @@ void Menu::addMenuItem(const MenuItemProperties& properties) { requestedPosition = afterPosition + 1; } } - + QAction* menuItemAction = NULL; if (properties.isSeparator) { addDisabledActionAndSeparator(menuObj, properties.menuItemName, requestedPosition); } else if (properties.isCheckable) { menuItemAction = addCheckableActionToQMenuAndActionHash(menuObj, properties.menuItemName, - properties.shortcutKeySequence, properties.isChecked, + properties.shortcutKeySequence, properties.isChecked, MenuScriptingInterface::getInstance(), SLOT(menuItemTriggered()), requestedPosition); } else { menuItemAction = addActionToQMenuAndActionHash(menuObj, properties.menuItemName, properties.shortcutKeySequence, diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 6e42e21b06..9a659e894d 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -1,13 +1,16 @@ // // Menu.h -// hifi +// interface/src // // Created by Stephen Birarda on 8/12/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__Menu__ -#define __hifi__Menu__ +#ifndef hifi_Menu_h +#define hifi_Menu_h #include #include @@ -19,6 +22,7 @@ #include #include "location/LocationManager.h" +#include "ui/PreferencesDialog.h" #include "ui/ChatWindow.h" const float ADJUST_LOD_DOWN_FPS = 40.0; @@ -68,10 +72,13 @@ public: void triggerOption(const QString& menuOption); QAction* getActionForOption(const QString& menuOption); - + float getAudioJitterBufferSamples() const { return _audioJitterBufferSamples; } + void setAudioJitterBufferSamples(float audioJitterBufferSamples) { _audioJitterBufferSamples = audioJitterBufferSamples; } float getFieldOfView() const { return _fieldOfView; } + void setFieldOfView(float fieldOfView) { _fieldOfView = fieldOfView; } float getFaceshiftEyeDeflection() const { return _faceshiftEyeDeflection; } + void setFaceshiftEyeDeflection(float faceshiftEyeDeflection) { _faceshiftEyeDeflection = faceshiftEyeDeflection; } BandwidthDialog* getBandwidthDialog() const { return _bandwidthDialog; } FrustumDrawMode getFrustumDrawMode() const { return _frustumDrawMode; } ViewFrustumOffset getViewFrustumOffset() const { return _viewFrustumOffset; } @@ -94,8 +101,7 @@ public: // User Tweakable PPS from Voxel Server int getMaxVoxelPacketsPerSecond() const { return _maxVoxelPacketsPerSecond; } - - QMenu* getActiveScriptsMenu() { return _activeScriptsMenu;} + void setMaxVoxelPacketsPerSecond(int maxVoxelPacketsPerSecond) { _maxVoxelPacketsPerSecond = maxVoxelPacketsPerSecond; } QAction* addActionToQMenuAndActionHash(QMenu* destinationMenu, const QString& actionName, @@ -104,12 +110,19 @@ public: const char* member = NULL, QAction::MenuRole role = QAction::NoRole, int menuItemLocation = UNSPECIFIED_POSITION); - + QAction* addActionToQMenuAndActionHash(QMenu* destinationMenu, + QAction* action, + const QString& actionName = QString(), + const QKeySequence& shortcut = 0, + QAction::MenuRole role = QAction::NoRole, + int menuItemLocation = UNSPECIFIED_POSITION); + void removeAction(QMenu* menu, const QString& actionName); bool goToDestination(QString destination); void goToOrientation(QString orientation); void goToDomain(const QString newDomain); + void goTo(QString destination); public slots: @@ -124,7 +137,7 @@ public slots: void goTo(); void goToUser(const QString& user); void pasteToVoxel(); - + void toggleLoginMenuItem(); QMenu* addMenu(const QString& menuName); @@ -166,7 +179,7 @@ private: void scanMenu(QMenu* menu, settingsAction modifySetting, QSettings* set); /// helper method to have separators with labels that are also compatible with OS X - void addDisabledActionAndSeparator(QMenu* destinationMenu, const QString& actionName, + void addDisabledActionAndSeparator(QMenu* destinationMenu, const QString& actionName, int menuItemLocation = UNSPECIFIED_POSITION); QAction* addCheckableActionToQMenuAndActionHash(QMenu* destinationMenu, @@ -189,7 +202,7 @@ private: int findPositionOfMenuItem(QMenu* menu, const QString& searchMenuItem); int positionBeforeSeparatorIfNeeded(QMenu* menu, int requestedPosition); QMenu* getMenu(const QString& menuName); - + QHash _actionHash; int _audioJitterBufferSamples; /// number of extra samples to wait before starting audio playback @@ -208,39 +221,20 @@ private: int _boundaryLevelAdjust; QAction* _useVoxelShader; int _maxVoxelPacketsPerSecond; - QMenu* _activeScriptsMenu; QString replaceLastOccurrence(QChar search, QChar replace, QString string); quint64 _lastAdjust; quint64 _lastAvatarDetailDrop; SimpleMovingAverage _fpsAverage; SimpleMovingAverage _fastFPSAverage; QAction* _loginAction; + QPointer _preferencesDialog; QAction* _chatAction; }; namespace MenuOption { const QString AboutApp = "About Interface"; const QString AmbientOcclusion = "Ambient Occlusion"; - const QString Avatars = "Avatars"; const QString Atmosphere = "Atmosphere"; - const QString DisableAutoAdjustLOD = "Disable Automatically Adjusting LOD"; - const QString Bandwidth = "Bandwidth Display"; - const QString BandwidthDetails = "Bandwidth Details"; - const QString BuckyBalls = "Bucky Balls"; - const QString ChatCircling = "Chat Circling"; - const QString Collisions = "Collisions"; - const QString CollideWithAvatars = "Collide With Avatars"; - const QString CollideWithParticles = "Collide With Particles"; - const QString CollideWithVoxels = "Collide With Voxels"; - const QString CollideWithEnvironment = "Collide With World Boundaries"; - const QString CullSharedFaces = "Cull Shared Voxel Faces"; - const QString DecreaseAvatarSize = "Decrease Avatar Size"; - const QString DecreaseVoxelSize = "Decrease Voxel Size"; - const QString DisplayFrustum = "Display Frustum"; - const QString DisplayHands = "Display Hands"; - const QString DisplayHandTargets = "Display Hand Targets"; - const QString FilterSixense = "Smooth Sixense Movement"; - const QString Enable3DTVMode = "Enable 3DTV Mode"; const QString AudioNoiseReduction = "Audio Noise Reduction"; const QString AudioToneInjection = "Inject Test Tone"; const QString AudioSpatialProcessing = "Audio Spatial Processing"; @@ -250,27 +244,48 @@ namespace MenuOption { const QString AudioSpatialProcessingStereoSource = "Audio Spatial Processing Stereo Source"; const QString AudioSpatialProcessingHeadOriented = "Audio Spatial Processing Head Oriented"; const QString AudioSpatialProcessingWithDiffusions = "Audio Spatial Processing With Diffusions"; - const QString EchoServerAudio = "Echo Server Audio"; - const QString EchoLocalAudio = "Echo Local Audio"; - const QString MuteAudio = "Mute Microphone"; + const QString Avatars = "Avatars"; + const QString Bandwidth = "Bandwidth Display"; + const QString BandwidthDetails = "Bandwidth Details"; + const QString BuckyBalls = "Bucky Balls"; + const QString Chat = "Chat..."; + const QString ChatCircling = "Chat Circling"; + const QString CollideWithAvatars = "Collide With Avatars"; + const QString CollideWithEnvironment = "Collide With World Boundaries"; + const QString CollideWithParticles = "Collide With Particles"; + const QString CollideWithVoxels = "Collide With Voxels"; + const QString Collisions = "Collisions"; + const QString CullSharedFaces = "Cull Shared Voxel Faces"; + const QString DecreaseAvatarSize = "Decrease Avatar Size"; + const QString DecreaseVoxelSize = "Decrease Voxel Size"; + const QString DisableAutoAdjustLOD = "Disable Automatically Adjusting LOD"; + const QString DisplayFrustum = "Display Frustum"; + const QString DisplayHands = "Display Hands"; + const QString DisplayHandTargets = "Display Hand Targets"; const QString DontFadeOnVoxelServerChanges = "Don't Fade In/Out on Voxel Server Changes"; - const QString HeadMouse = "Head Mouse"; - const QString HandsCollideWithSelf = "Collide With Self"; + const QString EchoLocalAudio = "Echo Local Audio"; + const QString EchoServerAudio = "Echo Server Audio"; + const QString Enable3DTVMode = "Enable 3DTV Mode"; + const QString Faceplus = "Faceplus"; const QString Faceshift = "Faceshift"; + const QString FilterSixense = "Smooth Sixense Movement"; const QString FirstPerson = "First Person"; const QString FrameTimer = "Show Timer"; const QString FrustumRenderMode = "Render Mode"; const QString Fullscreen = "Fullscreen"; const QString FullscreenMirror = "Fullscreen Mirror"; const QString GlowMode = "Cycle Glow Mode"; + const QString GoHome = "Go Home"; + const QString GoTo = "Go To..."; const QString GoToDomain = "Go To Domain..."; const QString GoToLocation = "Go To Location..."; - const QString NameLocation = "Name this location"; - const QString GoTo = "Go To..."; + const QString Gravity = "Use Gravity"; + const QString HandsCollideWithSelf = "Collide With Self"; + const QString HeadMouse = "Head Mouse"; const QString IncreaseAvatarSize = "Increase Avatar Size"; const QString IncreaseVoxelSize = "Increase Voxel Size"; - const QString GoHome = "Go Home"; - const QString Gravity = "Use Gravity"; + const QString LoadScript = "Open and Run Script File..."; + const QString LoadScriptURL = "Open and Run Script from URL..."; const QString LodTools = "LOD Tools"; const QString Log = "Log"; const QString Login = "Login"; @@ -278,48 +293,48 @@ namespace MenuOption { const QString LookAtVectors = "Look-at Vectors"; const QString LowPassFilter = "Low Pass Filter"; const QString MetavoxelEditor = "Metavoxel Editor..."; - const QString Chat = "Chat..."; const QString Metavoxels = "Metavoxels"; const QString Mirror = "Mirror"; const QString MoveWithLean = "Move with Lean"; + const QString MuteAudio = "Mute Microphone"; + const QString NameLocation = "Name this location"; const QString NewVoxelCullingMode = "New Voxel Culling Mode"; + const QString OctreeStats = "Voxel and Particle Statistics"; const QString OffAxisProjection = "Off-Axis Projection"; const QString OldVoxelCullingMode = "Old Voxel Culling Mode"; - const QString TurnWithHead = "Turn using Head"; - const QString LoadScript = "Open and Run Script File..."; - const QString LoadScriptURL = "Open and Run Script from URL..."; - const QString Oscilloscope = "Audio Oscilloscope"; const QString Pair = "Pair"; const QString Particles = "Particles"; const QString PasteToVoxel = "Paste to Voxel..."; const QString PipelineWarnings = "Show Render Pipeline Warnings"; const QString PlaySlaps = "Play Slaps"; const QString Preferences = "Preferences..."; + const QString Quit = "Quit"; const QString ReloadAllScripts = "Reload All Scripts"; - const QString RenderSkeletonCollisionProxies = "Skeleton Collision Proxies"; - const QString RenderHeadCollisionProxies = "Head Collision Proxies"; + const QString RenderBoundingCollisionShapes = "Bounding Collision Shapes"; + const QString RenderHeadCollisionShapes = "Head Collision Shapes"; + const QString RenderSkeletonCollisionShapes = "Skeleton Collision Shapes"; const QString ResetAvatarSize = "Reset Avatar Size"; + const QString RunningScripts = "Running Scripts"; const QString RunTimingTests = "Run Timing Tests"; + const QString SettingsExport = "Export Settings"; const QString SettingsImport = "Import Settings"; const QString Shadows = "Shadows"; - const QString SettingsExport = "Export Settings"; const QString ShowCulledSharedFaces = "Show Culled Shared Voxel Faces"; - const QString SuppressShortTimings = "Suppress Timings Less than 10ms"; const QString Stars = "Stars"; const QString Stats = "Stats"; const QString StopAllScripts = "Stop All Scripts"; + const QString SuppressShortTimings = "Suppress Timings Less than 10ms"; const QString TestPing = "Test Ping"; const QString TransmitterDrive = "Transmitter Drive"; + const QString TurnWithHead = "Turn using Head"; const QString UploadHead = "Upload Head Model"; const QString UploadSkeleton = "Upload Skeleton Model"; const QString Visage = "Visage"; - const QString Quit = "Quit"; - const QString Voxels = "Voxels"; const QString VoxelMode = "Cycle Voxel Mode"; - const QString OctreeStats = "Voxel and Particle Statistics"; + const QString Voxels = "Voxels"; const QString VoxelTextures = "Voxel Textures"; } void sendFakeEnterEvent(); -#endif /* defined(__hifi__Menu__) */ +#endif // hifi_Menu_h diff --git a/interface/src/MetavoxelSystem.cpp b/interface/src/MetavoxelSystem.cpp index 042c9329f2..78c97c1703 100644 --- a/interface/src/MetavoxelSystem.cpp +++ b/interface/src/MetavoxelSystem.cpp @@ -1,9 +1,12 @@ // // MetavoxelSystem.cpp -// interface +// interface/src // // Created by Andrzej Kapolka on 12/10/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include @@ -69,13 +72,13 @@ SharedObjectPointer MetavoxelSystem::findFirstRaySpannerIntersection( return closestSpanner; } -void MetavoxelSystem::applyEdit(const MetavoxelEditMessage& edit) { +void MetavoxelSystem::applyEdit(const MetavoxelEditMessage& edit, bool reliable) { foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { if (node->getType() == NodeType::MetavoxelServer) { QMutexLocker locker(&node->getMutex()); MetavoxelClient* client = static_cast(node->getLinkedData()); if (client) { - client->applyEdit(edit); + client->applyEdit(edit, reliable); } } } @@ -228,7 +231,7 @@ MetavoxelSystem::RenderVisitor::RenderVisitor() : } bool MetavoxelSystem::RenderVisitor::visit(Spanner* spanner, const glm::vec3& clipMinimum, float clipSize) { - spanner->getRenderer()->render(1.0f, clipMinimum, clipSize); + spanner->getRenderer()->render(1.0f, SpannerRenderer::DEFAULT_MODE, clipMinimum, clipSize); return true; } @@ -267,12 +270,17 @@ void MetavoxelClient::guide(MetavoxelVisitor& visitor) { _data.guide(visitor); } -void MetavoxelClient::applyEdit(const MetavoxelEditMessage& edit) { - // apply immediately to local tree - edit.apply(_data, _sequencer.getWeakSharedObjectHash()); +void MetavoxelClient::applyEdit(const MetavoxelEditMessage& edit, bool reliable) { + if (reliable) { + _sequencer.getReliableOutputChannel()->sendMessage(QVariant::fromValue(edit)); + + } else { + // apply immediately to local tree + edit.apply(_data, _sequencer.getWeakSharedObjectHash()); - // start sending it out - _sequencer.sendHighPriorityMessage(QVariant::fromValue(edit)); + // start sending it out + _sequencer.sendHighPriorityMessage(QVariant::fromValue(edit)); + } } void MetavoxelClient::simulate(float deltaTime) { @@ -290,11 +298,13 @@ void MetavoxelClient::simulate(float deltaTime) { int MetavoxelClient::parseData(const QByteArray& packet) { // process through sequencer QMetaObject::invokeMethod(&_sequencer, "receivedDatagram", Q_ARG(const QByteArray&, packet)); + Application::getInstance()->getBandwidthMeter()->inputStream(BandwidthMeter::METAVOXELS).updateValue(packet.size()); return packet.size(); } void MetavoxelClient::sendData(const QByteArray& data) { NodeList::getInstance()->writeDatagram(data, _node); + Application::getInstance()->getBandwidthMeter()->outputStream(BandwidthMeter::METAVOXELS).updateValue(data.size()); } void MetavoxelClient::readPacket(Bitstream& in) { @@ -340,9 +350,9 @@ static void enableClipPlane(GLenum plane, float x, float y, float z, float w) { glEnable(plane); } -void ClippedRenderer::render(float alpha, const glm::vec3& clipMinimum, float clipSize) { +void ClippedRenderer::render(float alpha, Mode mode, const glm::vec3& clipMinimum, float clipSize) { if (clipSize == 0.0f) { - renderUnclipped(alpha); + renderUnclipped(alpha, mode); return; } enableClipPlane(GL_CLIP_PLANE0, -1.0f, 0.0f, 0.0f, clipMinimum.x + clipSize); @@ -352,7 +362,7 @@ void ClippedRenderer::render(float alpha, const glm::vec3& clipMinimum, float cl enableClipPlane(GL_CLIP_PLANE4, 0.0f, 0.0f, -1.0f, clipMinimum.z + clipSize); enableClipPlane(GL_CLIP_PLANE5, 0.0f, 0.0f, 1.0f, -clipMinimum.z); - renderUnclipped(alpha); + renderUnclipped(alpha, mode); glDisable(GL_CLIP_PLANE0); glDisable(GL_CLIP_PLANE1); @@ -365,9 +375,9 @@ void ClippedRenderer::render(float alpha, const glm::vec3& clipMinimum, float cl SphereRenderer::SphereRenderer() { } -void SphereRenderer::render(float alpha, const glm::vec3& clipMinimum, float clipSize) { +void SphereRenderer::render(float alpha, Mode mode, const glm::vec3& clipMinimum, float clipSize) { if (clipSize == 0.0f) { - renderUnclipped(alpha); + renderUnclipped(alpha, mode); return; } // slight performance optimization: don't render if clip bounds are entirely within sphere @@ -376,13 +386,13 @@ void SphereRenderer::render(float alpha, const glm::vec3& clipMinimum, float cli for (int i = 0; i < Box::VERTEX_COUNT; i++) { const float CLIP_PROPORTION = 0.95f; if (glm::distance(sphere->getTranslation(), clipBox.getVertex(i)) >= sphere->getScale() * CLIP_PROPORTION) { - ClippedRenderer::render(alpha, clipMinimum, clipSize); + ClippedRenderer::render(alpha, mode, clipMinimum, clipSize); return; } } } -void SphereRenderer::renderUnclipped(float alpha) { +void SphereRenderer::renderUnclipped(float alpha, Mode mode) { Sphere* sphere = static_cast(parent()); const QColor& color = sphere->getColor(); glColor4f(color.redF(), color.greenF(), color.blueF(), color.alphaF() * alpha); @@ -390,7 +400,7 @@ void SphereRenderer::renderUnclipped(float alpha) { glPushMatrix(); const glm::vec3& translation = sphere->getTranslation(); glTranslatef(translation.x, translation.y, translation.z); - glm::quat rotation = glm::quat(glm::radians(sphere->getRotation())); + glm::quat rotation = sphere->getRotation(); glm::vec3 axis = glm::axis(rotation); glRotatef(glm::angle(rotation), axis.x, axis.y, axis.z); @@ -413,7 +423,7 @@ void StaticModelRenderer::init(Spanner* spanner) { applyURL(staticModel->getURL()); connect(spanner, SIGNAL(translationChanged(const glm::vec3&)), SLOT(applyTranslation(const glm::vec3&))); - connect(spanner, SIGNAL(rotationChanged(const glm::vec3&)), SLOT(applyRotation(const glm::vec3&))); + connect(spanner, SIGNAL(rotationChanged(const glm::quat&)), SLOT(applyRotation(const glm::quat&))); connect(spanner, SIGNAL(scaleChanged(float)), SLOT(applyScale(float))); connect(spanner, SIGNAL(urlChanged(const QUrl&)), SLOT(applyURL(const QUrl&))); } @@ -430,7 +440,20 @@ void StaticModelRenderer::simulate(float deltaTime) { _model->simulate(deltaTime); } -void StaticModelRenderer::renderUnclipped(float alpha) { +void StaticModelRenderer::renderUnclipped(float alpha, Mode mode) { + switch (mode) { + case DIFFUSE_MODE: + _model->render(alpha, Model::DIFFUSE_RENDER_MODE); + break; + + case NORMAL_MODE: + _model->render(alpha, Model::NORMAL_RENDER_MODE); + break; + + default: + _model->render(alpha); + break; + } _model->render(alpha); } @@ -443,8 +466,8 @@ void StaticModelRenderer::applyTranslation(const glm::vec3& translation) { _model->setTranslation(translation); } -void StaticModelRenderer::applyRotation(const glm::vec3& rotation) { - _model->setRotation(glm::quat(glm::radians(rotation))); +void StaticModelRenderer::applyRotation(const glm::quat& rotation) { + _model->setRotation(rotation); } void StaticModelRenderer::applyScale(float scale) { diff --git a/interface/src/MetavoxelSystem.h b/interface/src/MetavoxelSystem.h index 58f40dad37..f98a260ab1 100644 --- a/interface/src/MetavoxelSystem.h +++ b/interface/src/MetavoxelSystem.h @@ -1,13 +1,16 @@ // // MetavoxelSystem.h -// interface +// interface/src // // Created by Andrzej Kapolka on 12/10/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__MetavoxelSystem__ -#define __interface__MetavoxelSystem__ +#ifndef hifi_MetavoxelSystem_h +#define hifi_MetavoxelSystem_h #include #include @@ -38,7 +41,7 @@ public: SharedObjectPointer findFirstRaySpannerIntersection(const glm::vec3& origin, const glm::vec3& direction, const AttributePointer& attribute, float& distance); - void applyEdit(const MetavoxelEditMessage& edit); + Q_INVOKABLE void applyEdit(const MetavoxelEditMessage& edit, bool reliable = false); void simulate(float deltaTime); void render(); @@ -98,7 +101,7 @@ public: void guide(MetavoxelVisitor& visitor); - void applyEdit(const MetavoxelEditMessage& edit); + void applyEdit(const MetavoxelEditMessage& edit, bool reliable = false); void simulate(float deltaTime); @@ -147,11 +150,11 @@ class ClippedRenderer : public SpannerRenderer { public: - virtual void render(float alpha, const glm::vec3& clipMinimum, float clipSize); + virtual void render(float alpha, Mode mode, const glm::vec3& clipMinimum, float clipSize); protected: - virtual void renderUnclipped(float alpha) = 0; + virtual void renderUnclipped(float alpha, Mode mode) = 0; }; /// Renders spheres. @@ -162,11 +165,11 @@ public: Q_INVOKABLE SphereRenderer(); - virtual void render(float alpha, const glm::vec3& clipMinimum, float clipSize); + virtual void render(float alpha, Mode mode, const glm::vec3& clipMinimum, float clipSize); protected: - virtual void renderUnclipped(float alpha); + virtual void renderUnclipped(float alpha, Mode mode); }; /// Renders static models. @@ -184,12 +187,12 @@ public: protected: - virtual void renderUnclipped(float alpha); + virtual void renderUnclipped(float alpha, Mode mode); private slots: void applyTranslation(const glm::vec3& translation); - void applyRotation(const glm::vec3& eulerAngles); // eulerAngles are in degrees + void applyRotation(const glm::quat& rotation); void applyScale(float scale); void applyURL(const QUrl& url); @@ -198,4 +201,4 @@ private: Model* _model; }; -#endif /* defined(__interface__MetavoxelSystem__) */ +#endif // hifi_MetavoxelSystem_h diff --git a/interface/src/ModelUploader.cpp b/interface/src/ModelUploader.cpp new file mode 100644 index 0000000000..edbc6c0ad9 --- /dev/null +++ b/interface/src/ModelUploader.cpp @@ -0,0 +1,371 @@ +// +// ModelUploader.cpp +// interface/src +// +// Created by Clément Brisset on 3/4/14. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "Application.h" +#include "renderer/FBXReader.h" + +#include "ModelUploader.h" + + +static const QString NAME_FIELD = "name"; +static const QString FILENAME_FIELD = "filename"; +static const QString TEXDIR_FIELD = "texdir"; +static const QString LOD_FIELD = "lod"; + +static const QString S3_URL = "http://highfidelity-public.s3-us-west-1.amazonaws.com"; +static const QString MODEL_URL = "/api/v1/models"; + +static const QString SETTING_NAME = "LastModelUploadLocation"; + +static const int MAX_SIZE = 10 * 1024 * 1024; // 10 MB +static const int TIMEOUT = 1000; +static const int MAX_CHECK = 30; + +static const int QCOMPRESS_HEADER_POSITION = 0; +static const int QCOMPRESS_HEADER_SIZE = 4; + +ModelUploader::ModelUploader(bool isHead) : + _lodCount(-1), + _texturesCount(-1), + _totalSize(0), + _isHead(isHead), + _readyToSend(false), + _dataMultiPart(new QHttpMultiPart(QHttpMultiPart::FormDataType)), + _numberOfChecks(MAX_CHECK) +{ + connect(&_timer, SIGNAL(timeout()), SLOT(checkS3())); +} + +ModelUploader::~ModelUploader() { + delete _dataMultiPart; +} + +bool ModelUploader::zip() { + // File Dialog + QSettings* settings = Application::getInstance()->lockSettings(); + QString lastLocation = settings->value(SETTING_NAME).toString(); + + if (lastLocation.isEmpty()) { + lastLocation = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation); + // Temporary fix to Qt bug: http://stackoverflow.com/questions/16194475 +#ifdef __APPLE__ + lastLocation.append("/model.fst"); +#endif + } + + + QString filename = QFileDialog::getOpenFileName(NULL, "Select your .fst file ...", lastLocation, "*.fst"); + if (filename == "") { + // If the user canceled we return. + Application::getInstance()->unlockSettings(); + return false; + } + settings->setValue(SETTING_NAME, filename); + Application::getInstance()->unlockSettings(); + + bool _nameIsPresent = false; + QString texDir; + QString fbxFile; + + + // First we check the FST file + QFile fst(filename); + if (!fst.open(QFile::ReadOnly | QFile::Text)) { + QMessageBox::warning(NULL, + QString("ModelUploader::zip()"), + QString("Could not open FST file."), + QMessageBox::Ok); + qDebug() << "[Warning] " << QString("Could not open FST file."); + return false; + } + qDebug() << "Reading FST file : " << QFileInfo(fst).filePath(); + + // Compress and copy the fst + if (!addPart(QFileInfo(fst).filePath(), QString("fst"))) { + return false; + } + + // Let's read through the FST file + QTextStream stream(&fst); + QList line; + while (!stream.atEnd()) { + line = stream.readLine().split(QRegExp("[ =]"), QString::SkipEmptyParts); + if (line.isEmpty()) { + continue; + } + + // according to what is read, we modify the command + if (line[0] == NAME_FIELD) { + QHttpPart textPart; + textPart.setHeader(QNetworkRequest::ContentDispositionHeader, "form-data;" + " name=\"model_name\""); + textPart.setBody(line[1].toUtf8()); + _dataMultiPart->append(textPart); + _url = S3_URL + ((_isHead)? "/models/heads/" : "/models/skeletons/") + line[1].toUtf8() + ".fst"; + _nameIsPresent = true; + } else if (line[0] == FILENAME_FIELD) { + fbxFile = QFileInfo(fst).path() + "/" + line[1]; + QFileInfo fbxInfo(fbxFile); + if (!fbxInfo.exists() || !fbxInfo.isFile()) { // Check existence + QMessageBox::warning(NULL, + QString("ModelUploader::zip()"), + QString("FBX file %1 could not be found.").arg(fbxInfo.fileName()), + QMessageBox::Ok); + qDebug() << "[Warning] " << QString("FBX file %1 could not be found.").arg(fbxInfo.fileName()); + return false; + } + // Compress and copy + if (!addPart(fbxInfo.filePath(), "fbx")) { + return false; + } + } else if (line[0] == TEXDIR_FIELD) { // Check existence + texDir = QFileInfo(fst).path() + "/" + line[1]; + QFileInfo texInfo(texDir); + if (!texInfo.exists() || !texInfo.isDir()) { + QMessageBox::warning(NULL, + QString("ModelUploader::zip()"), + QString("Texture directory could not be found."), + QMessageBox::Ok); + qDebug() << "[Warning] " << QString("Texture directory could not be found."); + return false; + } + } else if (line[0] == LOD_FIELD) { + QFileInfo lod(QFileInfo(fst).path() + "/" + line[1]); + if (!lod.exists() || !lod.isFile()) { // Check existence + QMessageBox::warning(NULL, + QString("ModelUploader::zip()"), + QString("LOD file %1 could not be found.").arg(lod.fileName()), + QMessageBox::Ok); + qDebug() << "[Warning] " << QString("FBX file %1 could not be found.").arg(lod.fileName()); + } + // Compress and copy + if (!addPart(lod.filePath(), QString("lod%1").arg(++_lodCount))) { + return false; + } + } + } + + if (!addTextures(texDir, fbxFile)) { + return false; + } + + QHttpPart textPart; + textPart.setHeader(QNetworkRequest::ContentDispositionHeader, "form-data;" + " name=\"model_category\""); + if (_isHead) { + textPart.setBody("heads"); + } else { + textPart.setBody("skeletons"); + } + _dataMultiPart->append(textPart); + + if (!_nameIsPresent) { + QMessageBox::warning(NULL, + QString("ModelUploader::zip()"), + QString("Model name is missing in the .fst file."), + QMessageBox::Ok); + qDebug() << "[Warning] " << QString("Model name is missing in the .fst file."); + return false; + } + + _readyToSend = true; + return true; +} + +void ModelUploader::send() { + if (!zip()) { + deleteLater(); + return; + } + + JSONCallbackParameters callbackParams; + callbackParams.jsonCallbackReceiver = this; + callbackParams.jsonCallbackMethod = "uploadSuccess"; + callbackParams.errorCallbackReceiver = this; + callbackParams.errorCallbackMethod = "uploadFailed"; + callbackParams.updateReciever = this; + callbackParams.updateSlot = SLOT(uploadUpdate(qint64, qint64)); + + AccountManager::getInstance().authenticatedRequest(MODEL_URL, QNetworkAccessManager::PostOperation, callbackParams, QByteArray(), _dataMultiPart); + _dataMultiPart = NULL; + qDebug() << "Sending model..."; + _progressDialog = new QDialog(); + _progressBar = new QProgressBar(_progressDialog); + _progressBar->setRange(0, 100); + _progressBar->setValue(0); + + _progressDialog->setWindowTitle("Uploading model..."); + _progressDialog->setLayout(new QGridLayout(_progressDialog)); + _progressDialog->layout()->addWidget(_progressBar); + + _progressDialog->exec(); + + delete _progressDialog; + _progressDialog = NULL; + _progressBar = NULL; +} + +void ModelUploader::uploadUpdate(qint64 bytesSent, qint64 bytesTotal) { + if (_progressDialog) { + _progressBar->setRange(0, bytesTotal); + _progressBar->setValue(bytesSent); + } +} + +void ModelUploader::uploadSuccess(const QJsonObject& jsonResponse) { + if (_progressDialog) { + _progressDialog->accept(); + } + QMessageBox::information(NULL, + QString("ModelUploader::uploadSuccess()"), + QString("We are reading your model information."), + QMessageBox::Ok); + qDebug() << "Model sent with success"; + checkS3(); +} + +void ModelUploader::uploadFailed(QNetworkReply::NetworkError errorCode, const QString& errorString) { + if (_progressDialog) { + _progressDialog->reject(); + } + QMessageBox::warning(NULL, + QString("ModelUploader::uploadFailed()"), + QString("There was a problem with your upload, please try again later."), + QMessageBox::Ok); + qDebug() << "Model upload failed (" << errorCode << "): " << errorString; + deleteLater(); +} + +void ModelUploader::checkS3() { + qDebug() << "Checking S3 for " << _url; + QNetworkRequest request(_url); + QNetworkReply* reply = _networkAccessManager.head(request); + connect(reply, SIGNAL(finished()), SLOT(processCheck())); +} + +void ModelUploader::processCheck() { + QNetworkReply* reply = static_cast(sender()); + _timer.stop(); + + switch (reply->error()) { + case QNetworkReply::NoError: + QMessageBox::information(NULL, + QString("ModelUploader::processCheck()"), + QString("Your model is now available in the browser."), + QMessageBox::Ok); + deleteLater(); + break; + case QNetworkReply::ContentNotFoundError: + if (--_numberOfChecks) { + _timer.start(TIMEOUT); + break; + } + default: + QMessageBox::warning(NULL, + QString("ModelUploader::processCheck()"), + QString("We could not verify that your model was sent sucessfully\n" + "but it may have. If you do not see it in the model browser, try to upload again."), + QMessageBox::Ok); + deleteLater(); + break; + } + + delete reply; +} + +bool ModelUploader::addTextures(const QString& texdir, const QString fbxFile) { + QFile fbx(fbxFile); + if (!fbx.open(QIODevice::ReadOnly)) { + return false; + } + + QByteArray buffer = fbx.readAll(); + QVariantHash variantHash = readMapping(buffer); + FBXGeometry geometry = readFBX(buffer, variantHash); + + foreach (FBXMesh mesh, geometry.meshes) { + foreach (FBXMeshPart part, mesh.parts) { + if (!part.diffuseFilename.isEmpty()) { + if (!addPart(texdir + "/" + part.diffuseFilename, + QString("texture%1").arg(++_texturesCount))) { + return false; + } + } + if (!part.normalFilename.isEmpty()) { + if (!addPart(texdir + "/" + part.normalFilename, + QString("texture%1").arg(++_texturesCount))) { + return false; + } + } + } + } + + return true; +} + +bool ModelUploader::addPart(const QString &path, const QString& name) { + QFile file(path); + if (!file.open(QIODevice::ReadOnly)) { + QMessageBox::warning(NULL, + QString("ModelUploader::addPart()"), + QString("Could not open %1").arg(path), + QMessageBox::Ok); + qDebug() << "[Warning] " << QString("Could not open %1").arg(path); + return false; + } + QByteArray buffer = qCompress(file.readAll()); + + // Qt's qCompress() default compression level (-1) is the standard zLib compression. + // Here remove Qt's custom header that prevent the data server from uncompressing the files with zLib. + buffer.remove(QCOMPRESS_HEADER_POSITION, QCOMPRESS_HEADER_SIZE); + + QHttpPart part; + part.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data;" + " name=\"" + name.toUtf8() + "\";" + " filename=\"" + QFileInfo(file).fileName().toUtf8() + "\"")); + part.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("application/octet-stream")); + part.setBody(buffer); + _dataMultiPart->append(part); + + + qDebug() << "File " << QFileInfo(file).fileName() << " added to model."; + _totalSize += file.size(); + if (_totalSize > MAX_SIZE) { + QMessageBox::warning(NULL, + QString("ModelUploader::zip()"), + QString("Model too big, over %1 Bytes.").arg(MAX_SIZE), + QMessageBox::Ok); + qDebug() << "[Warning] " << QString("Model too big, over %1 Bytes.").arg(MAX_SIZE); + return false; + } + qDebug() << "Current model size: " << _totalSize; + + return true; +} + + + + + + diff --git a/interface/src/ModelUploader.h b/interface/src/ModelUploader.h new file mode 100644 index 0000000000..ff22673cdd --- /dev/null +++ b/interface/src/ModelUploader.h @@ -0,0 +1,62 @@ +// +// ModelUploader.h +// interface/src +// +// Created by Clément Brisset on 3/4/14. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_ModelUploader_h +#define hifi_ModelUploader_h + +#include + +class QDialog; +class QFileInfo; +class QHttpMultiPart; +class QProgressBar; + +class ModelUploader : public QObject { + Q_OBJECT + +public: + ModelUploader(bool isHead); + ~ModelUploader(); + +public slots: + void send(); + +private slots: + void uploadUpdate(qint64 bytesSent, qint64 bytesTotal); + void uploadSuccess(const QJsonObject& jsonResponse); + void uploadFailed(QNetworkReply::NetworkError errorCode, const QString& errorString); + void checkS3(); + void processCheck(); + +private: + QString _url; + int _lodCount; + int _texturesCount; + int _totalSize; + bool _isHead; + bool _readyToSend; + + QHttpMultiPart* _dataMultiPart; + QNetworkAccessManager _networkAccessManager; + + int _numberOfChecks; + QTimer _timer; + + QDialog* _progressDialog; + QProgressBar* _progressBar; + + + bool zip(); + bool addTextures(const QString& texdir, const QString fbxFile); + bool addPart(const QString& path, const QString& name); +}; + +#endif // hifi_ModelUploader_h diff --git a/interface/src/ParticleTreeRenderer.cpp b/interface/src/ParticleTreeRenderer.cpp index 59784c8c1f..aa498082d9 100644 --- a/interface/src/ParticleTreeRenderer.cpp +++ b/interface/src/ParticleTreeRenderer.cpp @@ -1,10 +1,12 @@ // // ParticleTreeRenderer.cpp -// hifi +// interface/src // // Created by Brad Hefta-Gaub on 12/6/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/interface/src/ParticleTreeRenderer.h b/interface/src/ParticleTreeRenderer.h index fe346ae730..7dc866c731 100644 --- a/interface/src/ParticleTreeRenderer.h +++ b/interface/src/ParticleTreeRenderer.h @@ -1,14 +1,16 @@ // // ParticleTreeRenderer.h -// hifi +// interface/src // // Created by Brad Hefta-Gaub on 12/6/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__ParticleTreeRenderer__ -#define __hifi__ParticleTreeRenderer__ +#ifndef hifi_ParticleTreeRenderer_h +#define hifi_ParticleTreeRenderer_h #include #include @@ -49,4 +51,4 @@ protected: QMap _particleModels; }; -#endif /* defined(__hifi__ParticleTreeRenderer__) */ \ No newline at end of file +#endif // hifi_ParticleTreeRenderer_h diff --git a/interface/src/Physics.cpp b/interface/src/Physics.cpp index 101087b1ef..30ea829c4e 100644 --- a/interface/src/Physics.cpp +++ b/interface/src/Physics.cpp @@ -1,10 +1,11 @@ // // Physics.cpp -// hifi +// interface/src // -// Created by Philip on July 11, 2013 +// Copyright 2013 High Fidelity, Inc. // -// Routines to help with doing virtual world physics +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include @@ -40,5 +41,4 @@ void applyDamping(float deltaTime, glm::vec3& velocity, float linearStrength, fl void applyDampedSpring(float deltaTime, glm::vec3& velocity, glm::vec3& position, glm::vec3& targetPosition, float k, float damping) { -} - +} \ No newline at end of file diff --git a/interface/src/Physics.h b/interface/src/Physics.h index 699497c187..97e873d920 100644 --- a/interface/src/Physics.h +++ b/interface/src/Physics.h @@ -1,9 +1,12 @@ // -// Balls.h -// hifi +// Physics.h +// interface/src // // Created by Philip on 4/25/13. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #ifndef hifi_Physics_h @@ -12,4 +15,4 @@ void applyStaticFriction(float deltaTime, glm::vec3& velocity, float maxVelocity, float strength); void applyDamping(float deltaTime, glm::vec3& velocity, float linearStrength, float squaredStrength); -#endif +#endif // hifi_Physics_h diff --git a/interface/src/Stars.cpp b/interface/src/Stars.cpp index dcfe726fff..e5662005d5 100755 --- a/interface/src/Stars.cpp +++ b/interface/src/Stars.cpp @@ -1,9 +1,12 @@ // -// Stars.cpp -// interface +// Stars.cpp +// interface/src // -// Created by Tobias Schwinger on 3/22/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Tobias Schwinger on 3/22/13. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "InterfaceConfig.h" diff --git a/interface/src/Stars.h b/interface/src/Stars.h index f6fe7cfb80..08f218b9fa 100755 --- a/interface/src/Stars.h +++ b/interface/src/Stars.h @@ -1,13 +1,16 @@ // -// Stars.h -// interface +// Stars.h +// interface/src // -// Created by Tobias Schwinger on 3/22/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Tobias Schwinger on 3/22/13. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__Stars__ -#define __interface__Stars__ +#ifndef hifi_Stars_h +#define hifi_Stars_h #include @@ -49,5 +52,4 @@ private: }; -#endif - +#endif // hifi_Stars_h diff --git a/interface/src/Util.cpp b/interface/src/Util.cpp index 1921fe924b..cecc363daa 100644 --- a/interface/src/Util.cpp +++ b/interface/src/Util.cpp @@ -1,9 +1,12 @@ // -// util.cpp -// interface +// Util.cpp +// interface/src // // Created by Philip Rosedale on 8/24/12. -// Copyright (c) 2012 High Fidelity, Inc. All rights reserved. +// Copyright 2012 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include @@ -348,10 +351,10 @@ void drawvec3(int x, int y, float scale, float radians, float thick, int mono, g glPopMatrix(); } -void renderCollisionOverlay(int width, int height, float magnitude) { +void renderCollisionOverlay(int width, int height, float magnitude, float red, float blue, float green) { const float MIN_VISIBLE_COLLISION = 0.01f; if (magnitude > MIN_VISIBLE_COLLISION) { - glColor4f(0, 0, 0, magnitude); + glColor4f(red, blue, green, magnitude); glBegin(GL_QUADS); glVertex2f(0, 0); glVertex2d(width, 0); @@ -626,4 +629,4 @@ bool pointInSphere(glm::vec3& point, glm::vec3& sphereCenter, double sphereRadiu return true; } return false; -} +} \ No newline at end of file diff --git a/interface/src/Util.h b/interface/src/Util.h index 732a36b98d..ac680645a9 100644 --- a/interface/src/Util.h +++ b/interface/src/Util.h @@ -1,13 +1,16 @@ // // Util.h -// interface +// interface/src // // Created by Philip Rosedale on 8/24/12. -// Copyright (c) 2012 High Fidelity, Inc. All rights reserved. +// Copyright 2012 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__Util__ -#define __interface__Util__ +#ifndef hifi_Util_h +#define hifi_Util_h #ifdef _WIN32 #include "Systime.h" @@ -59,7 +62,7 @@ float extractUniformScale(const glm::vec3& scale); double diffclock(timeval *clock1,timeval *clock2); -void renderCollisionOverlay(int width, int height, float magnitude); +void renderCollisionOverlay(int width, int height, float magnitude, float red = 0, float blue = 0, float green = 0); void renderOrientationDirections( glm::vec3 position, const glm::quat& orientation, float size ); @@ -77,4 +80,4 @@ bool rayIntersectsSphere(const glm::vec3& rayStarting, const glm::vec3& rayNorma bool pointInSphere(glm::vec3& point, glm::vec3& sphereCenter, double sphereRadius); -#endif +#endif // hifi_Util_h diff --git a/interface/src/XmppClient.cpp b/interface/src/XmppClient.cpp index df8cf34874..d930c16b53 100644 --- a/interface/src/XmppClient.cpp +++ b/interface/src/XmppClient.cpp @@ -1,9 +1,12 @@ // // XmppClient.cpp -// interface +// interface/src // -// Created by Dimitar Dobrev on 10/3/14 -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Dimitar Dobrev on 10/3/14. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #ifdef HAVE_QXMPP diff --git a/interface/src/XmppClient.h b/interface/src/XmppClient.h index 905d6e64fb..8af3204377 100644 --- a/interface/src/XmppClient.h +++ b/interface/src/XmppClient.h @@ -1,15 +1,18 @@ // // XmppClient.h -// interface +// interface/src // -// Created by Dimitar Dobrev on 10/3/14 -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Dimitar Dobrev on 10/3/14. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #ifdef HAVE_QXMPP -#ifndef __interface__XmppClient__ -#define __interface__XmppClient__ +#ifndef hifi_XmppClient_h +#define hifi_XmppClient_h #include #include @@ -44,4 +47,4 @@ private: #endif // __interface__XmppClient__ -#endif +#endif // hifi_XmppClient_h diff --git a/interface/src/avatar/Avatar.cpp b/interface/src/avatar/Avatar.cpp index 16181f46b9..475e7a1abc 100644 --- a/interface/src/avatar/Avatar.cpp +++ b/interface/src/avatar/Avatar.cpp @@ -1,9 +1,13 @@ // // Avatar.cpp -// interface +// interface/src/avatar // // Created by Philip Rosedale on 9/11/12. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// #include @@ -46,7 +50,6 @@ Avatar::Avatar() : _mode(AVATAR_MODE_STANDING), _velocity(0.0f, 0.0f, 0.0f), _thrust(0.0f, 0.0f, 0.0f), - _speed(0.0f), _leanScale(0.5f), _scale(1.0f), _worldUpDirection(DEFAULT_UP_DIRECTION), @@ -56,8 +59,7 @@ Avatar::Avatar() : _owningAvatarMixer(), _collisionFlags(0), _initialized(false), - _shouldRenderBillboard(true), - _modelsDirty(true) + _shouldRenderBillboard(true) { // we may have been created in the network thread, but we live in the main thread moveToThread(Application::getInstance()->thread()); @@ -118,24 +120,28 @@ void Avatar::simulate(float deltaTime) { getHand()->simulate(deltaTime, false); _skeletonModel.setLODDistance(getLODDistance()); - // copy joint data to skeleton - for (int i = 0; i < _jointData.size(); i++) { - const JointData& data = _jointData.at(i); - _skeletonModel.setJointState(i, data.valid, data.rotation); - } - glm::vec3 headPosition = _position; if (!_shouldRenderBillboard && inViewFrustum) { - _skeletonModel.simulate(deltaTime, _modelsDirty); - _modelsDirty = false; + if (_hasNewJointRotations) { + for (int i = 0; i < _jointData.size(); i++) { + const JointData& data = _jointData.at(i); + _skeletonModel.setJointState(i, data.valid, data.rotation); + } + _skeletonModel.simulate(deltaTime); + } + _skeletonModel.simulate(deltaTime, _hasNewJointRotations); + _hasNewJointRotations = false; + + glm::vec3 headPosition = _position; _skeletonModel.getHeadPosition(headPosition); + Head* head = getHead(); + head->setPosition(headPosition); + head->setScale(_scale); + head->simulate(deltaTime, false, _shouldRenderBillboard); } - Head* head = getHead(); - head->setPosition(headPosition); - head->setScale(_scale); - head->simulate(deltaTime, false, _shouldRenderBillboard); // use speed and angular velocity to determine walking vs. standing - if (_speed + fabs(_bodyYawDelta) > 0.2) { + float speed = glm::length(_velocity); + if (speed + fabs(_bodyYawDelta) > 0.2) { _mode = AVATAR_MODE_WALKING; } else { _mode = AVATAR_MODE_INTERACTING; @@ -204,37 +210,52 @@ void Avatar::render(const glm::vec3& cameraPosition, RenderMode renderMode) { { // glow when moving far away const float GLOW_DISTANCE = 20.0f; - Glower glower(_moving && distanceToTarget > GLOW_DISTANCE && renderMode == NORMAL_RENDER_MODE ? 1.0f : 0.0f); + const float GLOW_MAX_LOUDNESS = 2500.0f; + const float MAX_GLOW = 0.5f; + const float GLOW_FROM_AVERAGE_LOUDNESS = ((this == Application::getInstance()->getAvatar()) + ? 0.0f + : MAX_GLOW * getHeadData()->getAudioLoudness() / GLOW_MAX_LOUDNESS); + Glower glower(_moving && distanceToTarget > GLOW_DISTANCE && renderMode == NORMAL_RENDER_MODE + ? 1.0f + : GLOW_FROM_AVERAGE_LOUDNESS); // render body if (Menu::getInstance()->isOptionChecked(MenuOption::Avatars)) { renderBody(renderMode); } - if (Menu::getInstance()->isOptionChecked(MenuOption::RenderSkeletonCollisionProxies)) { - _skeletonModel.renderCollisionProxies(0.7f); + if (Menu::getInstance()->isOptionChecked(MenuOption::RenderSkeletonCollisionShapes)) { + _skeletonModel.updateShapePositions(); + _skeletonModel.renderJointCollisionShapes(0.7f); } - if (Menu::getInstance()->isOptionChecked(MenuOption::RenderHeadCollisionProxies)) { - getHead()->getFaceModel().renderCollisionProxies(0.7f); + if (Menu::getInstance()->isOptionChecked(MenuOption::RenderHeadCollisionShapes)) { + getHead()->getFaceModel().updateShapePositions(); + getHead()->getFaceModel().renderJointCollisionShapes(0.7f); + } + if (Menu::getInstance()->isOptionChecked(MenuOption::RenderBoundingCollisionShapes)) { + getHead()->getFaceModel().updateShapePositions(); + getHead()->getFaceModel().renderBoundingCollisionShapes(0.7f); + _skeletonModel.updateShapePositions(); + _skeletonModel.renderBoundingCollisionShapes(0.7f); } // quick check before falling into the code below: // (a 10 degree breadth of an almost 2 meter avatar kicks in at about 12m) - const float MIN_VOICE_SPHERE_DISTANCE = 12.f; + const float MIN_VOICE_SPHERE_DISTANCE = 12.0f; if (distanceToTarget > MIN_VOICE_SPHERE_DISTANCE) { // render voice intensity sphere for avatars that are farther away - const float MAX_SPHERE_ANGLE = 10.f * RADIANS_PER_DEGREE; - const float MIN_SPHERE_ANGLE = 1.f * RADIANS_PER_DEGREE; + const float MAX_SPHERE_ANGLE = 10.0f * RADIANS_PER_DEGREE; + const float MIN_SPHERE_ANGLE = 1.0f * RADIANS_PER_DEGREE; const float MIN_SPHERE_SIZE = 0.01f; const float SPHERE_LOUDNESS_SCALING = 0.0005f; const float SPHERE_COLOR[] = { 0.5f, 0.8f, 0.8f }; float height = getSkeletonHeight(); - glm::vec3 delta = height * (getHead()->getCameraOrientation() * IDENTITY_UP) / 2.f; + glm::vec3 delta = height * (getHead()->getCameraOrientation() * IDENTITY_UP) / 2.0f; float angle = abs(angleBetween(toTarget + delta, toTarget - delta)); float sphereRadius = getHead()->getAverageLoudness() * SPHERE_LOUDNESS_SCALING; if (renderMode == NORMAL_RENDER_MODE && (sphereRadius > MIN_SPHERE_SIZE) && (angle < MAX_SPHERE_ANGLE) && (angle > MIN_SPHERE_ANGLE)) { - glColor4f(SPHERE_COLOR[0], SPHERE_COLOR[1], SPHERE_COLOR[2], 1.f - angle / MAX_SPHERE_ANGLE); + glColor4f(SPHERE_COLOR[0], SPHERE_COLOR[1], SPHERE_COLOR[2], 1.0f - angle / MAX_SPHERE_ANGLE); glPushMatrix(); glTranslatef(_position.x, _position.y, _position.z); glScalef(height, height, height); @@ -266,9 +287,9 @@ void Avatar::render(const glm::vec3& cameraPosition, RenderMode renderMode) { glm::vec3 chatAxis = glm::axis(chatRotation); glRotatef(glm::degrees(glm::angle(chatRotation)), chatAxis.x, chatAxis.y, chatAxis.z); - glColor3f(0.f, 0.8f, 0.f); - glRotatef(180.f, 0.f, 1.f, 0.f); - glRotatef(180.f, 0.f, 0.f, 1.f); + glColor3f(0.0f, 0.8f, 0.0f); + glRotatef(180.0f, 0.0f, 1.0f, 0.0f); + glRotatef(180.0f, 0.0f, 0.0f, 1.0f); glScalef(_scale * CHAT_MESSAGE_SCALE, _scale * CHAT_MESSAGE_SCALE, 1.0f); glDisable(GL_LIGHTING); @@ -284,7 +305,7 @@ void Avatar::render(const glm::vec3& cameraPosition, RenderMode renderMode) { _chatMessage[lastIndex] = '\0'; textRenderer(CHAT)->draw(-width / 2.0f, 0, _chatMessage.c_str()); _chatMessage[lastIndex] = lastChar; - glColor3f(0.f, 1.f, 0.f); + glColor3f(0.0f, 1.0f, 0.0f); textRenderer(CHAT)->draw(width / 2.0f - lastWidth, 0, _chatMessage.c_str() + lastIndex); } glEnable(GL_LIGHTING); @@ -316,11 +337,17 @@ void Avatar::renderBody(RenderMode renderMode) { renderBillboard(); return; } - _skeletonModel.render(1.0f, renderMode == SHADOW_RENDER_MODE); - getHead()->render(1.0f, renderMode == SHADOW_RENDER_MODE); + Model::RenderMode modelRenderMode = (renderMode == SHADOW_RENDER_MODE) ? + Model::SHADOW_RENDER_MODE : Model::DEFAULT_RENDER_MODE; + _skeletonModel.render(1.0f, modelRenderMode); + getHead()->render(1.0f, modelRenderMode); getHand()->render(false); } +void Avatar::updateJointMappings() { + // no-op; joint mappings come from skeleton model +} + void Avatar::renderBillboard() { if (_billboard.isEmpty()) { return; @@ -502,6 +529,11 @@ bool Avatar::findSphereCollisions(const glm::vec3& penetratorCenter, float penet //return getHead()->getFaceModel().findSphereCollisions(penetratorCenter, penetratorRadius, collisions); } +bool Avatar::findPlaneCollisions(const glm::vec4& plane, CollisionList& collisions) { + return _skeletonModel.findPlaneCollisions(plane, collisions) || + getHead()->getFaceModel().findPlaneCollisions(plane, collisions); +} + void Avatar::updateShapePositions() { _skeletonModel.updateShapePositions(); Model& headModel = getHead()->getFaceModel(); @@ -530,7 +562,7 @@ bool Avatar::findParticleCollisions(const glm::vec3& particleCenter, float parti const PalmData* palm = handData->getPalm(i); if (palm && palm->hasPaddle()) { // create a disk collision proxy where the hand is - glm::vec3 fingerAxis(0.f); + glm::vec3 fingerAxis(0.0f); for (size_t f = 0; f < palm->getNumFingers(); ++f) { const FingerData& finger = (palm->getFingers())[f]; if (finger.isActive()) { @@ -653,9 +685,6 @@ int Avatar::parseDataAtOffset(const QByteArray& packet, int offset) { const float MOVE_DISTANCE_THRESHOLD = 0.001f; _moving = glm::distance(oldPosition, _position) > MOVE_DISTANCE_THRESHOLD; - // note that we need to update our models - _modelsDirty = true; - return bytesRead; } @@ -675,8 +704,8 @@ void Avatar::renderJointConnectingCone(glm::vec3 position1, glm::vec3 position2, glm::vec3 perpCos = glm::normalize(glm::cross(axis, perpSin)); perpSin = glm::cross(perpCos, axis); - float anglea = 0.f; - float angleb = 0.f; + float anglea = 0.0f; + float angleb = 0.0f; for (int i = 0; i < NUM_BODY_CONE_SIDES; i ++) { @@ -726,8 +755,8 @@ void Avatar::updateCollisionFlags() { void Avatar::setScale(float scale) { _scale = scale; - if (_targetScale * (1.f - RESCALING_TOLERANCE) < _scale && - _scale < _targetScale * (1.f + RESCALING_TOLERANCE)) { + if (_targetScale * (1.0f - RESCALING_TOLERANCE) < _scale && + _scale < _targetScale * (1.0f + RESCALING_TOLERANCE)) { _scale = _targetScale; } } diff --git a/interface/src/avatar/Avatar.h b/interface/src/avatar/Avatar.h index f2ee400ba2..ca05e5dbbf 100755 --- a/interface/src/avatar/Avatar.h +++ b/interface/src/avatar/Avatar.h @@ -1,12 +1,15 @@ // // Avatar.h -// interface +// interface/src/avatar // -// Copyright (c) 2012 High Fidelity, Inc. All rights reserved. +// Copyright 2012 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__avatar__ -#define __interface__avatar__ +#ifndef hifi_Avatar_h +#define hifi_Avatar_h #include #include @@ -61,7 +64,7 @@ enum ScreenTintLayer { // Where one's own Avatar begins in the world (will be overwritten if avatar data file is found) // this is basically in the center of the ground plane. Slightly adjusted. This was asked for by // Grayson as he's building a street around here for demo dinner 2 -const glm::vec3 START_LOCATION(0.485f * TREE_SCALE, 0.f, 0.5f * TREE_SCALE); +const glm::vec3 START_LOCATION(0.485f * TREE_SCALE, 0.0f, 0.5f * TREE_SCALE); class Texture; @@ -116,6 +119,12 @@ public: bool findSphereCollisions(const glm::vec3& penetratorCenter, float penetratorRadius, CollisionList& collisions, int skeletonSkipIndex = -1); + /// Checks for penetration between the described plane and the avatar. + /// \param plane the penetration plane + /// \param collisions[out] a list to which collisions get appended + /// \return whether or not the plane penetrated + bool findPlaneCollisions(const glm::vec4& plane, CollisionList& collisions); + /// Checks for collision between the a spherical particle and the avatar (including paddle hands) /// \param collisionCenter the center of particle's bounding sphere /// \param collisionRadius the radius of particle's bounding sphere @@ -140,8 +149,6 @@ public: static void renderJointConnectingCone(glm::vec3 position1, glm::vec3 position2, float radius1, float radius2); - - /// \return true if we expect the avatar would move as a result of the collision bool collisionWouldMoveAvatar(CollisionInfo& collision) const; @@ -154,13 +161,15 @@ public: public slots: void updateCollisionFlags(); +signals: + void collisionWithAvatar(const QUuid& myUUID, const QUuid& theirUUID, const CollisionInfo& collision); + protected: SkeletonModel _skeletonModel; float _bodyYawDelta; AvatarMode _mode; glm::vec3 _velocity; glm::vec3 _thrust; - float _speed; float _leanScale; float _scale; glm::vec3 _worldUpDirection; @@ -187,16 +196,17 @@ protected: void renderDisplayName(); virtual void renderBody(RenderMode renderMode); + virtual void updateJointMappings(); + private: bool _initialized; QScopedPointer _billboardTexture; bool _shouldRenderBillboard; - bool _modelsDirty; void renderBillboard(); float getBillboardSize() const; }; -#endif +#endif // hifi_Avatar_h diff --git a/interface/src/avatar/AvatarManager.cpp b/interface/src/avatar/AvatarManager.cpp index c2ba28ac7b..5798f33d0f 100644 --- a/interface/src/avatar/AvatarManager.cpp +++ b/interface/src/avatar/AvatarManager.cpp @@ -1,10 +1,14 @@ // // AvatarManager.cpp -// hifi +// interface/src/avatar // // Created by Stephen Birarda on 1/23/2014. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + #include #include @@ -123,8 +127,8 @@ void AvatarManager::renderAvatarFades(const glm::vec3& cameraPosition, Avatar::R } } -AvatarSharedPointer AvatarManager::matchingOrNewAvatar(const QUuid& nodeUUID, const QWeakPointer& mixerWeakPointer) { - AvatarSharedPointer matchingAvatar = _avatarHash.value(nodeUUID); +AvatarSharedPointer AvatarManager::matchingOrNewAvatar(const QUuid& sessionUUID, const QWeakPointer& mixerWeakPointer) { + AvatarSharedPointer matchingAvatar = _avatarHash.value(sessionUUID); if (!matchingAvatar) { // construct a new Avatar for this node @@ -133,9 +137,9 @@ AvatarSharedPointer AvatarManager::matchingOrNewAvatar(const QUuid& nodeUUID, co // insert the new avatar into our hash matchingAvatar = AvatarSharedPointer(avatar); - _avatarHash.insert(nodeUUID, matchingAvatar); + _avatarHash.insert(sessionUUID, matchingAvatar); - qDebug() << "Adding avatar with UUID" << nodeUUID << "to AvatarManager hash."; + qDebug() << "Adding avatar with sessionUUID " << sessionUUID << "to AvatarManager hash."; } return matchingAvatar; @@ -166,10 +170,10 @@ void AvatarManager::processAvatarDataPacket(const QByteArray &datagram, const QW // enumerate over all of the avatars in this packet // only add them if mixerWeakPointer points to something (meaning that mixer is still around) while (bytesRead < datagram.size() && mixerWeakPointer.data()) { - QUuid nodeUUID = QUuid::fromRfc4122(datagram.mid(bytesRead, NUM_BYTES_RFC4122_UUID)); + QUuid sessionUUID = QUuid::fromRfc4122(datagram.mid(bytesRead, NUM_BYTES_RFC4122_UUID)); bytesRead += NUM_BYTES_RFC4122_UUID; - AvatarSharedPointer matchingAvatarData = matchingOrNewAvatar(nodeUUID, mixerWeakPointer); + AvatarSharedPointer matchingAvatarData = matchingOrNewAvatar(sessionUUID, mixerWeakPointer); // have the matching (or new) avatar parse the data from the packet bytesRead += matchingAvatarData->parseDataAtOffset(datagram, bytesRead); @@ -188,16 +192,16 @@ void AvatarManager::processAvatarIdentityPacket(const QByteArray &packet, const QDataStream identityStream(packet); identityStream.skipRawData(numBytesForPacketHeader(packet)); - QUuid nodeUUID; + QUuid sessionUUID; while (!identityStream.atEnd()) { QUrl faceMeshURL, skeletonURL; QString displayName; - identityStream >> nodeUUID >> faceMeshURL >> skeletonURL >> displayName; + identityStream >> sessionUUID >> faceMeshURL >> skeletonURL >> displayName; // mesh URL for a UUID, find avatar in our list - AvatarSharedPointer matchingAvatar = matchingOrNewAvatar(nodeUUID, mixerWeakPointer); + AvatarSharedPointer matchingAvatar = matchingOrNewAvatar(sessionUUID, mixerWeakPointer); if (matchingAvatar) { Avatar* avatar = static_cast(matchingAvatar.data()); @@ -218,9 +222,9 @@ void AvatarManager::processAvatarIdentityPacket(const QByteArray &packet, const void AvatarManager::processAvatarBillboardPacket(const QByteArray& packet, const QWeakPointer& mixerWeakPointer) { int headerSize = numBytesForPacketHeader(packet); - QUuid nodeUUID = QUuid::fromRfc4122(QByteArray::fromRawData(packet.constData() + headerSize, NUM_BYTES_RFC4122_UUID)); + QUuid sessionUUID = QUuid::fromRfc4122(QByteArray::fromRawData(packet.constData() + headerSize, NUM_BYTES_RFC4122_UUID)); - AvatarSharedPointer matchingAvatar = matchingOrNewAvatar(nodeUUID, mixerWeakPointer); + AvatarSharedPointer matchingAvatar = matchingOrNewAvatar(sessionUUID, mixerWeakPointer); if (matchingAvatar) { Avatar* avatar = static_cast(matchingAvatar.data()); QByteArray billboard = packet.mid(headerSize + NUM_BYTES_RFC4122_UUID); @@ -232,10 +236,10 @@ void AvatarManager::processAvatarBillboardPacket(const QByteArray& packet, const void AvatarManager::processKillAvatar(const QByteArray& datagram) { // read the node id - QUuid nodeUUID = QUuid::fromRfc4122(datagram.mid(numBytesForPacketHeader(datagram), NUM_BYTES_RFC4122_UUID)); + QUuid sessionUUID = QUuid::fromRfc4122(datagram.mid(numBytesForPacketHeader(datagram), NUM_BYTES_RFC4122_UUID)); // remove the avatar with that UUID from our hash, if it exists - AvatarHash::iterator matchedAvatar = _avatarHash.find(nodeUUID); + AvatarHash::iterator matchedAvatar = _avatarHash.find(sessionUUID); if (matchedAvatar != _avatarHash.end()) { erase(matchedAvatar); } diff --git a/interface/src/avatar/AvatarManager.h b/interface/src/avatar/AvatarManager.h index bd04dddb78..78491b3a5d 100644 --- a/interface/src/avatar/AvatarManager.h +++ b/interface/src/avatar/AvatarManager.h @@ -1,13 +1,16 @@ // // AvatarManager.h -// hifi +// interface/src/avatar // // Created by Stephen Birarda on 1/23/2014. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__AvatarManager__ -#define __hifi__AvatarManager__ +#ifndef hifi_AvatarManager_h +#define hifi_AvatarManager_h #include #include @@ -56,4 +59,4 @@ private: QSharedPointer _myAvatar; }; -#endif /* defined(__hifi__AvatarManager__) */ +#endif // hifi_AvatarManager_h diff --git a/interface/src/avatar/FaceModel.cpp b/interface/src/avatar/FaceModel.cpp index 19120d10be..709a9fc79d 100644 --- a/interface/src/avatar/FaceModel.cpp +++ b/interface/src/avatar/FaceModel.cpp @@ -1,9 +1,12 @@ // // FaceModel.cpp -// interface +// interface/src/avatar // // Created by Andrzej Kapolka on 9/16/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include @@ -18,11 +21,8 @@ FaceModel::FaceModel(Head* owningHead) : { } -void FaceModel::simulate(float deltaTime) { - QVector newJointStates = updateGeometry(); - if (!isActive()) { - return; - } +void FaceModel::simulate(float deltaTime, bool fullUpdate) { + updateGeometry(); Avatar* owningAvatar = static_cast(_owningHead->_owningAvatar); glm::vec3 neckPosition; if (!owningAvatar->getSkeletonModel().getNeckPosition(neckPosition)) { @@ -37,12 +37,13 @@ void FaceModel::simulate(float deltaTime) { const float MODEL_SCALE = 0.0006f; setScale(glm::vec3(1.0f, 1.0f, 1.0f) * _owningHead->getScale() * MODEL_SCALE); - setOffset(-_geometry->getFBXGeometry().neckPivot); - setPupilDilation(_owningHead->getPupilDilation()); setBlendshapeCoefficients(_owningHead->getBlendshapeCoefficients()); - Model::simulate(deltaTime, true, newJointStates); + if (isActive()) { + setOffset(-_geometry->getFBXGeometry().neckPivot); + Model::simulateInternal(deltaTime); + } } void FaceModel::maybeUpdateNeckRotation(const JointState& parentState, const FBXJoint& joint, JointState& state) { diff --git a/interface/src/avatar/FaceModel.h b/interface/src/avatar/FaceModel.h index acf2d2baf4..fdf8ab1fd2 100644 --- a/interface/src/avatar/FaceModel.h +++ b/interface/src/avatar/FaceModel.h @@ -1,13 +1,16 @@ // // FaceModel.h -// interface +// interface/src/avatar // // Created by Andrzej Kapolka on 9/16/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__FaceModel__ -#define __interface__FaceModel__ +#ifndef hifi_FaceModel_h +#define hifi_FaceModel_h #include "renderer/Model.h" @@ -21,7 +24,7 @@ public: FaceModel(Head* owningHead); - void simulate(float deltaTime); + virtual void simulate(float deltaTime, bool fullUpdate = true); protected: @@ -33,4 +36,4 @@ private: Head* _owningHead; }; -#endif /* defined(__interface__FaceModel__) */ +#endif // hifi_FaceModel_h diff --git a/interface/src/avatar/Hand.cpp b/interface/src/avatar/Hand.cpp index daf82f2599..0f0df8a484 100644 --- a/interface/src/avatar/Hand.cpp +++ b/interface/src/avatar/Hand.cpp @@ -1,8 +1,12 @@ // // Hand.cpp -// interface +// interface/src/avatar +// +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. #include @@ -159,6 +163,11 @@ void Hand::collideAgainstAvatar(Avatar* avatar, bool isMyHand) { // TODO: submit collision info to MyAvatar which should lean accordingly averageContactPoint /= (float)handCollisions.size(); avatar->applyCollision(averageContactPoint, totalPenetration); + + CollisionInfo collision; + collision._penetration = totalPenetration; + collision._contactPoint = averageContactPoint; + emit avatar->collisionWithAvatar(avatar->getSessionUUID(), _owningAvatar->getSessionUUID(), collision); } } } @@ -254,7 +263,7 @@ void Hand::render(bool isMine) { _renderAlpha = 1.0; - if (Menu::getInstance()->isOptionChecked(MenuOption::RenderSkeletonCollisionProxies)) { + if (Menu::getInstance()->isOptionChecked(MenuOption::RenderSkeletonCollisionShapes)) { // draw a green sphere at hand joint location, which is actually near the wrist) for (size_t i = 0; i < getNumPalms(); i++) { PalmData& palm = getPalms()[i]; diff --git a/interface/src/avatar/Hand.h b/interface/src/avatar/Hand.h index 3be3bc0f77..1c857a198a 100755 --- a/interface/src/avatar/Hand.h +++ b/interface/src/avatar/Hand.h @@ -1,8 +1,11 @@ // // Hand.h -// interface +// interface/src/avatar // -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #ifndef hifi_Hand_h @@ -81,5 +84,4 @@ private: void playSlaps(PalmData& palm, Avatar* avatar); }; -#endif - +#endif // hifi_Hand_h diff --git a/interface/src/avatar/Head.cpp b/interface/src/avatar/Head.cpp index ffa0975ccb..a213603a89 100644 --- a/interface/src/avatar/Head.cpp +++ b/interface/src/avatar/Head.cpp @@ -1,8 +1,12 @@ // // Head.cpp -// interface +// interface/src/avatar +// +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. #include @@ -14,6 +18,7 @@ #include "Head.h" #include "Menu.h" #include "Util.h" +#include "devices/OculusManager.h" using namespace std; @@ -59,17 +64,11 @@ void Head::reset() { void Head::simulate(float deltaTime, bool isMine, bool billboard) { // Update audio trailing average for rendering facial animations - Faceshift* faceshift = Application::getInstance()->getFaceshift(); - Visage* visage = Application::getInstance()->getVisage(); if (isMine) { - _isFaceshiftConnected = false; - if (faceshift->isActive()) { - _blendshapeCoefficients = faceshift->getBlendshapeCoefficients(); - _isFaceshiftConnected = true; - - } else if (visage->isActive()) { - _blendshapeCoefficients = visage->getBlendshapeCoefficients(); - _isFaceshiftConnected = true; + FaceTracker* faceTracker = Application::getInstance()->getActiveFaceTracker(); + if ((_isFaceshiftConnected = faceTracker)) { + _blendshapeCoefficients = faceTracker->getBlendshapeCoefficients(); + _isFaceshiftConnected = true; } } @@ -151,8 +150,9 @@ void Head::simulate(float deltaTime, bool isMine, bool billboard) { const float BROW_LIFT_SCALE = 500.0f; const float JAW_OPEN_SCALE = 0.01f; const float JAW_OPEN_DEAD_ZONE = 0.75f; - faceshift->updateFakeCoefficients(_leftEyeBlink, _rightEyeBlink, min(1.0f, _browAudioLift * BROW_LIFT_SCALE), - glm::clamp(sqrt(_averageLoudness * JAW_OPEN_SCALE) - JAW_OPEN_DEAD_ZONE, 0.0f, 1.0f), _blendshapeCoefficients); + Application::getInstance()->getFaceshift()->updateFakeCoefficients(_leftEyeBlink, _rightEyeBlink, + min(1.0f, _browAudioLift * BROW_LIFT_SCALE), glm::clamp(sqrt(_averageLoudness * JAW_OPEN_SCALE) - + JAW_OPEN_DEAD_ZONE, 0.0f, 1.0f), _blendshapeCoefficients); } if (!isMine) { @@ -179,8 +179,8 @@ void Head::relaxLean(float deltaTime) { _deltaLeanForward *= relaxationFactor; } -void Head::render(float alpha, bool forShadowMap) { - if (_faceModel.render(alpha, forShadowMap) && _renderLookatVectors) { +void Head::render(float alpha, Model::RenderMode mode) { + if (_faceModel.render(alpha, mode) && _renderLookatVectors) { renderLookatVectors(_leftEyePosition, _rightEyePosition, _lookAtPosition); } } @@ -198,6 +198,9 @@ glm::quat Head::getFinalOrientation() const { } glm::quat Head::getCameraOrientation () const { + if (OculusManager::isConnected()) { + return getOrientation(); + } Avatar* owningAvatar = static_cast(_owningAvatar); return owningAvatar->getWorldAlignedOrientation() * glm::quat(glm::radians(glm::vec3(_basePitch, 0.f, 0.0f))); } diff --git a/interface/src/avatar/Head.h b/interface/src/avatar/Head.h index 0ec0b17a8c..4ae27faf79 100644 --- a/interface/src/avatar/Head.h +++ b/interface/src/avatar/Head.h @@ -1,8 +1,11 @@ // // Head.h -// interface +// interface/src/avatar // -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #ifndef hifi_Head_h @@ -39,7 +42,7 @@ public: void init(); void reset(); void simulate(float deltaTime, bool isMine, bool billboard = false); - void render(float alpha, bool forShadowMap); + void render(float alpha, Model::RenderMode mode); void setScale(float scale); void setPosition(glm::vec3 position) { _position = position; } void setGravity(glm::vec3 gravity) { _gravity = gravity; } @@ -144,4 +147,4 @@ private: friend class FaceModel; }; -#endif +#endif // hifi_Head_h diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 62ba24a384..59bb438316 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -1,9 +1,12 @@ // // MyAvatar.cpp -// interface +// interface/src/avatar // // Created by Mark Peng on 8/16/13. -// Copyright (c) 2012 High Fidelity, Inc. All rights reserved. +// Copyright 2012 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include @@ -11,6 +14,7 @@ #include +#include #include #include @@ -20,6 +24,8 @@ #include #include +#include + #include "Application.h" #include "Audio.h" #include "Environment.h" @@ -56,10 +62,12 @@ MyAvatar::MyAvatar() : _isThrustOn(false), _thrustMultiplier(1.0f), _moveTarget(0,0,0), + _lastBodyPenetration(0.0f), _moveTargetStepCounter(0), _lookAtTargetAvatar(), _shouldRender(true), - _billboardValid(false) + _billboardValid(false), + _oculusYawOffset(0.0f) { for (int i = 0; i < MAX_DRIVE_KEYS; i++) { _driveKeys[i] = 0.0f; @@ -82,10 +90,11 @@ void MyAvatar::reset() { _skeletonModel.reset(); getHead()->reset(); getHand()->reset(); + _oculusYawOffset = 0.0f; - setVelocity(glm::vec3(0,0,0)); - setThrust(glm::vec3(0,0,0)); - setOrientation(glm::quat(glm::vec3(0,0,0))); + setVelocity(glm::vec3(0.0f)); + setThrust(glm::vec3(0.0f)); + setOrientation(glm::quat(glm::vec3(0.0f))); } void MyAvatar::setMoveTarget(const glm::vec3 moveTarget) { @@ -108,8 +117,8 @@ void MyAvatar::update(float deltaTime) { // TODO? resurrect headMouse stuff? //glm::vec3 headVelocity = faceshift->getHeadAngularVelocity(); //// sets how quickly head angular rotation moves the head mouse - //const float HEADMOUSE_FACESHIFT_YAW_SCALE = 40.f; - //const float HEADMOUSE_FACESHIFT_PITCH_SCALE = 30.f; + //const float HEADMOUSE_FACESHIFT_YAW_SCALE = 40.0f; + //const float HEADMOUSE_FACESHIFT_PITCH_SCALE = 30.0f; //_headMouseX -= headVelocity.y * HEADMOUSE_FACESHIFT_YAW_SCALE; //_headMouseY -= headVelocity.x * HEADMOUSE_FACESHIFT_PITCH_SCALE; // @@ -118,16 +127,6 @@ void MyAvatar::update(float deltaTime) { //_headMouseY = glm::clamp(_headMouseY, 0, _glWidget->height()); } - if (OculusManager::isConnected()) { - float yaw, pitch, roll; // these angles will be in radians - OculusManager::getEulerAngles(yaw, pitch, roll); - - // but these euler angles are stored in degrees - head->setBaseYaw(yaw * DEGREES_PER_RADIAN); - head->setBasePitch(pitch * DEGREES_PER_RADIAN); - head->setBaseRoll(roll * DEGREES_PER_RADIAN); - } - // Get audio loudness data from audio input device Audio* audio = Application::getInstance()->getAudio(); head->setAudioLoudness(audio->getLastInputLoudness()); @@ -150,15 +149,15 @@ void MyAvatar::simulate(float deltaTime) { _elapsedTimeSinceCollision += deltaTime; const float VELOCITY_MOVEMENT_TIMER_THRESHOLD = 0.2f; if (glm::length(_velocity) < VELOCITY_MOVEMENT_TIMER_THRESHOLD) { - _elapsedTimeMoving = 0.f; + _elapsedTimeMoving = 0.0f; _elapsedTimeStopped += deltaTime; } else { - _elapsedTimeStopped = 0.f; + _elapsedTimeStopped = 0.0f; _elapsedTimeMoving += deltaTime; } if (_scale != _targetScale) { - float scale = (1.f - SMOOTHING_RATIO) * _scale + SMOOTHING_RATIO * _targetScale; + float scale = (1.0f - SMOOTHING_RATIO) * _scale + SMOOTHING_RATIO * _targetScale; setScale(scale); Application::getInstance()->getCamera()->setScale(scale); } @@ -166,12 +165,6 @@ void MyAvatar::simulate(float deltaTime) { // Collect thrust forces from keyboard and devices updateThrust(deltaTime); - // copy velocity so we can use it later for acceleration - glm::vec3 oldVelocity = getVelocity(); - - // calculate speed - _speed = glm::length(_velocity); - // update the movement of the hand and process handshaking with other avatars... updateHandMovementAndTouching(deltaTime); @@ -192,31 +185,31 @@ void MyAvatar::simulate(float deltaTime) { // decay body rotation momentum const float BODY_SPIN_FRICTION = 7.5f; - float bodySpinMomentum = 1.f - BODY_SPIN_FRICTION * deltaTime; + float bodySpinMomentum = 1.0f - BODY_SPIN_FRICTION * deltaTime; if (bodySpinMomentum < 0.0f) { bodySpinMomentum = 0.0f; } _bodyPitchDelta *= bodySpinMomentum; _bodyYawDelta *= bodySpinMomentum; _bodyRollDelta *= bodySpinMomentum; float MINIMUM_ROTATION_RATE = 2.0f; - if (fabs(_bodyYawDelta) < MINIMUM_ROTATION_RATE) { _bodyYawDelta = 0.f; } - if (fabs(_bodyRollDelta) < MINIMUM_ROTATION_RATE) { _bodyRollDelta = 0.f; } - if (fabs(_bodyPitchDelta) < MINIMUM_ROTATION_RATE) { _bodyPitchDelta = 0.f; } + if (fabs(_bodyYawDelta) < MINIMUM_ROTATION_RATE) { _bodyYawDelta = 0.0f; } + if (fabs(_bodyRollDelta) < MINIMUM_ROTATION_RATE) { _bodyRollDelta = 0.0f; } + if (fabs(_bodyPitchDelta) < MINIMUM_ROTATION_RATE) { _bodyPitchDelta = 0.0f; } - const float MAX_STATIC_FRICTION_VELOCITY = 0.5f; - const float STATIC_FRICTION_STRENGTH = _scale * 20.f; - applyStaticFriction(deltaTime, _velocity, MAX_STATIC_FRICTION_VELOCITY, STATIC_FRICTION_STRENGTH); + const float MAX_STATIC_FRICTION_SPEED = 0.5f; + const float STATIC_FRICTION_STRENGTH = _scale * 20.0f; + applyStaticFriction(deltaTime, _velocity, MAX_STATIC_FRICTION_SPEED, STATIC_FRICTION_STRENGTH); // Damp avatar velocity const float LINEAR_DAMPING_STRENGTH = 0.5f; const float SPEED_BRAKE_POWER = _scale * 10.0f; const float SQUARED_DAMPING_STRENGTH = 0.007f; - const float SLOW_NEAR_RADIUS = 5.f; + const float SLOW_NEAR_RADIUS = 5.0f; float linearDamping = LINEAR_DAMPING_STRENGTH; - const float NEAR_AVATAR_DAMPING_FACTOR = 50.f; + const float NEAR_AVATAR_DAMPING_FACTOR = 50.0f; if (_distanceToNearestAvatar < _scale * SLOW_NEAR_RADIUS) { - linearDamping *= 1.f + NEAR_AVATAR_DAMPING_FACTOR * + linearDamping *= 1.0f + NEAR_AVATAR_DAMPING_FACTOR * ((SLOW_NEAR_RADIUS - _distanceToNearestAvatar) / SLOW_NEAR_RADIUS); } if (_speedBrakes) { @@ -225,35 +218,61 @@ void MyAvatar::simulate(float deltaTime) { applyDamping(deltaTime, _velocity, linearDamping, SQUARED_DAMPING_STRENGTH); } + if (OculusManager::isConnected()) { + // these angles will be in radians + float yaw, pitch, roll; + OculusManager::getEulerAngles(yaw, pitch, roll); + // ... so they need to be converted to degrees before we do math... + + // The neck is limited in how much it can yaw, so we check its relative + // yaw from the body and yaw the body if necessary. + yaw *= DEGREES_PER_RADIAN; + float bodyToHeadYaw = yaw - _oculusYawOffset; + const float MAX_NECK_YAW = 85.0f; // degrees + if ((fabs(bodyToHeadYaw) > 2.0f * MAX_NECK_YAW) && (yaw * _oculusYawOffset < 0.0f)) { + // We've wrapped around the range for yaw so adjust + // the measured yaw to be relative to _oculusYawOffset. + if (yaw > 0.0f) { + yaw -= 360.0f; + } else { + yaw += 360.0f; + } + bodyToHeadYaw = yaw - _oculusYawOffset; + } + + float delta = fabs(bodyToHeadYaw) - MAX_NECK_YAW; + if (delta > 0.0f) { + yaw = MAX_NECK_YAW; + if (bodyToHeadYaw < 0.0f) { + delta *= -1.0f; + bodyToHeadYaw = -MAX_NECK_YAW; + } else { + bodyToHeadYaw = MAX_NECK_YAW; + } + // constrain _oculusYawOffset to be within range [-180,180] + _oculusYawOffset = fmod((_oculusYawOffset + delta) + 180.0f, 360.0f) - 180.0f; + + // We must adjust the body orientation using a delta rotation (rather than + // doing yaw math) because the body's yaw ranges are not the same + // as what the Oculus API provides. + glm::vec3 UP_AXIS = glm::vec3(0.0f, 1.0f, 0.0f); + glm::quat bodyCorrection = glm::angleAxis(glm::radians(delta), UP_AXIS); + orientation = orientation * bodyCorrection; + } + Head* head = getHead(); + head->setBaseYaw(bodyToHeadYaw); + + head->setBasePitch(pitch * DEGREES_PER_RADIAN); + head->setBaseRoll(roll * DEGREES_PER_RADIAN); + } + // update the euler angles setOrientation(orientation); - // Compute instantaneous acceleration - float forwardAcceleration = glm::length(glm::dot(getBodyFrontDirection(), getVelocity() - oldVelocity)) / deltaTime; - const float OCULUS_ACCELERATION_PULL_THRESHOLD = 1.0f; - const int OCULUS_YAW_OFFSET_THRESHOLD = 10; - - if (!Application::getInstance()->getFaceshift()->isActive() && OculusManager::isConnected() && - fabsf(forwardAcceleration) > OCULUS_ACCELERATION_PULL_THRESHOLD && - fabs(getHead()->getBaseYaw()) > OCULUS_YAW_OFFSET_THRESHOLD) { - - // if we're wearing the oculus - // and this acceleration is above the pull threshold - // and the head yaw if off the body by more than OCULUS_YAW_OFFSET_THRESHOLD - - // match the body yaw to the oculus yaw - _bodyYaw = getAbsoluteHeadYaw(); - - // set the head yaw to zero for this draw - getHead()->setBaseYaw(0); - - // correct the oculus yaw offset - OculusManager::updateYawOffset(); - } - const float WALKING_SPEED_THRESHOLD = 0.2f; // use speed and angular velocity to determine walking vs. standing - if (_speed + fabs(_bodyYawDelta) > WALKING_SPEED_THRESHOLD) { + float speed = glm::length(_velocity); + if (speed + fabs(_bodyYawDelta) > WALKING_SPEED_THRESHOLD) { _mode = AVATAR_MODE_WALKING; } else { _mode = AVATAR_MODE_INTERACTING; @@ -261,11 +280,11 @@ void MyAvatar::simulate(float deltaTime) { // update moving flag based on speed const float MOVING_SPEED_THRESHOLD = 0.01f; - _moving = _speed > MOVING_SPEED_THRESHOLD; + _moving = speed > MOVING_SPEED_THRESHOLD; // If a move target is set, update position explicitly const float MOVE_FINISHED_TOLERANCE = 0.1f; - const float MOVE_SPEED_FACTOR = 2.f; + const float MOVE_SPEED_FACTOR = 2.0f; const int MOVE_TARGET_MAX_STEPS = 250; if ((glm::length(_moveTarget) > EPSILON) && (_moveTargetStepCounter < MOVE_TARGET_MAX_STEPS)) { if (glm::length(_position - _moveTarget) > MOVE_FINISHED_TOLERANCE) { @@ -305,7 +324,7 @@ void MyAvatar::simulate(float deltaTime) { head->simulate(deltaTime, true); // Zero thrust out now that we've added it to velocity in this frame - _thrust = glm::vec3(0, 0, 0); + _thrust = glm::vec3(0.0f); // now that we're done stepping the avatar forward in time, compute new collisions if (_collisionFlags != 0) { @@ -313,7 +332,7 @@ void MyAvatar::simulate(float deltaTime) { float radius = getSkeletonHeight() * COLLISION_RADIUS_SCALE; if (myCamera->getMode() == CAMERA_MODE_FIRST_PERSON && !OculusManager::isConnected()) { - radius = myCamera->getAspectRatio() * (myCamera->getNearClip() / cos(myCamera->getFieldOfView() / 2.f)); + radius = myCamera->getAspectRatio() * (myCamera->getNearClip() / cos(myCamera->getFieldOfView() / 2.0f)); radius *= COLLISION_RADIUS_SCALAR; } @@ -334,45 +353,35 @@ void MyAvatar::simulate(float deltaTime) { // Update avatar head rotation with sensor data void MyAvatar::updateFromGyros(float deltaTime) { - Faceshift* faceshift = Application::getInstance()->getFaceshift(); - Visage* visage = Application::getInstance()->getVisage(); glm::vec3 estimatedPosition, estimatedRotation; - bool trackerActive = false; - if (faceshift->isActive()) { - estimatedPosition = faceshift->getHeadTranslation(); - estimatedRotation = glm::degrees(safeEulerAngles(faceshift->getHeadRotation())); - trackerActive = true; - - } else if (visage->isActive()) { - estimatedPosition = visage->getHeadTranslation(); - estimatedRotation = glm::degrees(safeEulerAngles(visage->getHeadRotation())); - trackerActive = true; - } - - Head* head = getHead(); - if (trackerActive) { + FaceTracker* tracker = Application::getInstance()->getActiveFaceTracker(); + if (tracker) { + estimatedPosition = tracker->getHeadTranslation(); + estimatedRotation = glm::degrees(safeEulerAngles(tracker->getHeadRotation())); + // Rotate the body if the head is turned beyond the screen if (Menu::getInstance()->isOptionChecked(MenuOption::TurnWithHead)) { const float TRACKER_YAW_TURN_SENSITIVITY = 0.5f; - const float TRACKER_MIN_YAW_TURN = 15.f; - const float TRACKER_MAX_YAW_TURN = 50.f; + const float TRACKER_MIN_YAW_TURN = 15.0f; + const float TRACKER_MAX_YAW_TURN = 50.0f; if ( (fabs(estimatedRotation.y) > TRACKER_MIN_YAW_TURN) && (fabs(estimatedRotation.y) < TRACKER_MAX_YAW_TURN) ) { - if (estimatedRotation.y > 0.f) { + if (estimatedRotation.y > 0.0f) { _bodyYawDelta += (estimatedRotation.y - TRACKER_MIN_YAW_TURN) * TRACKER_YAW_TURN_SENSITIVITY; } else { _bodyYawDelta += (estimatedRotation.y + TRACKER_MIN_YAW_TURN) * TRACKER_YAW_TURN_SENSITIVITY; } } } - } + } // Set the rotation of the avatar's head (as seen by others, not affecting view frustum) // to be scaled. Pitch is greater to emphasize nodding behavior / synchrony. const float AVATAR_HEAD_PITCH_MAGNIFY = 1.0f; const float AVATAR_HEAD_YAW_MAGNIFY = 1.0f; const float AVATAR_HEAD_ROLL_MAGNIFY = 1.0f; + Head* head = getHead(); head->setDeltaPitch(estimatedRotation.x * AVATAR_HEAD_PITCH_MAGNIFY); head->setDeltaYaw(estimatedRotation.y * AVATAR_HEAD_YAW_MAGNIFY); head->setDeltaRoll(estimatedRotation.z * AVATAR_HEAD_ROLL_MAGNIFY); @@ -397,20 +406,20 @@ void MyAvatar::moveWithLean() { float leanSideways = head->getLeanSideways(); // Degrees of 'dead zone' when leaning, and amount of acceleration to apply to lean angle - const float LEAN_FWD_DEAD_ZONE = 15.f; - const float LEAN_SIDEWAYS_DEAD_ZONE = 10.f; - const float LEAN_FWD_THRUST_SCALE = 4.f; - const float LEAN_SIDEWAYS_THRUST_SCALE = 3.f; + const float LEAN_FWD_DEAD_ZONE = 15.0f; + const float LEAN_SIDEWAYS_DEAD_ZONE = 10.0f; + const float LEAN_FWD_THRUST_SCALE = 4.0f; + const float LEAN_SIDEWAYS_THRUST_SCALE = 3.0f; if (fabs(leanForward) > LEAN_FWD_DEAD_ZONE) { - if (leanForward > 0.f) { + if (leanForward > 0.0f) { addThrust(front * -(leanForward - LEAN_FWD_DEAD_ZONE) * LEAN_FWD_THRUST_SCALE); } else { addThrust(front * -(leanForward + LEAN_FWD_DEAD_ZONE) * LEAN_FWD_THRUST_SCALE); } } if (fabs(leanSideways) > LEAN_SIDEWAYS_DEAD_ZONE) { - if (leanSideways > 0.f) { + if (leanSideways > 0.0f) { addThrust(right * -(leanSideways - LEAN_SIDEWAYS_DEAD_ZONE) * LEAN_SIDEWAYS_THRUST_SCALE); } else { addThrust(right * -(leanSideways + LEAN_SIDEWAYS_DEAD_ZONE) * LEAN_SIDEWAYS_THRUST_SCALE); @@ -457,7 +466,7 @@ void MyAvatar::renderHeadMouse() const { // TODO? resurrect headMouse stuff? /* // Display small target box at center or head mouse target that can also be used to measure LOD - glColor3f(1.f, 1.f, 1.f); + glColor3f(1.0f, 1.0f, 1.0f); glDisable(GL_LINE_SMOOTH); const int PIXEL_BOX = 16; glBegin(GL_LINES); @@ -467,7 +476,7 @@ void MyAvatar::renderHeadMouse() const { glVertex2f(_headMouseX, _headMouseY + PIXEL_BOX/2); glEnd(); glEnable(GL_LINE_SMOOTH); - glColor3f(1.f, 0.f, 0.f); + glColor3f(1.0f, 0.0f, 0.0f); glPointSize(3.0f); glDisable(GL_POINT_SMOOTH); glBegin(GL_POINTS); @@ -479,7 +488,7 @@ void MyAvatar::renderHeadMouse() const { int eyeTargetX = (_glWidget->width() / 2) - _faceshift.getEstimatedEyeYaw() * EYE_TARGET_PIXELS_PER_DEGREE; int eyeTargetY = (_glWidget->height() / 2) - _faceshift.getEstimatedEyePitch() * EYE_TARGET_PIXELS_PER_DEGREE; - glColor3f(0.f, 1.f, 1.f); + glColor3f(0.0f, 1.0f, 1.0f); glDisable(GL_LINE_SMOOTH); glBegin(GL_LINES); glVertex2f(eyeTargetX - PIXEL_BOX/2, eyeTargetY); @@ -600,11 +609,6 @@ void MyAvatar::clearLookAtTargetAvatar() { _lookAtTargetAvatar.clear(); } -float MyAvatar::getAbsoluteHeadYaw() const { - const Head* head = static_cast(_headData); - return glm::yaw(head->getOrientation()); -} - glm::vec3 MyAvatar::getUprightHeadPosition() const { return _position + getWorldAlignedOrientation() * glm::vec3(0.0f, getPelvisToHeadLength(), 0.0f); } @@ -639,14 +643,16 @@ void MyAvatar::renderBody(RenderMode renderMode) { } // Render the body's voxels and head - _skeletonModel.render(1.0f, renderMode == SHADOW_RENDER_MODE); + Model::RenderMode modelRenderMode = (renderMode == SHADOW_RENDER_MODE) ? + Model::SHADOW_RENDER_MODE : Model::DEFAULT_RENDER_MODE; + _skeletonModel.render(1.0f, modelRenderMode); // Render head so long as the camera isn't inside it - const float RENDER_HEAD_CUTOFF_DISTANCE = 0.40f; + const float RENDER_HEAD_CUTOFF_DISTANCE = 0.50f; Camera* myCamera = Application::getInstance()->getCamera(); if (renderMode != NORMAL_RENDER_MODE || (glm::length(myCamera->getPosition() - getHead()->calculateAverageEyePosition()) > RENDER_HEAD_CUTOFF_DISTANCE * _scale)) { - getHead()->render(1.0f, renderMode == SHADOW_RENDER_MODE); + getHead()->render(1.0f, modelRenderMode); } getHand()->render(true); } @@ -661,11 +667,11 @@ void MyAvatar::updateThrust(float deltaTime) { glm::vec3 up = orientation * IDENTITY_UP; const float THRUST_MAG_UP = 800.0f; - const float THRUST_MAG_DOWN = 300.f; - const float THRUST_MAG_FWD = 500.f; - const float THRUST_MAG_BACK = 300.f; - const float THRUST_MAG_LATERAL = 250.f; - const float THRUST_JUMP = 120.f; + const float THRUST_MAG_DOWN = 300.0f; + const float THRUST_MAG_FWD = 500.0f; + const float THRUST_MAG_BACK = 300.0f; + const float THRUST_MAG_LATERAL = 250.0f; + const float THRUST_JUMP = 120.0f; // Add Thrusts from keyboard _thrust += _driveKeys[FWD] * _scale * THRUST_MAG_FWD * _thrustMultiplier * deltaTime * front; @@ -674,6 +680,28 @@ void MyAvatar::updateThrust(float deltaTime) { _thrust -= _driveKeys[LEFT] * _scale * THRUST_MAG_LATERAL * _thrustMultiplier * deltaTime * right; _thrust += _driveKeys[UP] * _scale * THRUST_MAG_UP * _thrustMultiplier * deltaTime * up; _thrust -= _driveKeys[DOWN] * _scale * THRUST_MAG_DOWN * _thrustMultiplier * deltaTime * up; + + // attenuate thrust when in penetration + if (glm::dot(_thrust, _lastBodyPenetration) > EPSILON) { + const float MAX_BODY_PENETRATION_DEPTH = 0.6f * _skeletonModel.getBoundingShapeRadius(); + float penetrationFactor = glm::min(1.0f, glm::length(_lastBodyPenetration) / MAX_BODY_PENETRATION_DEPTH); + glm::vec3 penetrationDirection = glm::normalize(_lastBodyPenetration); + // attenuate parallel component + glm::vec3 parallelThrust = glm::dot(_thrust, penetrationDirection) * penetrationDirection; + // attenuate perpendicular component (friction) + glm::vec3 perpendicularThrust = _thrust - parallelThrust; + // recombine to get the final thrust + _thrust = (1.0f - penetrationFactor) * parallelThrust + (1.0f - penetrationFactor * penetrationFactor) * perpendicularThrust; + + // attenuate the growth of _thrustMultiplier when in penetration + // otherwise the avatar will eventually be able to tunnel through the obstacle + _thrustMultiplier *= (1.0f - penetrationFactor * penetrationFactor); + } else if (_thrustMultiplier < 1.0f) { + // rapid healing of attenuated thrustMultiplier after penetration event + _thrustMultiplier = 1.0f; + } + _lastBodyPenetration = glm::vec3(0.0f); + _bodyYawDelta -= _driveKeys[ROT_RIGHT] * YAW_SPEED * deltaTime; _bodyYawDelta += _driveKeys[ROT_LEFT] * YAW_SPEED * deltaTime; getHead()->setBasePitch(getHead()->getBasePitch() + (_driveKeys[ROT_UP] - _driveKeys[ROT_DOWN]) * PITCH_SPEED * deltaTime); @@ -682,12 +710,12 @@ void MyAvatar::updateThrust(float deltaTime) { if (_driveKeys[FWD] || _driveKeys[BACK] || _driveKeys[RIGHT] || _driveKeys[LEFT] || _driveKeys[UP] || _driveKeys[DOWN]) { const float THRUST_INCREASE_RATE = 1.05f; const float MAX_THRUST_MULTIPLIER = 75.0f; - //printf("m = %.3f\n", _thrustMultiplier); - if (_thrustMultiplier < MAX_THRUST_MULTIPLIER) { - _thrustMultiplier *= 1.f + deltaTime * THRUST_INCREASE_RATE; + _thrustMultiplier *= 1.0f + deltaTime * THRUST_INCREASE_RATE; + if (_thrustMultiplier > MAX_THRUST_MULTIPLIER) { + _thrustMultiplier = MAX_THRUST_MULTIPLIER; } } else { - _thrustMultiplier = 1.f; + _thrustMultiplier = 1.0f; } // Add one time jumping force if requested @@ -703,11 +731,12 @@ void MyAvatar::updateThrust(float deltaTime) { if ((glm::length(_thrust) == 0.0f) && _isThrustOn && (glm::length(_velocity) > MIN_SPEED_BRAKE_VELOCITY)) { _speedBrakes = true; } + _isThrustOn = (glm::length(_thrust) > EPSILON); - if (_speedBrakes && (glm::length(_velocity) < MIN_SPEED_BRAKE_VELOCITY)) { + if (_isThrustOn || (_speedBrakes && (glm::length(_velocity) < MIN_SPEED_BRAKE_VELOCITY))) { _speedBrakes = false; } - _isThrustOn = (glm::length(_thrust) > EPSILON); + } void MyAvatar::updateHandMovementAndTouching(float deltaTime) { @@ -791,11 +820,11 @@ void MyAvatar::applyHardCollision(const glm::vec3& penetration, float elasticity if (penetrationLength > EPSILON) { _elapsedTimeSinceCollision = 0.0f; glm::vec3 direction = penetration / penetrationLength; - _velocity -= glm::dot(_velocity, direction) * direction * (1.f + elasticity); - _velocity *= glm::clamp(1.f - damping, 0.0f, 1.0f); - if ((glm::length(_velocity) < HALTING_VELOCITY) && (glm::length(_thrust) == 0.f)) { + _velocity -= glm::dot(_velocity, direction) * direction * (1.0f + elasticity); + _velocity *= glm::clamp(1.0f - damping, 0.0f, 1.0f); + if ((glm::length(_velocity) < HALTING_VELOCITY) && (glm::length(_thrust) == 0.0f)) { // If moving really slowly after a collision, and not applying forces, stop altogether - _velocity *= 0.f; + _velocity *= 0.0f; } } } @@ -803,7 +832,7 @@ void MyAvatar::applyHardCollision(const glm::vec3& penetration, float elasticity void MyAvatar::updateCollisionSound(const glm::vec3 &penetration, float deltaTime, float frequency) { // consider whether to have the collision make a sound const float AUDIBLE_COLLISION_THRESHOLD = 0.02f; - const float COLLISION_LOUDNESS = 1.f; + const float COLLISION_LOUDNESS = 1.0f; const float DURATION_SCALING = 0.004f; const float NOISE_SCALING = 0.1f; glm::vec3 velocity = _velocity; @@ -823,10 +852,10 @@ void MyAvatar::updateCollisionSound(const glm::vec3 &penetration, float deltaTim // Noise is a function of the angle of collision // Duration of the sound is a function of both base frequency and velocity of impact Application::getInstance()->getAudio()->startCollisionSound( - std::min(COLLISION_LOUDNESS * velocityTowardCollision, 1.f), - frequency * (1.f + velocityTangentToCollision / velocityTowardCollision), - std::min(velocityTangentToCollision / velocityTowardCollision * NOISE_SCALING, 1.f), - 1.f - DURATION_SCALING * powf(frequency, 0.5f) / velocityTowardCollision, true); + std::min(COLLISION_LOUDNESS * velocityTowardCollision, 1.0f), + frequency * (1.0f + velocityTangentToCollision / velocityTowardCollision), + std::min(velocityTangentToCollision / velocityTowardCollision * NOISE_SCALING, 1.0f), + 1.0f - DURATION_SCALING * powf(frequency, 0.5f) / velocityTowardCollision, true); } } @@ -839,8 +868,8 @@ bool findAvatarAvatarPenetration(const glm::vec3 positionA, float radiusA, float float halfHeights = 0.5 * (heightA + heightB); if (yDistance < halfHeights) { // cylinders collide - if (xzDistance > 0.f) { - positionBA.y = 0.f; + if (xzDistance > 0.0f) { + positionBA.y = 0.0f; // note, penetration should point from A into B penetration = positionBA * ((radiusA + radiusB - xzDistance) / xzDistance); return true; @@ -850,7 +879,7 @@ bool findAvatarAvatarPenetration(const glm::vec3 positionA, float radiusA, float } } else if (yDistance < halfHeights + radiusA + radiusB) { // caps collide - if (positionBA.y < 0.f) { + if (positionBA.y < 0.0f) { // A is above B positionBA.y += halfHeights; float BA = glm::length(positionBA); @@ -868,6 +897,8 @@ bool findAvatarAvatarPenetration(const glm::vec3 positionA, float radiusA, float return false; } +const float BODY_COLLISION_RESOLUTION_TIMESCALE = 0.5f; // seconds + void MyAvatar::updateCollisionWithAvatars(float deltaTime) { // Reset detector for nearest avatar _distanceToNearestAvatar = std::numeric_limits::max(); @@ -879,14 +910,7 @@ void MyAvatar::updateCollisionWithAvatars(float deltaTime) { updateShapePositions(); float myBoundingRadius = getBoundingRadius(); - /* TODO: Andrew to fix Avatar-Avatar body collisions - // HACK: body-body collision uses two coaxial capsules with axes parallel to y-axis - // TODO: make the collision work without assuming avatar orientation - Extents myStaticExtents = _skeletonModel.getStaticExtents(); - glm::vec3 staticScale = myStaticExtents.maximum - myStaticExtents.minimum; - float myCapsuleRadius = 0.25f * (staticScale.x + staticScale.z); - float myCapsuleHeight = staticScale.y; - */ + const float BODY_COLLISION_RESOLUTION_FACTOR = glm::max(1.0f, deltaTime / BODY_COLLISION_RESOLUTION_TIMESCALE); foreach (const AvatarSharedPointer& avatarPointer, avatars) { Avatar* avatar = static_cast(avatarPointer.data()); @@ -901,23 +925,28 @@ void MyAvatar::updateCollisionWithAvatars(float deltaTime) { } float theirBoundingRadius = avatar->getBoundingRadius(); if (distance < myBoundingRadius + theirBoundingRadius) { - /* TODO: Andrew to fix Avatar-Avatar body collisions - Extents theirStaticExtents = _skeletonModel.getStaticExtents(); - glm::vec3 staticScale = theirStaticExtents.maximum - theirStaticExtents.minimum; - float theirCapsuleRadius = 0.25f * (staticScale.x + staticScale.z); - float theirCapsuleHeight = staticScale.y; + // collide our body against theirs + QVector myShapes; + _skeletonModel.getBodyShapes(myShapes); + QVector theirShapes; + avatar->getSkeletonModel().getBodyShapes(theirShapes); - glm::vec3 penetration(0.f); - if (findAvatarAvatarPenetration(_position, myCapsuleRadius, myCapsuleHeight, - avatar->getPosition(), theirCapsuleRadius, theirCapsuleHeight, penetration)) { - // move the avatar out by half the penetration - setPosition(_position - 0.5f * penetration); + CollisionInfo collision; + if (ShapeCollider::collideShapesCoarse(myShapes, theirShapes, collision)) { + float penetrationDepth = glm::length(collision._penetration); + if (penetrationDepth > myBoundingRadius) { + qDebug() << "WARNING: ignoring avatar-avatar penetration depth " << penetrationDepth; + } + else if (penetrationDepth > EPSILON) { + setPosition(getPosition() - BODY_COLLISION_RESOLUTION_FACTOR * collision._penetration); + _lastBodyPenetration += collision._penetration; + emit collisionWithAvatar(getSessionUUID(), avatar->getSessionUUID(), collision); + } } - */ // collide our hands against them // TODO: make this work when we can figure out when the other avatar won't yeild - // (for example, we're colling against their chest or leg) + // (for example, we're colliding against their chest or leg) //getHand()->collideAgainstAvatar(avatar, true); // collide their hands against us @@ -1069,15 +1098,15 @@ void MyAvatar::goHome() { } void MyAvatar::increaseSize() { - if ((1.f + SCALING_RATIO) * _targetScale < MAX_AVATAR_SCALE) { - _targetScale *= (1.f + SCALING_RATIO); + if ((1.0f + SCALING_RATIO) * _targetScale < MAX_AVATAR_SCALE) { + _targetScale *= (1.0f + SCALING_RATIO); qDebug("Changed scale to %f", _targetScale); } } void MyAvatar::decreaseSize() { - if (MIN_AVATAR_SCALE < (1.f - SCALING_RATIO) * _targetScale) { - _targetScale *= (1.f - SCALING_RATIO); + if (MIN_AVATAR_SCALE < (1.0f - SCALING_RATIO) * _targetScale) { + _targetScale *= (1.0f - SCALING_RATIO); qDebug("Changed scale to %f", _targetScale); } } @@ -1143,6 +1172,7 @@ void MyAvatar::goToLocationFromResponse(const QJsonObject& jsonObject) { glm::vec3 newPosition = glm::vec3(coordinateItems[0].toFloat(), coordinateItems[1].toFloat(), coordinateItems[2].toFloat()) - newOrientation * IDENTITY_FRONT * DISTANCE_TO_USER; setPosition(newPosition); + emit transformChanged(); } } @@ -1153,8 +1183,8 @@ void MyAvatar::applyCollision(const glm::vec3& contactPoint, const glm::vec3& pe if (leverLength > EPSILON) { // compute lean perturbation angles glm::quat bodyRotation = getOrientation(); - glm::vec3 xAxis = bodyRotation * glm::vec3(1.f, 0.f, 0.f); - glm::vec3 zAxis = bodyRotation * glm::vec3(0.f, 0.f, 1.f); + glm::vec3 xAxis = bodyRotation * glm::vec3(1.0f, 0.0f, 0.0f); + glm::vec3 zAxis = bodyRotation * glm::vec3(0.0f, 0.0f, 1.0f); leverAxis = leverAxis / leverLength; glm::vec3 effectivePenetration = penetration - glm::dot(penetration, leverAxis) * leverAxis; diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h index 38edc5356e..66ab322444 100644 --- a/interface/src/avatar/MyAvatar.h +++ b/interface/src/avatar/MyAvatar.h @@ -1,13 +1,16 @@ // // MyAvatar.h -// interface +// interface/src/avatar // // Created by Mark Peng on 8/16/13. -// Copyright (c) 2012 High Fidelity, Inc. All rights reserved. +// Copyright 2012 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__myavatar__ -#define __interface__myavatar__ +#ifndef hifi_MyAvatar_h +#define hifi_MyAvatar_h #include @@ -50,12 +53,10 @@ public: void setShouldRenderLocally(bool shouldRender) { _shouldRender = shouldRender; } // getters - float getSpeed() const { return _speed; } AvatarMode getMode() const { return _mode; } float getLeanScale() const { return _leanScale; } float getElapsedTimeStopped() const { return _elapsedTimeStopped; } float getElapsedTimeMoving() const { return _elapsedTimeMoving; } - float getAbsoluteHeadYaw() const; // degrees const glm::vec3& getMouseRayOrigin() const { return _mouseRayOrigin; } const glm::vec3& getMouseRayDirection() const { return _mouseRayDirection; } glm::vec3 getGravity() const { return _gravity; } @@ -105,6 +106,9 @@ public slots: glm::vec3 getThrust() { return _thrust; }; void setThrust(glm::vec3 newThrust) { _thrust = newThrust; } +signals: + void transformChanged(); + private: bool _mousePressed; float _bodyPitchDelta; // degrees @@ -121,12 +125,13 @@ private: bool _isThrustOn; float _thrustMultiplier; glm::vec3 _moveTarget; + glm::vec3 _lastBodyPenetration; int _moveTargetStepCounter; QWeakPointer _lookAtTargetAvatar; glm::vec3 _targetAvatarPosition; bool _shouldRender; - bool _billboardValid; + float _oculusYawOffset; // private methods void updateThrust(float deltaTime); @@ -140,4 +145,4 @@ private: void maybeUpdateBillboard(); }; -#endif +#endif // hifi_MyAvatar_h diff --git a/interface/src/avatar/SkeletonModel.cpp b/interface/src/avatar/SkeletonModel.cpp index ca18c62718..b9ac280711 100644 --- a/interface/src/avatar/SkeletonModel.cpp +++ b/interface/src/avatar/SkeletonModel.cpp @@ -1,9 +1,12 @@ // // SkeletonModel.cpp -// interface +// interface/src/avatar // // Created by Andrzej Kapolka on 10/17/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include @@ -14,7 +17,7 @@ #include "Menu.h" #include "SkeletonModel.h" -SkeletonModel::SkeletonModel(Avatar* owningAvatar) : +SkeletonModel::SkeletonModel(Avatar* owningAvatar) : _owningAvatar(owningAvatar) { } @@ -63,7 +66,7 @@ void SkeletonModel::simulate(float deltaTime, bool fullUpdate) { } void SkeletonModel::getHandShapes(int jointIndex, QVector& shapes) const { - if (jointIndex < 0 || jointIndex >= int(_shapes.size())) { + if (jointIndex < 0 || jointIndex >= int(_jointShapes.size())) { return; } if (jointIndex == getLeftHandJointIndex() @@ -75,16 +78,16 @@ void SkeletonModel::getHandShapes(int jointIndex, QVector& shapes) int parentIndex = joint.parentIndex; if (i == jointIndex) { // this shape is the hand - shapes.push_back(_shapes[i]); + shapes.push_back(_jointShapes[i]); if (parentIndex != -1) { // also add the forearm - shapes.push_back(_shapes[parentIndex]); + shapes.push_back(_jointShapes[parentIndex]); } } else { while (parentIndex != -1) { if (parentIndex == jointIndex) { // this shape is a child of the hand - shapes.push_back(_shapes[i]); + shapes.push_back(_jointShapes[i]); break; } parentIndex = geometry.joints[parentIndex].parentIndex; @@ -94,6 +97,12 @@ void SkeletonModel::getHandShapes(int jointIndex, QVector& shapes) } } +void SkeletonModel::getBodyShapes(QVector& shapes) const { + // for now we push a single bounding shape, + // but later we could push a subset of joint shapes + shapes.push_back(&_boundingShape); +} + class IndexValue { public: int index; diff --git a/interface/src/avatar/SkeletonModel.h b/interface/src/avatar/SkeletonModel.h index 213a53d9ed..2020ccf3b2 100644 --- a/interface/src/avatar/SkeletonModel.h +++ b/interface/src/avatar/SkeletonModel.h @@ -1,14 +1,16 @@ // // SkeletonModel.h -// interface +// interface/src/avatar // // Created by Andrzej Kapolka on 10/17/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__SkeletonModel__ -#define __interface__SkeletonModel__ - +#ifndef hifi_SkeletonModel_h +#define hifi_SkeletonModel_h #include "renderer/Model.h" @@ -28,8 +30,11 @@ public: /// \param shapes[out] list in which is stored pointers to hand shapes void getHandShapes(int jointIndex, QVector& shapes) const; + /// \param shapes[out] list of shapes for body collisions + void getBodyShapes(QVector& shapes) const; + protected: - + void applyHandPosition(int jointIndex, const glm::vec3& position); void applyPalmData(int jointIndex, const QVector& fingerJointIndices, @@ -45,4 +50,4 @@ private: Avatar* _owningAvatar; }; -#endif /* defined(__interface__SkeletonModel__) */ +#endif // hifi_SkeletonModel_h diff --git a/interface/src/devices/FaceTracker.cpp b/interface/src/devices/FaceTracker.cpp new file mode 100644 index 0000000000..52fe04de77 --- /dev/null +++ b/interface/src/devices/FaceTracker.cpp @@ -0,0 +1,17 @@ +// +// FaceTracker.cpp +// interface/src/devices +// +// Created by Andrzej Kapolka on 4/9/14. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include "FaceTracker.h" + +FaceTracker::FaceTracker() : + _estimatedEyePitch(0.0f), + _estimatedEyeYaw(0.0f) { +} diff --git a/interface/src/devices/FaceTracker.h b/interface/src/devices/FaceTracker.h new file mode 100644 index 0000000000..459f38cafc --- /dev/null +++ b/interface/src/devices/FaceTracker.h @@ -0,0 +1,46 @@ +// +// FaceTracker.h +// interface/src/devices +// +// Created by Andrzej Kapolka on 4/9/14. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_FaceTracker_h +#define hifi_FaceTracker_h + +#include +#include + +#include +#include + +/// Base class for face trackers (Faceshift, Visage, Faceplus). +class FaceTracker : public QObject { + Q_OBJECT + +public: + + FaceTracker(); + + const glm::vec3& getHeadTranslation() const { return _headTranslation; } + const glm::quat& getHeadRotation() const { return _headRotation; } + + float getEstimatedEyePitch() const { return _estimatedEyePitch; } + float getEstimatedEyeYaw() const { return _estimatedEyeYaw; } + + const QVector& getBlendshapeCoefficients() const { return _blendshapeCoefficients; } + +protected: + + glm::vec3 _headTranslation; + glm::quat _headRotation; + float _estimatedEyePitch; + float _estimatedEyeYaw; + QVector _blendshapeCoefficients; +}; + +#endif // hifi_FaceTracker_h diff --git a/interface/src/devices/Faceplus.cpp b/interface/src/devices/Faceplus.cpp new file mode 100644 index 0000000000..f7f2f1f1bd --- /dev/null +++ b/interface/src/devices/Faceplus.cpp @@ -0,0 +1,230 @@ +// +// Faceplus.cpp +// interface/src/devices +// +// Created by Andrzej Kapolka on 4/9/14. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include + +#ifdef HAVE_FACEPLUS +#include +#endif + +#include "Application.h" +#include "Faceplus.h" +#include "renderer/FBXReader.h" + +static int floatVectorMetaTypeId = qRegisterMetaType >(); + +Faceplus::Faceplus() : + _enabled(false), + _active(false) { + +#ifdef HAVE_FACEPLUS + // these are ignored--any values will do + faceplus_log_in("username", "password"); +#endif +} + +Faceplus::~Faceplus() { + setEnabled(false); +} + +void Faceplus::init() { + connect(Application::getInstance()->getFaceshift(), SIGNAL(connectionStateChanged()), SLOT(updateEnabled())); + updateEnabled(); +} + +void Faceplus::setState(const glm::quat& headRotation, float estimatedEyePitch, float estimatedEyeYaw, + const QVector& blendshapeCoefficients) { + _headRotation = headRotation; + _estimatedEyePitch = estimatedEyePitch; + _estimatedEyeYaw = estimatedEyeYaw; + _blendshapeCoefficients = blendshapeCoefficients; + _active = true; +} + +void Faceplus::updateEnabled() { + setEnabled(Menu::getInstance()->isOptionChecked(MenuOption::Faceplus) && + !(Menu::getInstance()->isOptionChecked(MenuOption::Faceshift) && + Application::getInstance()->getFaceshift()->isConnectedOrConnecting())); +} + +void Faceplus::setEnabled(bool enabled) { + if (_enabled == enabled) { + return; + } + if ((_enabled = enabled)) { + _reader = new FaceplusReader(); + QThread* readerThread = new QThread(this); + _reader->moveToThread(readerThread); + readerThread->start(); + QMetaObject::invokeMethod(_reader, "init"); + + } else { + QThread* readerThread = _reader->thread(); + QMetaObject::invokeMethod(_reader, "shutdown"); + readerThread->wait(); + delete readerThread; + _active = false; + } +} + +#ifdef HAVE_FACEPLUS +static QMultiHash > createChannelNameMap() { + QMultiHash > blendshapeMap; + blendshapeMap.insert("EyeBlink_L", QPair("Mix::Blink_Left", 1.0f)); + blendshapeMap.insert("EyeBlink_R", QPair("Mix::Blink_Right", 1.0f)); + blendshapeMap.insert("BrowsD_L", QPair("Mix::BrowsDown_Left", 1.0f)); + blendshapeMap.insert("BrowsD_R", QPair("Mix::BrowsDown_Right", 1.0f)); + blendshapeMap.insert("...", QPair("Mix::BrowsIn_Left", 1.0f)); + blendshapeMap.insert("...", QPair("Mix::BrowsIn_Right", 1.0f)); + blendshapeMap.insert("...", QPair("Mix::BrowsOuterLower_Left", 1.0f)); + blendshapeMap.insert("...", QPair("Mix::BrowsOuterLower_Right", 1.0f)); + blendshapeMap.insert("BrowsU_L", QPair("Mix::BrowsUp_Left", 10.0f)); + blendshapeMap.insert("BrowsU_R", QPair("Mix::BrowsUp_Right", 10.0f)); + blendshapeMap.insert("EyeOpen_L", QPair("Mix::EyesWide_Left", 1.0f)); + blendshapeMap.insert("EyeOpen_R", QPair("Mix::EyesWide_Right", 1.0f)); + blendshapeMap.insert("MouthFrown_L", QPair("Mix::Frown_Left", 1.0f)); + blendshapeMap.insert("MouthFrown_R", QPair("Mix::Frown_Right", 1.0f)); + blendshapeMap.insert("JawLeft", QPair("Mix::Jaw_RotateY_Left", 1.0f)); + blendshapeMap.insert("JawRight", QPair("Mix::Jaw_RotateY_Right", 1.0f)); + blendshapeMap.insert("LipsLowerDown", QPair("Mix::LowerLipDown_Left", 0.5f)); + blendshapeMap.insert("LipsLowerDown", QPair("Mix::LowerLipDown_Right", 0.5f)); + blendshapeMap.insert("...", QPair("Mix::LowerLipIn", 1.0f)); + blendshapeMap.insert("...", QPair("Mix::LowerLipOut", 1.0f)); + blendshapeMap.insert("MouthLeft", QPair("Mix::Midmouth_Left", 1.0f)); + blendshapeMap.insert("MouthRight", QPair("Mix::Midmouth_Right", 1.0f)); + blendshapeMap.insert("...", QPair("Mix::MouthDown", 1.0f)); + blendshapeMap.insert("...", QPair("Mix::MouthNarrow_Left", 1.0f)); + blendshapeMap.insert("...", QPair("Mix::MouthNarrow_Right", 1.0f)); + blendshapeMap.insert("JawOpen", QPair("Mix::MouthOpen", 1.0f)); + blendshapeMap.insert("...", QPair("Mix::MouthUp", 1.0f)); + blendshapeMap.insert("LipsPucker", QPair("Mix::MouthWhistle_NarrowAdjust_Left", 0.5f)); + blendshapeMap.insert("LipsPucker", QPair("Mix::MouthWhistle_NarrowAdjust_Right", 0.5f)); + blendshapeMap.insert("Sneer", QPair("Mix::NoseScrunch_Left", 0.5f)); + blendshapeMap.insert("Sneer", QPair("Mix::NoseScrunch_Right", 0.5f)); + blendshapeMap.insert("MouthSmile_L", QPair("Mix::Smile_Left", 1.0f)); + blendshapeMap.insert("MouthSmile_R", QPair("Mix::Smile_Right", 1.0f)); + blendshapeMap.insert("EyeSquint_L", QPair("Mix::Squint_Left", 1.0f)); + blendshapeMap.insert("EyeSquint_R", QPair("Mix::Squint_Right", 1.0f)); + blendshapeMap.insert("...", QPair("Mix::UpperLipIn", 1.0f)); + blendshapeMap.insert("...", QPair("Mix::UpperLipOut", 1.0f)); + blendshapeMap.insert("LipsUpperUp", QPair("Mix::UpperLipUp_Left", 0.5f)); + blendshapeMap.insert("LipsUpperUp", QPair("Mix::UpperLipUp_Right", 0.5f)); + + QMultiHash > channelNameMap; + for (int i = 0;; i++) { + QByteArray blendshape = FACESHIFT_BLENDSHAPES[i]; + if (blendshape.isEmpty()) { + break; + } + for (QMultiHash >::const_iterator it = blendshapeMap.constFind(blendshape); + it != blendshapeMap.constEnd() && it.key() == blendshape; it++) { + channelNameMap.insert(it.value().first, QPair(i, it.value().second)); + } + } + + return channelNameMap; +} + +static const QMultiHash >& getChannelNameMap() { + static QMultiHash > channelNameMap = createChannelNameMap(); + return channelNameMap; +} +#endif + +FaceplusReader::~FaceplusReader() { +#ifdef HAVE_FACEPLUS + if (faceplus_teardown()) { + qDebug() << "Faceplus torn down."; + } +#endif +} + +void FaceplusReader::init() { +#ifdef HAVE_FACEPLUS + if (!faceplus_init("VGA")) { + qDebug() << "Failed to initialized Faceplus."; + return; + } + qDebug() << "Faceplus initialized."; + + int channelCount = faceplus_output_channels_count(); + _outputVector.resize(channelCount); + + int maxIndex = -1; + _channelIndexMap.clear(); + for (int i = 0; i < channelCount; i++) { + QByteArray name = faceplus_output_channel_name(i); + if (name == "Head_Joint::Rotation_X") { + _headRotationIndices[0] = i; + + } else if (name == "Head_Joint::Rotation_Y") { + _headRotationIndices[1] = i; + + } else if (name == "Head_Joint::Rotation_Z") { + _headRotationIndices[2] = i; + + } else if (name == "Left_Eye_Joint::Rotation_X") { + _leftEyeRotationIndices[0] = i; + + } else if (name == "Left_Eye_Joint::Rotation_Y") { + _leftEyeRotationIndices[1] = i; + + } else if (name == "Right_Eye_Joint::Rotation_X") { + _rightEyeRotationIndices[0] = i; + + } else if (name == "Right_Eye_Joint::Rotation_Y") { + _rightEyeRotationIndices[1] = i; + } + for (QMultiHash >::const_iterator it = getChannelNameMap().constFind(name); + it != getChannelNameMap().constEnd() && it.key() == name; it++) { + _channelIndexMap.insert(i, it.value()); + maxIndex = qMax(maxIndex, it.value().first); + } + } + _blendshapeCoefficients.resize(maxIndex + 1); + + QMetaObject::invokeMethod(this, "update", Qt::QueuedConnection); +#endif +} + +void FaceplusReader::shutdown() { + deleteLater(); + thread()->quit(); +} + +void FaceplusReader::update() { +#ifdef HAVE_FACEPLUS + if (!(faceplus_synchronous_track() && faceplus_current_output_vector(_outputVector.data()))) { + QMetaObject::invokeMethod(this, "update", Qt::QueuedConnection); + return; + } + glm::quat headRotation(glm::radians(glm::vec3(-_outputVector.at(_headRotationIndices[0]), + _outputVector.at(_headRotationIndices[1]), -_outputVector.at(_headRotationIndices[2])))); + float estimatedEyePitch = (_outputVector.at(_leftEyeRotationIndices[0]) + + _outputVector.at(_rightEyeRotationIndices[0])) * -0.5f; + float estimatedEyeYaw = (_outputVector.at(_leftEyeRotationIndices[1]) + + _outputVector.at(_rightEyeRotationIndices[1])) * 0.5f; + + qFill(_blendshapeCoefficients.begin(), _blendshapeCoefficients.end(), 0.0f); + for (int i = 0; i < _outputVector.size(); i++) { + for (QMultiHash >::const_iterator it = _channelIndexMap.constFind(i); + it != _channelIndexMap.constEnd() && it.key() == i; it++) { + _blendshapeCoefficients[it.value().first] += _outputVector.at(i) * it.value().second; + } + } + + QMetaObject::invokeMethod(Application::getInstance()->getFaceplus(), "setState", Q_ARG(const glm::quat&, headRotation), + Q_ARG(float, estimatedEyePitch), Q_ARG(float, estimatedEyeYaw), Q_ARG(const QVector&, _blendshapeCoefficients)); + + QMetaObject::invokeMethod(this, "update", Qt::QueuedConnection); +#endif +} + diff --git a/interface/src/devices/Faceplus.h b/interface/src/devices/Faceplus.h new file mode 100644 index 0000000000..2b9219f3fd --- /dev/null +++ b/interface/src/devices/Faceplus.h @@ -0,0 +1,79 @@ +// +// Faceplus.h +// interface/src/devices +// +// Created by Andrzej Kapolka on 4/9/14. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_Faceplus_h +#define hifi_Faceplus_h + +#include +#include +#include + +#include "FaceTracker.h" + +class FaceplusReader; + +/// Interface for Mixamo FacePlus. +class Faceplus : public FaceTracker { + Q_OBJECT + +public: + + Faceplus(); + virtual ~Faceplus(); + + void init(); + + bool isActive() const { return _active; } + + Q_INVOKABLE void setState(const glm::quat& headRotation, float estimatedEyePitch, float estimatedEyeYaw, + const QVector& blendshapeCoefficients); + +public slots: + + void updateEnabled(); + +private: + + void setEnabled(bool enabled); + + bool _enabled; + bool _active; + + FaceplusReader* _reader; +}; + +Q_DECLARE_METATYPE(QVector) + +/// The reader object that lives in its own thread. +class FaceplusReader : public QObject { + Q_OBJECT + +public: + + virtual ~FaceplusReader(); + + Q_INVOKABLE void init(); + Q_INVOKABLE void shutdown(); + Q_INVOKABLE void update(); + +private: + +#ifdef HAVE_FACEPLUS + QMultiHash > _channelIndexMap; + QVector _outputVector; + int _headRotationIndices[3]; + int _leftEyeRotationIndices[2]; + int _rightEyeRotationIndices[2]; + QVector _blendshapeCoefficients; +#endif +}; + +#endif // hifi_Faceplus_h diff --git a/interface/src/devices/Faceshift.cpp b/interface/src/devices/Faceshift.cpp index 9f1734c7e5..59f2c245df 100644 --- a/interface/src/devices/Faceshift.cpp +++ b/interface/src/devices/Faceshift.cpp @@ -1,9 +1,12 @@ // // Faceshift.cpp -// interface +// interface/src/devices // // Created by Andrzej Kapolka on 9/3/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include @@ -42,9 +45,7 @@ Faceshift::Faceshift() : _jawOpenIndex(21), _longTermAverageEyePitch(0.0f), _longTermAverageEyeYaw(0.0f), - _longTermAverageInitialized(false), - _estimatedEyePitch(0.0f), - _estimatedEyeYaw(0.0f) + _longTermAverageInitialized(false) { connect(&_tcpSocket, SIGNAL(connected()), SLOT(noteConnected())); connect(&_tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(noteError(QAbstractSocket::SocketError))); diff --git a/interface/src/devices/Faceshift.h b/interface/src/devices/Faceshift.h index f878056b57..2fc1aaddb1 100644 --- a/interface/src/devices/Faceshift.h +++ b/interface/src/devices/Faceshift.h @@ -1,24 +1,26 @@ // // Faceshift.h -// interface +// interface/src/devices // // Created by Andrzej Kapolka on 9/3/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__Faceshift__ -#define __interface__Faceshift__ +#ifndef hifi_Faceshift_h +#define hifi_Faceshift_h #include #include -#include -#include - #include +#include "FaceTracker.h" + /// Handles interaction with the Faceshift software, which provides head position/orientation and facial features. -class Faceshift : public QObject { +class Faceshift : public FaceTracker { Q_OBJECT public: @@ -31,9 +33,7 @@ public: bool isActive() const; - const glm::quat& getHeadRotation() const { return _headRotation; } const glm::vec3& getHeadAngularVelocity() const { return _headAngularVelocity; } - const glm::vec3& getHeadTranslation() const { return _headTranslation; } // these pitch/yaw angles are in degrees float getEyeGazeLeftPitch() const { return _eyeGazeLeftPitch; } @@ -42,11 +42,6 @@ public: float getEyeGazeRightPitch() const { return _eyeGazeRightPitch; } float getEyeGazeRightYaw() const { return _eyeGazeRightYaw; } - float getEstimatedEyePitch() const { return _estimatedEyePitch; } - float getEstimatedEyeYaw() const { return _estimatedEyeYaw; } - - const QVector& getBlendshapeCoefficients() const { return _blendshapeCoefficients; } - float getLeftBlink() const { return getBlendshapeCoefficient(_leftBlinkIndex); } float getRightBlink() const { return getBlendshapeCoefficient(_rightBlinkIndex); } float getLeftEyeOpen() const { return getBlendshapeCoefficient(_leftEyeOpenIndex); } @@ -99,9 +94,7 @@ private: bool _tracking; quint64 _lastTrackingStateReceived; - glm::quat _headRotation; glm::vec3 _headAngularVelocity; - glm::vec3 _headTranslation; // degrees float _eyeGazeLeftPitch; @@ -109,8 +102,6 @@ private: float _eyeGazeRightPitch; float _eyeGazeRightYaw; - QVector _blendshapeCoefficients; - int _leftBlinkIndex; int _rightBlinkIndex; int _leftEyeOpenIndex; @@ -132,10 +123,6 @@ private: float _longTermAverageEyePitch; float _longTermAverageEyeYaw; bool _longTermAverageInitialized; - - // degrees - float _estimatedEyePitch; - float _estimatedEyeYaw; }; -#endif /* defined(__interface__Faceshift__) */ +#endif // hifi_Faceshift_h diff --git a/interface/src/devices/OculusManager.cpp b/interface/src/devices/OculusManager.cpp index c5377ce428..d3da8fe7c3 100644 --- a/interface/src/devices/OculusManager.cpp +++ b/interface/src/devices/OculusManager.cpp @@ -1,9 +1,12 @@ // // OculusManager.cpp -// hifi +// interface/src/devices // // Created by Stephen Birarda on 5/9/13. -// Copyright (c) 2012 High Fidelity, Inc. All rights reserved. +// Copyright 2012 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "InterfaceConfig.h" @@ -27,7 +30,6 @@ int OculusManager::_scaleLocation; int OculusManager::_scaleInLocation; int OculusManager::_hmdWarpParamLocation; bool OculusManager::_isConnected = false; -float OculusManager::_yawOffset = 0.0f; // radians #ifdef HAVE_LIBOVR using namespace OVR; @@ -187,18 +189,9 @@ void OculusManager::reset() { #endif } -void OculusManager::updateYawOffset() { -#ifdef HAVE_LIBOVR - float yaw, pitch, roll; - _sensorFusion->GetOrientation().GetEulerAngles(&yaw, &pitch, &roll); - _yawOffset = yaw; -#endif -} - void OculusManager::getEulerAngles(float& yaw, float& pitch, float& roll) { #ifdef HAVE_LIBOVR _sensorFusion->GetOrientation().GetEulerAngles(&yaw, &pitch, &roll); - yaw = yaw - _yawOffset; #endif } diff --git a/interface/src/devices/OculusManager.h b/interface/src/devices/OculusManager.h index b3cd400ac8..6376df05ca 100644 --- a/interface/src/devices/OculusManager.h +++ b/interface/src/devices/OculusManager.h @@ -1,13 +1,16 @@ // // OculusManager.h -// hifi +// interface/src/devices // // Created by Stephen Birarda on 5/9/13. -// Copyright (c) 2012 High Fidelity, Inc. All rights reserved. +// Copyright 2012 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__OculusManager__ -#define __hifi__OculusManager__ +#ifndef hifi_OculusManager_h +#define hifi_OculusManager_h #include @@ -48,7 +51,6 @@ private: static int _scaleInLocation; static int _hmdWarpParamLocation; static bool _isConnected; - static float _yawOffset; #ifdef HAVE_LIBOVR static OVR::Ptr _deviceManager; @@ -59,4 +61,4 @@ private: #endif }; -#endif /* defined(__hifi__OculusManager__) */ +#endif // hifi_OculusManager_h diff --git a/interface/src/devices/SixenseManager.cpp b/interface/src/devices/SixenseManager.cpp index 8e54e034ac..b950e6097c 100644 --- a/interface/src/devices/SixenseManager.cpp +++ b/interface/src/devices/SixenseManager.cpp @@ -1,9 +1,12 @@ // -// Sixense.cpp -// interface +// SixenseManager.cpp +// interface/src/devices // // Created by Andrzej Kapolka on 11/15/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/interface/src/devices/SixenseManager.h b/interface/src/devices/SixenseManager.h index de4cccb399..2fc6b3dcb3 100644 --- a/interface/src/devices/SixenseManager.h +++ b/interface/src/devices/SixenseManager.h @@ -1,13 +1,16 @@ // // SixenseManager.h -// interface +// interface/src/devices // // Created by Andrzej Kapolka on 11/15/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__SixenseManager__ -#define __interface__SixenseManager__ +#ifndef hifi_SixenseManager_h +#define hifi_SixenseManager_h #include @@ -63,5 +66,4 @@ private: quint64 _lastMovement; }; -#endif /* defined(__interface__SixenseManager__) */ - +#endif // hifi_SixenseManager_h diff --git a/interface/src/devices/TV3DManager.cpp b/interface/src/devices/TV3DManager.cpp index 07aeea92b4..fcbef0385c 100644 --- a/interface/src/devices/TV3DManager.cpp +++ b/interface/src/devices/TV3DManager.cpp @@ -1,9 +1,12 @@ // // TV3DManager.cpp -// hifi +// interface/src/devices // // Created by Brad Hefta-Gaub on 12/24/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "InterfaceConfig.h" diff --git a/interface/src/devices/TV3DManager.h b/interface/src/devices/TV3DManager.h index edea489745..91a78e9bce 100644 --- a/interface/src/devices/TV3DManager.h +++ b/interface/src/devices/TV3DManager.h @@ -1,13 +1,16 @@ // // TV3DManager.h -// hifi +// interface/src/devices // -// Created by Brad Hefta-Gaub on 12/24/2013 -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 12/24/2013. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__TV3DManager__ -#define __hifi__TV3DManager__ +#ifndef hifi_TV3DManager_h +#define hifi_TV3DManager_h #include @@ -38,4 +41,4 @@ private: static eyeFrustum _rightEye; }; -#endif /* defined(__hifi__TV3DManager__) */ +#endif // hifi_TV3DManager_h diff --git a/interface/src/devices/Visage.cpp b/interface/src/devices/Visage.cpp index b96ef1ee72..e2f40e4741 100644 --- a/interface/src/devices/Visage.cpp +++ b/interface/src/devices/Visage.cpp @@ -1,9 +1,12 @@ // // Visage.cpp -// interface +// interface/src/devices // // Created by Andrzej Kapolka on 2/11/14. -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include @@ -34,9 +37,7 @@ const glm::vec3 DEFAULT_HEAD_ORIGIN(0.0f, 0.0f, 0.7f); Visage::Visage() : _enabled(false), _active(false), - _headOrigin(DEFAULT_HEAD_ORIGIN), - _estimatedEyePitch(0.0f), - _estimatedEyeYaw(0.0f) { + _headOrigin(DEFAULT_HEAD_ORIGIN) { #ifdef HAVE_VISAGE QByteArray licensePath = Application::resourcesPath().toLatin1() + "visage/license.vlc"; @@ -161,6 +162,7 @@ void Visage::reset() { void Visage::updateEnabled() { setEnabled(Menu::getInstance()->isOptionChecked(MenuOption::Visage) && + !Menu::getInstance()->isOptionChecked(MenuOption::Faceplus) && !(Menu::getInstance()->isOptionChecked(MenuOption::Faceshift) && Application::getInstance()->getFaceshift()->isConnectedOrConnecting())); } diff --git a/interface/src/devices/Visage.h b/interface/src/devices/Visage.h index 6e98abbb61..33e2f0a7e1 100644 --- a/interface/src/devices/Visage.h +++ b/interface/src/devices/Visage.h @@ -1,20 +1,22 @@ // // Visage.h -// interface +// interface/src/devices // // Created by Andrzej Kapolka on 2/11/14. -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__Visage__ -#define __interface__Visage__ +#ifndef hifi_Visage_h +#define hifi_Visage_h #include #include #include -#include -#include +#include "FaceTracker.h" namespace VisageSDK { class VisageTracker2; @@ -22,7 +24,7 @@ namespace VisageSDK { } /// Handles input from the Visage webcam feature tracking software. -class Visage : public QObject { +class Visage : public FaceTracker { Q_OBJECT public: @@ -34,14 +36,6 @@ public: bool isActive() const { return _active; } - const glm::quat& getHeadRotation() const { return _headRotation; } - const glm::vec3& getHeadTranslation() const { return _headTranslation; } - - float getEstimatedEyePitch() const { return _estimatedEyePitch; } - float getEstimatedEyeYaw() const { return _estimatedEyeYaw; } - - const QVector& getBlendshapeCoefficients() const { return _blendshapeCoefficients; } - void update(); void reset(); @@ -61,15 +55,8 @@ private: bool _enabled; bool _active; - glm::quat _headRotation; - glm::vec3 _headTranslation; - + glm::vec3 _headOrigin; - - float _estimatedEyePitch; - float _estimatedEyeYaw; - - QVector _blendshapeCoefficients; }; -#endif /* defined(__interface__Visage__) */ +#endif // hifi_Visage_h diff --git a/interface/src/location/LocationManager.cpp b/interface/src/location/LocationManager.cpp index b83094ba4c..8009551b6c 100644 --- a/interface/src/location/LocationManager.cpp +++ b/interface/src/location/LocationManager.cpp @@ -1,9 +1,12 @@ // // LocationManager.cpp -// hifi +// interface/src/location // // Created by Stojce Slavkovski on 2/7/14. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "Application.h" @@ -115,8 +118,6 @@ void LocationManager::checkForMultipleDestinations() { Application::getInstance()->getAvatar()->goToLocationFromResponse(_placeData); return; } - - emit locationChanged(); } } @@ -175,6 +176,7 @@ void LocationManager::goToOrientation(QString orientation) { glm::quat avatarOrientation = myAvatar->getOrientation(); if (newAvatarOrientation != avatarOrientation) { myAvatar->setOrientation(newAvatarOrientation); + emit myAvatar->transformChanged(); } } } @@ -208,6 +210,7 @@ bool LocationManager::goToDestination(QString destination) { qDebug("Going To Location: %f, %f, %f...", x, y, z); myAvatar->setPosition(newAvatarPos); + emit myAvatar->transformChanged(); } return true; diff --git a/interface/src/location/LocationManager.h b/interface/src/location/LocationManager.h index a6bdaf66b4..ac66b3d08b 100644 --- a/interface/src/location/LocationManager.h +++ b/interface/src/location/LocationManager.h @@ -1,13 +1,16 @@ // // LocationManager.h -// hifi +// interface/src/location // // Created by Stojce Slavkovski on 2/7/14. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__LocationManager__ -#define __hifi__LocationManager__ +#ifndef hifi_LocationManager_h +#define hifi_LocationManager_h #include @@ -45,7 +48,6 @@ private: signals: void creationCompleted(LocationManager::NamedLocationCreateResponse response); void multipleDestinationsFound(const QJsonObject& userData, const QJsonObject& placeData); - void locationChanged(); private slots: void namedLocationDataReceived(const QJsonObject& data); @@ -55,4 +57,4 @@ private slots: }; -#endif /* defined(__hifi__LocationManager__) */ +#endif // hifi_LocationManager_h diff --git a/interface/src/location/NamedLocation.cpp b/interface/src/location/NamedLocation.cpp index c6daef4961..ed7701a391 100644 --- a/interface/src/location/NamedLocation.cpp +++ b/interface/src/location/NamedLocation.cpp @@ -1,9 +1,12 @@ // -// LocationManager.cpp -// hifi +// NamedLocation.cpp +// interface/src/location // // Created by Stojce Slavkovski on 2/1/14. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "NamedLocation.h" diff --git a/interface/src/location/NamedLocation.h b/interface/src/location/NamedLocation.h index 81af03b45e..ffbd157263 100644 --- a/interface/src/location/NamedLocation.h +++ b/interface/src/location/NamedLocation.h @@ -1,13 +1,16 @@ // // NamedLocation.h -// hifi +// interface/src/location // // Created by Stojce Slavkovski on 2/1/14. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__NamedLocation__ -#define __hifi__NamedLocation__ +#ifndef hifi_NamedLocation_h +#define hifi_NamedLocation_h #include #include @@ -55,4 +58,4 @@ private: }; -#endif /* defined(__hifi__NamedLocation__) */ +#endif // hifi_NamedLocation_h diff --git a/interface/src/main.cpp b/interface/src/main.cpp index f2c516792b..40e2a9ab27 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -1,18 +1,11 @@ -// -// Interface // -// Allows you to connect to and see/hear the shared 3D space. -// Optionally uses serialUSB connection to get gyro data for head movement. -// Optionally gets UDP stream from transmitter to animate controller/hand. -// -// Usage: The interface client first attempts to contact a domain server to -// discover the appropriate audio, voxel, and avatar servers to contact. -// Right now, the default domain server is "highfidelity.below92.com" -// You can change the domain server to use your own by editing the -// DOMAIN_HOSTNAME or DOMAIN_IP strings in the file NodeList.cpp +// main.cpp +// interface/src // +// Copyright 2013 High Fidelity, Inc. // -// Welcome Aboard! +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "Application.h" diff --git a/interface/src/renderer/AmbientOcclusionEffect.cpp b/interface/src/renderer/AmbientOcclusionEffect.cpp index a492552e7c..635e6c9bd6 100644 --- a/interface/src/renderer/AmbientOcclusionEffect.cpp +++ b/interface/src/renderer/AmbientOcclusionEffect.cpp @@ -1,9 +1,12 @@ // // AmbientOcclusionEffect.cpp -// interface +// interface/src/renderer // // Created by Andrzej Kapolka on 7/14/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // // include this before QOpenGLFramebufferObject, which includes an earlier version of OpenGL diff --git a/interface/src/renderer/AmbientOcclusionEffect.h b/interface/src/renderer/AmbientOcclusionEffect.h index e56164bad4..3b22c7629a 100644 --- a/interface/src/renderer/AmbientOcclusionEffect.h +++ b/interface/src/renderer/AmbientOcclusionEffect.h @@ -1,13 +1,16 @@ // // AmbientOcclusionEffect.h -// interface +// interface/src/renderer // // Created by Andrzej Kapolka on 7/14/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__AmbientOcclusionEffect__ -#define __interface__AmbientOcclusionEffect__ +#ifndef hifi_AmbientOcclusionEffect_h +#define hifi_AmbientOcclusionEffect_h class ProgramObject; @@ -37,4 +40,4 @@ private: GLuint _rotationTextureID; }; -#endif /* defined(__interface__AmbientOcclusionEffect__) */ +#endif // hifi_AmbientOcclusionEffect_h diff --git a/interface/src/renderer/FBXReader.cpp b/interface/src/renderer/FBXReader.cpp index 9a8ba43e34..959c015eea 100644 --- a/interface/src/renderer/FBXReader.cpp +++ b/interface/src/renderer/FBXReader.cpp @@ -1,9 +1,12 @@ // // FBXReader.cpp -// interface +// interface/src/renderer // // Created by Andrzej Kapolka on 9/18/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include @@ -41,6 +44,11 @@ bool Extents::containsPoint(const glm::vec3& point) const { && point.z >= minimum.z && point.z <= maximum.z); } +void Extents::addExtents(const Extents& extents) { + minimum = glm::min(minimum, extents.minimum); + maximum = glm::max(maximum, extents.maximum); +} + void Extents::addPoint(const glm::vec3& point) { minimum = glm::min(minimum, point); maximum = glm::max(maximum, point); @@ -1343,7 +1351,6 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping) } geometry.bindExtents.reset(); - geometry.staticExtents.reset(); geometry.meshExtents.reset(); for (QHash::iterator it = meshes.begin(); it != meshes.end(); it++) { @@ -1511,8 +1518,6 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping) JointShapeInfo& jointShapeInfo = jointShapeInfos[jointIndex]; jointShapeInfo.boneBegin = rotateMeshToJoint * (radiusScale * (boneBegin - boneEnd)); - bool jointIsStatic = joint.freeLineage.isEmpty(); - glm::vec3 jointTranslation = extractTranslation(geometry.offset * joint.bindTransform); float totalWeight = 0.0f; for (int j = 0; j < cluster.indices.size(); j++) { int oldIndex = cluster.indices.at(j); @@ -1534,10 +1539,6 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping) jointShapeInfo.extents.addPoint(vertexInJointFrame); jointShapeInfo.averageVertex += vertexInJointFrame; ++jointShapeInfo.numVertices; - if (jointIsStatic) { - // expand the extents of static (nonmovable) joints - geometry.staticExtents.addPoint(vertex + jointTranslation); - } } // look for an unused slot in the weights vector diff --git a/interface/src/renderer/FBXReader.h b/interface/src/renderer/FBXReader.h index 5f6a4f51ba..73c305e2eb 100644 --- a/interface/src/renderer/FBXReader.h +++ b/interface/src/renderer/FBXReader.h @@ -1,13 +1,16 @@ // // FBXReader.h -// interface +// interface/src/renderer // // Created by Andrzej Kapolka on 9/18/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__FBXReader__ -#define __interface__FBXReader__ +#ifndef hifi_FBXReader_h +#define hifi_FBXReader_h #include #include @@ -30,6 +33,10 @@ public: /// set minimum and maximum to FLT_MAX and -FLT_MAX respectively void reset(); + /// \param extents another intance of extents + /// expand current limits to contain other extents + void addExtents(const Extents& extents); + /// \param point new point to compare against existing limits /// compare point to current limits and expand them if necessary to contain point void addPoint(const glm::vec3& point); @@ -174,7 +181,6 @@ public: glm::vec3 neckPivot; Extents bindExtents; - Extents staticExtents; Extents meshExtents; QVector attachments; @@ -197,4 +203,4 @@ FBXGeometry readFBX(const QByteArray& model, const QVariantHash& mapping); /// Reads SVO geometry from the supplied model data. FBXGeometry readSVO(const QByteArray& model); -#endif /* defined(__interface__FBXReader__) */ +#endif // hifi_FBXReader_h diff --git a/interface/src/renderer/GeometryCache.cpp b/interface/src/renderer/GeometryCache.cpp index b835e91a12..7b4eef1ac1 100644 --- a/interface/src/renderer/GeometryCache.cpp +++ b/interface/src/renderer/GeometryCache.cpp @@ -1,9 +1,13 @@ // // GeometryCache.cpp -// interface +// interface/src/renderer // // Created by Andrzej Kapolka on 6/21/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// #include diff --git a/interface/src/renderer/GeometryCache.h b/interface/src/renderer/GeometryCache.h index 252a0c401b..c2d276fb5e 100644 --- a/interface/src/renderer/GeometryCache.h +++ b/interface/src/renderer/GeometryCache.h @@ -1,13 +1,16 @@ // // GeometryCache.h -// interface +// interface/src/renderer // // Created by Andrzej Kapolka on 6/21/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__GeometryCache__ -#define __interface__GeometryCache__ +#ifndef hifi_GeometryCache_h +#define hifi_GeometryCache_h // include this before QOpenGLBuffer, which includes an earlier version of OpenGL #include "InterfaceConfig.h" @@ -137,4 +140,4 @@ public: int getTranslucentPartCount() const; }; -#endif /* defined(__interface__GeometryCache__) */ +#endif // hifi_GeometryCache_h diff --git a/interface/src/renderer/GlowEffect.cpp b/interface/src/renderer/GlowEffect.cpp index f926a81941..b52e8d8531 100644 --- a/interface/src/renderer/GlowEffect.cpp +++ b/interface/src/renderer/GlowEffect.cpp @@ -1,9 +1,13 @@ // // GlowEffect.cpp -// interface +// interface/src/renderer // // Created by Andrzej Kapolka on 8/7/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// // include this before QOpenGLFramebufferObject, which includes an earlier version of OpenGL #include "InterfaceConfig.h" diff --git a/interface/src/renderer/GlowEffect.h b/interface/src/renderer/GlowEffect.h index 65d3d6c8ce..b675589526 100644 --- a/interface/src/renderer/GlowEffect.h +++ b/interface/src/renderer/GlowEffect.h @@ -1,13 +1,16 @@ // // GlowEffect.h -// interface +// interface/src/renderer // // Created by Andrzej Kapolka on 8/7/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__GlowEffect__ -#define __interface__GlowEffect__ +#ifndef hifi_GlowEffect_h +#define hifi_GlowEffect_h #include #include @@ -80,4 +83,4 @@ public: ~Glower(); }; -#endif /* defined(__interface__GlowEffect__) */ +#endif // hifi_GlowEffect_h diff --git a/interface/src/renderer/Model.cpp b/interface/src/renderer/Model.cpp index 36ac6bec99..2d47a077b7 100644 --- a/interface/src/renderer/Model.cpp +++ b/interface/src/renderer/Model.cpp @@ -1,9 +1,12 @@ // // Model.cpp -// interface +// interface/src/renderer // // Created by Andrzej Kapolka on 10/18/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include @@ -32,9 +35,11 @@ Model::Model(QObject* parent) : QObject(parent), _scale(1.0f, 1.0f, 1.0f), _shapesAreDirty(true), + _boundingRadius(0.f), + _boundingShape(), + _boundingShapeLocalOffset(0.f), _lodDistance(0.0f), - _pupilDilation(0.0f), - _boundingRadius(0.f) { + _pupilDilation(0.0f) { // we may have been created in the network thread, but we live in the main thread moveToThread(Application::getInstance()->thread()); } @@ -54,6 +59,17 @@ Model::SkinLocations Model::_skinLocations; Model::SkinLocations Model::_skinNormalMapLocations; Model::SkinLocations Model::_skinShadowLocations; +void Model::setScale(const glm::vec3& scale) { + glm::vec3 deltaScale = _scale - scale; + + // decreased epsilon because this wasn't handling scale changes of 0.01 + const float SMALLER_EPSILON = EPSILON * 0.0001f; + if (glm::length2(deltaScale) > SMALLER_EPSILON) { + _scale = scale; + rebuildShapes(); + } +} + void Model::initSkinProgram(ProgramObject& program, Model::SkinLocations& locations) { program.bind(); locations.clusterMatrices = program.uniformLocation("clusterMatrices"); @@ -73,6 +89,44 @@ QVector Model::createJointStates(const FBXGeometry& geometry) state.rotation = joint.rotation; jointStates.append(state); } + + // compute transforms + // Unfortunately, the joints are not neccessarily in order from parents to children, + // so we must iterate over the list multiple times until all are set correctly. + QVector jointIsSet; + int numJoints = jointStates.size(); + jointIsSet.fill(false, numJoints); + int numJointsSet = 0; + int lastNumJointsSet = -1; + while (numJointsSet < numJoints && numJointsSet != lastNumJointsSet) { + lastNumJointsSet = numJointsSet; + for (int i = 0; i < numJoints; ++i) { + if (jointIsSet[i]) { + continue; + } + JointState& state = jointStates[i]; + const FBXJoint& joint = geometry.joints[i]; + int parentIndex = joint.parentIndex; + if (parentIndex == -1) { + glm::mat4 baseTransform = glm::mat4_cast(_rotation) * glm::scale(_scale) * glm::translate(_offset); + glm::quat combinedRotation = joint.preRotation * state.rotation * joint.postRotation; + state.transform = baseTransform * geometry.offset * glm::translate(state.translation) * joint.preTransform * + glm::mat4_cast(combinedRotation) * joint.postTransform; + state.combinedRotation = _rotation * combinedRotation; + ++numJointsSet; + jointIsSet[i] = true; + } else if (jointIsSet[parentIndex]) { + const JointState& parentState = jointStates.at(parentIndex); + glm::quat combinedRotation = joint.preRotation * state.rotation * joint.postRotation; + state.transform = parentState.transform * glm::translate(state.translation) * joint.preTransform * + glm::mat4_cast(combinedRotation) * joint.postTransform; + state.combinedRotation = parentState.combinedRotation * combinedRotation; + ++numJointsSet; + jointIsSet[i] = true; + } + } + } + return jointStates; } @@ -142,66 +196,101 @@ void Model::reset() { } } -void Model::clearShapes() { - for (int i = 0; i < _shapes.size(); ++i) { - delete _shapes[i]; - } - _shapes.clear(); -} - -void Model::createCollisionShapes() { - clearShapes(); - const FBXGeometry& geometry = _geometry->getFBXGeometry(); - float uniformScale = extractUniformScale(_scale); - for (int i = 0; i < _jointStates.size(); i++) { - const FBXJoint& joint = geometry.joints[i]; - glm::vec3 meshCenter = _jointStates[i].combinedRotation * joint.shapePosition; - glm::vec3 position = _rotation * (extractTranslation(_jointStates[i].transform) + uniformScale * meshCenter) + _translation; - - float radius = uniformScale * joint.boneRadius; - if (joint.shapeType == Shape::CAPSULE_SHAPE) { - float halfHeight = 0.5f * uniformScale * joint.distanceToParent; - CapsuleShape* shape = new CapsuleShape(radius, halfHeight); - shape->setPosition(position); - _shapes.push_back(shape); - } else { - SphereShape* shape = new SphereShape(radius, position); - _shapes.push_back(shape); +bool Model::updateGeometry() { + // NOTE: this is a recursive call that walks all attachments, and their attachments + bool needFullUpdate = false; + for (int i = 0; i < _attachments.size(); i++) { + Model* model = _attachments.at(i); + if (model->updateGeometry()) { + needFullUpdate = true; } } -} -void Model::updateShapePositions() { - if (_shapesAreDirty && _shapes.size() == _jointStates.size()) { - _boundingRadius = 0.f; - float uniformScale = extractUniformScale(_scale); - const FBXGeometry& geometry = _geometry->getFBXGeometry(); - for (int i = 0; i < _jointStates.size(); i++) { - const FBXJoint& joint = geometry.joints[i]; - // shape position and rotation need to be in world-frame - glm::vec3 jointToShapeOffset = uniformScale * (_jointStates[i].combinedRotation * joint.shapePosition); - glm::vec3 worldPosition = extractTranslation(_jointStates[i].transform) + jointToShapeOffset + _translation; - _shapes[i]->setPosition(worldPosition); - _shapes[i]->setRotation(_jointStates[i].combinedRotation * joint.shapeRotation); - float distance2 = glm::distance2(worldPosition, _translation); - if (distance2 > _boundingRadius) { - _boundingRadius = distance2; + bool needToRebuild = false; + if (_nextGeometry) { + _nextGeometry = _nextGeometry->getLODOrFallback(_lodDistance, _nextLODHysteresis); + _nextGeometry->setLoadPriority(this, -_lodDistance); + _nextGeometry->ensureLoading(); + if (_nextGeometry->isLoaded()) { + applyNextGeometry(); + needToRebuild = true; + } + } + if (!_geometry) { + // geometry is not ready + return false; + } + + QSharedPointer geometry = _geometry->getLODOrFallback(_lodDistance, _lodHysteresis); + if (_geometry != geometry) { + // NOTE: it is theoretically impossible to reach here after passing through the applyNextGeometry() call above. + // Which means we don't need to worry about calling deleteGeometry() below immediately after creating new geometry. + + const FBXGeometry& newGeometry = geometry->getFBXGeometry(); + QVector newJointStates = createJointStates(newGeometry); + if (! _jointStates.isEmpty()) { + // copy the existing joint states + const FBXGeometry& oldGeometry = _geometry->getFBXGeometry(); + for (QHash::const_iterator it = oldGeometry.jointIndices.constBegin(); + it != oldGeometry.jointIndices.constEnd(); it++) { + int oldIndex = it.value() - 1; + int newIndex = newGeometry.getJointIndex(it.key()); + if (newIndex != -1) { + newJointStates[newIndex] = _jointStates.at(oldIndex); + } } + } + deleteGeometry(); + _dilatedTextures.clear(); + _geometry = geometry; + _jointStates = newJointStates; + needToRebuild = true; + } else if (_jointStates.isEmpty()) { + const FBXGeometry& fbxGeometry = geometry->getFBXGeometry(); + if (fbxGeometry.joints.size() > 0) { + _jointStates = createJointStates(fbxGeometry); + needToRebuild = true; } - _boundingRadius = sqrtf(_boundingRadius); - _shapesAreDirty = false; } + _geometry->setLoadPriority(this, -_lodDistance); + _geometry->ensureLoading(); + + if (needToRebuild) { + const FBXGeometry& fbxGeometry = geometry->getFBXGeometry(); + foreach (const FBXMesh& mesh, fbxGeometry.meshes) { + MeshState state; + state.clusterMatrices.resize(mesh.clusters.size()); + _meshStates.append(state); + + QOpenGLBuffer buffer; + if (!mesh.blendshapes.isEmpty()) { + buffer.setUsagePattern(QOpenGLBuffer::DynamicDraw); + buffer.create(); + buffer.bind(); + buffer.allocate((mesh.vertices.size() + mesh.normals.size()) * sizeof(glm::vec3)); + buffer.write(0, mesh.vertices.constData(), mesh.vertices.size() * sizeof(glm::vec3)); + buffer.write(mesh.vertices.size() * sizeof(glm::vec3), mesh.normals.constData(), + mesh.normals.size() * sizeof(glm::vec3)); + buffer.release(); + } + _blendedVertexBuffers.append(buffer); + } + foreach (const FBXAttachment& attachment, fbxGeometry.attachments) { + Model* model = new Model(this); + model->init(); + model->setURL(attachment.url); + _attachments.append(model); + } + rebuildShapes(); + needFullUpdate = true; + } + return needFullUpdate; } -void Model::simulate(float deltaTime, bool fullUpdate) { - // update our LOD, then simulate - simulate(deltaTime, fullUpdate, updateGeometry()); -} - -bool Model::render(float alpha, bool forShadowMap) { +bool Model::render(float alpha, RenderMode mode) { // render the attachments foreach (Model* attachment, _attachments) { - attachment->render(alpha); + attachment->render(alpha, mode); } if (_meshStates.isEmpty()) { return false; @@ -222,20 +311,24 @@ bool Model::render(float alpha, bool forShadowMap) { glDisable(GL_COLOR_MATERIAL); - glEnable(GL_CULL_FACE); + if (mode == DIFFUSE_RENDER_MODE || mode == NORMAL_RENDER_MODE) { + glDisable(GL_CULL_FACE); + } else { + glEnable(GL_CULL_FACE); + } // render opaque meshes with alpha testing glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.5f * alpha); - renderMeshes(alpha, forShadowMap, false); + renderMeshes(alpha, mode, false); glDisable(GL_ALPHA_TEST); - // render translucent meshes afterwards, with back face culling + // render translucent meshes afterwards - renderMeshes(alpha, forShadowMap, true); + renderMeshes(alpha, mode, true); glDisable(GL_CULL_FACE); @@ -264,15 +357,6 @@ Extents Model::getBindExtents() const { return scaledExtents; } -Extents Model::getStaticExtents() const { - if (!isActive()) { - return Extents(); - } - const Extents& staticExtents = _geometry->getFBXGeometry().staticExtents; - Extents scaledExtents = { staticExtents.minimum * _scale, staticExtents.maximum * _scale }; - return scaledExtents; -} - bool Model::getJointState(int index, glm::quat& rotation) const { if (index == -1 || index >= _jointStates.size()) { return false; @@ -375,6 +459,107 @@ void Model::setURL(const QUrl& url, const QUrl& fallback, bool retainCurrent, bo } } +void Model::clearShapes() { + for (int i = 0; i < _jointShapes.size(); ++i) { + delete _jointShapes[i]; + } + _jointShapes.clear(); +} + +void Model::rebuildShapes() { + clearShapes(); + + if (_jointStates.isEmpty()) { + return; + } + + // make sure all the joints are updated correctly before we try to create their shapes + for (int i = 0; i < _jointStates.size(); i++) { + updateJointState(i); + } + + const FBXGeometry& geometry = _geometry->getFBXGeometry(); + float uniformScale = extractUniformScale(_scale); + glm::quat inverseRotation = glm::inverse(_rotation); + glm::vec3 rootPosition(0.f); + + // joint shapes + Extents totalExtents; + totalExtents.reset(); + for (int i = 0; i < _jointStates.size(); i++) { + const FBXJoint& joint = geometry.joints[i]; + + glm::vec3 jointToShapeOffset = uniformScale * (_jointStates[i].combinedRotation * joint.shapePosition); + glm::vec3 worldPosition = extractTranslation(_jointStates[i].transform) + jointToShapeOffset + _translation; + Extents shapeExtents; + shapeExtents.reset(); + + if (joint.parentIndex == -1) { + rootPosition = worldPosition; + } + + float radius = uniformScale * joint.boneRadius; + float halfHeight = 0.5f * uniformScale * joint.distanceToParent; + if (joint.shapeType == Shape::CAPSULE_SHAPE && halfHeight > EPSILON) { + CapsuleShape* capsule = new CapsuleShape(radius, halfHeight); + capsule->setPosition(worldPosition); + capsule->setRotation(_jointStates[i].combinedRotation * joint.shapeRotation); + _jointShapes.push_back(capsule); + + glm::vec3 endPoint; + capsule->getEndPoint(endPoint); + glm::vec3 startPoint; + capsule->getStartPoint(startPoint); + glm::vec3 axis = (halfHeight + radius) * glm::normalize(endPoint - startPoint); + shapeExtents.addPoint(worldPosition + axis); + shapeExtents.addPoint(worldPosition - axis); + } else { + SphereShape* sphere = new SphereShape(radius, worldPosition); + _jointShapes.push_back(sphere); + + glm::vec3 axis = glm::vec3(radius); + shapeExtents.addPoint(worldPosition + axis); + shapeExtents.addPoint(worldPosition - axis); + } + totalExtents.addExtents(shapeExtents); + } + + // bounding shape + // NOTE: we assume that the longest side of totalExtents is the yAxis + glm::vec3 diagonal = totalExtents.maximum - totalExtents.minimum; + float capsuleRadius = 0.25f * (diagonal.x + diagonal.z); // half the average of x and z + _boundingShape.setRadius(capsuleRadius); + _boundingShape.setHalfHeight(0.5f * diagonal.y - capsuleRadius); + _boundingShapeLocalOffset = inverseRotation * (0.5f * (totalExtents.maximum + totalExtents.minimum) - rootPosition); +} + +void Model::updateShapePositions() { + if (_shapesAreDirty && _jointShapes.size() == _jointStates.size()) { + glm::vec3 rootPosition(0.f); + _boundingRadius = 0.f; + float uniformScale = extractUniformScale(_scale); + const FBXGeometry& geometry = _geometry->getFBXGeometry(); + for (int i = 0; i < _jointStates.size(); i++) { + const FBXJoint& joint = geometry.joints[i]; + // shape position and rotation need to be in world-frame + glm::vec3 jointToShapeOffset = uniformScale * (_jointStates[i].combinedRotation * joint.shapePosition); + glm::vec3 worldPosition = extractTranslation(_jointStates[i].transform) + jointToShapeOffset + _translation; + _jointShapes[i]->setPosition(worldPosition); + _jointShapes[i]->setRotation(_jointStates[i].combinedRotation * joint.shapeRotation); + float distance2 = glm::distance2(worldPosition, _translation); + if (distance2 > _boundingRadius) { + _boundingRadius = distance2; + } + if (joint.parentIndex == -1) { + rootPosition = worldPosition; + } + } + _boundingRadius = sqrtf(_boundingRadius); + _shapesAreDirty = false; + _boundingShape.setPosition(rootPosition + _rotation * _boundingShapeLocalOffset); + } +} + bool Model::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance) const { const glm::vec3 relativeOrigin = origin - _translation; const FBXGeometry& geometry = _geometry->getFBXGeometry(); @@ -408,9 +593,9 @@ bool Model::findCollisions(const QVector shapes, CollisionList& co bool collided = false; for (int i = 0; i < shapes.size(); ++i) { const Shape* theirShape = shapes[i]; - for (int j = 0; j < _shapes.size(); ++j) { - const Shape* ourShape = _shapes[j]; - if (ShapeCollider::shapeShape(theirShape, ourShape, collisions)) { + for (int j = 0; j < _jointShapes.size(); ++j) { + const Shape* ourShape = _jointShapes[j]; + if (ShapeCollider::collideShapes(theirShape, ourShape, collisions)) { collided = true; } } @@ -421,10 +606,9 @@ bool Model::findCollisions(const QVector shapes, CollisionList& co bool Model::findSphereCollisions(const glm::vec3& sphereCenter, float sphereRadius, CollisionList& collisions, int skipIndex) { bool collided = false; - updateShapePositions(); SphereShape sphere(sphereRadius, sphereCenter); const FBXGeometry& geometry = _geometry->getFBXGeometry(); - for (int i = 0; i < _shapes.size(); i++) { + for (int i = 0; i < _jointShapes.size(); i++) { const FBXJoint& joint = geometry.joints[i]; if (joint.parentIndex != -1) { if (skipIndex != -1) { @@ -438,7 +622,7 @@ bool Model::findSphereCollisions(const glm::vec3& sphereCenter, float sphereRadi } while (ancestorIndex != -1); } } - if (ShapeCollider::shapeShape(&sphere, _shapes[i], collisions)) { + if (ShapeCollider::collideShapes(&sphere, _jointShapes[i], collisions)) { CollisionInfo* collision = collisions.getLastCollision(); collision->_type = MODEL_COLLISION; collision->_data = (void*)(this); @@ -450,43 +634,19 @@ bool Model::findSphereCollisions(const glm::vec3& sphereCenter, float sphereRadi return collided; } -QVector Model::updateGeometry() { - QVector newJointStates; - if (_nextGeometry) { - _nextGeometry = _nextGeometry->getLODOrFallback(_lodDistance, _nextLODHysteresis); - _nextGeometry->setLoadPriority(this, -_lodDistance); - _nextGeometry->ensureLoading(); - if (_nextGeometry->isLoaded()) { - applyNextGeometry(); - return newJointStates; +bool Model::findPlaneCollisions(const glm::vec4& plane, CollisionList& collisions) { + bool collided = false; + PlaneShape planeShape(plane); + for (int i = 0; i < _jointShapes.size(); i++) { + if (ShapeCollider::collideShapes(&planeShape, _jointShapes[i], collisions)) { + CollisionInfo* collision = collisions.getLastCollision(); + collision->_type = MODEL_COLLISION; + collision->_data = (void*)(this); + collision->_flags = i; + collided = true; } } - if (!_geometry) { - return newJointStates; - } - QSharedPointer geometry = _geometry->getLODOrFallback(_lodDistance, _lodHysteresis); - if (_geometry != geometry) { - if (!_jointStates.isEmpty()) { - // copy the existing joint states - const FBXGeometry& oldGeometry = _geometry->getFBXGeometry(); - const FBXGeometry& newGeometry = geometry->getFBXGeometry(); - newJointStates = createJointStates(newGeometry); - for (QHash::const_iterator it = oldGeometry.jointIndices.constBegin(); - it != oldGeometry.jointIndices.constEnd(); it++) { - int oldIndex = it.value() - 1; - int newIndex = newGeometry.getJointIndex(it.key()); - if (newIndex != -1) { - newJointStates[newIndex] = _jointStates.at(oldIndex); - } - } - } - deleteGeometry(); - _dilatedTextures.clear(); - _geometry = geometry; - } - _geometry->setLoadPriority(this, -_lodDistance); - _geometry->ensureLoading(); - return newJointStates; + return collided; } class Blender : public QRunnable { @@ -551,53 +711,23 @@ void Blender::run() { Q_ARG(const QVector&, vertices), Q_ARG(const QVector&, normals)); } -void Model::simulate(float deltaTime, bool fullUpdate, const QVector& newJointStates) { - if (!isActive()) { - return; +void Model::simulate(float deltaTime, bool fullUpdate) { + fullUpdate = updateGeometry() || fullUpdate; + if (isActive() && fullUpdate) { + simulateInternal(deltaTime); } - - // set up world vertices on first simulate after load - const FBXGeometry& geometry = _geometry->getFBXGeometry(); - if (_jointStates.isEmpty()) { - _jointStates = newJointStates.isEmpty() ? createJointStates(geometry) : newJointStates; - foreach (const FBXMesh& mesh, geometry.meshes) { - MeshState state; - state.clusterMatrices.resize(mesh.clusters.size()); - _meshStates.append(state); - - QOpenGLBuffer buffer; - if (!mesh.blendshapes.isEmpty()) { - buffer.setUsagePattern(QOpenGLBuffer::DynamicDraw); - buffer.create(); - buffer.bind(); - buffer.allocate((mesh.vertices.size() + mesh.normals.size()) * sizeof(glm::vec3)); - buffer.write(0, mesh.vertices.constData(), mesh.vertices.size() * sizeof(glm::vec3)); - buffer.write(mesh.vertices.size() * sizeof(glm::vec3), mesh.normals.constData(), - mesh.normals.size() * sizeof(glm::vec3)); - buffer.release(); - } - _blendedVertexBuffers.append(buffer); - } - foreach (const FBXAttachment& attachment, geometry.attachments) { - Model* model = new Model(this); - model->init(); - model->setURL(attachment.url); - _attachments.append(model); - } - fullUpdate = true; - createCollisionShapes(); - } - - // exit early if we don't have to perform a full update - if (!fullUpdate) { - return; - } - +} + +void Model::simulateInternal(float deltaTime) { + // NOTE: this is a recursive call that walks all attachments, and their attachments // update the world space transforms for all joints for (int i = 0; i < _jointStates.size(); i++) { updateJointState(i); } + _shapesAreDirty = true; + const FBXGeometry& geometry = _geometry->getFBXGeometry(); + // update the attachment transforms and simulate them for (int i = 0; i < _attachments.size(); i++) { const FBXAttachment& attachment = geometry.attachments.at(i); @@ -612,7 +742,9 @@ void Model::simulate(float deltaTime, bool fullUpdate, const QVector model->setRotation(jointRotation * attachment.rotation); model->setScale(_scale * attachment.scale); - model->simulate(deltaTime); + if (model->isActive()) { + model->simulateInternal(deltaTime); + } } for (int i = 0; i < _meshStates.size(); i++) { @@ -631,7 +763,6 @@ void Model::simulate(float deltaTime, bool fullUpdate, const QVector } void Model::updateJointState(int index) { - _shapesAreDirty = true; JointState& state = _jointStates[index]; const FBXGeometry& geometry = _geometry->getFBXGeometry(); const FBXJoint& joint = geometry.joints.at(index); @@ -643,7 +774,7 @@ void Model::updateJointState(int index) { state.transform = baseTransform * geometry.offset * glm::translate(state.translation) * joint.preTransform * glm::mat4_cast(combinedRotation) * joint.postTransform; state.combinedRotation = _rotation * combinedRotation; - + } else { const JointState& parentState = _jointStates.at(joint.parentIndex); if (index == geometry.leanJointIndex) { @@ -749,6 +880,7 @@ bool Model::setJointPosition(int jointIndex, const glm::vec3& position, int last for (int j = freeLineage.size() - 1; j >= 0; j--) { updateJointState(freeLineage.at(j)); } + _shapesAreDirty = true; return true; } @@ -827,15 +959,15 @@ void Model::applyRotationDelta(int jointIndex, const glm::quat& delta, bool cons state.rotation = newRotation; } -void Model::renderCollisionProxies(float alpha) { +const int BALL_SUBDIVISIONS = 10; + +void Model::renderJointCollisionShapes(float alpha) { glPushMatrix(); Application::getInstance()->loadTranslatedViewMatrix(_translation); - updateShapePositions(); - const int BALL_SUBDIVISIONS = 10; - for (int i = 0; i < _shapes.size(); i++) { + for (int i = 0; i < _jointShapes.size(); i++) { glPushMatrix(); - Shape* shape = _shapes[i]; + Shape* shape = _jointShapes[i]; if (shape->getType() == Shape::SPHERE_SHAPE) { // shapes are stored in world-frame, so we have to transform into model frame @@ -878,6 +1010,36 @@ void Model::renderCollisionProxies(float alpha) { glPopMatrix(); } +void Model::renderBoundingCollisionShapes(float alpha) { + glPushMatrix(); + + Application::getInstance()->loadTranslatedViewMatrix(_translation); + + // draw a blue sphere at the capsule endpoint + glm::vec3 endPoint; + _boundingShape.getEndPoint(endPoint); + endPoint = endPoint - _translation; + glTranslatef(endPoint.x, endPoint.y, endPoint.z); + glColor4f(0.6f, 0.6f, 0.8f, alpha); + glutSolidSphere(_boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS); + + // draw a yellow sphere at the capsule startpoint + glm::vec3 startPoint; + _boundingShape.getStartPoint(startPoint); + startPoint = startPoint - _translation; + glm::vec3 axis = endPoint - startPoint; + glTranslatef(-axis.x, -axis.y, -axis.z); + glColor4f(0.8f, 0.8f, 0.6f, alpha); + glutSolidSphere(_boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS); + + // draw a green cylinder between the two points + glm::vec3 origin(0.f); + glColor4f(0.6f, 0.8f, 0.6f, alpha); + Avatar::renderJointConnectingCone( origin, axis, _boundingShape.getRadius(), _boundingShape.getRadius()); + + glPopMatrix(); +} + bool Model::collisionHitsMoveableJoint(CollisionInfo& collision) const { if (collision._type == MODEL_COLLISION) { // the joint is pokable by a collision if it exists and is free to move @@ -975,7 +1137,7 @@ void Model::deleteGeometry() { } } -void Model::renderMeshes(float alpha, bool forShadowMap, bool translucent) { +void Model::renderMeshes(float alpha, RenderMode mode, bool translucent) { const FBXGeometry& geometry = _geometry->getFBXGeometry(); const QVector& networkMeshes = _geometry->getMeshes(); @@ -1000,7 +1162,7 @@ void Model::renderMeshes(float alpha, bool forShadowMap, bool translucent) { ProgramObject* program = &_program; ProgramObject* skinProgram = &_skinProgram; SkinLocations* skinLocations = &_skinLocations; - if (forShadowMap) { + if (mode == SHADOW_RENDER_MODE) { program = &_shadowProgram; skinProgram = &_skinShadowProgram; skinLocations = &_skinShadowLocations; @@ -1038,7 +1200,7 @@ void Model::renderMeshes(float alpha, bool forShadowMap, bool translucent) { } if (mesh.blendshapes.isEmpty()) { - if (!(mesh.tangents.isEmpty() || forShadowMap)) { + if (!(mesh.tangents.isEmpty() || mode == SHADOW_RENDER_MODE)) { activeProgram->setAttributeBuffer(tangentLocation, GL_FLOAT, vertexCount * 2 * sizeof(glm::vec3), 3); activeProgram->enableAttributeArray(tangentLocation); } @@ -1048,7 +1210,7 @@ void Model::renderMeshes(float alpha, bool forShadowMap, bool translucent) { (mesh.tangents.size() + mesh.colors.size()) * sizeof(glm::vec3))); } else { - if (!(mesh.tangents.isEmpty() || forShadowMap)) { + if (!(mesh.tangents.isEmpty() || mode == SHADOW_RENDER_MODE)) { activeProgram->setAttributeBuffer(tangentLocation, GL_FLOAT, 0, 3); activeProgram->enableAttributeArray(tangentLocation); } @@ -1077,7 +1239,7 @@ void Model::renderMeshes(float alpha, bool forShadowMap, bool translucent) { continue; } // apply material properties - if (forShadowMap) { + if (mode == SHADOW_RENDER_MODE) { glBindTexture(GL_TEXTURE_2D, 0); } else { @@ -1118,7 +1280,7 @@ void Model::renderMeshes(float alpha, bool forShadowMap, bool translucent) { glDisableClientState(GL_TEXTURE_COORD_ARRAY); } - if (!(mesh.tangents.isEmpty() || forShadowMap)) { + if (!(mesh.tangents.isEmpty() || mode == SHADOW_RENDER_MODE)) { glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, 0); glActiveTexture(GL_TEXTURE0); diff --git a/interface/src/renderer/Model.h b/interface/src/renderer/Model.h index 3fdf1cd291..65b79fffdd 100644 --- a/interface/src/renderer/Model.h +++ b/interface/src/renderer/Model.h @@ -1,17 +1,22 @@ // // Model.h -// interface +// interface/src/renderer // // Created by Andrzej Kapolka on 10/18/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__Model__ -#define __interface__Model__ +#ifndef hifi_Model_h +#define hifi_Model_h #include #include +#include + #include "GeometryCache.h" #include "InterfaceConfig.h" #include "ProgramObject.h" @@ -34,7 +39,7 @@ public: void setRotation(const glm::quat& rotation) { _rotation = rotation; } const glm::quat& getRotation() const { return _rotation; } - void setScale(const glm::vec3& scale) { _scale = scale; } + void setScale(const glm::vec3& scale); const glm::vec3& getScale() const { return _scale; } void setOffset(const glm::vec3& offset) { _offset = offset; } @@ -54,12 +59,12 @@ public: void init(); void reset(); - void clearShapes(); - void createCollisionShapes(); - void updateShapePositions(); - void simulate(float deltaTime, bool fullUpdate = true); - bool render(float alpha = 1.0f, bool forShadowMap = false); + virtual void simulate(float deltaTime, bool fullUpdate = true); + enum RenderMode { DEFAULT_RENDER_MODE, SHADOW_RENDER_MODE, DIFFUSE_RENDER_MODE, NORMAL_RENDER_MODE }; + + bool render(float alpha = 1.0f, RenderMode mode = DEFAULT_RENDER_MODE); + /// Sets the URL of the model to render. /// \param fallback the URL of a fallback model to render if the requested model fails to load /// \param retainCurrent if true, keep rendering the current model until the new one is loaded @@ -75,9 +80,6 @@ public: /// Returns the extents of the model in its bind pose. Extents getBindExtents() const; - /// Returns the extents of the unmovable joints of the model. - Extents getStaticExtents() const; - /// Returns a reference to the shared geometry. const QSharedPointer& getGeometry() const { return _geometry; } @@ -159,6 +161,12 @@ public: /// Returns the extended length from the right hand to its first free ancestor. float getRightArmLength() const; + void clearShapes(); + void rebuildShapes(); + void updateShapePositions(); + void renderJointCollisionShapes(float alpha); + void renderBoundingCollisionShapes(float alpha); + bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance) const; /// \param shapes list of pointers shapes to test against Model @@ -168,9 +176,9 @@ public: bool findSphereCollisions(const glm::vec3& penetratorCenter, float penetratorRadius, CollisionList& collisions, int skipIndex = -1); - - void renderCollisionProxies(float alpha); + bool findPlaneCollisions(const glm::vec4& plane, CollisionList& collisions); + /// \param collision details about the collisions /// \return true if the collision is against a moveable joint bool collisionHitsMoveableJoint(CollisionInfo& collision) const; @@ -180,6 +188,7 @@ public: void applyCollision(CollisionInfo& collision); float getBoundingRadius() const { return _boundingRadius; } + float getBoundingShapeRadius() const { return _boundingShape.getRadius(); } /// Sets blended vertices computed in a separate thread. void setBlendedVertices(const QVector& vertices, const QVector& normals); @@ -203,7 +212,11 @@ protected: bool _shapesAreDirty; QVector _jointStates; - QVector _shapes; + QVector _jointShapes; + + float _boundingRadius; + CapsuleShape _boundingShape; + glm::vec3 _boundingShapeLocalOffset; class MeshState { public: @@ -212,9 +225,11 @@ protected: QVector _meshStates; - QVector updateGeometry(); - void simulate(float deltaTime, bool fullUpdate, const QVector& newJointStates); - + // returns 'true' if needs fullUpdate after geometry change + bool updateGeometry(); + + void simulateInternal(float deltaTime); + /// Updates the state of the joint at the specified index. virtual void updateJointState(int index); @@ -247,7 +262,8 @@ private: void applyNextGeometry(); void deleteGeometry(); - void renderMeshes(float alpha, bool forShadowMap, bool translucent); + void renderMeshes(float alpha, RenderMode mode, bool translucent); + QVector createJointStates(const FBXGeometry& geometry); QSharedPointer _baseGeometry; ///< reference required to prevent collection of base QSharedPointer _nextBaseGeometry; @@ -267,8 +283,6 @@ private: QVector _attachments; - float _boundingRadius; - static ProgramObject _program; static ProgramObject _normalMapProgram; static ProgramObject _shadowProgram; @@ -291,11 +305,10 @@ private: static SkinLocations _skinShadowLocations; static void initSkinProgram(ProgramObject& program, SkinLocations& locations); - static QVector createJointStates(const FBXGeometry& geometry); }; Q_DECLARE_METATYPE(QPointer) Q_DECLARE_METATYPE(QWeakPointer) Q_DECLARE_METATYPE(QVector) -#endif /* defined(__interface__Model__) */ +#endif // hifi_Model_h diff --git a/interface/src/renderer/PointShader.cpp b/interface/src/renderer/PointShader.cpp index 6dd4aae485..68df69f284 100644 --- a/interface/src/renderer/PointShader.cpp +++ b/interface/src/renderer/PointShader.cpp @@ -1,9 +1,13 @@ // // PointShader.cpp -// interface +// interface/src/renderer // // Created by Brad Hefta-Gaub on 10/30/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// // include this before QOpenGLFramebufferObject, which includes an earlier version of OpenGL #include "InterfaceConfig.h" diff --git a/interface/src/renderer/PointShader.h b/interface/src/renderer/PointShader.h index b7e1b8c008..1db4f1b201 100644 --- a/interface/src/renderer/PointShader.h +++ b/interface/src/renderer/PointShader.h @@ -1,13 +1,16 @@ // // PointShader.h -// interface +// interface/src/renderer // // Created by Brad Hefta-Gaub on 10/30/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__PointShader__ -#define __interface__PointShader__ +#ifndef hifi_PointShader_h +#define hifi_PointShader_h #include @@ -42,4 +45,4 @@ private: ProgramObject* _program; }; -#endif /* defined(__interface__PointShader__) */ +#endif // hifi_PointShader_h diff --git a/interface/src/renderer/ProgramObject.cpp b/interface/src/renderer/ProgramObject.cpp index 5108c15068..b88be69f07 100644 --- a/interface/src/renderer/ProgramObject.cpp +++ b/interface/src/renderer/ProgramObject.cpp @@ -1,9 +1,13 @@ // // ProgramObject.cpp -// interface +// interface/src/renderer // // Created by Andrzej Kapolka on 5/7/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// #include "ProgramObject.h" diff --git a/interface/src/renderer/ProgramObject.h b/interface/src/renderer/ProgramObject.h index 78f07b7a1b..21e01ac8b3 100644 --- a/interface/src/renderer/ProgramObject.h +++ b/interface/src/renderer/ProgramObject.h @@ -1,13 +1,16 @@ // // ProgramObject.h -// interface +// interface/src/renderer // // Created by Andrzej Kapolka on 5/7/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__ProgramObject__ -#define __interface__ProgramObject__ +#ifndef hifi_ProgramObject_h +#define hifi_ProgramObject_h #include @@ -22,4 +25,4 @@ public: void setUniform(const char* name, const glm::vec3& value); }; -#endif /* defined(__interface__ProgramObject__) */ +#endif // hifi_ProgramObject_h diff --git a/interface/src/renderer/RenderUtil.cpp b/interface/src/renderer/RenderUtil.cpp index 11ec8b572c..0575ceaa88 100644 --- a/interface/src/renderer/RenderUtil.cpp +++ b/interface/src/renderer/RenderUtil.cpp @@ -1,9 +1,13 @@ // // RenderUtil.cpp -// interface +// interface/src/renderer // // Created by Andrzej Kapolka on 8/15/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// #include "InterfaceConfig.h" #include "RenderUtil.h" diff --git a/interface/src/renderer/RenderUtil.h b/interface/src/renderer/RenderUtil.h index 5e7e9b5d64..637596c78b 100644 --- a/interface/src/renderer/RenderUtil.h +++ b/interface/src/renderer/RenderUtil.h @@ -1,15 +1,18 @@ // // RenderUtil.h -// interface +// interface/src/renderer // // Created by Andrzej Kapolka on 8/15/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__RenderUtil__ -#define __interface__RenderUtil__ +#ifndef hifi_RenderUtil_h +#define hifi_RenderUtil_h /// Renders a quad from (-1, -1, 0) to (1, 1, 0) with texture coordinates from (sMin, 0) to (sMax, 1). void renderFullscreenQuad(float sMin = 0.0f, float sMax = 1.0f); -#endif /* defined(__interface__RenderUtil__) */ +#endif // hifi_RenderUtil_h diff --git a/interface/src/renderer/TextureCache.cpp b/interface/src/renderer/TextureCache.cpp index b3820abf25..17146dc2bb 100644 --- a/interface/src/renderer/TextureCache.cpp +++ b/interface/src/renderer/TextureCache.cpp @@ -1,9 +1,13 @@ // // TextureCache.cpp -// interface +// interface/src/renderer // // Created by Andrzej Kapolka on 8/6/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// // include this before QGLWidget, which includes an earlier version of OpenGL #include "InterfaceConfig.h" diff --git a/interface/src/renderer/TextureCache.h b/interface/src/renderer/TextureCache.h index dc874ab7b0..e66044d843 100644 --- a/interface/src/renderer/TextureCache.h +++ b/interface/src/renderer/TextureCache.h @@ -1,13 +1,16 @@ // // TextureCache.h -// interface +// interface/src/renderer // // Created by Andrzej Kapolka on 8/6/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__TextureCache__ -#define __interface__TextureCache__ +#ifndef hifi_TextureCache_h +#define hifi_TextureCache_h #include #include @@ -155,4 +158,4 @@ private: QMap > _dilatedTextures; }; -#endif /* defined(__interface__TextureCache__) */ +#endif // hifi_TextureCache_h diff --git a/interface/src/renderer/VoxelShader.cpp b/interface/src/renderer/VoxelShader.cpp index fab40fc338..0982304adf 100644 --- a/interface/src/renderer/VoxelShader.cpp +++ b/interface/src/renderer/VoxelShader.cpp @@ -1,9 +1,13 @@ // // VoxelShader.cpp -// interface +// interface/src/renderer // // Created by Brad Hefta-Gaub on 9/22/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// // include this before QOpenGLFramebufferObject, which includes an earlier version of OpenGL #include "InterfaceConfig.h" diff --git a/interface/src/renderer/VoxelShader.h b/interface/src/renderer/VoxelShader.h index 33e8ea0073..cfcd27bba7 100644 --- a/interface/src/renderer/VoxelShader.h +++ b/interface/src/renderer/VoxelShader.h @@ -1,13 +1,16 @@ // // VoxelShader.h -// interface +// interface/src/renderer // // Created by Brad Hefta-Gaub on 9/23/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__VoxelShader__ -#define __interface__VoxelShader__ +#ifndef hifi_VoxelShader_h +#define hifi_VoxelShader_h #include @@ -43,4 +46,4 @@ private: ProgramObject* _program; }; -#endif /* defined(__interface__VoxelShader__) */ +#endif // hifi_VoxelShader_h diff --git a/interface/src/scripting/AudioDeviceScriptingInterface.cpp b/interface/src/scripting/AudioDeviceScriptingInterface.cpp index a184e8a2f6..688b0942d5 100644 --- a/interface/src/scripting/AudioDeviceScriptingInterface.cpp +++ b/interface/src/scripting/AudioDeviceScriptingInterface.cpp @@ -1,9 +1,12 @@ // // AudioDeviceScriptingInterface.cpp -// hifi +// interface/src/scripting // -// Created by Brad Hefta-Gaub on 3/23/14 -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 3/23/14. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "Application.h" diff --git a/interface/src/scripting/AudioDeviceScriptingInterface.h b/interface/src/scripting/AudioDeviceScriptingInterface.h index adc86cb15c..62f1153a0b 100644 --- a/interface/src/scripting/AudioDeviceScriptingInterface.h +++ b/interface/src/scripting/AudioDeviceScriptingInterface.h @@ -1,13 +1,16 @@ // // AudioDeviceScriptingInterface.h -// hifi +// interface/src/scripting // -// Created by Brad Hefta-Gaub on 3/22/14 -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 3/22/14. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__AudioDeviceScriptingInterface__ -#define __hifi__AudioDeviceScriptingInterface__ +#ifndef hifi_AudioDeviceScriptingInterface_h +#define hifi_AudioDeviceScriptingInterface_h #include #include @@ -38,4 +41,4 @@ public slots: void setInputVolume(float volume); }; -#endif /* defined(__hifi__AudioDeviceScriptingInterface__) */ +#endif // hifi_AudioDeviceScriptingInterface_h diff --git a/interface/src/scripting/ClipboardScriptingInterface.cpp b/interface/src/scripting/ClipboardScriptingInterface.cpp index 2ddef524aa..b11c0fdbff 100644 --- a/interface/src/scripting/ClipboardScriptingInterface.cpp +++ b/interface/src/scripting/ClipboardScriptingInterface.cpp @@ -1,8 +1,11 @@ // // ClipboardScriptingInterface.cpp -// interface +// interface/src/scripting // -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "Application.h" @@ -96,4 +99,4 @@ void ClipboardScriptingInterface::nudgeVoxel(float x, float y, float z, float s, s / (float)TREE_SCALE }; Application::getInstance()->nudgeVoxelsByVector(sourceVoxel, nudgeVecInTreeSpace); -} \ No newline at end of file +} diff --git a/interface/src/scripting/ClipboardScriptingInterface.h b/interface/src/scripting/ClipboardScriptingInterface.h index 78e72d6de0..f0258b0cc7 100644 --- a/interface/src/scripting/ClipboardScriptingInterface.h +++ b/interface/src/scripting/ClipboardScriptingInterface.h @@ -1,14 +1,15 @@ // // ClipboardScriptingInterface.h -// interface +// interface/src/scripting // -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. // -// Scriptable interface for the Application clipboard +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__Clipboard__ -#define __interface__Clipboard__ +#ifndef hifi_ClipboardScriptingInterface_h +#define hifi_ClipboardScriptingInterface_h #include #include @@ -43,4 +44,4 @@ public slots: void nudgeVoxel(float x, float y, float z, float s, const glm::vec3& nudgeVec); }; -#endif // __interface__Clipboard__ +#endif // hifi_ClipboardScriptingInterface_h diff --git a/interface/src/scripting/ControllerScriptingInterface.cpp b/interface/src/scripting/ControllerScriptingInterface.cpp index f5ab1653f5..aa14f769de 100644 --- a/interface/src/scripting/ControllerScriptingInterface.cpp +++ b/interface/src/scripting/ControllerScriptingInterface.cpp @@ -1,9 +1,12 @@ // -// ControllerScriptingInterface.h -// hifi +// ControllerScriptingInterface.cpp +// interface/src/scripting // -// Created by Brad Hefta-Gaub on 12/17/13 -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 12/17/13. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/interface/src/scripting/ControllerScriptingInterface.h b/interface/src/scripting/ControllerScriptingInterface.h index 6fe5a60fa4..c5d805dca5 100644 --- a/interface/src/scripting/ControllerScriptingInterface.h +++ b/interface/src/scripting/ControllerScriptingInterface.h @@ -1,14 +1,16 @@ - // // ControllerScriptingInterface.h -// hifi +// interface/src/scripting // -// Created by Brad Hefta-Gaub on 12/17/13 -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 12/17/13. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__ControllerScriptingInterface__ -#define __hifi__ControllerScriptingInterface__ +#ifndef hifi_ControllerScriptingInterface_h +#define hifi_ControllerScriptingInterface_h #include @@ -96,4 +98,4 @@ const int NUMBER_OF_BUTTONS_PER_PALM = 6; const int PALM_SPATIALCONTROL = 0; const int TIP_SPATIALCONTROL = 1; -#endif /* defined(__hifi__ControllerScriptingInterface__) */ +#endif // hifi_ControllerScriptingInterface_h diff --git a/interface/src/scripting/MenuScriptingInterface.cpp b/interface/src/scripting/MenuScriptingInterface.cpp index 4f9003b288..11d681bfc7 100644 --- a/interface/src/scripting/MenuScriptingInterface.cpp +++ b/interface/src/scripting/MenuScriptingInterface.cpp @@ -1,9 +1,12 @@ // // MenuScriptingInterface.cpp -// hifi +// interface/src/scripting // -// Created by Brad Hefta-Gaub on 2/25/14 -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 2/25/14. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "Application.h" diff --git a/interface/src/scripting/MenuScriptingInterface.h b/interface/src/scripting/MenuScriptingInterface.h index a4496e3054..d127bd6edc 100644 --- a/interface/src/scripting/MenuScriptingInterface.h +++ b/interface/src/scripting/MenuScriptingInterface.h @@ -1,13 +1,16 @@ // // MenuScriptingInterface.h -// hifi +// interface/src/scripting // -// Created by Brad Hefta-Gaub on 2/25/14 -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 2/25/14. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__MenuScriptingInterface__ -#define __hifi__MenuScriptingInterface__ +#ifndef hifi_MenuScriptingInterface_h +#define hifi_MenuScriptingInterface_h #include #include @@ -47,4 +50,4 @@ signals: void menuItemEvent(const QString& menuItem); }; -#endif /* defined(__hifi__MenuScriptingInterface__) */ +#endif // hifi_MenuScriptingInterface_h diff --git a/interface/src/scripting/SettingsScriptingInterface.cpp b/interface/src/scripting/SettingsScriptingInterface.cpp index 2a788c2776..ea9d645a94 100644 --- a/interface/src/scripting/SettingsScriptingInterface.cpp +++ b/interface/src/scripting/SettingsScriptingInterface.cpp @@ -1,9 +1,12 @@ // // SettingsScriptingInterface.cpp -// hifi +// interface/src/scripting // -// Created by Brad Hefta-Gaub on 2/25/14 -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 2/25/14. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "Application.h" diff --git a/interface/src/scripting/SettingsScriptingInterface.h b/interface/src/scripting/SettingsScriptingInterface.h index 12bda2173f..e3138be4a0 100644 --- a/interface/src/scripting/SettingsScriptingInterface.h +++ b/interface/src/scripting/SettingsScriptingInterface.h @@ -1,13 +1,16 @@ // // SettingsScriptingInterface.h -// hifi +// interface/src/scripting // -// Created by Brad Hefta-Gaub on 3/22/14 -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 3/22/14. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__SettingsScriptingInterface__ -#define __hifi__SettingsScriptingInterface__ +#ifndef hifi_SettingsScriptingInterface_h +#define hifi_SettingsScriptingInterface_h #include #include @@ -27,4 +30,4 @@ public slots: void setValue(const QString& setting, const QVariant& value); }; -#endif /* defined(__hifi__SettingsScriptingInterface__) */ +#endif // hifi_SettingsScriptingInterface_h diff --git a/interface/src/starfield/Config.h b/interface/src/starfield/Config.h index b92aec9a4c..7777c5207b 100755 --- a/interface/src/starfield/Config.h +++ b/interface/src/starfield/Config.h @@ -1,17 +1,16 @@ // -// starfield/Config.h -// interface +// Config.h +// interface/src/starfield // -// Created by Tobias Schwinger on 3/29/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Tobias Schwinger on 3/29/13. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__starfield__Config__ -#define __interface__starfield__Config__ - -// -// Dependencies: -// +#ifndef hifi_Config_h +#define hifi_Config_h #include "InterfaceConfig.h" #include "renderer/ProgramObject.h" @@ -59,5 +58,4 @@ namespace starfield { } -#endif - +#endif // hifi_Config_h diff --git a/interface/src/starfield/Controller.cpp b/interface/src/starfield/Controller.cpp index 0987a14dd5..b50c393f00 100755 --- a/interface/src/starfield/Controller.cpp +++ b/interface/src/starfield/Controller.cpp @@ -1,10 +1,12 @@ // -// starfield/Controller.cpp -// interface +// Controller.cpp +// interface/src/starfield // -// Created by Chris Barnard on 10/16/13 -// Portions of code based on earlier work by Tobias Schwinger. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Chris Barnard on 10/16/13. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #ifdef _WIN32 diff --git a/interface/src/starfield/Controller.h b/interface/src/starfield/Controller.h index 5403d2fb75..06db5cb833 100755 --- a/interface/src/starfield/Controller.h +++ b/interface/src/starfield/Controller.h @@ -1,14 +1,17 @@ // -// starfield/Controller.h -// interface +// Controller.h +// interface/src/starfield // -// Created by Tobias Schwinger on 3/29/13. -// Modified by Chris Barnard 10/16/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Tobias Schwinger on 3/29/13. +// Modified by Chris Barnard on 10/16/13. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__starfield__Controller__ -#define __interface__starfield__Controller__ +#ifndef hifi_Controller_h +#define hifi_Controller_h #include @@ -38,4 +41,4 @@ namespace starfield { Renderer* _renderer; }; } -#endif +#endif // hifi_Controller_h diff --git a/interface/src/starfield/Generator.cpp b/interface/src/starfield/Generator.cpp index 6065140505..15d1736e4e 100644 --- a/interface/src/starfield/Generator.cpp +++ b/interface/src/starfield/Generator.cpp @@ -1,9 +1,12 @@ // -// starfield/Generator.cpp -// interface +// Generator.cpp +// interface/src/starfield // -// Created by Chris Barnard on 10/13/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Chris Barnard on 10/13/13. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #ifdef _WIN32 diff --git a/interface/src/starfield/Generator.h b/interface/src/starfield/Generator.h index 1029bd6a52..5352b3daf1 100644 --- a/interface/src/starfield/Generator.h +++ b/interface/src/starfield/Generator.h @@ -1,13 +1,16 @@ // -// starfield/Generator.h -// interface +// Generator.h +// interface/src/starfield // -// Created by Chris Barnard on 10/13/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Chris Barnard on 10/13/13. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__starfield__Generator__ -#define __interface__starfield__Generator__ +#ifndef hifi_Generator_h +#define hifi_Generator_h #include #include @@ -34,4 +37,4 @@ namespace starfield { }; } -#endif \ No newline at end of file +#endif // hifi_Generator_h diff --git a/interface/src/starfield/data/GpuVertex.cpp b/interface/src/starfield/data/GpuVertex.cpp index 58db1d499a..b7fee1f2b1 100755 --- a/interface/src/starfield/data/GpuVertex.cpp +++ b/interface/src/starfield/data/GpuVertex.cpp @@ -1,11 +1,15 @@ // -// starfield/data/GpuVertex.cpp -// interface +// GpuVertex.cpp +// interface/src/starfield/data // -// Created by Chris Barnard on 10/17/13. -// Based on code by Tobias Schwinger on 3/29/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Chris Barnard on 10/17/13. +// Based on code by Tobias Schwinger on 3/29/13. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + #include "starfield/data/GpuVertex.h" using namespace starfield; diff --git a/interface/src/starfield/data/GpuVertex.h b/interface/src/starfield/data/GpuVertex.h index 39eeb19634..f3b3ccd451 100755 --- a/interface/src/starfield/data/GpuVertex.h +++ b/interface/src/starfield/data/GpuVertex.h @@ -1,14 +1,17 @@ // -// starfield/data/GpuVertex.h -// interface +// GpuVertex.h +// interface/src/starfield/data // -// Created by Tobias Schwinger on 3/29/13. -// Modified 10/17/13 Chris Barnard. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Tobias Schwinger on 3/29/13. +// Modified by Chris Barnard on 10/17/13. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__starfield__data__GpuVertex__ -#define __interface__starfield__data__GpuVertex__ +#ifndef hifi_GpuVertex_h +#define hifi_GpuVertex_h #include "starfield/data/InputVertex.h" @@ -31,5 +34,4 @@ namespace starfield { } -#endif - +#endif // hifi_GpuVertex_h diff --git a/interface/src/starfield/data/InputVertex.cpp b/interface/src/starfield/data/InputVertex.cpp index 28bffb0ec0..5dead34beb 100755 --- a/interface/src/starfield/data/InputVertex.cpp +++ b/interface/src/starfield/data/InputVertex.cpp @@ -1,10 +1,13 @@ // -// starfield/data/InputVertex.cpp -// interface +// InputVertex.cpp +// interface/src/starfield/data // -// Created by Chris Barnard on 10/17.13. -// Based on code by Tobias Schwinger 3/29/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Chris Barnard on 10/17/13. +// Based on code by Tobias Schwinger 3/29/13. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "starfield/data/InputVertex.h" diff --git a/interface/src/starfield/data/InputVertex.h b/interface/src/starfield/data/InputVertex.h index d8c21a37a2..2eeda183ec 100755 --- a/interface/src/starfield/data/InputVertex.h +++ b/interface/src/starfield/data/InputVertex.h @@ -1,14 +1,17 @@ // -// starfield/data/InputVertex.h -// interface +// InputVertex.h +// interface/src/starfield/data // -// Created by Tobias Schwinger on 3/29/13. -// Modified by Chris Barnard 10/17/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Tobias Schwinger on 3/29/13. +// Modified by Chris Barnard on 10/17/13. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__starfield__data__InputVertex__ -#define __interface__starfield__data__InputVertex__ +#ifndef hifi_InputVertex_h +#define hifi_InputVertex_h #include "starfield/Config.h" @@ -33,5 +36,4 @@ namespace starfield { } -#endif - +#endif // hifi_InputVertex_h diff --git a/interface/src/starfield/data/Tile.h b/interface/src/starfield/data/Tile.h index bdef4e612f..7273394984 100755 --- a/interface/src/starfield/data/Tile.h +++ b/interface/src/starfield/data/Tile.h @@ -1,13 +1,16 @@ // -// starfield/data/Tile.h -// interface +// Tile.h +// interface/src/starfield/data // -// Created by Tobias Schwinger on 3/22/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Tobias Schwinger on 3/22/13. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__starfield__data__Tile__ -#define __interface__starfield__data__Tile__ +#ifndef hifi_Tile_h +#define hifi_Tile_h #include "starfield/Config.h" @@ -26,5 +29,4 @@ namespace starfield { } -#endif - +#endif // hifi_Tile_h diff --git a/interface/src/starfield/renderer/Renderer.cpp b/interface/src/starfield/renderer/Renderer.cpp index 0be9850338..034a571814 100755 --- a/interface/src/starfield/renderer/Renderer.cpp +++ b/interface/src/starfield/renderer/Renderer.cpp @@ -1,10 +1,13 @@ // -// starfield/renderer/Renderer.cpp -// interface +// Renderer.cpp +// interface/src/starfield/renderer // -// Created by Chris Barnard on 10/17/13. -// Based on earlier work by Tobias Schwinger 3/22/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Chris Barnard on 10/17/13. +// Based on earlier work by Tobias Schwinger 3/22/13. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "starfield/renderer/Renderer.h" diff --git a/interface/src/starfield/renderer/Renderer.h b/interface/src/starfield/renderer/Renderer.h index 7504dd0182..1e271512d2 100755 --- a/interface/src/starfield/renderer/Renderer.h +++ b/interface/src/starfield/renderer/Renderer.h @@ -1,14 +1,17 @@ // -// starfield/renderer/Renderer.h -// interface +// Renderer.h +// interface/src/starfield/renderer // -// Created by Tobias Schwinger on 3/22/13. -// Modified 10/17/13 Chris Barnard. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Tobias Schwinger on 3/22/13. +// Modified by Chris Barnard on 10/17/13. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__starfield__renderer__Renderer__ -#define __interface__starfield__renderer__Renderer__ +#ifndef hifi_Renderer_h +#define hifi_Renderer_h #include "starfield/Config.h" #include "starfield/data/InputVertex.h" @@ -136,5 +139,4 @@ namespace starfield { } -#endif - +#endif // hifi_Renderer_h diff --git a/interface/src/starfield/renderer/Tiling.h b/interface/src/starfield/renderer/Tiling.h index d4a1446690..e299b0998f 100755 --- a/interface/src/starfield/renderer/Tiling.h +++ b/interface/src/starfield/renderer/Tiling.h @@ -1,13 +1,16 @@ // -// starfield/renderer/Tiling.h -// interface +// Tiling.h +// interface/src/starfield/renderer // -// Created by Tobias Schwinger on 3/22/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Tobias Schwinger on 3/22/13. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__starfield__renderer__Tiling__ -#define __interface__starfield__renderer__Tiling__ +#ifndef hifi_Tiling_h +#define hifi_Tiling_h #include "starfield/Config.h" @@ -42,5 +45,4 @@ namespace starfield { }; } -#endif - +#endif // hifi_Tiling_h diff --git a/interface/src/starfield/renderer/VertexOrder.cpp b/interface/src/starfield/renderer/VertexOrder.cpp index 78f5229f90..ec36f1eea2 100755 --- a/interface/src/starfield/renderer/VertexOrder.cpp +++ b/interface/src/starfield/renderer/VertexOrder.cpp @@ -1,11 +1,13 @@ // -// starfield/renderer/VertexOrder.cpp -// interface +// VertexOrder.cpp +// interface/src/starfield/renderer // -// Created by Chris Barnard on 10/17/13. -// Based on code by Tobias Schwinger on 3/22/13. +// Created by Chris Barnard on 10/17/13. +// Based on code by Tobias Schwinger on 3/22/13. +// Copyright 2013 High Fidelity, Inc. // -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "starfield/renderer/VertexOrder.h" @@ -15,4 +17,4 @@ using namespace starfield; bool VertexOrder::bit(InputVertex const& vertex, state_type const& state) const { unsigned key = _tiling.getTileIndex(vertex.getAzimuth(), vertex.getAltitude()); return base::bit(key, state); -} \ No newline at end of file +} diff --git a/interface/src/starfield/renderer/VertexOrder.h b/interface/src/starfield/renderer/VertexOrder.h index 85c738ce0d..e45ccdedb0 100755 --- a/interface/src/starfield/renderer/VertexOrder.h +++ b/interface/src/starfield/renderer/VertexOrder.h @@ -1,13 +1,16 @@ // -// starfield/renderer/VertexOrder.h -// interface +// VertexOrder.h +// interface/src/starfield/renderer // -// Created by Tobias Schwinger on 3/22/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Tobias Schwinger on 3/22/13. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__starfield__renderer__VertexOrder__ -#define __interface__starfield__renderer__VertexOrder__ +#ifndef hifi_VertexOrder_h +#define hifi_VertexOrder_h #include "starfield/Config.h" #include "starfield/data/InputVertex.h" @@ -35,5 +38,4 @@ namespace starfield { } // anonymous namespace -#endif - +#endif // hifi_VertexOrder_h diff --git a/interface/src/ui/BandwidthDialog.cpp b/interface/src/ui/BandwidthDialog.cpp index 8cefc9cf93..3e6d9d876b 100644 --- a/interface/src/ui/BandwidthDialog.cpp +++ b/interface/src/ui/BandwidthDialog.cpp @@ -1,9 +1,12 @@ // -// BandwidthDialog.h -// interface +// BandwidthDialog.cpp +// interface/src/ui // // Created by Tobias Schwinger on 6/21/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/interface/src/ui/BandwidthDialog.h b/interface/src/ui/BandwidthDialog.h index a702b1be23..c1e9c5b82e 100644 --- a/interface/src/ui/BandwidthDialog.h +++ b/interface/src/ui/BandwidthDialog.h @@ -1,13 +1,16 @@ // // BandwidthDialog.h -// interface +// interface/src/ui // // Created by Tobias Schwinger on 6/21/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__BandwidthDialog__ -#define __hifi__BandwidthDialog__ +#ifndef hifi_BandwidthDialog_h +#define hifi_BandwidthDialog_h #include #include @@ -43,5 +46,4 @@ private: QLabel* _labels[BandwidthMeter::N_STREAMS]; }; -#endif /* defined(__interface__BandwidthDialog__) */ - +#endif // hifi_BandwidthDialog_h diff --git a/interface/src/ui/BandwidthMeter.cpp b/interface/src/ui/BandwidthMeter.cpp index 64ff74b846..3ed66c53e1 100644 --- a/interface/src/ui/BandwidthMeter.cpp +++ b/interface/src/ui/BandwidthMeter.cpp @@ -1,9 +1,12 @@ // -// BandwidthMeter.h -// interface +// BandwidthMeter.cpp +// interface/src/ui // // Created by Tobias Schwinger on 6/20/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include @@ -42,7 +45,8 @@ namespace { // .cpp-local BandwidthMeter::ChannelInfo BandwidthMeter::_CHANNELS[] = { { "Audio" , "Kbps", 8000.0 / 1024.0, 0x33cc99ff }, { "Avatars" , "Kbps", 8000.0 / 1024.0, 0xffef40c0 }, - { "Voxels" , "Kbps", 8000.0 / 1024.0, 0xd0d0d0a0 } + { "Voxels" , "Kbps", 8000.0 / 1024.0, 0xd0d0d0a0 }, + { "Metavoxels", "Kbps", 8000.0 / 1024.0, 0xd0d0d0a0 } }; BandwidthMeter::BandwidthMeter() : diff --git a/interface/src/ui/BandwidthMeter.h b/interface/src/ui/BandwidthMeter.h index 5879b1546d..45226c8e82 100644 --- a/interface/src/ui/BandwidthMeter.h +++ b/interface/src/ui/BandwidthMeter.h @@ -1,13 +1,16 @@ // // BandwidthMeter.h -// interface +// interface/src/ui // // Created by Tobias Schwinger on 6/20/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__BandwidthMeter__ -#define __interface__BandwidthMeter__ +#ifndef hifi_BandwidthMeter_h +#define hifi_BandwidthMeter_h #ifdef _WIN32 #define WANT_TIMEVAL @@ -30,11 +33,11 @@ public: bool isWithinArea(int x, int y, int screenWidth, int screenHeight); // Number of channels / streams. - static size_t const N_CHANNELS = 3; + static size_t const N_CHANNELS = 4; static size_t const N_STREAMS = N_CHANNELS * 2; // Channel usage. - enum ChannelIndex { AUDIO, AVATARS, VOXELS }; + enum ChannelIndex { AUDIO, AVATARS, VOXELS, METAVOXELS }; // Meta information held for a communication channel (bidirectional). struct ChannelInfo { @@ -84,5 +87,4 @@ private: int _scaleMaxIndex; }; -#endif /* defined(__interface__BandwidthMeter__) */ - +#endif // hifi_BandwidthMeter_h diff --git a/interface/src/ui/ChatWindow.cpp b/interface/src/ui/ChatWindow.cpp index 6963c208c5..8a83ba680b 100644 --- a/interface/src/ui/ChatWindow.cpp +++ b/interface/src/ui/ChatWindow.cpp @@ -1,18 +1,23 @@ // // ChatWindow.cpp -// interface +// interface/src/ui // // Created by Dimitar Dobrev on 3/6/14. -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include #include #include +#include #include #include #include #include +#include #include "Application.h" #include "FlowLayout.h" @@ -32,7 +37,9 @@ ChatWindow::ChatWindow() : { ui->setupUi(this); - // remove the title bar (see the Qt docs on setTitleBarWidget) + // remove the title bar (see the Qt docs on setTitleBarWidget), but we keep it for undocking + // + titleBar = titleBarWidget(); setTitleBarWidget(new QWidget()); FlowLayout* flowLayout = new FlowLayout(0, 4, 4); @@ -42,6 +49,10 @@ ChatWindow::ChatWindow() : ui->messagesGridLayout->setColumnStretch(1, 3); ui->messagePlainTextEdit->installEventFilter(this); + + if (!AccountManager::getInstance().isLoggedIn()) { + ui->connectingToXMPPLabel->setText(tr("You must be logged in to chat with others.")); + } #ifdef HAVE_QXMPP const QXmppClient& xmppClient = XmppClient::getInstance().getXMPPClient(); @@ -132,7 +143,7 @@ QString ChatWindow::getParticipantName(const QString& participant) { void ChatWindow::addTimeStamp() { QTimeSpan timePassed = QDateTime::currentDateTime() - lastMessageStamp; int times[] = { timePassed.daysPart(), timePassed.hoursPart(), timePassed.minutesPart() }; - QString strings[] = { tr("day", 0, times[0]), tr("hour", 0, times[1]), tr("minute", 0, times[2]) }; + QString strings[] = { tr("%n day(s)", 0, times[0]), tr("%n hour(s)", 0, times[1]), tr("%n minute(s)", 0, times[2]) }; QString timeString = ""; for (int i = 0; i < 3; i++) { if (times[i] > 0) { @@ -253,3 +264,16 @@ void ChatWindow::messageReceived(const QXmppMessage& message) { } #endif + +void ChatWindow::togglePinned() { + QMainWindow* mainWindow = Application::getInstance()->getWindow(); + mainWindow->removeDockWidget(this); + if (ui->togglePinnedButton->isChecked()) { + mainWindow->addDockWidget(ui->togglePinnedButton->isChecked() ? Qt::RightDockWidgetArea : Qt::NoDockWidgetArea, this); + } + if (!this->toggleViewAction()->isChecked()) { + this->toggleViewAction()->trigger(); + } + this->setFloating(!ui->togglePinnedButton->isChecked()); + setTitleBarWidget(ui->togglePinnedButton->isChecked()?new QWidget():titleBar); +} \ No newline at end of file diff --git a/interface/src/ui/ChatWindow.h b/interface/src/ui/ChatWindow.h index da8d423b9d..614afc1ef1 100644 --- a/interface/src/ui/ChatWindow.h +++ b/interface/src/ui/ChatWindow.h @@ -1,13 +1,16 @@ // // ChatWindow.h -// interface +// interface/src/ui // // Created by Dimitar Dobrev on 3/6/14. -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__ChatWindow__ -#define __interface__ChatWindow__ +#ifndef hifi_ChatWindow_h +#define hifi_ChatWindow_h #include #include @@ -47,12 +50,14 @@ private: void addTimeStamp(); Ui::ChatWindow* ui; + QWidget* titleBar; int numMessagesAfterLastTimeStamp; QDateTime lastMessageStamp; private slots: void connected(); void timeout(); + void togglePinned(); #ifdef HAVE_QXMPP void error(QXmppClient::Error error); void participantsChanged(); @@ -60,4 +65,4 @@ private slots: #endif }; -#endif /* defined(__interface__ChatWindow__) */ +#endif // hifi_ChatWindow_h diff --git a/interface/src/ui/FramelessDialog.cpp b/interface/src/ui/FramelessDialog.cpp new file mode 100644 index 0000000000..18e3bca89a --- /dev/null +++ b/interface/src/ui/FramelessDialog.cpp @@ -0,0 +1,100 @@ +// +// FramelessDialog.cpp +// interface/src/ui +// +// Created by Stojce Slavkovski on 2/20/14. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include "Application.h" +#include "FramelessDialog.h" + +const int RESIZE_HANDLE_WIDTH = 7; + +FramelessDialog::FramelessDialog(QWidget *parent, Qt::WindowFlags flags) : +QDialog(parent, flags | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint) { + setAttribute(Qt::WA_DeleteOnClose); + + // handle rezize and move events + parentWidget()->installEventFilter(this); + + // handle minimize, restore and focus events + Application::getInstance()->installEventFilter(this); +} + +bool FramelessDialog::eventFilter(QObject* sender, QEvent* event) { + switch (event->type()) { + case QEvent::Move: + if (sender == parentWidget()) { + // move to upper left corner on app move + move(parentWidget()->geometry().topLeft()); + } + break; + case QEvent::Resize: + if (sender == parentWidget()) { + // keep full app height on resizing the app + setFixedHeight(parentWidget()->size().height()); + } + break; + case QEvent::WindowStateChange: + if (parentWidget()->isMinimized()) { + setHidden(true); + } else { + setHidden(false); + } + break; + case QEvent::ApplicationDeactivate: + // hide on minimize and focus lost + setHidden(true); + break; + case QEvent::ApplicationActivate: + setHidden(false); + break; + default: + break; + } + + return false; +} + +void FramelessDialog::setStyleSheetFile(const QString& fileName) { + QFile globalStyleSheet(Application::resourcesPath() + "styles/global.qss"); + QFile styleSheet(Application::resourcesPath() + fileName); + if (styleSheet.open(QIODevice::ReadOnly) && globalStyleSheet.open(QIODevice::ReadOnly) ) { + QDir::setCurrent(Application::resourcesPath()); + setStyleSheet(globalStyleSheet.readAll() + styleSheet.readAll()); + } +} + +void FramelessDialog::showEvent(QShowEvent* event) { + // move to upper left corner + move(parentWidget()->geometry().topLeft()); + + // keep full app height + setFixedHeight(parentWidget()->size().height()); + + // resize parrent if width is smaller than this dialog + if (parentWidget()->size().width() < size().width()) { + parentWidget()->resize(size().width(), parentWidget()->size().height()); + } +} +void FramelessDialog::mousePressEvent(QMouseEvent* mouseEvent) { + if (abs(mouseEvent->pos().x() - size().width()) < RESIZE_HANDLE_WIDTH && mouseEvent->button() == Qt::LeftButton) { + _isResizing = true; + QApplication::setOverrideCursor(Qt::SizeHorCursor); + } +} + +void FramelessDialog::mouseReleaseEvent(QMouseEvent* mouseEvent) { + QApplication::restoreOverrideCursor(); + _isResizing = false; +} + +void FramelessDialog::mouseMoveEvent(QMouseEvent* mouseEvent) { + if (_isResizing) { + resize(mouseEvent->pos().x(), size().height()); + } +} diff --git a/interface/src/ui/FramelessDialog.h b/interface/src/ui/FramelessDialog.h new file mode 100644 index 0000000000..db9f6dfd6c --- /dev/null +++ b/interface/src/ui/FramelessDialog.h @@ -0,0 +1,38 @@ +// +// FramelessDialog.h +// interface/src/ui +// +// Created by Stojce Slavkovski on 2/20/14. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + + +#ifndef hifi_FramelessDialog_h +#define hifi_FramelessDialog_h + +#include + +class FramelessDialog : public QDialog { + Q_OBJECT + +public: + FramelessDialog(QWidget* parent = 0, Qt::WindowFlags flags = 0); + void setStyleSheetFile(const QString& fileName); + +protected: + virtual void mouseMoveEvent(QMouseEvent* mouseEvent); + virtual void mousePressEvent(QMouseEvent* mouseEvent); + virtual void mouseReleaseEvent(QMouseEvent* mouseEvent); + virtual void showEvent(QShowEvent* event); + + bool eventFilter(QObject* sender, QEvent* event); + +private: + bool _isResizing; + +}; + +#endif // hifi_FramelessDialog_h diff --git a/interface/src/ui/ImportDialog.cpp b/interface/src/ui/ImportDialog.cpp index 2741fada0a..67b89773fb 100644 --- a/interface/src/ui/ImportDialog.cpp +++ b/interface/src/ui/ImportDialog.cpp @@ -1,9 +1,12 @@ // // ImportDialog.cpp -// hifi +// interface/src/ui // // Created by Clement Brisset on 8/12/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "InterfaceConfig.h" diff --git a/interface/src/ui/ImportDialog.h b/interface/src/ui/ImportDialog.h index 278fac932d..88cfda7a7c 100644 --- a/interface/src/ui/ImportDialog.h +++ b/interface/src/ui/ImportDialog.h @@ -1,13 +1,16 @@ // // ImportDialog.h -// hifi +// interface/src/ui // // Created by Clement Brisset on 8/12/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__ImportDialog__ -#define __hifi__ImportDialog__ +#ifndef hifi_ImportDialog_h +#define hifi_ImportDialog_h #include "InterfaceConfig.h" @@ -67,4 +70,4 @@ private: void setImportTypes(); }; -#endif /* defined(__hifi__ImportDialog__) */ +#endif // hifi_ImportDialog_h diff --git a/interface/src/ui/InfoView.cpp b/interface/src/ui/InfoView.cpp index 8ed4da254c..06de3fdf2e 100644 --- a/interface/src/ui/InfoView.cpp +++ b/interface/src/ui/InfoView.cpp @@ -1,9 +1,12 @@ // -// InfoView -// hifi +// InfoView.cpp +// interface/src/ui // // Created by Stojce Slavkovski on 9/7/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "InfoView.h" diff --git a/interface/src/ui/InfoView.h b/interface/src/ui/InfoView.h index 009587c1d5..94d18ff6a1 100644 --- a/interface/src/ui/InfoView.h +++ b/interface/src/ui/InfoView.h @@ -1,13 +1,16 @@ // // InfoView.h -// hifi +// interface/src/ui // // Created by Stojce Slavkovski on 9/7/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__InfoView__ -#define __hifi__InfoView__ +#ifndef hifi_InfoView_h +#define hifi_InfoView_h #include @@ -26,4 +29,4 @@ private slots: void loaded(bool ok); }; -#endif /* defined(__hifi__InfoView__) */ +#endif // hifi_InfoView_h diff --git a/interface/src/ui/LodToolsDialog.cpp b/interface/src/ui/LodToolsDialog.cpp index 564669757c..35d5eada41 100644 --- a/interface/src/ui/LodToolsDialog.cpp +++ b/interface/src/ui/LodToolsDialog.cpp @@ -1,9 +1,12 @@ // // LodToolsDialog.cpp -// interface +// interface/src/ui // // Created by Brad Hefta-Gaub on 7/19/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/interface/src/ui/LodToolsDialog.h b/interface/src/ui/LodToolsDialog.h index 98a5fce5f8..a3223806aa 100644 --- a/interface/src/ui/LodToolsDialog.h +++ b/interface/src/ui/LodToolsDialog.h @@ -1,13 +1,16 @@ // // LodToolsDialog.h -// interface +// interface/src/ui // // Created by Brad Hefta-Gaub on 7/19/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__LodToolsDialog__ -#define __hifi__LodToolsDialog__ +#ifndef hifi_LodToolsDialog_h +#define hifi_LodToolsDialog_h #include #include @@ -41,5 +44,4 @@ private: QLabel* _feedback; }; -#endif /* defined(__interface__LodToolsDialog__) */ - +#endif // hifi_LodToolsDialog_h diff --git a/interface/src/ui/LogDialog.cpp b/interface/src/ui/LogDialog.cpp index d219c08698..5db704b230 100644 --- a/interface/src/ui/LogDialog.cpp +++ b/interface/src/ui/LogDialog.cpp @@ -1,9 +1,12 @@ // // LogDialog.cpp -// interface +// interface/src/ui // // Created by Stojce Slavkovski on 12/12/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "InterfaceConfig.h" diff --git a/interface/src/ui/LogDialog.h b/interface/src/ui/LogDialog.h index 5138e231c7..914e1b4949 100644 --- a/interface/src/ui/LogDialog.h +++ b/interface/src/ui/LogDialog.h @@ -1,13 +1,16 @@ // // LogDialog.h -// interface +// interface/src/ui // // Created by Stojce Slavkovski on 12/12/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__LogDialog__ -#define __interface__LogDialog__ +#ifndef hifi_LogDialog_h +#define hifi_LogDialog_h #include "InterfaceConfig.h" @@ -71,5 +74,4 @@ private: void showLogData(); }; -#endif - +#endif // hifi_LogDialog_h diff --git a/interface/src/ui/MetavoxelEditor.cpp b/interface/src/ui/MetavoxelEditor.cpp index 19f5902336..a42c84470b 100644 --- a/interface/src/ui/MetavoxelEditor.cpp +++ b/interface/src/ui/MetavoxelEditor.cpp @@ -1,9 +1,16 @@ // // MetavoxelEditor.cpp -// interface +// interface/src/ui // // Created by Andrzej Kapolka on 1/21/14. -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +// include this before QOpenGLFramebufferObject, which includes an earlier version of OpenGL +#include "InterfaceConfig.h" #include #include @@ -13,8 +20,12 @@ #include #include #include +#include +#include #include +#include #include +#include #include #include @@ -565,7 +576,7 @@ void PlaceSpannerTool::render() { } Spanner* spanner = static_cast(_editor->getValue().value().data()); const float SPANNER_ALPHA = 0.25f; - spanner->getRenderer()->render(SPANNER_ALPHA, glm::vec3(), 0.0f); + spanner->getRenderer()->render(SPANNER_ALPHA, SpannerRenderer::DEFAULT_MODE, glm::vec3(), 0.0f); } bool PlaceSpannerTool::appliesTo(const AttributePointer& attribute) const { @@ -582,20 +593,18 @@ bool PlaceSpannerTool::eventFilter(QObject* watched, QEvent* event) { void PlaceSpannerTool::place() { AttributePointer attribute = AttributeRegistry::getInstance()->getAttribute(_editor->getSelectedAttribute()); - if (!attribute) { - return; + if (attribute) { + applyEdit(attribute, _editor->getValue().value()); } - SharedObjectPointer spanner = _editor->getValue().value(); - MetavoxelEditMessage message = { createEdit(attribute, spanner) }; - Application::getInstance()->getMetavoxels()->applyEdit(message); } InsertSpannerTool::InsertSpannerTool(MetavoxelEditor* editor) : PlaceSpannerTool(editor, "Insert Spanner", "Insert") { } -QVariant InsertSpannerTool::createEdit(const AttributePointer& attribute, const SharedObjectPointer& spanner) { - return QVariant::fromValue(InsertSpannerEdit(attribute, spanner)); +void InsertSpannerTool::applyEdit(const AttributePointer& attribute, const SharedObjectPointer& spanner) { + MetavoxelEditMessage message = { QVariant::fromValue(InsertSpannerEdit(attribute, spanner)) }; + Application::getInstance()->getMetavoxels()->applyEdit(message); } RemoveSpannerTool::RemoveSpannerTool(MetavoxelEditor* editor) : @@ -654,6 +663,230 @@ bool SetSpannerTool::appliesTo(const AttributePointer& attribute) const { return attribute == AttributeRegistry::getInstance()->getSpannersAttribute(); } -QVariant SetSpannerTool::createEdit(const AttributePointer& attribute, const SharedObjectPointer& spanner) { - return QVariant::fromValue(SetSpannerEdit(spanner)); +glm::quat DIRECTION_ROTATIONS[] = { + rotationBetween(glm::vec3(-1.0f, 0.0f, 0.0f), IDENTITY_FRONT), + rotationBetween(glm::vec3(1.0f, 0.0f, 0.0f), IDENTITY_FRONT), + rotationBetween(glm::vec3(0.0f, -1.0f, 0.0f), IDENTITY_FRONT), + rotationBetween(glm::vec3(0.0f, 1.0f, 0.0f), IDENTITY_FRONT), + rotationBetween(glm::vec3(0.0f, 0.0f, -1.0f), IDENTITY_FRONT), + rotationBetween(glm::vec3(0.0f, 0.0f, 1.0f), IDENTITY_FRONT) }; + +/// Represents a view from one direction of the spanner to be voxelized. +class DirectionImages { +public: + QImage color; + QVector depth; + glm::vec3 minima; + glm::vec3 maxima; + glm::vec3 scale; +}; + +class Voxelizer : public QRunnable { +public: + + Voxelizer(float size, const Box& bounds, float granularity, const QVector& directionImages); + + virtual void run(); + +private: + + void voxelize(const glm::vec3& center); + + float _size; + Box _bounds; + float _granularity; + QVector _directionImages; +}; + +Voxelizer::Voxelizer(float size, const Box& bounds, float granularity, const QVector& directionImages) : + _size(size), + _bounds(bounds), + _granularity(granularity), + _directionImages(directionImages) { +} + +void Voxelizer::run() { + // voxelize separately each cell within the bounds + float halfSize = _size * 0.5f; + for (float x = _bounds.minimum.x + halfSize; x < _bounds.maximum.x; x += _size) { + for (float y = _bounds.minimum.y + halfSize; y < _bounds.maximum.y; y += _size) { + for (float z = _bounds.minimum.z + halfSize; z < _bounds.maximum.z; z += _size) { + voxelize(glm::vec3(x, y, z)); + } + } + } +} + +class VoxelizationVisitor : public MetavoxelVisitor { +public: + + VoxelizationVisitor(const QVector& directionImages, const glm::vec3& center, float granularity); + + virtual int visit(MetavoxelInfo& info); + +private: + + QVector _directionImages; + glm::vec3 _center; + float _granularity; +}; + +VoxelizationVisitor::VoxelizationVisitor(const QVector& directionImages, + const glm::vec3& center, float granularity) : + MetavoxelVisitor(QVector(), QVector() << + AttributeRegistry::getInstance()->getColorAttribute()), + _directionImages(directionImages), + _center(center), + _granularity(granularity) { +} + +bool checkDisjoint(const DirectionImages& images, const glm::vec3& minimum, const glm::vec3& maximum, float extent) { + for (int x = qMax(0, (int)minimum.x), xmax = qMin(images.color.width(), (int)maximum.x); x < xmax; x++) { + for (int y = qMax(0, (int)minimum.y), ymax = qMin(images.color.height(), (int)maximum.y); y < ymax; y++) { + float depth = 1.0f - images.depth.at(y * images.color.width() + x); + if (depth - minimum.z >= -extent - EPSILON) { + return false; + } + } + } + return true; +} + +int VoxelizationVisitor::visit(MetavoxelInfo& info) { + float halfSize = info.size * 0.5f; + glm::vec3 center = info.minimum + _center + glm::vec3(halfSize, halfSize, halfSize); + const float EXTENT_SCALE = 2.0f; + if (info.size > _granularity) { + for (unsigned int i = 0; i < sizeof(DIRECTION_ROTATIONS) / sizeof(DIRECTION_ROTATIONS[0]); i++) { + glm::vec3 rotated = DIRECTION_ROTATIONS[i] * center; + const DirectionImages& images = _directionImages.at(i); + glm::vec3 relative = (rotated - images.minima) * images.scale; + glm::vec3 extents = images.scale * halfSize; + glm::vec3 minimum = relative - extents; + glm::vec3 maximum = relative + extents; + if (checkDisjoint(images, minimum, maximum, extents.z * EXTENT_SCALE)) { + info.outputValues[0] = AttributeValue(_outputs.at(0)); + return STOP_RECURSION; + } + } + return DEFAULT_ORDER; + } + QRgb closestColor; + float closestDistance = FLT_MAX; + for (unsigned int i = 0; i < sizeof(DIRECTION_ROTATIONS) / sizeof(DIRECTION_ROTATIONS[0]); i++) { + glm::vec3 rotated = DIRECTION_ROTATIONS[i] * center; + const DirectionImages& images = _directionImages.at(i); + glm::vec3 relative = (rotated - images.minima) * images.scale; + int x = qMax(qMin((int)glm::round(relative.x), images.color.width() - 1), 0); + int y = qMax(qMin((int)glm::round(relative.y), images.color.height() - 1), 0); + float depth = 1.0f - images.depth.at(y * images.color.width() + x); + float distance = depth - relative.z; + float extent = images.scale.z * halfSize * EXTENT_SCALE; + if (distance < -extent - EPSILON) { + info.outputValues[0] = AttributeValue(_outputs.at(0)); + return STOP_RECURSION; + } + QRgb color = images.color.pixel(x, y); + if (distance < extent + EPSILON) { + info.outputValues[0] = AttributeValue(_outputs.at(0), encodeInline(color)); + return STOP_RECURSION; + } + if (distance < closestDistance) { + closestColor = color; + closestDistance = distance; + } + } + info.outputValues[0] = AttributeValue(_outputs.at(0), encodeInline(closestColor)); + return STOP_RECURSION; +} + +void Voxelizer::voxelize(const glm::vec3& center) { + MetavoxelData data; + data.setSize(_size); + + VoxelizationVisitor visitor(_directionImages, center, _granularity); + data.guide(visitor); + + MetavoxelEditMessage edit = { QVariant::fromValue(SetDataEdit( + center - glm::vec3(_size, _size, _size) * 0.5f, data, true)) }; + QMetaObject::invokeMethod(Application::getInstance()->getMetavoxels(), "applyEdit", + Q_ARG(const MetavoxelEditMessage&, edit), Q_ARG(bool, true)); +} + +void SetSpannerTool::applyEdit(const AttributePointer& attribute, const SharedObjectPointer& spanner) { + Spanner* spannerData = static_cast(spanner.data()); + Box bounds = spannerData->getBounds(); + float longestSide(qMax(bounds.getLongestSide(), spannerData->getPlacementGranularity())); + float size = powf(2.0f, floorf(logf(longestSide) / logf(2.0f))); + Box cellBounds(glm::floor(bounds.minimum / size) * size, glm::ceil(bounds.maximum / size) * size); + + Application::getInstance()->getTextureCache()->getPrimaryFramebufferObject()->bind(); + + glEnable(GL_SCISSOR_TEST); + glEnable(GL_LIGHTING); + glEnable(GL_DEPTH_TEST); + glDisable(GL_BLEND); + + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + + QVector directionImages; + + for (unsigned int i = 0; i < sizeof(DIRECTION_ROTATIONS) / sizeof(DIRECTION_ROTATIONS[0]); i++) { + glm::vec3 minima(FLT_MAX, FLT_MAX, FLT_MAX); + glm::vec3 maxima(-FLT_MAX, -FLT_MAX, -FLT_MAX); + for (int j = 0; j < Box::VERTEX_COUNT; j++) { + glm::vec3 rotated = DIRECTION_ROTATIONS[i] * cellBounds.getVertex(j); + minima = glm::min(minima, rotated); + maxima = glm::max(maxima, rotated); + } + float renderGranularity = spannerData->getVoxelizationGranularity() / 4.0f; + int width = glm::round((maxima.x - minima.x) / renderGranularity); + int height = glm::round((maxima.y - minima.y) / renderGranularity); + + glViewport(0, 0, width, height); + glScissor(0, 0, width, height); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glLoadIdentity(); + glOrtho(minima.x, maxima.x, minima.y, maxima.y, -maxima.z, -minima.z); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glm::vec3 axis = glm::axis(DIRECTION_ROTATIONS[i]); + glRotatef(glm::degrees(glm::angle(DIRECTION_ROTATIONS[i])), axis.x, axis.y, axis.z); + + Application::getInstance()->setupWorldLight(); + + Application::getInstance()->updateUntranslatedViewMatrix(); + + spannerData->getRenderer()->render(1.0f, SpannerRenderer::DIFFUSE_MODE, glm::vec3(), 0.0f); + + DirectionImages images = { QImage(width, height, QImage::Format_ARGB32), + QVector(width * height), minima, maxima, glm::vec3(width / (maxima.x - minima.x), + height / (maxima.y - minima.y), 1.0f / (maxima.z - minima.z)) }; + glReadPixels(0, 0, width, height, GL_BGRA, GL_UNSIGNED_BYTE, images.color.bits()); + glReadPixels(0, 0, width, height, GL_DEPTH_COMPONENT, GL_FLOAT, images.depth.data()); + directionImages.append(images); + + glMatrixMode(GL_PROJECTION); + } + glPopMatrix(); + + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + + glEnable(GL_BLEND); + glDisable(GL_SCISSOR_TEST); + + Application::getInstance()->getTextureCache()->getPrimaryFramebufferObject()->release(); + + glViewport(0, 0, Application::getInstance()->getGLWidget()->width(), Application::getInstance()->getGLWidget()->height()); + + // send the images off to the lab for processing + QThreadPool::globalInstance()->start(new Voxelizer(size, cellBounds, + spannerData->getVoxelizationGranularity(), directionImages)); } diff --git a/interface/src/ui/MetavoxelEditor.h b/interface/src/ui/MetavoxelEditor.h index 76ef8baf6f..79ffd1e64c 100644 --- a/interface/src/ui/MetavoxelEditor.h +++ b/interface/src/ui/MetavoxelEditor.h @@ -1,13 +1,16 @@ // // MetavoxelEditor.h -// interface +// interface/src/ui // // Created by Andrzej Kapolka on 1/21/14. -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__MetavoxelEditor__ -#define __interface__MetavoxelEditor__ +#ifndef hifi_MetavoxelEditor_h +#define hifi_MetavoxelEditor_h #include #include @@ -157,7 +160,7 @@ public: protected: - virtual QVariant createEdit(const AttributePointer& attribute, const SharedObjectPointer& spanner) = 0; + virtual void applyEdit(const AttributePointer& attribute, const SharedObjectPointer& spanner) = 0; private slots: @@ -174,7 +177,7 @@ public: protected: - virtual QVariant createEdit(const AttributePointer& attribute, const SharedObjectPointer& spanner); + virtual void applyEdit(const AttributePointer& attribute, const SharedObjectPointer& spanner); }; /// Allows removing a spanner from the scene. @@ -217,7 +220,7 @@ public: protected: - virtual QVariant createEdit(const AttributePointer& attribute, const SharedObjectPointer& spanner); + virtual void applyEdit(const AttributePointer& attribute, const SharedObjectPointer& spanner); }; -#endif /* defined(__interface__MetavoxelEditor__) */ +#endif // hifi_MetavoxelEditor_h diff --git a/interface/src/ui/ModelBrowser.cpp b/interface/src/ui/ModelBrowser.cpp deleted file mode 100644 index e03081273f..0000000000 --- a/interface/src/ui/ModelBrowser.cpp +++ /dev/null @@ -1,150 +0,0 @@ -// -// ModelBrowser.cpp -// hifi -// -// Created by Clement on 3/17/14. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. -// - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "ModelBrowser.h" - -static const QString PREFIX_PARAMETER_NAME = "prefix"; -static const QString MARKER_PARAMETER_NAME = "marker"; -static const QString IS_TRUNCATED_NAME = "IsTruncated"; -static const QString CONTAINER_NAME = "Contents"; -static const QString KEY_NAME = "Key"; - -ModelBrowser::ModelBrowser(ModelType modelType, QWidget* parent) : QWidget(parent), _type(modelType) { - QUrl url(S3_URL); - QUrlQuery query; - - if (_type == Head) { - query.addQueryItem(PREFIX_PARAMETER_NAME, HEAD_MODELS_LOCATION); - } else if (_type == Skeleton) { - query.addQueryItem(PREFIX_PARAMETER_NAME, SKELETON_MODELS_LOCATION); - } - url.setQuery(query); - - _downloader = new FileDownloader(url); - connect(_downloader, SIGNAL(done(QNetworkReply::NetworkError)), SLOT(downloadFinished())); -} - -ModelBrowser::~ModelBrowser() { - delete _downloader; -} - -void ModelBrowser::downloadFinished() { - parseXML(_downloader->getData()); -} - -void ModelBrowser::browse() { - QDialog dialog(this); - dialog.setWindowTitle("Browse models"); - - QGridLayout* layout = new QGridLayout(&dialog); - dialog.setLayout(layout); - - QLineEdit* searchBar = new QLineEdit(&dialog); - layout->addWidget(searchBar, 0, 0); - - ListView* listView = new ListView(&dialog); - listView->setEditTriggers(QAbstractItemView::NoEditTriggers); - layout->addWidget(listView, 1, 0); - listView->connect(searchBar, SIGNAL(textChanged(const QString&)), SLOT(keyboardSearch(const QString&))); - dialog.connect(listView, SIGNAL(doubleClicked(const QModelIndex&)), SLOT(accept())); - - QStringListModel* model = new QStringListModel(_models.keys(), listView); - model->sort(0); - listView->setModel(model); - - QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); - layout->addWidget(buttons, 2, 0); - dialog.connect(buttons, SIGNAL(accepted()), SLOT(accept())); - dialog.connect(buttons, SIGNAL(rejected()), SLOT(reject())); - - if (dialog.exec() == QDialog::Rejected) { - return; - } - - QString selectedKey = model->data(listView->currentIndex(), Qt::DisplayRole).toString(); - - emit selected(_models[selectedKey]); -} - -bool ModelBrowser::parseXML(QByteArray xmlFile) { - QXmlStreamReader xml(xmlFile); - QRegExp rx(".*fst"); - bool truncated = false; - QString lastKey; - - // Read xml until the end or an error is detected - while(!xml.atEnd() && !xml.hasError()) { - if(xml.tokenType() == QXmlStreamReader::StartElement && xml.name() == IS_TRUNCATED_NAME) { - while(!(xml.tokenType() == QXmlStreamReader::EndElement && xml.name() == IS_TRUNCATED_NAME)) { - // Let's check if there is more - xml.readNext(); - if (xml.text().toString() == "True") { - truncated = true; - } - } - } - - if(xml.tokenType() == QXmlStreamReader::StartElement && xml.name() == CONTAINER_NAME) { - while(!(xml.tokenType() == QXmlStreamReader::EndElement && xml.name() == CONTAINER_NAME)) { - // If a file is find, process it - if(xml.tokenType() == QXmlStreamReader::StartElement && xml.name() == KEY_NAME) { - xml.readNext(); - lastKey = xml.text().toString(); - if (rx.exactMatch(xml.text().toString())) { - // Add the found file to the list - _models.insert(QFileInfo(xml.text().toString()).baseName(), - S3_URL + "/" + xml.text().toString()); - } - } - xml.readNext(); - } - } - xml.readNext(); - } - - // Error handling - if(xml.hasError()) { - _models.clear(); - QMessageBox::critical(this, - "ModelBrowser::ModelBrowser()", - xml.errorString(), - QMessageBox::Ok); - return false; - } - - // If we didn't all the files, download the next ones - if (truncated) { - QUrl url(S3_URL); - QUrlQuery query; - - if (_type == Head) { - query.addQueryItem(PREFIX_PARAMETER_NAME, HEAD_MODELS_LOCATION); - } else if (_type == Skeleton) { - query.addQueryItem(PREFIX_PARAMETER_NAME, SKELETON_MODELS_LOCATION); - } - query.addQueryItem(MARKER_PARAMETER_NAME, lastKey); - url.setQuery(query); - - delete _downloader; - _downloader = new FileDownloader(url); - connect(_downloader, SIGNAL(done(QNetworkReply::NetworkError)), SLOT(downloadFinished())); - } - - return true; -} \ No newline at end of file diff --git a/interface/src/ui/ModelBrowser.h b/interface/src/ui/ModelBrowser.h deleted file mode 100644 index 4628642e89..0000000000 --- a/interface/src/ui/ModelBrowser.h +++ /dev/null @@ -1,62 +0,0 @@ -// -// ModelBrowser.h -// hifi -// -// Created by Clement on 3/17/14. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. -// - -#ifndef __hifi__ModelBrowser__ -#define __hifi__ModelBrowser__ - -#include - -#include -#include - -static const QString S3_URL = "http://highfidelity-public.s3-us-west-1.amazonaws.com"; -static const QString HEAD_MODELS_LOCATION = "models/heads/"; -static const QString SKELETON_MODELS_LOCATION = "models/skeletons/"; - -enum ModelType { - Head, - Skeleton -}; - -class ModelBrowser : public QWidget { - Q_OBJECT - -public: - ModelBrowser(ModelType modelType, QWidget* parent = NULL); - ~ModelBrowser(); - -signals: - void selected(QString filename); - -public slots: - void browse(); - -private slots: - void downloadFinished(); - -private: - ModelType _type; - FileDownloader* _downloader; - QHash _models; - - bool parseXML(QByteArray xmlFile); -}; - - - -class ListView : public QListView { - Q_OBJECT -public: - ListView(QWidget* parent) : QListView(parent) {} - public slots: - void keyboardSearch(const QString& text) { - QAbstractItemView::keyboardSearch(text); - } -}; - -#endif /* defined(__hifi__ModelBrowser__) */ diff --git a/interface/src/ui/ModelsBrowser.cpp b/interface/src/ui/ModelsBrowser.cpp new file mode 100644 index 0000000000..77e056bdd3 --- /dev/null +++ b/interface/src/ui/ModelsBrowser.cpp @@ -0,0 +1,374 @@ +// +// ModelsBrowser.cpp +// interface/src/ui +// +// Created by Clement on 3/17/14. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "Application.h" + +#include "ModelsBrowser.h" + +static const QString S3_URL = "http://highfidelity-public.s3-us-west-1.amazonaws.com"; +static const QString PUBLIC_URL = "http://public.highfidelity.io"; +static const QString HEAD_MODELS_LOCATION = "models/heads"; +static const QString SKELETON_MODELS_LOCATION = "models/skeletons/"; + +static const QString PREFIX_PARAMETER_NAME = "prefix"; +static const QString MARKER_PARAMETER_NAME = "marker"; +static const QString IS_TRUNCATED_NAME = "IsTruncated"; +static const QString CONTAINER_NAME = "Contents"; +static const QString KEY_NAME = "Key"; +static const QString LOADING_MSG = "Loading..."; +static const QString ERROR_MSG = "Error loading files"; + +static const QString DO_NOT_MODIFY_TAG = "DoNotModify"; + +enum ModelMetaData { + NAME, + CREATOR, + DATE_ADDED, + TOTAL_SIZE, + POLY_NUM, + TAGS, + + MODEL_METADATA_COUNT +}; +static const QString propertiesNames[MODEL_METADATA_COUNT] = { + "Name", + "Creator", + "Date Added", + "Total Size", + "Poly#", + "Tags" +}; +static const QString propertiesIds[MODEL_METADATA_COUNT] = { + DO_NOT_MODIFY_TAG, + "Creator", + "Date-Added", + "Total-Size", + "Poly-Num", + "Tags" +}; + +ModelsBrowser::ModelsBrowser(ModelType modelsType, QWidget* parent) : + QWidget(parent, Qt::WindowStaysOnTopHint), + _handler(new ModelHandler(modelsType)) +{ + connect(_handler, SIGNAL(doneDownloading()), SLOT(resizeView())); + connect(_handler, SIGNAL(updated()), SLOT(resizeView())); + + // Connect handler + _handler->connect(this, SIGNAL(startDownloading()), SLOT(download())); + _handler->connect(_handler, SIGNAL(doneDownloading()), SLOT(update())); + _handler->connect(this, SIGNAL(destroyed()), SLOT(exit())); + + // Setup and launch update thread + QThread* thread = new QThread(); + thread->connect(_handler, SIGNAL(destroyed()), SLOT(quit())); + thread->connect(thread, SIGNAL(finished()), SLOT(deleteLater())); + _handler->moveToThread(thread); + thread->start(); + emit startDownloading(); + + // Initialize the view + _view.setEditTriggers(QAbstractItemView::NoEditTriggers); + _view.setRootIsDecorated(false); + _view.setModel(_handler->getModel()); +} + +void ModelsBrowser::applyFilter(const QString &filter) { + QStringList filters = filter.split(" "); + + _handler->lockModel(); + QStandardItemModel* model = _handler->getModel(); + int rows = model->rowCount(); + + // Try and match every filter with each rows + for (int i = 0; i < rows; ++i) { + bool match = false; + for (int k = 0; k < filters.count(); ++k) { + match = false; + for (int j = 0; j < MODEL_METADATA_COUNT; ++j) { + if (model->item(i, j)->text().contains(filters.at(k), Qt::CaseInsensitive)) { + match = true; + break; + } + } + if (!match) { + break; + } + } + + // Hid the row if it doesn't match (Make sure it's not it it does) + if (match) { + _view.setRowHidden(i, QModelIndex(), false); + } else { + _view.setRowHidden(i, QModelIndex(), true); + } + } + _handler->unlockModel(); +} + +void ModelsBrowser::resizeView() { + for (int i = 0; i < MODEL_METADATA_COUNT; ++i) { + _view.resizeColumnToContents(i); + } +} + +void ModelsBrowser::browse() { + QDialog dialog; + dialog.setWindowTitle("Browse models"); + dialog.setMinimumSize(570, 500); + + QGridLayout* layout = new QGridLayout(&dialog); + dialog.setLayout(layout); + + QLineEdit* searchBar = new QLineEdit(&dialog); + layout->addWidget(searchBar, 0, 0); + + layout->addWidget(&_view, 1, 0); + dialog.connect(&_view, SIGNAL(doubleClicked(const QModelIndex&)), SLOT(accept())); + connect(searchBar, SIGNAL(textChanged(const QString&)), SLOT(applyFilter(const QString&))); + + QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + layout->addWidget(buttons, 2, 0); + dialog.connect(buttons, SIGNAL(accepted()), SLOT(accept())); + dialog.connect(buttons, SIGNAL(rejected()), SLOT(reject())); + + if (dialog.exec() == QDialog::Accepted) { + _handler->lockModel(); + QVariant selectedFile = _handler->getModel()->data(_view.currentIndex(), Qt::UserRole); + _handler->unlockModel(); + if (selectedFile.isValid()) { + emit selected(selectedFile.toString()); + } + } + + // So that we don't have to reconstruct the view + _view.setParent(NULL); +} + + +ModelHandler::ModelHandler(ModelType modelsType, QWidget* parent) : + QObject(parent), + _initiateExit(false), + _type(modelsType) +{ + // set headers data + QStringList headerData; + for (int i = 0; i < MODEL_METADATA_COUNT; ++i) { + headerData << propertiesNames[i]; + } + _model.setHorizontalHeaderLabels(headerData); +} + +void ModelHandler::download() { + _lock.lockForWrite(); + if (_initiateExit) { + _lock.unlock(); + return; + } + // Show loading message + QStandardItem* loadingItem = new QStandardItem(LOADING_MSG); + loadingItem->setEnabled(false); + _model.appendRow(loadingItem); + _lock.unlock(); + + // Query models list + queryNewFiles(); +} + +void ModelHandler::update() { + _lock.lockForWrite(); + if (_initiateExit) { + _lock.unlock(); + return; + } + for (int i = 0; i < _model.rowCount(); ++i) { + QUrl url(_model.item(i,0)->data(Qt::UserRole).toString()); + QNetworkAccessManager* accessManager = new QNetworkAccessManager(this); + QNetworkRequest request(url); + accessManager->head(request); + connect(accessManager, SIGNAL(finished(QNetworkReply*)), SLOT(downloadFinished(QNetworkReply*))); + } + _lock.unlock(); +} + +void ModelHandler::exit() { + _lock.lockForWrite(); + _initiateExit = true; + + // Disconnect everything + disconnect(); + thread()->disconnect(); + + // Make sure the thread will exit correctly + thread()->connect(this, SIGNAL(destroyed()), SLOT(quit())); + thread()->connect(thread(), SIGNAL(finished()), SLOT(deleteLater())); + deleteLater(); + _lock.unlock(); +} + +void ModelHandler::downloadFinished(QNetworkReply* reply) { + QByteArray data = reply->readAll(); + + if (!data.isEmpty()) { + parseXML(data); + } else { + parseHeaders(reply); + } + reply->deleteLater(); + sender()->deleteLater(); +} + +void ModelHandler::queryNewFiles(QString marker) { + if (_initiateExit) { + return; + } + + // Build query + QUrl url(S3_URL); + QUrlQuery query; + if (_type == Head) { + query.addQueryItem(PREFIX_PARAMETER_NAME, HEAD_MODELS_LOCATION); + } else if (_type == Skeleton) { + query.addQueryItem(PREFIX_PARAMETER_NAME, SKELETON_MODELS_LOCATION); + } + + if (!marker.isEmpty()) { + query.addQueryItem(MARKER_PARAMETER_NAME, marker); + } + + // Download + url.setQuery(query); + QNetworkAccessManager* accessManager = new QNetworkAccessManager(this); + QNetworkRequest request(url); + accessManager->get(request); + connect(accessManager, SIGNAL(finished(QNetworkReply*)), SLOT(downloadFinished(QNetworkReply*))); + +} + +bool ModelHandler::parseXML(QByteArray xmlFile) { + _lock.lockForWrite(); + if (_initiateExit) { + _lock.unlock(); + return false; + } + + QXmlStreamReader xml(xmlFile); + QRegExp rx(".*fst"); + bool truncated = false; + QString lastKey; + + // Remove loading indication + int oldLastRow = _model.rowCount() - 1; + delete _model.takeRow(oldLastRow).first(); + + // Read xml until the end or an error is detected + while(!xml.atEnd() && !xml.hasError()) { + if (_initiateExit) { + _lock.unlock(); + return false; + } + + if(xml.tokenType() == QXmlStreamReader::StartElement && xml.name() == IS_TRUNCATED_NAME) { + while(!(xml.tokenType() == QXmlStreamReader::EndElement && xml.name() == IS_TRUNCATED_NAME)) { + // Let's check if there is more + xml.readNext(); + if (xml.text().toString() == "True") { + truncated = true; + } + } + } + + if(xml.tokenType() == QXmlStreamReader::StartElement && xml.name() == CONTAINER_NAME) { + while(!(xml.tokenType() == QXmlStreamReader::EndElement && xml.name() == CONTAINER_NAME)) { + // If a file is find, process it + if(xml.tokenType() == QXmlStreamReader::StartElement && xml.name() == KEY_NAME) { + xml.readNext(); + lastKey = xml.text().toString(); + if (rx.exactMatch(xml.text().toString())) { + // Add the found file to the list + QList model; + model << new QStandardItem(QFileInfo(xml.text().toString()).baseName()); + model.first()->setData(PUBLIC_URL + "/" + xml.text().toString(), Qt::UserRole); + for (int i = 1; i < MODEL_METADATA_COUNT; ++i) { + model << new QStandardItem(); + } + + _model.appendRow(model); + } + } + xml.readNext(); + } + } + xml.readNext(); + } + + // Error handling + if(xml.hasError()) { + _model.clear(); + QStandardItem* errorItem = new QStandardItem(ERROR_MSG); + errorItem->setEnabled(false); + _model.appendRow(errorItem); + + _lock.unlock(); + return false; + } + + // If we didn't all the files, download the next ones + if (truncated) { + // Indicate more files are being loaded + QStandardItem* loadingItem = new QStandardItem(LOADING_MSG); + loadingItem->setEnabled(false); + _model.appendRow(loadingItem); + + // query those files + queryNewFiles(lastKey); + } + _lock.unlock(); + + if (!truncated) { + emit doneDownloading(); + } + + return true; +} + +bool ModelHandler::parseHeaders(QNetworkReply* reply) { + _lock.lockForWrite(); + + QList items = _model.findItems(QFileInfo(reply->url().toString()).baseName()); + if (items.isEmpty() || items.first()->text() == DO_NOT_MODIFY_TAG) { + return false; + } + + for (int i = 0; i < MODEL_METADATA_COUNT; ++i) { + for (int k = 1; k < reply->rawHeaderPairs().count(); ++k) { + QString key = reply->rawHeaderPairs().at(k).first.data(); + QString item = reply->rawHeaderPairs().at(k).second.data(); + if (key == propertiesIds[i]) { + _model.item(_model.indexFromItem(items.first()).row(), i)->setText(item); + } + } + } + _lock.unlock(); + + emit updated(); + return true; +} + diff --git a/interface/src/ui/ModelsBrowser.h b/interface/src/ui/ModelsBrowser.h new file mode 100644 index 0000000000..81f64c6730 --- /dev/null +++ b/interface/src/ui/ModelsBrowser.h @@ -0,0 +1,81 @@ +// +// ModelsBrowser.h +// interface/src/ui +// +// Created by Clement on 3/17/14. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_ModelsBrowser_h +#define hifi_ModelsBrowser_h + +#include +#include +#include + + +enum ModelType { + Head, + Skeleton +}; + +class ModelHandler : public QObject { + Q_OBJECT +public: + ModelHandler(ModelType modelsType, QWidget* parent = NULL); + + void lockModel() { _lock.lockForRead(); } + QStandardItemModel* getModel() { return &_model; } + void unlockModel() { _lock.unlock(); } + +signals: + void doneDownloading(); + void updated(); + +public slots: + void download(); + void update(); + void exit(); + +private slots: + void downloadFinished(QNetworkReply* reply); + +private: + bool _initiateExit; + ModelType _type; + QReadWriteLock _lock; + QStandardItemModel _model; + + void queryNewFiles(QString marker = QString()); + bool parseXML(QByteArray xmlFile); + bool parseHeaders(QNetworkReply* reply); +}; + + +class ModelsBrowser : public QWidget { + Q_OBJECT +public: + + ModelsBrowser(ModelType modelsType, QWidget* parent = NULL); + +signals: + void startDownloading(); + void startUpdating(); + void selected(QString filename); + +public slots: + void browse(); + +private slots: + void applyFilter(const QString& filter); + void resizeView(); + +private: + ModelHandler* _handler; + QTreeView _view; +}; + +#endif // hifi_ModelsBrowser_h diff --git a/interface/src/ui/OctreeStatsDialog.cpp b/interface/src/ui/OctreeStatsDialog.cpp index daf5a68587..c56aa0b6ab 100644 --- a/interface/src/ui/OctreeStatsDialog.cpp +++ b/interface/src/ui/OctreeStatsDialog.cpp @@ -1,9 +1,12 @@ // // OctreeStatsDialog.cpp -// interface +// interface/src/ui // // Created by Brad Hefta-Gaub on 7/19/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/interface/src/ui/OctreeStatsDialog.h b/interface/src/ui/OctreeStatsDialog.h index ef190e6a52..2488667a09 100644 --- a/interface/src/ui/OctreeStatsDialog.h +++ b/interface/src/ui/OctreeStatsDialog.h @@ -1,13 +1,16 @@ // // OctreeStatsDialog.h -// interface +// interface/src/ui // // Created by Brad Hefta-Gaub on 7/19/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__OctreeStatsDialog__ -#define __hifi__OctreeStatsDialog__ +#ifndef hifi_OctreeStatsDialog_h +#define hifi_OctreeStatsDialog_h #include #include @@ -66,5 +69,4 @@ private: details _extraServerDetails[MAX_VOXEL_SERVERS]; }; -#endif /* defined(__interface__OctreeStatsDialog__) */ - +#endif // hifi_OctreeStatsDialog_h diff --git a/interface/src/ui/Oscilloscope.cpp b/interface/src/ui/Oscilloscope.cpp deleted file mode 100644 index a47586b436..0000000000 --- a/interface/src/ui/Oscilloscope.cpp +++ /dev/null @@ -1,189 +0,0 @@ -// -// Oscilloscope.cpp -// interface -// -// Created by Philip on 1/28/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. -// - -#include -#include -#include - -#include -#include - -#include "InterfaceConfig.h" - -#include "Oscilloscope.h" - -// Reimplemented 4/26/13 (tosh) - don't blame Philip for bugs - -using namespace std; - -namespace { // everything in here only exists while compiling this .cpp file - - // one sample buffer per channel - unsigned const MAX_SAMPLES = Oscilloscope::MAX_SAMPLES_PER_CHANNEL * Oscilloscope::MAX_CHANNELS; - - // adding an x-coordinate yields twice the amount of vertices - unsigned const MAX_COORDS_PER_CHANNEL = Oscilloscope::MAX_SAMPLES_PER_CHANNEL * 2; - // allocated once for each channel - unsigned const MAX_COORDS = MAX_COORDS_PER_CHANNEL * Oscilloscope::MAX_CHANNELS; - - // total amount of memory to allocate (in 16-bit integers) - unsigned const N_INT16_TO_ALLOC = MAX_SAMPLES + MAX_COORDS; -} - - -Oscilloscope::Oscilloscope(int w, int h, bool isEnabled) : - enabled(isEnabled), - inputPaused(false), - _width(w), - _height(h), - _samples(0l), - _vertices(0l), - // some filtering (see details in Log.h) - _lowPassCoeff(0.4f), - // three in -> one out - _downsampleRatio(3) { - - // allocate enough space for the sample data and to turn it into - // vertices and since they're all 'short', do so in one shot - _samples = new short[N_INT16_TO_ALLOC]; - memset(_samples, 0, N_INT16_TO_ALLOC * sizeof(short)); - _vertices = _samples + MAX_SAMPLES; - - // initialize write positions to start of each channel's region - for (unsigned ch = 0; ch < MAX_CHANNELS; ++ch) { - _writePos[ch] = MAX_SAMPLES_PER_CHANNEL * ch; - } - - _colors[0] = 0xffffff; - _colors[1] = 0x00ffff; - _colors[2] = 0x00ffff; -} - -Oscilloscope::~Oscilloscope() { - - delete[] _samples; -} - -void Oscilloscope::addSamples(const QByteArray& audioByteArray, bool isStereo, bool isInput) { - - if (! enabled || inputPaused) { - return; - } - - unsigned numSamplesPerChannel = audioByteArray.size() / (sizeof(int16_t) * (isStereo ? 2 : 1)); - int16_t* samples = (int16_t*) audioByteArray.data(); - - for (int channel = 0; channel < (isStereo ? 2 : 1); channel++) { - // add samples for each of the channels - - // determine start/end offset of this channel's region - unsigned baseOffs = MAX_SAMPLES_PER_CHANNEL * (channel + !isInput); - unsigned endOffs = baseOffs + MAX_SAMPLES_PER_CHANNEL; - - // fetch write position for this channel - unsigned writePos = _writePos[channel + !isInput]; - - // determine write position after adding the samples - unsigned newWritePos = writePos + numSamplesPerChannel; - unsigned n2 = 0; - if (newWritePos >= endOffs) { - // passed boundary of the circular buffer? -> we need to copy two blocks - n2 = newWritePos - endOffs; - newWritePos = baseOffs + n2; - numSamplesPerChannel -= n2; - } - - if (!isStereo) { - // copy data - memcpy(_samples + writePos, samples, numSamplesPerChannel * sizeof(int16_t)); - if (n2 > 0) { - memcpy(_samples + baseOffs, samples + numSamplesPerChannel, n2 * sizeof(int16_t)); - } - } else { - // we have interleaved samples we need to separate into two channels - for (unsigned i = 0; i < numSamplesPerChannel + n2; i++) { - if (i < numSamplesPerChannel - n2) { - _samples[writePos] = samples[(i * 2) + channel]; - } else { - _samples[baseOffs] = samples[(i * 2) + channel]; - } - } - } - - // set new write position for this channel - _writePos[channel + !isInput] = newWritePos; - } -} - -void Oscilloscope::render(int x, int y) { - - if (! enabled) { - return; - } - - // fetch low pass factor (and convert to fix point) / downsample factor - int lowPassFixPt = -(int)(std::numeric_limits::min()) * _lowPassCoeff; - unsigned downsample = _downsampleRatio; - // keep half of the buffer for writing and ensure an even vertex count - unsigned usedWidth = min(_width, MAX_SAMPLES_PER_CHANNEL / (downsample * 2)) & ~1u; - unsigned usedSamples = usedWidth * downsample; - - // expand samples to vertex data - for (unsigned ch = 0; ch < MAX_CHANNELS; ++ch) { - // for each channel: determine memory regions - short const* basePtr = _samples + MAX_SAMPLES_PER_CHANNEL * ch; - short const* endPtr = basePtr + MAX_SAMPLES_PER_CHANNEL; - short const* inPtr = _samples + _writePos[ch]; - short* outPtr = _vertices + MAX_COORDS_PER_CHANNEL * ch; - int sample = 0, x = usedWidth; - for (int i = (int)usedSamples; --i >= 0 ;) { - if (inPtr == basePtr) { - // handle boundary, reading the circular sample buffer - inPtr = endPtr; - } - // read and (eventually) filter sample - sample += ((*--inPtr - sample) * lowPassFixPt) >> 15; - // write every nth as y with a corresponding x-coordinate - if (i % downsample == 0) { - *outPtr++ = short(--x); - *outPtr++ = short(sample); - } - } - } - - // set up rendering state (vertex data lives at _vertices) - glLineWidth(1.0); - glDisable(GL_LINE_SMOOTH); - glPushMatrix(); - glTranslatef((float)x + 0.0f, (float)y + _height / 2.0f, 0.0f); - glScaled(1.0f, _height / 32767.0f, 1.0f); - glVertexPointer(2, GL_SHORT, 0, _vertices); - glEnableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_COLOR_ARRAY); - glDisableClientState(GL_INDEX_ARRAY); - glDisableClientState(GL_NORMAL_ARRAY); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - - // render channel 0 - glColor3ub(GLubyte(_colors[0] >> 16), GLubyte((_colors[0] >> 8) & 0xff), GLubyte(_colors[0] & 0xff)); - glDrawArrays(GL_LINES, MAX_SAMPLES_PER_CHANNEL * 0, usedWidth); - - // render channel 1 - glColor3f(0.0f, 1.0f ,1.0f); - glColor3ub(GLubyte(_colors[1] >> 16), GLubyte((_colors[1] >> 8) & 0xff), GLubyte(_colors[1] & 0xff)); - glDrawArrays(GL_LINES, MAX_SAMPLES_PER_CHANNEL * 1, usedWidth); - - // render channel 2 - glColor3ub(GLubyte(_colors[2] >> 16), GLubyte((_colors[2] >> 8) & 0xff), GLubyte(_colors[2] & 0xff)); - glDrawArrays(GL_LINES, MAX_SAMPLES_PER_CHANNEL * 2, usedWidth); - - // reset rendering state - glDisableClientState(GL_VERTEX_ARRAY); - glPopMatrix(); -} - diff --git a/interface/src/ui/Oscilloscope.h b/interface/src/ui/Oscilloscope.h deleted file mode 100644 index a245f79f05..0000000000 --- a/interface/src/ui/Oscilloscope.h +++ /dev/null @@ -1,81 +0,0 @@ -// -// Oscilloscope.h -// interface -// -// Created by Philip on 1/28/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. -// - -#ifndef __interface__Oscilloscope__ -#define __interface__Oscilloscope__ - -#include - -#include - -class Oscilloscope : public QObject { - Q_OBJECT -public: - Oscilloscope(int width, int height, bool isEnabled); - ~Oscilloscope(); - - void render(int x, int y); - - // Switches: On/Off, Stop Time - volatile bool enabled; - volatile bool inputPaused; - - // Limits - static unsigned const MAX_CHANNELS = 3; - static unsigned const MAX_SAMPLES_PER_CHANNEL = 4096; - - // Sets the color for a specific channel. - void setColor(unsigned ch, unsigned rgb) { assert(ch < MAX_CHANNELS); if (! inputPaused) { _colors[ch] = rgb; } } - - // Controls a simple one pole IIR low pass filter that is provided to - // reduce high frequencies aliasing (to lower ones) when downsampling. - // - // The parameter sets the influence of the input in respect to the - // feed-back signal on the output. - // - // +---------+ - // in O--------------|+ ideal |--o--------------O out - // .---|- op amp | | - // | +---------+ | - // | | - // o-------||-------o - // | | - // | __V__ - // -------------|_____|-------+ - // : : | - // 0.0 - 1.0 (GND) - // - // The values in range 0.0 - 1.0 correspond to "all closed" (input has - // no influence on the output) to "all open" (feedback has no influence - // on the output) configurations. - void setLowpassOpenness(float w) { assert(w >= 0.0f && w <= 1.0f); _lowPassCoeff = w; } - - // Sets the number of input samples per output sample. Without filtering - // just uses every nTh sample. - void setDownsampleRatio(unsigned n) { assert(n > 0); _downsampleRatio = n; } -public slots: - void addSamples(const QByteArray& audioByteArray, bool isStereo, bool isInput); -private: - // don't copy/assign - Oscilloscope(Oscilloscope const&); // = delete; - Oscilloscope& operator=(Oscilloscope const&); // = delete; - - // state variables - - unsigned _width; - unsigned _height; - short* _samples; - short* _vertices; - unsigned _writePos[MAX_CHANNELS]; - - float _lowPassCoeff; - unsigned _downsampleRatio; - unsigned _colors[MAX_CHANNELS]; -}; - -#endif /* defined(__interface__oscilloscope__) */ diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp new file mode 100644 index 0000000000..a14e80e62f --- /dev/null +++ b/interface/src/ui/PreferencesDialog.cpp @@ -0,0 +1,164 @@ +// +// PreferencesDialog.cpp +// interface/src/ui +// +// Created by Stojce Slavkovski on 2/20/14. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + + +#include "Application.h" +#include "Menu.h" +#include "PreferencesDialog.h" +#include "ModelsBrowser.h" + +const int SCROLL_PANEL_BOTTOM_MARGIN = 30; +const int OK_BUTTON_RIGHT_MARGIN = 30; +const int BUTTONS_TOP_MARGIN = 24; + +PreferencesDialog::PreferencesDialog(QWidget* parent, Qt::WindowFlags flags) : FramelessDialog(parent, flags) { + + ui.setupUi(this); + setStyleSheetFile("styles/preferences.qss"); + loadPreferences(); + connect(ui.closeButton, &QPushButton::clicked, this, &QDialog::close); + + connect(ui.buttonBrowseHead, &QPushButton::clicked, this, &PreferencesDialog::openHeadModelBrowser); + connect(ui.buttonBrowseBody, &QPushButton::clicked, this, &PreferencesDialog::openBodyModelBrowser); +} + +void PreferencesDialog::accept() { + savePreferences(); + close(); +} + +void PreferencesDialog::setHeadUrl(QString modelUrl) { + ui.faceURLEdit->setText(modelUrl); + setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint); +} + +void PreferencesDialog::setSkeletonUrl(QString modelUrl) { + ui.skeletonURLEdit->setText(modelUrl); + setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint); +} + +void PreferencesDialog::openHeadModelBrowser() { + setWindowFlags(windowFlags() & ~Qt::WindowStaysOnTopHint); + ModelsBrowser modelBrowser(Head); + connect(&modelBrowser, &ModelsBrowser::selected, this, &PreferencesDialog::setHeadUrl); + modelBrowser.browse(); +} + +void PreferencesDialog::openBodyModelBrowser() { + setWindowFlags(windowFlags() & ~Qt::WindowStaysOnTopHint); + ModelsBrowser modelBrowser(Skeleton); + connect(&modelBrowser, &ModelsBrowser::selected, this, &PreferencesDialog::setSkeletonUrl); + modelBrowser.browse(); +} + +void PreferencesDialog::resizeEvent(QResizeEvent *resizeEvent) { + + // keep buttons panel at the bottom + ui.buttonsPanel->setGeometry(0, size().height() - ui.buttonsPanel->height(), size().width(), ui.buttonsPanel->height()); + + // set width and height of srcollarea to match bottom panel and width + ui.scrollArea->setGeometry(ui.scrollArea->geometry().x(), ui.scrollArea->geometry().y(), + size().width(), + size().height() - ui.buttonsPanel->height() - + SCROLL_PANEL_BOTTOM_MARGIN - ui.scrollArea->geometry().y()); + + // move Save button to left position + ui.defaultButton->move(size().width() - OK_BUTTON_RIGHT_MARGIN - ui.defaultButton->size().width(), BUTTONS_TOP_MARGIN); + + // move Save button to left position + ui.cancelButton->move(ui.defaultButton->pos().x() - ui.cancelButton->size().width(), BUTTONS_TOP_MARGIN); + + // move close button + ui.closeButton->move(size().width() - OK_BUTTON_RIGHT_MARGIN - ui.closeButton->size().width(), ui.closeButton->pos().y()); +} + +void PreferencesDialog::loadPreferences() { + + MyAvatar* myAvatar = Application::getInstance()->getAvatar(); + Menu* menuInstance = Menu::getInstance(); + + _displayNameString = myAvatar->getDisplayName(); + ui.displayNameEdit->setText(_displayNameString); + + _faceURLString = myAvatar->getHead()->getFaceModel().getURL().toString(); + ui.faceURLEdit->setText(_faceURLString); + + _skeletonURLString = myAvatar->getSkeletonModel().getURL().toString(); + ui.skeletonURLEdit->setText(_skeletonURLString); + + ui.pupilDilationSlider->setValue(myAvatar->getHead()->getPupilDilation() * + ui.pupilDilationSlider->maximum()); + + ui.faceshiftEyeDeflectionSider->setValue(menuInstance->getFaceshiftEyeDeflection() * + ui.faceshiftEyeDeflectionSider->maximum()); + + ui.audioJitterSpin->setValue(menuInstance->getAudioJitterBufferSamples()); + + ui.fieldOfViewSpin->setValue(menuInstance->getFieldOfView()); + + ui.leanScaleSpin->setValue(myAvatar->getLeanScale()); + + ui.avatarScaleSpin->setValue(myAvatar->getScale()); + + ui.maxVoxelsSpin->setValue(menuInstance->getMaxVoxels()); + + ui.maxVoxelsPPSSpin->setValue(menuInstance->getMaxVoxelPacketsPerSecond()); +} + +void PreferencesDialog::savePreferences() { + + MyAvatar* myAvatar = Application::getInstance()->getAvatar(); + bool shouldDispatchIdentityPacket = false; + + QString displayNameStr(ui.displayNameEdit->text()); + if (displayNameStr != _displayNameString) { + myAvatar->setDisplayName(displayNameStr); + shouldDispatchIdentityPacket = true; + } + + QUrl faceModelURL(ui.faceURLEdit->text()); + if (faceModelURL.toString() != _faceURLString) { + // change the faceModelURL in the profile, it will also update this user's BlendFace + myAvatar->setFaceModelURL(faceModelURL); + shouldDispatchIdentityPacket = true; + } + + QUrl skeletonModelURL(ui.skeletonURLEdit->text()); + if (skeletonModelURL.toString() != _skeletonURLString) { + // change the skeletonModelURL in the profile, it will also update this user's Body + myAvatar->setSkeletonModelURL(skeletonModelURL); + shouldDispatchIdentityPacket = true; + } + + if (shouldDispatchIdentityPacket) { + myAvatar->sendIdentityPacket(); + Application::getInstance()->bumpSettings(); + } + + myAvatar->getHead()->setPupilDilation(ui.pupilDilationSlider->value() / (float)ui.pupilDilationSlider->maximum()); + myAvatar->setLeanScale(ui.leanScaleSpin->value()); + myAvatar->setClampedTargetScale(ui.avatarScaleSpin->value()); + + Application::getInstance()->getVoxels()->setMaxVoxels(ui.maxVoxelsSpin->value()); + Application::getInstance()->resizeGL(Application::getInstance()->getGLWidget()->width(), + Application::getInstance()->getGLWidget()->height()); + + Menu::getInstance()->setFieldOfView(ui.fieldOfViewSpin->value()); + + Menu::getInstance()->setFaceshiftEyeDeflection(ui.faceshiftEyeDeflectionSider->value() / + (float)ui.faceshiftEyeDeflectionSider->maximum()); + Menu::getInstance()->setMaxVoxelPacketsPerSecond(ui.maxVoxelsPPSSpin->value()); + + Menu::getInstance()->setAudioJitterBufferSamples(ui.audioJitterSpin->value()); + + Application::getInstance()->resizeGL(Application::getInstance()->getGLWidget()->width(), + Application::getInstance()->getGLWidget()->height()); +} diff --git a/interface/src/ui/PreferencesDialog.h b/interface/src/ui/PreferencesDialog.h new file mode 100644 index 0000000000..c9514e584a --- /dev/null +++ b/interface/src/ui/PreferencesDialog.h @@ -0,0 +1,47 @@ +// +// PreferencesDialog.h +// interface/src/ui +// +// Created by Stojce Slavkovski on 2/20/14. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_PreferencesDialog_h +#define hifi_PreferencesDialog_h + +#include "FramelessDialog.h" +#include "ui_preferencesDialog.h" + +#include + +class PreferencesDialog : public FramelessDialog { + Q_OBJECT + +public: + PreferencesDialog(QWidget* parent = 0, Qt::WindowFlags flags = 0); + +protected: + void resizeEvent(QResizeEvent* resizeEvent); + +private: + void loadPreferences(); + void savePreferences(); + void openHeadModelBrowser(); + void openBodyModelBrowser(); + + Ui_PreferencesDialog ui; + QString _faceURLString; + QString _skeletonURLString; + QString _displayNameString; + +private slots: + void accept(); + void setHeadUrl(QString modelUrl); + void setSkeletonUrl(QString modelUrl); + +}; + +#endif // hifi_PreferencesDialog_h diff --git a/interface/src/ui/RearMirrorTools.cpp b/interface/src/ui/RearMirrorTools.cpp index 314fd7157b..9620469a22 100644 --- a/interface/src/ui/RearMirrorTools.cpp +++ b/interface/src/ui/RearMirrorTools.cpp @@ -1,9 +1,13 @@ // // RearMirrorTools.cpp -// interface +// interface/src/ui +// +// Created by Stojce Slavkovski on 10/23/2013. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -// Created by stojce on 23.10.2013. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. #include "InterfaceConfig.h" @@ -18,9 +22,8 @@ const char SETTINGS_GROUP_NAME[] = "Rear View Tools"; const char ZOOM_LEVEL_SETTINGS[] = "ZoomLevel"; -const int ICON_SIZE = 20; +const int ICON_SIZE = 24; const int ICON_PADDING = 5; -const int MID_ICON_PADDING = 70; RearMirrorTools::RearMirrorTools(QGLWidget* parent, QRect& bounds, QSettings* settings) : _parent(parent), @@ -29,16 +32,19 @@ RearMirrorTools::RearMirrorTools(QGLWidget* parent, QRect& bounds, QSettings* se _fullScreen(false) { _zoomLevel = HEAD; - _closeTextureId = _parent->bindTexture(QImage(Application::resourcesPath() + "images/close.png")); - _resetTextureId = _parent->bindTexture(QImage(Application::resourcesPath() + "images/reset.png")); - _zoomHeadTextureId = _parent->bindTexture(QImage(Application::resourcesPath() + "images/head.png")); - _zoomBodyTextureId = _parent->bindTexture(QImage(Application::resourcesPath() + "images/body.png")); + _closeTextureId = _parent->bindTexture(QImage(Application::resourcesPath() + "images/close.svg")); + + // Disabled for now https://worklist.net/19548 + // _resetTextureId = _parent->bindTexture(QImage(Application::resourcesPath() + "images/reset.png")); + + _zoomHeadTextureId = _parent->bindTexture(QImage(Application::resourcesPath() + "images/plus.svg")); + _zoomBodyTextureId = _parent->bindTexture(QImage(Application::resourcesPath() + "images/minus.svg")); _shrinkIconRect = QRect(ICON_PADDING, ICON_PADDING, ICON_SIZE, ICON_SIZE); _closeIconRect = QRect(_bounds.left() + ICON_PADDING, _bounds.top() + ICON_PADDING, ICON_SIZE, ICON_SIZE); _resetIconRect = QRect(_bounds.width() - ICON_SIZE - ICON_PADDING, _bounds.top() + ICON_PADDING, ICON_SIZE, ICON_SIZE); - _bodyZoomIconRect = QRect(_bounds.width() - MID_ICON_PADDING - ICON_SIZE, _bounds.bottom() - ICON_PADDING - ICON_SIZE, ICON_SIZE, ICON_SIZE); - _headZoomIconRect = QRect(_bounds.left() + MID_ICON_PADDING, _bounds.bottom() - ICON_PADDING - ICON_SIZE, ICON_SIZE, ICON_SIZE); + _bodyZoomIconRect = QRect(_bounds.width() - ICON_SIZE - ICON_PADDING, _bounds.bottom() - ICON_PADDING - ICON_SIZE, ICON_SIZE, ICON_SIZE); + _headZoomIconRect = QRect(_bounds.left() + ICON_PADDING, _bounds.bottom() - ICON_PADDING - ICON_SIZE, ICON_SIZE, ICON_SIZE); settings->beginGroup(SETTINGS_GROUP_NAME); _zoomLevel = loadSetting(settings, ZOOM_LEVEL_SETTINGS, 0) == HEAD ? HEAD : BODY; @@ -55,7 +61,10 @@ void RearMirrorTools::render(bool fullScreen) { _windowed = _bounds.contains(mousePosition.x(), mousePosition.y()); if (_windowed) { displayIcon(_bounds, _closeIconRect, _closeTextureId); - displayIcon(_bounds, _resetIconRect, _resetTextureId); + + // Disabled for now https://worklist.net/19548 + // displayIcon(_bounds, _resetIconRect, _resetTextureId); + displayIcon(_bounds, _headZoomIconRect, _zoomHeadTextureId, _zoomLevel == HEAD); displayIcon(_bounds, _bodyZoomIconRect, _zoomBodyTextureId, _zoomLevel == BODY); } @@ -69,11 +78,13 @@ bool RearMirrorTools::mousePressEvent(int x, int y) { emit closeView(); return true; } - + + /* Disabled for now https://worklist.net/19548 if (_resetIconRect.contains(x, y)) { emit resetView(); return true; } + */ if (_headZoomIconRect.contains(x, y)) { _zoomLevel = HEAD; @@ -84,7 +95,7 @@ bool RearMirrorTools::mousePressEvent(int x, int y) { _zoomLevel = BODY; return true; } - + if (_bounds.contains(x, y)) { _windowed = false; emit restoreView(); @@ -120,7 +131,7 @@ void RearMirrorTools::displayIcon(QRect bounds, QRect iconBounds, GLuint texture glEnable(GL_TEXTURE_2D); if (selected) { - glColor3f(1, 1, 0); + glColor3f(.5f, .5f, .5f); } else { glColor3f(1, 1, 1); } diff --git a/interface/src/ui/RearMirrorTools.h b/interface/src/ui/RearMirrorTools.h index 7f13eafbee..a595572e7a 100644 --- a/interface/src/ui/RearMirrorTools.h +++ b/interface/src/ui/RearMirrorTools.h @@ -1,13 +1,16 @@ // // RearMirrorTools.h -// interface +// interface/src/ui +// +// Created by Stojce Slavkovski on 10/23/2013. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -// Created by stojce on 23.10.2013. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. - -#ifndef __hifi__RearMirrorTools__ -#define __hifi__RearMirrorTools__ +#ifndef hifi_RearMirrorTools_h +#define hifi_RearMirrorTools_h #include "InterfaceConfig.h" @@ -55,4 +58,4 @@ private: void displayIcon(QRect bounds, QRect iconBounds, GLuint textureId, bool selected = false); }; -#endif /* defined(__hifi__RearMirrorTools__) */ +#endif // hifi_RearMirrorTools_h diff --git a/interface/src/ui/RunningScriptsWidget.cpp b/interface/src/ui/RunningScriptsWidget.cpp new file mode 100644 index 0000000000..9a9a1c7486 --- /dev/null +++ b/interface/src/ui/RunningScriptsWidget.cpp @@ -0,0 +1,207 @@ +// +// RunningScriptsWidget.cpp +// interface/src/ui +// +// Created by Mohammed Nafees on 03/28/2014. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include "ui_runningScriptsWidget.h" +#include "RunningScriptsWidget.h" + +#include +#include + +#include "Application.h" + +RunningScriptsWidget::RunningScriptsWidget(QDockWidget *parent) : + QDockWidget(parent), + ui(new Ui::RunningScriptsWidget) +{ + ui->setupUi(this); + + // remove the title bar (see the Qt docs on setTitleBarWidget) + setTitleBarWidget(new QWidget()); + + ui->runningScriptsTableWidget->setColumnCount(2); + ui->runningScriptsTableWidget->verticalHeader()->setVisible(false); + ui->runningScriptsTableWidget->horizontalHeader()->setVisible(false); + ui->runningScriptsTableWidget->setSelectionMode(QAbstractItemView::NoSelection); + ui->runningScriptsTableWidget->setShowGrid(false); + ui->runningScriptsTableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers); + ui->runningScriptsTableWidget->setColumnWidth(0, 235); + ui->runningScriptsTableWidget->setColumnWidth(1, 25); + connect(ui->runningScriptsTableWidget, &QTableWidget::cellClicked, this, &RunningScriptsWidget::stopScript); + + ui->recentlyLoadedScriptsTableWidget->setColumnCount(2); + ui->recentlyLoadedScriptsTableWidget->verticalHeader()->setVisible(false); + ui->recentlyLoadedScriptsTableWidget->horizontalHeader()->setVisible(false); + ui->recentlyLoadedScriptsTableWidget->setSelectionMode(QAbstractItemView::NoSelection); + ui->recentlyLoadedScriptsTableWidget->setShowGrid(false); + ui->recentlyLoadedScriptsTableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers); + ui->recentlyLoadedScriptsTableWidget->setColumnWidth(0, 25); + ui->recentlyLoadedScriptsTableWidget->setColumnWidth(1, 235); + connect(ui->recentlyLoadedScriptsTableWidget, &QTableWidget::cellClicked, + this, &RunningScriptsWidget::loadScript); + + connect(ui->hideWidgetButton, &QPushButton::clicked, + Application::getInstance(), &Application::toggleRunningScriptsWidget); + connect(ui->reloadAllButton, &QPushButton::clicked, + Application::getInstance(), &Application::reloadAllScripts); + connect(ui->stopAllButton, &QPushButton::clicked, + this, &RunningScriptsWidget::allScriptsStopped); +} + +RunningScriptsWidget::~RunningScriptsWidget() +{ + delete ui; +} + +void RunningScriptsWidget::setRunningScripts(const QStringList& list) +{ + ui->runningScriptsTableWidget->setRowCount(list.size()); + + ui->noRunningScriptsLabel->setVisible(list.isEmpty()); + ui->currentlyRunningLabel->setVisible(!list.isEmpty()); + ui->line1->setVisible(!list.isEmpty()); + ui->runningScriptsTableWidget->setVisible(!list.isEmpty()); + ui->reloadAllButton->setVisible(!list.isEmpty()); + ui->stopAllButton->setVisible(!list.isEmpty()); + + for (int i = 0; i < list.size(); ++i) { + QTableWidgetItem *scriptName = new QTableWidgetItem; + scriptName->setText(list.at(i)); + scriptName->setToolTip(list.at(i)); + scriptName->setTextAlignment(Qt::AlignCenter); + QTableWidgetItem *closeIcon = new QTableWidgetItem; + closeIcon->setIcon(QIcon(Application::resourcesPath() + "/images/kill-script.svg")); + + ui->runningScriptsTableWidget->setItem(i, 0, scriptName); + ui->runningScriptsTableWidget->setItem(i, 1, closeIcon); + } + + createRecentlyLoadedScriptsTable(); +} + +void RunningScriptsWidget::keyPressEvent(QKeyEvent *e) +{ + switch(e->key()) { + case Qt::Key_Escape: + Application::getInstance()->toggleRunningScriptsWidget(); + break; + + case Qt::Key_1: + if (_recentlyLoadedScripts.size() > 0) { + Application::getInstance()->loadScript(_recentlyLoadedScripts.at(0)); + } + break; + + case Qt::Key_2: + if (_recentlyLoadedScripts.size() > 0 && _recentlyLoadedScripts.size() >= 2) { + Application::getInstance()->loadScript(_recentlyLoadedScripts.at(1)); + } + break; + + case Qt::Key_3: + if (_recentlyLoadedScripts.size() > 0 && _recentlyLoadedScripts.size() >= 3) { + Application::getInstance()->loadScript(_recentlyLoadedScripts.at(2)); + } + break; + + case Qt::Key_4: + if (_recentlyLoadedScripts.size() > 0 && _recentlyLoadedScripts.size() >= 4) { + Application::getInstance()->loadScript(_recentlyLoadedScripts.at(3)); + } + break; + case Qt::Key_5: + if (_recentlyLoadedScripts.size() > 0 && _recentlyLoadedScripts.size() >= 5) { + Application::getInstance()->loadScript(_recentlyLoadedScripts.at(4)); + } + break; + + case Qt::Key_6: + if (_recentlyLoadedScripts.size() > 0 && _recentlyLoadedScripts.size() >= 6) { + Application::getInstance()->loadScript(_recentlyLoadedScripts.at(5)); + } + break; + + case Qt::Key_7: + if (_recentlyLoadedScripts.size() > 0 && _recentlyLoadedScripts.size() >= 7) { + Application::getInstance()->loadScript(_recentlyLoadedScripts.at(6)); + } + break; + case Qt::Key_8: + if (_recentlyLoadedScripts.size() > 0 && _recentlyLoadedScripts.size() >= 8) { + Application::getInstance()->loadScript(_recentlyLoadedScripts.at(7)); + } + break; + + case Qt::Key_9: + if (_recentlyLoadedScripts.size() > 0 && _recentlyLoadedScripts.size() >= 9) { + Application::getInstance()->loadScript(_recentlyLoadedScripts.at(8)); + } + break; + + default: + break; + } +} + +void RunningScriptsWidget::stopScript(int row, int column) +{ + if (column == 1) { // make sure the user has clicked on the close icon + _lastStoppedScript = ui->runningScriptsTableWidget->item(row, 0)->text(); + emit stopScriptName(ui->runningScriptsTableWidget->item(row, 0)->text()); + } +} + +void RunningScriptsWidget::loadScript(int row, int column) +{ + Application::getInstance()->loadScript(ui->recentlyLoadedScriptsTableWidget->item(row, column)->text()); +} + +void RunningScriptsWidget::allScriptsStopped() +{ + QStringList list = Application::getInstance()->getRunningScripts(); + for (int i = 0; i < list.size(); ++i) { + _recentlyLoadedScripts.prepend(list.at(i)); + } + + Application::getInstance()->stopAllScripts(); +} + +void RunningScriptsWidget::createRecentlyLoadedScriptsTable() +{ + if (!_recentlyLoadedScripts.contains(_lastStoppedScript) && !_lastStoppedScript.isEmpty()) { + _recentlyLoadedScripts.prepend(_lastStoppedScript); + _lastStoppedScript = ""; + } + + for (int i = 0; i < _recentlyLoadedScripts.size(); ++i) { + if (Application::getInstance()->getRunningScripts().contains(_recentlyLoadedScripts.at(i))) { + _recentlyLoadedScripts.removeOne(_recentlyLoadedScripts.at(i)); + } + } + + ui->recentlyLoadedLabel->setVisible(!_recentlyLoadedScripts.isEmpty()); + ui->line2->setVisible(!_recentlyLoadedScripts.isEmpty()); + ui->recentlyLoadedScriptsTableWidget->setVisible(!_recentlyLoadedScripts.isEmpty()); + ui->recentlyLoadedInstruction->setVisible(!_recentlyLoadedScripts.isEmpty()); + + int limit = _recentlyLoadedScripts.size() > 9 ? 9 : _recentlyLoadedScripts.size(); + ui->recentlyLoadedScriptsTableWidget->setRowCount(limit); + for (int i = 0; i < limit; ++i) { + QTableWidgetItem *scriptName = new QTableWidgetItem; + scriptName->setText(_recentlyLoadedScripts.at(i)); + scriptName->setToolTip(_recentlyLoadedScripts.at(i)); + scriptName->setTextAlignment(Qt::AlignCenter); + QTableWidgetItem *number = new QTableWidgetItem; + number->setText(QString::number(i+1) + "."); + + ui->recentlyLoadedScriptsTableWidget->setItem(i, 0, number); + ui->recentlyLoadedScriptsTableWidget->setItem(i, 1, scriptName); + } +} diff --git a/interface/src/ui/RunningScriptsWidget.h b/interface/src/ui/RunningScriptsWidget.h new file mode 100644 index 0000000000..c4e1316e15 --- /dev/null +++ b/interface/src/ui/RunningScriptsWidget.h @@ -0,0 +1,50 @@ +// +// RunningScriptsWidget.h +// interface/src/ui +// +// Created by Mohammed Nafees on 03/28/2014. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_RunningScriptsWidget_h +#define hifi_RunningScriptsWidget_h + +// Qt +#include + +namespace Ui { + class RunningScriptsWidget; +} + +class RunningScriptsWidget : public QDockWidget +{ + Q_OBJECT +public: + explicit RunningScriptsWidget(QDockWidget *parent = 0); + ~RunningScriptsWidget(); + + void setRunningScripts(const QStringList& list); + +signals: + void stopScriptName(const QString& name); + +protected: + void keyPressEvent(QKeyEvent *e); + +private slots: + void stopScript(int row, int column); + void loadScript(int row, int column); + void allScriptsStopped(); + +private: + Ui::RunningScriptsWidget *ui; + QStringList _recentlyLoadedScripts; + QString _lastStoppedScript; + + void createRecentlyLoadedScriptsTable(); +}; + +#endif // hifi_RunningScriptsWidget_h diff --git a/interface/src/ui/Snapshot.cpp b/interface/src/ui/Snapshot.cpp index a29a96f009..5360924e63 100644 --- a/interface/src/ui/Snapshot.cpp +++ b/interface/src/ui/Snapshot.cpp @@ -1,9 +1,12 @@ // // Snapshot.cpp -// hifi +// interface/src/ui // // Created by Stojce Slavkovski on 1/26/14. -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/interface/src/ui/Snapshot.h b/interface/src/ui/Snapshot.h index 1b78e8328e..0fa9017b0a 100644 --- a/interface/src/ui/Snapshot.h +++ b/interface/src/ui/Snapshot.h @@ -1,13 +1,16 @@ // // Snapshot.h -// hifi +// interface/src/ui // // Created by Stojce Slavkovski on 1/26/14. -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__Snapshot__ -#define __hifi__Snapshot__ +#ifndef hifi_Snapshot_h +#define hifi_Snapshot_h #include "InterfaceConfig.h" @@ -42,4 +45,4 @@ public: static SnapshotMetaData* parseSnapshotData(QString snapshotPath); }; -#endif /* defined(__hifi__Snapshot__) */ +#endif // hifi_Snapshot_h diff --git a/interface/src/ui/Stats.cpp b/interface/src/ui/Stats.cpp new file mode 100644 index 0000000000..c540877262 --- /dev/null +++ b/interface/src/ui/Stats.cpp @@ -0,0 +1,549 @@ +// +// Stats.cpp +// interface/src/ui +// +// Created by Lucas Crisman on 22/03/14. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include + +#include + +#include +#include +#include +#include + +#include "Stats.h" +#include "InterfaceConfig.h" +#include "Menu.h" +#include "Util.h" + +using namespace std; + +const int STATS_PELS_PER_LINE = 20; + +const int STATS_GENERAL_MIN_WIDTH = 165; +const int STATS_PING_MIN_WIDTH = 190; +const int STATS_GEO_MIN_WIDTH = 240; +const int STATS_VOXEL_MIN_WIDTH = 410; + +Stats* Stats::getInstance() { + static Stats stats; + return &stats; +} + +Stats::Stats(): + _expanded(false), + _recentMaxPackets(0), + _resetRecentMaxPacketsSoon(true), + _generalStatsWidth(STATS_GENERAL_MIN_WIDTH), + _pingStatsWidth(STATS_PING_MIN_WIDTH), + _geoStatsWidth(STATS_GEO_MIN_WIDTH), + _voxelStatsWidth(STATS_VOXEL_MIN_WIDTH), + _lastHorizontalOffset(0) +{ + QGLWidget* glWidget = Application::getInstance()->getGLWidget(); + resetWidth(glWidget->width(), 0); +} + +void Stats::toggleExpanded() { + _expanded = !_expanded; +} + +// called on mouse click release +// check for clicks over stats in order to expand or contract them +void Stats::checkClick(int mouseX, int mouseY, int mouseDragStartedX, int mouseDragStartedY, int horizontalOffset) { + QGLWidget* glWidget = Application::getInstance()->getGLWidget(); + + if (0 != glm::compMax(glm::abs(glm::ivec2(mouseX - mouseDragStartedX, mouseY - mouseDragStartedY)))) { + // not worried about dragging on stats + return; + } + + int statsHeight = 0, + statsWidth = 0, + statsX = 0, + statsY = 0, + lines = 0; + + statsX = horizontalOffset; + + // top-left stats click + lines = _expanded ? 5 : 3; + statsHeight = lines * STATS_PELS_PER_LINE + 10; + if (mouseX > statsX && mouseX < statsX + _generalStatsWidth && mouseY > statsY && mouseY < statsY + statsHeight) { + toggleExpanded(); + return; + } + statsX += _generalStatsWidth; + + // ping stats click + if (Menu::getInstance()->isOptionChecked(MenuOption::TestPing)) { + lines = _expanded ? 4 : 3; + statsHeight = lines * STATS_PELS_PER_LINE + 10; + if (mouseX > statsX && mouseX < statsX + _pingStatsWidth && mouseY > statsY && mouseY < statsY + statsHeight) { + toggleExpanded(); + return; + } + statsX += _pingStatsWidth; + } + + // geo stats panel click + lines = _expanded ? 4 : 3; + statsHeight = lines * STATS_PELS_PER_LINE + 10; + if (mouseX > statsX && mouseX < statsX + _geoStatsWidth && mouseY > statsY && mouseY < statsY + statsHeight) { + toggleExpanded(); + return; + } + statsX += _geoStatsWidth; + + // top-right stats click + lines = _expanded ? 11 : 3; + statsHeight = lines * STATS_PELS_PER_LINE + 10; + statsWidth = glWidget->width() - statsX; + if (mouseX > statsX && mouseX < statsX + statsWidth && mouseY > statsY && mouseY < statsY + statsHeight) { + toggleExpanded(); + return; + } +} + +void Stats::resetWidth(int width, int horizontalOffset) { + QGLWidget* glWidget = Application::getInstance()->getGLWidget(); + int extraSpace = glWidget->width() - horizontalOffset -2 + - STATS_GENERAL_MIN_WIDTH + - (Menu::getInstance()->isOptionChecked(MenuOption::TestPing) ? STATS_PING_MIN_WIDTH -1 : 0) + - STATS_GEO_MIN_WIDTH + - STATS_VOXEL_MIN_WIDTH; + + int panels = 4; + + _generalStatsWidth = STATS_GENERAL_MIN_WIDTH; + if (Menu::getInstance()->isOptionChecked(MenuOption::TestPing)) { + _pingStatsWidth = STATS_PING_MIN_WIDTH; + } else { + _pingStatsWidth = 0; + panels = 3; + } + _geoStatsWidth = STATS_GEO_MIN_WIDTH; + _voxelStatsWidth = STATS_VOXEL_MIN_WIDTH; + + if (extraSpace > panels) { + _generalStatsWidth += (int) extraSpace / panels; + if (Menu::getInstance()->isOptionChecked(MenuOption::TestPing)) { + _pingStatsWidth += (int) extraSpace / panels; + } + _geoStatsWidth += (int) extraSpace / panels; + _voxelStatsWidth += glWidget->width() - (_generalStatsWidth + _pingStatsWidth + _geoStatsWidth + 3); + } +} + + +// translucent background box that makes stats more readable +void Stats::drawBackground(unsigned int rgba, int x, int y, int width, int height) { + glBegin(GL_QUADS); + glColor4f(((rgba >> 24) & 0xff) / 255.0f, + ((rgba >> 16) & 0xff) / 255.0f, + ((rgba >> 8) & 0xff) / 255.0f, + (rgba & 0xff) / 255.0f); + glVertex3f(x, y, 0); + glVertex3f(x + width, y, 0); + glVertex3f(x + width, y + height, 0); + glVertex3f(x , y + height, 0); + glEnd(); + glColor4f(1, 1, 1, 1); +} + +// display expanded or contracted stats +void Stats::display( + const float* color, + int horizontalOffset, + float fps, + int packetsPerSecond, + int bytesPerSecond, + int voxelPacketsToProcess) +{ + QGLWidget* glWidget = Application::getInstance()->getGLWidget(); + + unsigned int backgroundColor = 0x33333399; + int verticalOffset = 0, lines = 0; + + QLocale locale(QLocale::English); + std::stringstream voxelStats; + + if (_lastHorizontalOffset != horizontalOffset) { + resetWidth(glWidget->width(), horizontalOffset); + _lastHorizontalOffset = horizontalOffset; + } + + glPointSize(1.0f); + + // we need to take one avatar out so we don't include ourselves + int totalAvatars = Application::getInstance()->getAvatarManager().size() - 1; + int totalServers = NodeList::getInstance()->size(); + + lines = _expanded ? 5 : 3; + drawBackground(backgroundColor, horizontalOffset, 0, _generalStatsWidth, lines * STATS_PELS_PER_LINE + 10); + horizontalOffset += 5; + + char serverNodes[30]; + sprintf(serverNodes, "Servers: %d", totalServers); + char avatarNodes[30]; + sprintf(avatarNodes, "Avatars: %d", totalAvatars); + char framesPerSecond[30]; + sprintf(framesPerSecond, "Framerate: %3.0f FPS", fps); + + verticalOffset += STATS_PELS_PER_LINE; + drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, serverNodes, color); + verticalOffset += STATS_PELS_PER_LINE; + drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, avatarNodes, color); + verticalOffset += STATS_PELS_PER_LINE; + drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, framesPerSecond, color); + + if (_expanded) { + char packetsPerSecondString[30]; + sprintf(packetsPerSecondString, "Pkts/sec: %d", packetsPerSecond); + char averageMegabitsPerSecond[30]; + sprintf(averageMegabitsPerSecond, "Mbps: %3.2f", (float)bytesPerSecond * 8.f / 1000000.f); + + verticalOffset += STATS_PELS_PER_LINE; + drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, packetsPerSecondString, color); + verticalOffset += STATS_PELS_PER_LINE; + drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, averageMegabitsPerSecond, color); + } + + verticalOffset = 0; + horizontalOffset = _lastHorizontalOffset + _generalStatsWidth +1; + + if (Menu::getInstance()->isOptionChecked(MenuOption::TestPing)) { + int pingAudio = 0, pingAvatar = 0, pingVoxel = 0, pingVoxelMax = 0; + + NodeList* nodeList = NodeList::getInstance(); + SharedNodePointer audioMixerNode = nodeList->soloNodeOfType(NodeType::AudioMixer); + SharedNodePointer avatarMixerNode = nodeList->soloNodeOfType(NodeType::AvatarMixer); + + pingAudio = audioMixerNode ? audioMixerNode->getPingMs() : 0; + pingAvatar = avatarMixerNode ? avatarMixerNode->getPingMs() : 0; + + // Now handle voxel servers, since there could be more than one, we average their ping times + unsigned long totalPingVoxel = 0; + int voxelServerCount = 0; + + foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { + if (node->getType() == NodeType::VoxelServer) { + totalPingVoxel += node->getPingMs(); + voxelServerCount++; + if (pingVoxelMax < node->getPingMs()) { + pingVoxelMax = node->getPingMs(); + } + } + } + + if (voxelServerCount) { + pingVoxel = totalPingVoxel/voxelServerCount; + } + + lines = _expanded ? 4 : 3; + drawBackground(backgroundColor, horizontalOffset, 0, _pingStatsWidth, lines * STATS_PELS_PER_LINE + 10); + horizontalOffset += 5; + + Audio* audio = Application::getInstance()->getAudio(); + + char audioJitter[30]; + sprintf(audioJitter, + "Buffer msecs %.1f", + (float) (audio->getNetworkBufferLengthSamplesPerChannel() + (float) audio->getJitterBufferSamples()) / + (float) audio->getNetworkSampleRate() * 1000.f); + drawText(30, glWidget->height() - 22, 0.10f, 0.f, 2.f, audioJitter, color); + + + char audioPing[30]; + sprintf(audioPing, "Audio ping: %d", pingAudio); + + + char avatarPing[30]; + sprintf(avatarPing, "Avatar ping: %d", pingAvatar); + char voxelAvgPing[30]; + sprintf(voxelAvgPing, "Voxel avg ping: %d", pingVoxel); + + verticalOffset += STATS_PELS_PER_LINE; + drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, audioPing, color); + verticalOffset += STATS_PELS_PER_LINE; + drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, avatarPing, color); + verticalOffset += STATS_PELS_PER_LINE; + drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, voxelAvgPing, color); + + if (_expanded) { + char voxelMaxPing[30]; + sprintf(voxelMaxPing, "Voxel max ping: %d", pingVoxelMax); + + verticalOffset += STATS_PELS_PER_LINE; + drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, voxelMaxPing, color); + } + + verticalOffset = 0; + horizontalOffset = _lastHorizontalOffset + _generalStatsWidth + _pingStatsWidth + 2; + } + + MyAvatar* myAvatar = Application::getInstance()->getAvatar(); + glm::vec3 avatarPos = myAvatar->getPosition(); + + lines = _expanded ? 5 : 3; + if (_expanded && Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessing)) { + lines += 3; // spatial audio processing adds 3 extra lines + } + + + drawBackground(backgroundColor, horizontalOffset, 0, _geoStatsWidth, lines * STATS_PELS_PER_LINE + 10); + horizontalOffset += 5; + + char avatarPosition[200]; + sprintf(avatarPosition, "Position: %.1f, %.1f, %.1f", avatarPos.x, avatarPos.y, avatarPos.z); + char avatarVelocity[30]; + sprintf(avatarVelocity, "Velocity: %.1f", glm::length(myAvatar->getVelocity())); + char avatarBodyYaw[30]; + sprintf(avatarBodyYaw, "Yaw: %.1f", myAvatar->getBodyYaw()); + char avatarMixerStats[200]; + + verticalOffset += STATS_PELS_PER_LINE; + drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, avatarPosition, color); + verticalOffset += STATS_PELS_PER_LINE; + drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, avatarVelocity, color); + verticalOffset += STATS_PELS_PER_LINE; + drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, avatarBodyYaw, color); + + if (_expanded) { + SharedNodePointer avatarMixer = NodeList::getInstance()->soloNodeOfType(NodeType::AvatarMixer); + if (avatarMixer) { + sprintf(avatarMixerStats, "Avatar Mixer: %.f kbps, %.f pps", + roundf(avatarMixer->getAverageKilobitsPerSecond()), + roundf(avatarMixer->getAveragePacketsPerSecond())); + } else { + sprintf(avatarMixerStats, "No Avatar Mixer"); + } + + verticalOffset += STATS_PELS_PER_LINE; + drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, avatarMixerStats, color); + + stringstream downloads; + downloads << "Downloads: "; + foreach (Resource* resource, ResourceCache::getLoadingRequests()) { + downloads << (int)(resource->getProgress() * 100.0f) << "% "; + } + downloads << "(" << ResourceCache::getPendingRequestCount() << " pending)"; + + verticalOffset += STATS_PELS_PER_LINE; + drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, downloads.str().c_str(), color); + + if (Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessing)) { + const AudioReflector* audioReflector = Application::getInstance()->getAudioReflector(); + + + // add some reflection stats + char reflectionsStatus[128]; + + sprintf(reflectionsStatus, "Reflections: %d, Original: %s, Ears: %s, Source: %s", + audioReflector->getReflections(), + (Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingIncudeOriginal) + ? "with" : "without"), + (Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingSeparateEars) + ? "two" : "one"), + (Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingStereoSource) + ? "stereo" : "mono") + ); + + verticalOffset += STATS_PELS_PER_LINE; + drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, reflectionsStatus, color); + + float preDelay = Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingPreDelay) ? + audioReflector->getPreDelay() : 0.0f; + + sprintf(reflectionsStatus, "Delay: pre: %f, average %f, max %f, min %f, speed: %f", + preDelay, + audioReflector->getAverageDelayMsecs(), + audioReflector->getMaxDelayMsecs(), + audioReflector->getMinDelayMsecs(), + audioReflector->getSoundMsPerMeter()); + + verticalOffset += STATS_PELS_PER_LINE; + drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, reflectionsStatus, color); + + sprintf(reflectionsStatus, "Attenuation: average %f, max %f, min %f, distance scale: %f", + audioReflector->getAverageAttenuation(), + audioReflector->getMaxAttenuation(), + audioReflector->getMinAttenuation(), + audioReflector->getDistanceAttenuationScalingFactor()); + + verticalOffset += STATS_PELS_PER_LINE; + drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, reflectionsStatus, color); + } + } + + verticalOffset = 0; + horizontalOffset = _lastHorizontalOffset + _generalStatsWidth + _pingStatsWidth + _geoStatsWidth + 3; + + VoxelSystem* voxels = Application::getInstance()->getVoxels(); + + lines = _expanded ? 12 : 3; + drawBackground(backgroundColor, horizontalOffset, 0, glWidget->width() - horizontalOffset, lines * STATS_PELS_PER_LINE + 10); + horizontalOffset += 5; + + if (_expanded) { + // Local Voxel Memory Usage + voxelStats.str(""); + voxelStats << "Voxels Memory Nodes: " << VoxelTreeElement::getTotalMemoryUsage() / 1000000.f << "MB"; + verticalOffset += STATS_PELS_PER_LINE; + drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), color); + + voxelStats.str(""); + voxelStats << + "Geometry RAM: " << voxels->getVoxelMemoryUsageRAM() / 1000000.f << "MB / " << + "VBO: " << voxels->getVoxelMemoryUsageVBO() / 1000000.f << "MB"; + if (voxels->hasVoxelMemoryUsageGPU()) { + voxelStats << " / GPU: " << voxels->getVoxelMemoryUsageGPU() / 1000000.f << "MB"; + } + verticalOffset += STATS_PELS_PER_LINE; + drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), color); + + // Voxel Rendering + voxelStats.str(""); + voxelStats.precision(4); + voxelStats << "Voxel Rendering Slots Max: " << voxels->getMaxVoxels() / 1000.f << "K"; + verticalOffset += STATS_PELS_PER_LINE; + drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), color); + } + + voxelStats.str(""); + voxelStats.precision(4); + voxelStats << "Drawn: " << voxels->getVoxelsWritten() / 1000.f << "K " << + "Abandoned: " << voxels->getAbandonedVoxels() / 1000.f << "K "; + verticalOffset += STATS_PELS_PER_LINE; + drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), color); + + // iterate all the current voxel stats, and list their sending modes, and total voxel counts + std::stringstream sendingMode(""); + sendingMode << "Octree Sending Mode: ["; + int serverCount = 0; + int movingServerCount = 0; + unsigned long totalNodes = 0; + unsigned long totalInternal = 0; + unsigned long totalLeaves = 0; + NodeToOctreeSceneStats* octreeServerSceneStats = Application::getInstance()->getOcteeSceneStats(); + for(NodeToOctreeSceneStatsIterator i = octreeServerSceneStats->begin(); i != octreeServerSceneStats->end(); i++) { + //const QUuid& uuid = i->first; + OctreeSceneStats& stats = i->second; + serverCount++; + if (_expanded) { + if (serverCount > 1) { + sendingMode << ","; + } + if (stats.isMoving()) { + sendingMode << "M"; + movingServerCount++; + } else { + sendingMode << "S"; + } + } + + // calculate server node totals + totalNodes += stats.getTotalElements(); + if (_expanded) { + totalInternal += stats.getTotalInternal(); + totalLeaves += stats.getTotalLeaves(); + } + } + if (_expanded) { + if (serverCount == 0) { + sendingMode << "---"; + } + sendingMode << "] " << serverCount << " servers"; + if (movingServerCount > 0) { + sendingMode << " "; + } else { + sendingMode << " "; + } + verticalOffset += STATS_PELS_PER_LINE; + drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)sendingMode.str().c_str(), color); + } + + // Incoming packets + if (_expanded) { + voxelStats.str(""); + QString packetsString = locale.toString((int)voxelPacketsToProcess); + QString maxString = locale.toString((int)_recentMaxPackets); + voxelStats << "Voxel Packets to Process: " << qPrintable(packetsString) + << " [Recent Max: " << qPrintable(maxString) << "]"; + verticalOffset += STATS_PELS_PER_LINE; + drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), color); + } + + if (_resetRecentMaxPacketsSoon && voxelPacketsToProcess > 0) { + _recentMaxPackets = 0; + _resetRecentMaxPacketsSoon = false; + } + if (voxelPacketsToProcess == 0) { + _resetRecentMaxPacketsSoon = true; + } else { + if (voxelPacketsToProcess > _recentMaxPackets) { + _recentMaxPackets = voxelPacketsToProcess; + } + } + + verticalOffset += (_expanded ? STATS_PELS_PER_LINE : 0); + + QString serversTotalString = locale.toString((uint)totalNodes); // consider adding: .rightJustified(10, ' '); + + // Server Voxels + voxelStats.str(""); + voxelStats << "Server voxels: " << qPrintable(serversTotalString); + verticalOffset += STATS_PELS_PER_LINE; + drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), color); + + if (_expanded) { + QString serversInternalString = locale.toString((uint)totalInternal); + QString serversLeavesString = locale.toString((uint)totalLeaves); + + voxelStats.str(""); + voxelStats << + "Internal: " << qPrintable(serversInternalString) << " " << + "Leaves: " << qPrintable(serversLeavesString) << ""; + verticalOffset += STATS_PELS_PER_LINE; + drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), color); + } + + unsigned long localTotal = VoxelTreeElement::getNodeCount(); + QString localTotalString = locale.toString((uint)localTotal); // consider adding: .rightJustified(10, ' '); + + // Local Voxels + voxelStats.str(""); + voxelStats << "Local voxels: " << qPrintable(localTotalString); + verticalOffset += STATS_PELS_PER_LINE; + drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), color); + + if (_expanded) { + unsigned long localInternal = VoxelTreeElement::getInternalNodeCount(); + unsigned long localLeaves = VoxelTreeElement::getLeafNodeCount(); + QString localInternalString = locale.toString((uint)localInternal); + QString localLeavesString = locale.toString((uint)localLeaves); + + voxelStats.str(""); + voxelStats << + "Internal: " << qPrintable(localInternalString) << " " << + "Leaves: " << qPrintable(localLeavesString) << ""; + verticalOffset += STATS_PELS_PER_LINE; + drawText(horizontalOffset, verticalOffset, 0.10f, 0, 2, (char*)voxelStats.str().c_str(), color); + } + + // LOD Details + if (_expanded) { + voxelStats.str(""); + QString displayLODDetails = Menu::getInstance()->getLODFeedbackText(); + voxelStats << "LOD: You can see " << qPrintable(displayLODDetails.trimmed()); + verticalOffset += STATS_PELS_PER_LINE; + drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), color); + } +} diff --git a/interface/src/ui/Stats.h b/interface/src/ui/Stats.h new file mode 100644 index 0000000000..1ce0807ee8 --- /dev/null +++ b/interface/src/ui/Stats.h @@ -0,0 +1,49 @@ +// +// Stats.h +// interface/src/ui +// +// Created by Lucas Crisman on 22/03/14. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_Stats_h +#define hifi_Stats_h + +#include + +#include + +class Stats: public QObject { + Q_OBJECT + +public: + static Stats* getInstance(); + + Stats(); + + static void drawBackground(unsigned int rgba, int x, int y, int width, int height); + + void toggleExpanded(); + void checkClick(int mouseX, int mouseY, int mouseDragStartedX, int mouseDragStartedY, int horizontalOffset); + void resetWidth(int width, int horizontalOffset); + void display(const float* color, int horizontalOffset, float fps, int packetsPerSecond, int bytesPerSecond, int voxelPacketsToProcess); +private: + static Stats* _sharedInstance; + + bool _expanded; + + int _recentMaxPackets; // recent max incoming voxel packets to process + bool _resetRecentMaxPacketsSoon; + + int _generalStatsWidth; + int _pingStatsWidth; + int _geoStatsWidth; + int _voxelStatsWidth; + + int _lastHorizontalOffset; +}; + +#endif // hifi_Stats_h diff --git a/interface/src/ui/TextRenderer.cpp b/interface/src/ui/TextRenderer.cpp index cacd730fd6..2743e3e572 100644 --- a/interface/src/ui/TextRenderer.cpp +++ b/interface/src/ui/TextRenderer.cpp @@ -1,9 +1,13 @@ // // TextRenderer.cpp -// interface +// interface/src/ui // // Created by Andrzej Kapolka on 4/24/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// #include #include diff --git a/interface/src/ui/TextRenderer.h b/interface/src/ui/TextRenderer.h index d6c24c1ce8..813f15a5ac 100644 --- a/interface/src/ui/TextRenderer.h +++ b/interface/src/ui/TextRenderer.h @@ -1,13 +1,16 @@ // // TextRenderer.h -// interface +// interface/src/ui // // Created by Andrzej Kapolka on 4/26/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__TextRenderer__ -#define __interface__TextRenderer__ +#ifndef hifi_TextRenderer_h +#define hifi_TextRenderer_h #include #include @@ -111,4 +114,4 @@ private: int _width; }; -#endif /* defined(__interface__TextRenderer__) */ +#endif // hifi_TextRenderer_h diff --git a/interface/src/ui/UpdateDialog.cpp b/interface/src/ui/UpdateDialog.cpp index 9919cd0a7b..ace022b683 100644 --- a/interface/src/ui/UpdateDialog.cpp +++ b/interface/src/ui/UpdateDialog.cpp @@ -1,9 +1,11 @@ // // UpdateDialog.cpp -// interface +// interface/src/ui // -// Created by Leonardo Murillo on 1/8/14. -// Copyright (c) 2013, 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "Application.h" // HACK ATTACK WARNING: for windows build to work, we need this ahead of QtGui @@ -49,4 +51,4 @@ void UpdateDialog::handleDownload() { void UpdateDialog::handleSkip() { Application::getInstance()->skipVersion(_latestVersion); this->close(); -} \ No newline at end of file +} diff --git a/interface/src/ui/UpdateDialog.h b/interface/src/ui/UpdateDialog.h index 14f4e6f39c..15a97bf024 100644 --- a/interface/src/ui/UpdateDialog.h +++ b/interface/src/ui/UpdateDialog.h @@ -1,13 +1,15 @@ // // UpdateDialog.h -// interface +// interface/src/ui // -// Created by Leonardo Murillo on 1/8/14. -// Copyright (c) 2013, 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__UpdateDialog__ -#define __hifi__UpdateDialog__ +#ifndef hifi_UpdateDialog_h +#define hifi_UpdateDialog_h #include @@ -26,4 +28,4 @@ private slots: void handleSkip(); }; -#endif /* defined(__hifi__UpdateDialog__) */ +#endif // hifi_UpdateDialog_h diff --git a/interface/src/ui/overlays/Base3DOverlay.cpp b/interface/src/ui/overlays/Base3DOverlay.cpp index bcd2ca1cd2..3500f400ab 100644 --- a/interface/src/ui/overlays/Base3DOverlay.cpp +++ b/interface/src/ui/overlays/Base3DOverlay.cpp @@ -1,8 +1,11 @@ // // Base3DOverlay.cpp -// interface +// interface/src/ui/overlays // -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // // include this before QGLWidget, which includes an earlier version of OpenGL diff --git a/interface/src/ui/overlays/Base3DOverlay.h b/interface/src/ui/overlays/Base3DOverlay.h index 286193393c..e2dcb82454 100644 --- a/interface/src/ui/overlays/Base3DOverlay.h +++ b/interface/src/ui/overlays/Base3DOverlay.h @@ -1,12 +1,15 @@ // // Base3DOverlay.h -// interface +// interface/src/ui/overlays // -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__Base3DOverlay__ -#define __interface__Base3DOverlay__ +#ifndef hifi_Base3DOverlay_h +#define hifi_Base3DOverlay_h #include "Overlay.h" @@ -33,4 +36,4 @@ protected: }; -#endif /* defined(__interface__Base3DOverlay__) */ +#endif // hifi_Base3DOverlay_h diff --git a/interface/src/ui/overlays/Cube3DOverlay.cpp b/interface/src/ui/overlays/Cube3DOverlay.cpp index 992a18e451..ab9418206f 100644 --- a/interface/src/ui/overlays/Cube3DOverlay.cpp +++ b/interface/src/ui/overlays/Cube3DOverlay.cpp @@ -1,8 +1,11 @@ // // Cube3DOverlay.cpp -// interface +// interface/src/ui/overlays // -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // // include this before QGLWidget, which includes an earlier version of OpenGL diff --git a/interface/src/ui/overlays/Cube3DOverlay.h b/interface/src/ui/overlays/Cube3DOverlay.h index a1705d47d0..828048e697 100644 --- a/interface/src/ui/overlays/Cube3DOverlay.h +++ b/interface/src/ui/overlays/Cube3DOverlay.h @@ -1,12 +1,15 @@ // // Cube3DOverlay.h -// interface +// interface/src/ui/overlays // -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__Cube3DOverlay__ -#define __interface__Cube3DOverlay__ +#ifndef hifi_Cube3DOverlay_h +#define hifi_Cube3DOverlay_h #include "Volume3DOverlay.h" @@ -20,4 +23,4 @@ public: }; -#endif /* defined(__interface__Cube3DOverlay__) */ +#endif // hifi_Cube3DOverlay_h diff --git a/interface/src/ui/overlays/ImageOverlay.cpp b/interface/src/ui/overlays/ImageOverlay.cpp index ac5c8ecefa..aa4766488a 100644 --- a/interface/src/ui/overlays/ImageOverlay.cpp +++ b/interface/src/ui/overlays/ImageOverlay.cpp @@ -1,8 +1,11 @@ // // ImageOverlay.cpp -// interface +// interface/src/ui/overlays // -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // // include this before QGLWidget, which includes an earlier version of OpenGL diff --git a/interface/src/ui/overlays/ImageOverlay.h b/interface/src/ui/overlays/ImageOverlay.h index d6165e388d..613cd95989 100644 --- a/interface/src/ui/overlays/ImageOverlay.h +++ b/interface/src/ui/overlays/ImageOverlay.h @@ -1,12 +1,15 @@ // // ImageOverlay.h -// interface +// interface/src/ui/overlays // -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__ImageOverlay__ -#define __interface__ImageOverlay__ +#ifndef hifi_ImageOverlay_h +#define hifi_ImageOverlay_h // include this before QGLWidget, which includes an earlier version of OpenGL #include "InterfaceConfig.h" @@ -59,4 +62,4 @@ private: }; -#endif /* defined(__interface__ImageOverlay__) */ +#endif // hifi_ImageOverlay_h diff --git a/interface/src/ui/overlays/Line3DOverlay.cpp b/interface/src/ui/overlays/Line3DOverlay.cpp index c357233329..6c036a898d 100644 --- a/interface/src/ui/overlays/Line3DOverlay.cpp +++ b/interface/src/ui/overlays/Line3DOverlay.cpp @@ -1,8 +1,11 @@ // // Line3DOverlay.cpp -// interface +// interface/src/ui/overlays // -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // // include this before QGLWidget, which includes an earlier version of OpenGL diff --git a/interface/src/ui/overlays/Line3DOverlay.h b/interface/src/ui/overlays/Line3DOverlay.h index d52b639d59..5b802f49c8 100644 --- a/interface/src/ui/overlays/Line3DOverlay.h +++ b/interface/src/ui/overlays/Line3DOverlay.h @@ -1,12 +1,15 @@ // // Line3DOverlay.h -// interface +// interface/src/ui/overlays // -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__Line3DOverlay__ -#define __interface__Line3DOverlay__ +#ifndef hifi_Line3DOverlay_h +#define hifi_Line3DOverlay_h #include "Base3DOverlay.h" @@ -31,4 +34,4 @@ protected: }; -#endif /* defined(__interface__Line3DOverlay__) */ +#endif // hifi_Line3DOverlay_h diff --git a/interface/src/ui/overlays/LocalVoxelsOverlay.cpp b/interface/src/ui/overlays/LocalVoxelsOverlay.cpp index 460f4eadb6..93736ddccb 100644 --- a/interface/src/ui/overlays/LocalVoxelsOverlay.cpp +++ b/interface/src/ui/overlays/LocalVoxelsOverlay.cpp @@ -1,11 +1,14 @@ // // LocalVoxelsOverlay.cpp -// hifi +// interface/src/ui/overlays // // Created by Clément Brisset on 2/28/14. -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // + // include this before QGLWidget, which includes an earlier version of OpenGL #include "InterfaceConfig.h" diff --git a/interface/src/ui/overlays/LocalVoxelsOverlay.h b/interface/src/ui/overlays/LocalVoxelsOverlay.h index 2b3ba1f535..cc23b05ff6 100644 --- a/interface/src/ui/overlays/LocalVoxelsOverlay.h +++ b/interface/src/ui/overlays/LocalVoxelsOverlay.h @@ -1,15 +1,16 @@ // // LocalVoxelsOverlay.h -// hifi +// interface/src/ui/overlays // // Created by Clément Brisset on 2/28/14. -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. // -// Scriptable interface for LocalVoxels +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__LocalVoxelsOverlay__ -#define __hifi__LocalVoxelsOverlay__ +#ifndef hifi_LocalVoxelsOverlay_h +#define hifi_LocalVoxelsOverlay_h // include this before QGLWidget, which includes an earlier version of OpenGL #include "InterfaceConfig.h" @@ -47,4 +48,4 @@ private: StrongVoxelSystemPointer _voxelSystem; }; -#endif /* defined(__hifi__LocalVoxelsOverlay__) */ +#endif // hifi_LocalVoxelsOverlay_h diff --git a/interface/src/ui/overlays/Overlay.cpp b/interface/src/ui/overlays/Overlay.cpp index 40da2253f4..3b38addb76 100644 --- a/interface/src/ui/overlays/Overlay.cpp +++ b/interface/src/ui/overlays/Overlay.cpp @@ -1,8 +1,11 @@ // // Overlay.cpp -// interface +// interface/src/ui/overlays // -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // // include this before QGLWidget, which includes an earlier version of OpenGL diff --git a/interface/src/ui/overlays/Overlay.h b/interface/src/ui/overlays/Overlay.h index ad1084e889..6feb159e05 100644 --- a/interface/src/ui/overlays/Overlay.h +++ b/interface/src/ui/overlays/Overlay.h @@ -1,12 +1,15 @@ // // Overlay.h -// interface +// interface/src/ui/overlays // -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__Overlay__ -#define __interface__Overlay__ +#ifndef hifi_Overlay_h +#define hifi_Overlay_h // include this before QGLWidget, which includes an earlier version of OpenGL #include "InterfaceConfig.h" @@ -51,4 +54,4 @@ protected: }; -#endif /* defined(__interface__Overlay__) */ +#endif // hifi_Overlay_h diff --git a/interface/src/ui/overlays/Overlay2D.cpp b/interface/src/ui/overlays/Overlay2D.cpp index 0c459811c4..0bdb8790cc 100644 --- a/interface/src/ui/overlays/Overlay2D.cpp +++ b/interface/src/ui/overlays/Overlay2D.cpp @@ -1,8 +1,11 @@ // // Overlay2D.cpp -// interface +// interface/src/ui/overlays // -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // // include this before QGLWidget, which includes an earlier version of OpenGL diff --git a/interface/src/ui/overlays/Overlay2D.h b/interface/src/ui/overlays/Overlay2D.h index 3da8f8bca4..34028de89a 100644 --- a/interface/src/ui/overlays/Overlay2D.h +++ b/interface/src/ui/overlays/Overlay2D.h @@ -1,12 +1,15 @@ // // Overlay2D.h -// interface +// interface/src/ui/overlays // -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__Overlay2D__ -#define __interface__Overlay2D__ +#ifndef hifi_Overlay2D_h +#define hifi_Overlay2D_h // include this before QGLWidget, which includes an earlier version of OpenGL #include "InterfaceConfig.h" @@ -48,4 +51,4 @@ protected: }; -#endif /* defined(__interface__Overlay2D__) */ +#endif // hifi_Overlay2D_h diff --git a/interface/src/ui/overlays/Overlays.cpp b/interface/src/ui/overlays/Overlays.cpp index 0c9415fa73..4eb4f030ac 100644 --- a/interface/src/ui/overlays/Overlays.cpp +++ b/interface/src/ui/overlays/Overlays.cpp @@ -1,8 +1,11 @@ // // Overlays.cpp -// interface +// interface/src/ui/overlays // -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // diff --git a/interface/src/ui/overlays/Overlays.h b/interface/src/ui/overlays/Overlays.h index c28f3ab83b..b3477be0c2 100644 --- a/interface/src/ui/overlays/Overlays.h +++ b/interface/src/ui/overlays/Overlays.h @@ -1,12 +1,15 @@ // // Overlays.h -// interface +// interface/src/ui/overlays // -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__Overlays__ -#define __interface__Overlays__ +#ifndef hifi_Overlays_h +#define hifi_Overlays_h #include @@ -45,4 +48,4 @@ private: }; -#endif /* defined(__interface__Overlays__) */ +#endif // hifi_Overlays_h diff --git a/interface/src/ui/overlays/Sphere3DOverlay.cpp b/interface/src/ui/overlays/Sphere3DOverlay.cpp index 7fded5bedb..e5f31fa1be 100644 --- a/interface/src/ui/overlays/Sphere3DOverlay.cpp +++ b/interface/src/ui/overlays/Sphere3DOverlay.cpp @@ -1,8 +1,11 @@ // // Sphere3DOverlay.cpp -// interface +// interface/src/ui/overlays // -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // // include this before QGLWidget, which includes an earlier version of OpenGL diff --git a/interface/src/ui/overlays/Sphere3DOverlay.h b/interface/src/ui/overlays/Sphere3DOverlay.h index 58ed0d7776..9a2816611b 100644 --- a/interface/src/ui/overlays/Sphere3DOverlay.h +++ b/interface/src/ui/overlays/Sphere3DOverlay.h @@ -1,12 +1,15 @@ // // Sphere3DOverlay.h -// interface +// interface/src/ui/overlays // -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__Sphere3DOverlay__ -#define __interface__Sphere3DOverlay__ +#ifndef hifi_Sphere3DOverlay_h +#define hifi_Sphere3DOverlay_h #include "Volume3DOverlay.h" @@ -20,4 +23,4 @@ public: }; -#endif /* defined(__interface__Sphere3DOverlay__) */ +#endif // hifi_Sphere3DOverlay_h diff --git a/interface/src/ui/overlays/TextOverlay.cpp b/interface/src/ui/overlays/TextOverlay.cpp index 1a6edb3ea2..e26c772b06 100644 --- a/interface/src/ui/overlays/TextOverlay.cpp +++ b/interface/src/ui/overlays/TextOverlay.cpp @@ -1,8 +1,11 @@ // // TextOverlay.cpp -// interface +// interface/src/ui/overlays // -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // // include this before QGLWidget, which includes an earlier version of OpenGL diff --git a/interface/src/ui/overlays/TextOverlay.h b/interface/src/ui/overlays/TextOverlay.h index d565aeb70d..fc04966d07 100644 --- a/interface/src/ui/overlays/TextOverlay.h +++ b/interface/src/ui/overlays/TextOverlay.h @@ -1,12 +1,15 @@ // // TextOverlay.h -// interface +// interface/src/ui/overlays // -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__TextOverlay__ -#define __interface__TextOverlay__ +#ifndef hifi_TextOverlay_h +#define hifi_TextOverlay_h // include this before QGLWidget, which includes an earlier version of OpenGL #include "InterfaceConfig.h" @@ -56,4 +59,4 @@ private: }; -#endif /* defined(__interface__TextOverlay__) */ +#endif // hifi_TextOverlay_h diff --git a/interface/src/ui/overlays/Volume3DOverlay.cpp b/interface/src/ui/overlays/Volume3DOverlay.cpp index dbc1582cc5..ee780d8329 100644 --- a/interface/src/ui/overlays/Volume3DOverlay.cpp +++ b/interface/src/ui/overlays/Volume3DOverlay.cpp @@ -1,8 +1,11 @@ // // Volume3DOverlay.cpp -// interface +// interface/src/ui/overlays // -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // // include this before QGLWidget, which includes an earlier version of OpenGL diff --git a/interface/src/ui/overlays/Volume3DOverlay.h b/interface/src/ui/overlays/Volume3DOverlay.h index 8badbf2c33..b06aea27fd 100644 --- a/interface/src/ui/overlays/Volume3DOverlay.h +++ b/interface/src/ui/overlays/Volume3DOverlay.h @@ -1,12 +1,15 @@ // // Volume3DOverlay.h -// interface +// interface/src/ui/overlays // -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__Volume3DOverlay__ -#define __interface__Volume3DOverlay__ +#ifndef hifi_Volume3DOverlay_h +#define hifi_Volume3DOverlay_h // include this before QGLWidget, which includes an earlier version of OpenGL #include "InterfaceConfig.h" @@ -39,4 +42,4 @@ protected: }; -#endif /* defined(__interface__Volume3DOverlay__) */ +#endif // hifi_Volume3DOverlay_h diff --git a/interface/src/voxels/PrimitiveRenderer.cpp b/interface/src/voxels/PrimitiveRenderer.cpp index 7f3607e363..a212245289 100644 --- a/interface/src/voxels/PrimitiveRenderer.cpp +++ b/interface/src/voxels/PrimitiveRenderer.cpp @@ -1,10 +1,12 @@ -/// -/// @file PrimitiveRenderer.cpp -/// A geometric primitive renderer. -/// -/// @author: Norman Crafts -/// @copyright 2014, High Fidelity, Inc. All rights reserved. -/// +// +// PrimitiveRenderer.cpp +// interface/src/voxels +// +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// #include @@ -737,4 +739,4 @@ unsigned long PrimitiveRenderer::vGetMemoryUsage() { unsigned long PrimitiveRenderer::vGetMemoryUsageGPU() { return _gpuMemoryUsage; -} \ No newline at end of file +} diff --git a/interface/src/voxels/PrimitiveRenderer.h b/interface/src/voxels/PrimitiveRenderer.h index 51d96e0840..8626e2e2a4 100644 --- a/interface/src/voxels/PrimitiveRenderer.h +++ b/interface/src/voxels/PrimitiveRenderer.h @@ -1,13 +1,16 @@ -/// -/// @file PrimitiveRenderer.h -/// A geometric primitive renderer. -/// -/// @author: Norman Crafts -/// @copyright 2014, High Fidelity, Inc. All rights reserved. -/// +// +// PrimitiveRenderer.h +// interface/src/voxels +// +// Created by Norman Craft. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// -#ifndef __interface__PrimitiveRenderer__ -#define __interface__PrimitiveRenderer__ +#ifndef hifi_PrimitiveRenderer_h +#define hifi_PrimitiveRenderer_h #include #include @@ -485,4 +488,4 @@ private: }; -#endif +#endif // hifi_PrimitiveRenderer_h diff --git a/interface/src/voxels/VoxelFade.cpp b/interface/src/voxels/VoxelFade.cpp index 8ce68c9724..c720717d7c 100644 --- a/interface/src/voxels/VoxelFade.cpp +++ b/interface/src/voxels/VoxelFade.cpp @@ -1,9 +1,12 @@ // // VoxelFade.cpp -// interface +// interface/src/voxels // // Created by Brad Hefta-Gaub on 8/6/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "InterfaceConfig.h" diff --git a/interface/src/voxels/VoxelFade.h b/interface/src/voxels/VoxelFade.h index fd7a73135b..1843fa2d67 100644 --- a/interface/src/voxels/VoxelFade.h +++ b/interface/src/voxels/VoxelFade.h @@ -1,13 +1,16 @@ // // VoxelFade.h -// interface +// interface/src/voxels // // Created by Brad Hefta-Gaub on 8/6/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__VoxelFade__ -#define __interface__VoxelFade__ +#ifndef hifi_VoxelFade_h +#define hifi_VoxelFade_h #include // for VoxelPositionSize @@ -40,4 +43,4 @@ public: bool isDone() const; }; -#endif // __interface__VoxelFade__ +#endif // hifi_VoxelFade_h diff --git a/interface/src/voxels/VoxelHideShowThread.cpp b/interface/src/voxels/VoxelHideShowThread.cpp index d7a25b4b6d..089da0d1da 100644 --- a/interface/src/voxels/VoxelHideShowThread.cpp +++ b/interface/src/voxels/VoxelHideShowThread.cpp @@ -1,11 +1,12 @@ // // VoxelHideShowThread.cpp -// interface +// interface/src/voxels // -// Created by Brad Hefta-Gaub on 12/1/13 -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 12/1/13. +// Copyright 2013 High Fidelity, Inc. // -// Threaded or non-threaded interface thread for hiding and showing voxels in the local tree. +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/interface/src/voxels/VoxelHideShowThread.h b/interface/src/voxels/VoxelHideShowThread.h index dc1f2062c1..6aa3c108ba 100644 --- a/interface/src/voxels/VoxelHideShowThread.h +++ b/interface/src/voxels/VoxelHideShowThread.h @@ -1,15 +1,18 @@ // // VoxelHideShowThread.h -// voxel-server +// interface/src/voxels // -// Created by Brad Hefta-Gaub on 12/1/13 -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 12/1/13. +// Copyright 2013 High Fidelity, Inc. // // Threaded or non-threaded voxel persistence // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// -#ifndef __interface__VoxelHideShowThread__ -#define __interface__VoxelHideShowThread__ +#ifndef hifi_VoxelHideShowThread_h +#define hifi_VoxelHideShowThread_h #include #include "VoxelSystem.h" @@ -29,4 +32,4 @@ private: VoxelSystem* _theSystem; }; -#endif // __interface__VoxelHideShowThread__ +#endif // hifi_VoxelHideShowThread_h diff --git a/interface/src/voxels/VoxelImporter.cpp b/interface/src/voxels/VoxelImporter.cpp index d3c1b259ae..f7d5562c06 100644 --- a/interface/src/voxels/VoxelImporter.cpp +++ b/interface/src/voxels/VoxelImporter.cpp @@ -1,9 +1,12 @@ // // VoxelImporter.cpp -// hifi +// interface/src/voxels // // Created by Clement Brisset on 8/9/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // // include this before QGLWidget, which includes an earlier version of OpenGL diff --git a/interface/src/voxels/VoxelImporter.h b/interface/src/voxels/VoxelImporter.h index 9ebfc2eef2..7da89c5a11 100644 --- a/interface/src/voxels/VoxelImporter.h +++ b/interface/src/voxels/VoxelImporter.h @@ -1,13 +1,16 @@ // // VoxelImporter.h -// hifi +// interface/src/voxels // // Created by Clement Brisset on 8/9/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__VoxelImporter__ -#define __hifi__VoxelImporter__ +#ifndef hifi_VoxelImporter_h +#define hifi_VoxelImporter_h #include #include @@ -44,4 +47,4 @@ private: void cleanupTask(); }; -#endif /* defined(__hifi__VoxelImporter__) */ +#endif // hifi_VoxelImporter_h diff --git a/interface/src/voxels/VoxelPacketProcessor.cpp b/interface/src/voxels/VoxelPacketProcessor.cpp index 142285664e..d9d001b644 100644 --- a/interface/src/voxels/VoxelPacketProcessor.cpp +++ b/interface/src/voxels/VoxelPacketProcessor.cpp @@ -1,11 +1,12 @@ // // VoxelPacketProcessor.cpp -// interface +// interface/src/voxels // // Created by Brad Hefta-Gaub on 8/12/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // -// Threaded or non-threaded voxel packet receiver for the Application +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/interface/src/voxels/VoxelPacketProcessor.h b/interface/src/voxels/VoxelPacketProcessor.h index 2acd347e99..36456c5cc2 100644 --- a/interface/src/voxels/VoxelPacketProcessor.h +++ b/interface/src/voxels/VoxelPacketProcessor.h @@ -1,15 +1,16 @@ // // VoxelPacketProcessor.h -// interface +// interface/src/voxels // // Created by Brad Hefta-Gaub on 8/12/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // -// Voxel Packet Receiver +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __shared__VoxelPacketProcessor__ -#define __shared__VoxelPacketProcessor__ +#ifndef hifi_VoxelPacketProcessor_h +#define hifi_VoxelPacketProcessor_h #include @@ -20,4 +21,4 @@ class VoxelPacketProcessor : public ReceivedPacketProcessor { protected: virtual void processPacket(const SharedNodePointer& sendingNode, const QByteArray& packet); }; -#endif // __shared__VoxelPacketProcessor__ +#endif // hifi_VoxelPacketProcessor_h diff --git a/interface/src/voxels/VoxelSystem.cpp b/interface/src/voxels/VoxelSystem.cpp index bb907c8a9a..692f299bdc 100644 --- a/interface/src/voxels/VoxelSystem.cpp +++ b/interface/src/voxels/VoxelSystem.cpp @@ -1,8 +1,12 @@ // // VoxelSystem.cpp +// interface/src/voxels // // Created by Philip on 12/31/12. -// Copyright (c) 2012 High Fidelity, Inc. All rights reserved. +// Copyright 2012 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // diff --git a/interface/src/voxels/VoxelSystem.h b/interface/src/voxels/VoxelSystem.h index bdc55450dd..b134fe1539 100644 --- a/interface/src/voxels/VoxelSystem.h +++ b/interface/src/voxels/VoxelSystem.h @@ -1,13 +1,16 @@ // // VoxelSystem.h -// interface +// interface/src/voxels // // Created by Philip on 12/31/12. -// Copyright (c) 2012 High Fidelity, Inc. All rights reserved. +// Copyright 2012 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__VoxelSystem__ -#define __interface__VoxelSystem__ +#ifndef hifi_VoxelSystem_h +#define hifi_VoxelSystem_h #include "InterfaceConfig.h" #include @@ -271,4 +274,4 @@ private: }; -#endif +#endif // hifi_VoxelSystem_h diff --git a/interface/src/windowshacks.h b/interface/src/windowshacks.h index aae7b2f923..fcd2f5a7f2 100644 --- a/interface/src/windowshacks.h +++ b/interface/src/windowshacks.h @@ -1,15 +1,18 @@ // // windowshacks.h -// hifi +// interface/src // // Created by Brad Hefta-Gaub on 1/12/14. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. // // hacks to get windows to compile // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// -#ifndef __hifi__windowshacks__ -#define __hifi__windowshacks__ +#ifndef hifi_windowshacks_h +#define hifi_windowshacks_h #ifdef WIN32 #undef NOMINMAX @@ -54,4 +57,4 @@ inline int c99_snprintf(char* str, size_t size, const char* format, ...) { #endif // WIN32 -#endif // __hifi__windowshacks__ \ No newline at end of file +#endif // hifi_windowshacks_h diff --git a/interface/src/world.h b/interface/src/world.h index bc8dab9106..8e680f3d95 100644 --- a/interface/src/world.h +++ b/interface/src/world.h @@ -1,15 +1,18 @@ // // world.h -// interface +// interface/src // // Created by Philip Rosedale on 8/23/12. -// Copyright (c) 2012 High Fidelity, Inc. All rights reserved. -// +// Copyright 2012 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// -#ifndef __interface__world__ -#define __interface__world__ +#ifndef hifi_world_h +#define hifi_world_h const float GRAVITY_EARTH = 9.80665f; const float EDGE_SIZE_GROUND_PLANE = 20.f; -#endif +#endif // hifi_world_h diff --git a/interface/ui/chatWindow.ui b/interface/ui/chatWindow.ui index 60a0c6badd..9f1f0527b8 100644 --- a/interface/ui/chatWindow.ui +++ b/interface/ui/chatWindow.ui @@ -20,7 +20,7 @@ font-family: Helvetica, Arial, sans-serif; - QDockWidget::NoDockWidgetFeatures + QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable Qt::NoDockWidgetArea @@ -79,6 +79,45 @@ + + + + + 0 + 0 + + + + + 16 + 16 + + + + Qt::NoFocus + + + + + + + ../resources/images/pin.svg + ../resources/images/pinned.svg../resources/images/pin.svg + + + true + + + true + + + false + + + true + + + @@ -100,8 +139,8 @@ - - :/images/close.svg:/images/close.svg + + ../resources/images/close.svg../resources/images/close.svg true @@ -200,10 +239,24 @@ messagePlainTextEdit messagesScrollArea - - - + + + togglePinnedButton + clicked() + ChatWindow + togglePinned() + + + 390 + 42 + + + 550 + 42 + + + closeButton clicked() diff --git a/interface/ui/preferencesDialog.ui b/interface/ui/preferencesDialog.ui new file mode 100644 index 0000000000..a151a499c6 --- /dev/null +++ b/interface/ui/preferencesDialog.ui @@ -0,0 +1,1375 @@ + + + PreferencesDialog + + + + 0 + 0 + 638 + 652 + + + + + 0 + 0 + + + + + 610 + 0 + + + + 0.950000000000000 + + + + + 0 + 560 + 611 + 97 + + + + + 0 + 0 + + + + + 0 + 97 + + + + + Arial + + + + background-color: #0e7077 + + + + + 310 + 24 + 91 + 50 + + + + + 0 + 0 + + + + + 0 + 50 + + + + + Arial + 18 + 50 + false + + + + + + + Cancel + + + + + + 400 + 24 + 188 + 50 + + + + + 0 + 0 + + + + + 188 + 49 + + + + + Arial + 18 + + + + background-color: #fff; +color: #0e7077 + + + Save all changes + + + true + + + + + + + 0 + 30 + 615 + 491 + + + + QFrame::NoFrame + + + QFrame::Plain + + + 0 + + + true + + + + + 0 + 0 + 615 + 833 + + + + + 0 + + + 30 + + + 0 + + + 30 + + + 30 + + + + + + 0 + 0 + + + + + Arial + 24 + + + + color: #0e7077 + + + Avatar + + + 25 + + + + + + + + + + + 0 + 0 + + + + + 0 + 30 + + + + + Arial + 16 + + + + color: #0e7077 + + + <html><head/><body><p>Avatar display name <span style=" color:#909090;">(optional)</span></p></body></html> + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + displayNameEdit + + + + + + + + 0 + 0 + + + + + 280 + 0 + + + + + Arial + + + + Qt::LeftToRight + + + + + + Not showing a name + + + + + + + + 0 + 0 + + + + + 0 + 30 + + + + + Arial + 16 + + + + color: #0e7077 + + + Head + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + 0 + + + faceURLEdit + + + + + + + + + + 0 + 0 + + + + + Arial + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 0 + 0 + + + + + 30 + 30 + + + + + 30 + 30 + + + + + + + + + + + 30 + 30 + + + + + + + + + + + 0 + 0 + + + + + 0 + 30 + + + + + Arial + 16 + + + + color: #0e7077 + + + Body + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + skeletonURLEdit + + + + + + + + + + 0 + 0 + + + + + Arial + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 0 + 0 + + + + + 30 + 30 + + + + + 30 + 30 + + + + + + + + + + + 30 + 30 + + + + + + + + + + Qt::Vertical + + + + 0 + 35 + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + Arial + 24 + + + + color: #0e7077 + + + Advanced Tuning + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + 25 + + + + + + + + 0 + 0 + + + + + Arial + 16 + + + + true + + + color: rgb(51, 51, 51); + + + It's not recomended that you play with these settings unless you've looked into exactly what they do. + + + false + + + true + + + + + + + + 0 + 0 + + + + + 0 + 40 + + + + + Arial + 20 + 50 + false + + + + color: #0e7077 + + + Avatar + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + + + + + 0 + + + 10 + + + 0 + + + 10 + + + + + + Arial + + + + + + + Vertical field of view + + + 15 + + + fieldOfViewSpin + + + + + + + + Arial + + + + Qt::Horizontal + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + 95 + 36 + + + + + 95 + 36 + + + + + Arial + + + + 1 + + + 180 + + + + + + + + + 0 + + + 10 + + + 10 + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 25 + + + + + Arial + + + + color: rgb(51, 51, 51) + + + Lean scale (applies to Faceshift users) + + + 15 + + + leanScaleSpin + + + + + + + + Arial + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 40 + 10 + + + + + + + + + 0 + 0 + + + + + 95 + 36 + + + + + 70 + 16777215 + + + + + Arial + + + + + + + + + + 0 + + + 10 + + + 0 + + + 10 + + + + + + Arial + + + + color: rgb(51, 51, 51) + + + Avatar scale <span style=" color:#909090;">(default is 1.0)</span> + + + 15 + + + avatarScaleSpin + + + + + + + + Arial + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 95 + 36 + + + + + 70 + 16777215 + + + + + Arial + + + + + + + + + + 0 + + + 10 + + + 0 + + + 10 + + + + + + Arial + + + + color: rgb(51, 51, 51) + + + Pupil dillation + + + 15 + + + pupilDilationSlider + + + + + + + + Arial + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 125 + 0 + + + + + Arial + + + + Qt::Horizontal + + + + + + + + + 0 + + + 10 + + + 0 + + + 10 + + + + + + Arial + + + + color: rgb(51, 51, 51) + + + Audio Jitter Buffer Samples (0 for automatic) + + + 15 + + + audioJitterSpin + + + + + + + + Arial + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 95 + 36 + + + + + 70 + 16777215 + + + + + Arial + + + + -10000 + + + 10000 + + + 1 + + + + + + + + + 0 + + + 10 + + + 0 + + + 10 + + + + + + Arial + + + + color: rgb(51, 51, 51) + + + Faceshift eye detection + + + 15 + + + faceshiftEyeDeflectionSider + + + + + + + + Arial + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 125 + 0 + + + + + Arial + + + + Qt::Horizontal + + + + + + + + + + 0 + 0 + + + + + 0 + 40 + + + + + Arial + 20 + 50 + false + + + + color: #0e7077 + + + Voxels + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + + + + + 0 + + + 10 + + + 0 + + + 10 + + + + + + Arial + + + + color: rgb(51, 51, 51) + + + Maximum voxels + + + 15 + + + maxVoxelsSpin + + + + + + + + Arial + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 125 + 36 + + + + + Arial + + + + 5000000 + + + 50000 + + + + + + + + + 0 + + + 10 + + + 0 + + + 10 + + + + + + Arial + + + + Max voxels sent each second + + + 15 + + + maxVoxelsPPSSpin + + + + + + + + Arial + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 95 + 36 + + + + + 70 + 16777215 + + + + + Arial + + + + 60 + + + 6000 + + + 10 + + + + + + + + + + + + 540 + 24 + 31 + 31 + + + + + PreferAntialias + + + + + + + + + + FramelessDialog + 1 + + + + + + cancelButton + clicked() + PreferencesDialog + close() + + + 495 + 749 + + + 528 + 0 + + + + + defaultButton + clicked() + PreferencesDialog + accept() + + + 504 + 749 + + + 20 + 20 + + + + + diff --git a/interface/ui/runningScriptsWidget.ui b/interface/ui/runningScriptsWidget.ui new file mode 100644 index 0000000000..c7fc9e43e8 --- /dev/null +++ b/interface/ui/runningScriptsWidget.ui @@ -0,0 +1,246 @@ + + + RunningScriptsWidget + + + + 0 + 0 + 310 + 651 + + + + Form + + + background: #f7f7f7; +font-family: Helvetica, Arial, "DejaVu Sans"; + + + + + 20 + 10 + 221 + 31 + + + + color: #0e7077; + + + <html><head/><body><p><span style=" font-size:18pt;">Running Scripts</span></p></body></html> + + + + + + 20 + 40 + 301 + 20 + + + + color: #0e7077; + + + <html><head/><body><p><span style=" font-weight:600;">Currently running</span></p></body></html> + + + + + + 40 + 230 + 111 + 31 + + + + PointingHandCursor + + + background: #0e7077; +color: #fff; +border-radius: 6px; + + + Reload All + + + + ../resources/images/reload.svg../resources/images/reload.svg + + + + + + 160 + 230 + 101 + 31 + + + + PointingHandCursor + + + background: #0e7077; +color: #fff; +border-radius: 6px; + + + Stop All + + + + ../resources/images/stop.svg../resources/images/stop.svg + + + + + + 20 + 280 + 301 + 20 + + + + color: #0e7077; + + + <html><head/><body><p><span style=" font-weight:600;">Recently loaded</span></p></body></html> + + + + + + 20 + 300 + 271 + 8 + + + + + + + Qt::Horizontal + + + + + + 20 + 590 + 271 + 41 + + + + color: #95a5a6; + + + (click a script or use the 1-9 keys to load and run it) + + + true + + + + + + 270 + 10 + 31 + 31 + + + + PointingHandCursor + + + + + + + ../resources/images/close.svg../resources/images/close.svg + + + + 20 + 20 + + + + true + + + + + + 20 + 70 + 271 + 141 + + + + background: transparent; + + + + + + 20 + 60 + 271 + 8 + + + + + + + Qt::Horizontal + + + + + + 20 + 310 + 271 + 281 + + + + background: transparent; + + + + + + 20 + 40 + 271 + 51 + + + + font: 14px; + + + There are no scripts currently running. + + + Qt::AlignCenter + + + + + + diff --git a/libraries/audio/src/AbstractAudioInterface.h b/libraries/audio/src/AbstractAudioInterface.h index dc3872efd5..f950eefcbd 100644 --- a/libraries/audio/src/AbstractAudioInterface.h +++ b/libraries/audio/src/AbstractAudioInterface.h @@ -1,14 +1,16 @@ // // AbstractAudioInterface.h -// hifi +// libraries/audio/src // // Created by Brad Hefta-Gaub on 12/4/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__AbstractAudioInterface__ -#define __hifi__AbstractAudioInterface__ +#ifndef hifi_AbstractAudioInterface_h +#define hifi_AbstractAudioInterface_h #include @@ -25,4 +27,4 @@ public slots: Q_DECLARE_METATYPE(AbstractAudioInterface*) -#endif /* defined(__hifi__AbstractAudioInterface__) */ \ No newline at end of file +#endif // hifi_AbstractAudioInterface_h diff --git a/libraries/audio/src/AudioInjector.cpp b/libraries/audio/src/AudioInjector.cpp index 7f0e5c7f1a..6370e51826 100644 --- a/libraries/audio/src/AudioInjector.cpp +++ b/libraries/audio/src/AudioInjector.cpp @@ -1,9 +1,12 @@ // // AudioInjector.cpp -// hifi +// libraries/audio/src // // Created by Stephen Birarda on 1/2/2014. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/audio/src/AudioInjector.h b/libraries/audio/src/AudioInjector.h index beff33a9ef..abaa804fb0 100644 --- a/libraries/audio/src/AudioInjector.h +++ b/libraries/audio/src/AudioInjector.h @@ -1,13 +1,16 @@ // // AudioInjector.h -// hifi +// libraries/audio/src // // Created by Stephen Birarda on 1/2/2014. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__AudioInjector__ -#define __hifi__AudioInjector__ +#ifndef hifi_AudioInjector_h +#define hifi_AudioInjector_h #include #include @@ -31,4 +34,4 @@ signals: void finished(); }; -#endif /* defined(__hifi__AudioInjector__) */ +#endif // hifi_AudioInjector_h diff --git a/libraries/audio/src/AudioInjectorOptions.cpp b/libraries/audio/src/AudioInjectorOptions.cpp index 30e8c3e490..cd6b08f6c7 100644 --- a/libraries/audio/src/AudioInjectorOptions.cpp +++ b/libraries/audio/src/AudioInjectorOptions.cpp @@ -1,9 +1,12 @@ // // AudioInjectorOptions.cpp -// hifi +// libraries/audio/src // // Created by Stephen Birarda on 1/2/2014. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "AudioInjectorOptions.h" @@ -23,4 +26,4 @@ AudioInjectorOptions::AudioInjectorOptions(const AudioInjectorOptions& other) { _volume = other._volume; _orientation = other._orientation; _loopbackAudioInterface = other._loopbackAudioInterface; -} \ No newline at end of file +} diff --git a/libraries/audio/src/AudioInjectorOptions.h b/libraries/audio/src/AudioInjectorOptions.h index 0c70ad43cb..bbe3d57b08 100644 --- a/libraries/audio/src/AudioInjectorOptions.h +++ b/libraries/audio/src/AudioInjectorOptions.h @@ -1,13 +1,16 @@ // // AudioInjectorOptions.h -// hifi +// libraries/audio/src // // Created by Stephen Birarda on 1/2/2014. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__AudioInjectorOptions__ -#define __hifi__AudioInjectorOptions__ +#ifndef hifi_AudioInjectorOptions_h +#define hifi_AudioInjectorOptions_h #include @@ -46,4 +49,4 @@ private: AbstractAudioInterface* _loopbackAudioInterface; }; -#endif /* defined(__hifi__AudioInjectorOptions__) */ +#endif // hifi_AudioInjectorOptions_h diff --git a/libraries/audio/src/AudioRingBuffer.cpp b/libraries/audio/src/AudioRingBuffer.cpp index 0b4b80b398..45dafdca58 100644 --- a/libraries/audio/src/AudioRingBuffer.cpp +++ b/libraries/audio/src/AudioRingBuffer.cpp @@ -1,9 +1,12 @@ // // AudioRingBuffer.cpp -// interface +// libraries/audio/src // // Created by Stephen Birarda on 2/1/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/audio/src/AudioRingBuffer.h b/libraries/audio/src/AudioRingBuffer.h index b0f6aab5ea..7ec686f1ac 100644 --- a/libraries/audio/src/AudioRingBuffer.h +++ b/libraries/audio/src/AudioRingBuffer.h @@ -1,13 +1,16 @@ // // AudioRingBuffer.h -// interface +// libraries/audio/src // // Created by Stephen Birarda on 2/1/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__AudioRingBuffer__ -#define __interface__AudioRingBuffer__ +#ifndef hifi_AudioRingBuffer_h +#define hifi_AudioRingBuffer_h #include #include @@ -87,4 +90,4 @@ protected: bool _hasStarted; }; -#endif /* defined(__interface__AudioRingBuffer__) */ +#endif // hifi_AudioRingBuffer_h diff --git a/libraries/audio/src/AudioScriptingInterface.cpp b/libraries/audio/src/AudioScriptingInterface.cpp index 1fe2c19922..0d76a42757 100644 --- a/libraries/audio/src/AudioScriptingInterface.cpp +++ b/libraries/audio/src/AudioScriptingInterface.cpp @@ -1,9 +1,12 @@ // // AudioScriptingInterface.cpp -// hifi +// libraries/audio/src // // Created by Stephen Birarda on 1/2/2014. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "AudioScriptingInterface.h" diff --git a/libraries/audio/src/AudioScriptingInterface.h b/libraries/audio/src/AudioScriptingInterface.h index f758923513..f2e9b02e9a 100644 --- a/libraries/audio/src/AudioScriptingInterface.h +++ b/libraries/audio/src/AudioScriptingInterface.h @@ -1,13 +1,16 @@ // // AudioScriptingInterface.h -// hifi +// libraries/audio/src // // Created by Stephen Birarda on 1/2/2014. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__AudioScriptingInterface__ -#define __hifi__AudioScriptingInterface__ +#ifndef hifi_AudioScriptingInterface_h +#define hifi_AudioScriptingInterface_h #include "AudioInjector.h" #include "Sound.h" @@ -22,4 +25,4 @@ public slots: const AudioInjectorOptions* injectorOptions = NULL); }; -#endif /* defined(__hifi__AudioScriptingInterface__) */ +#endif // hifi_AudioScriptingInterface_h diff --git a/libraries/audio/src/InjectedAudioRingBuffer.cpp b/libraries/audio/src/InjectedAudioRingBuffer.cpp index f8205a846f..2658b4c336 100644 --- a/libraries/audio/src/InjectedAudioRingBuffer.cpp +++ b/libraries/audio/src/InjectedAudioRingBuffer.cpp @@ -1,9 +1,12 @@ // // InjectedAudioRingBuffer.cpp -// hifi +// libraries/audio/src // // Created by Stephen Birarda on 6/5/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/audio/src/InjectedAudioRingBuffer.h b/libraries/audio/src/InjectedAudioRingBuffer.h index d4dfb5e360..fd766e2848 100644 --- a/libraries/audio/src/InjectedAudioRingBuffer.h +++ b/libraries/audio/src/InjectedAudioRingBuffer.h @@ -1,13 +1,16 @@ // // InjectedAudioRingBuffer.h -// hifi +// libraries/audio/src // // Created by Stephen Birarda on 6/5/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__InjectedAudioRingBuffer__ -#define __hifi__InjectedAudioRingBuffer__ +#ifndef hifi_InjectedAudioRingBuffer_h +#define hifi_InjectedAudioRingBuffer_h #include @@ -32,4 +35,4 @@ private: float _attenuationRatio; }; -#endif /* defined(__hifi__InjectedAudioRingBuffer__) */ +#endif // hifi_InjectedAudioRingBuffer_h diff --git a/libraries/audio/src/MixedAudioRingBuffer.cpp b/libraries/audio/src/MixedAudioRingBuffer.cpp index 0ffab23519..c975d7b68e 100644 --- a/libraries/audio/src/MixedAudioRingBuffer.cpp +++ b/libraries/audio/src/MixedAudioRingBuffer.cpp @@ -1,9 +1,12 @@ // // MixedAudioRingBuffer.cpp -// hifi +// libraries/audio/src // -// Created by Stephen Birarda on 2014-03-26. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Created by Stephen Birarda on 2014. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "MixedAudioRingBuffer.h" @@ -46,4 +49,4 @@ qint64 MixedAudioRingBuffer::readSamples(int16_t* destination, qint64 maxSamples _lastReadFrameAverageLoudness = averageLoudness; return AudioRingBuffer::readSamples(destination, maxSamples); -} \ No newline at end of file +} diff --git a/libraries/audio/src/MixedAudioRingBuffer.h b/libraries/audio/src/MixedAudioRingBuffer.h index c116361689..25574a3ea6 100644 --- a/libraries/audio/src/MixedAudioRingBuffer.h +++ b/libraries/audio/src/MixedAudioRingBuffer.h @@ -1,13 +1,16 @@ // // MixedAudioRingBuffer.h -// hifi +// libraries/audio/src // -// Created by Stephen Birarda on 2014-03-26. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Created by Stephen Birarda on 2014. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__MixedAudioRingBuffer__ -#define __hifi__MixedAudioRingBuffer__ +#ifndef hifi_MixedAudioRingBuffer_h +#define hifi_MixedAudioRingBuffer_h #include "AudioRingBuffer.h" @@ -23,4 +26,4 @@ private: float _lastReadFrameAverageLoudness; }; -#endif /* defined(__hifi__MixedAudioRingBuffer__) */ +#endif // hifi_MixedAudioRingBuffer_h diff --git a/libraries/audio/src/PositionalAudioRingBuffer.cpp b/libraries/audio/src/PositionalAudioRingBuffer.cpp index 7bdedfc793..70da363267 100644 --- a/libraries/audio/src/PositionalAudioRingBuffer.cpp +++ b/libraries/audio/src/PositionalAudioRingBuffer.cpp @@ -1,9 +1,12 @@ // // PositionalAudioRingBuffer.cpp -// hifi +// libraries/audio/src // // Created by Stephen Birarda on 6/5/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/audio/src/PositionalAudioRingBuffer.h b/libraries/audio/src/PositionalAudioRingBuffer.h index a82df0b857..b130a9b216 100644 --- a/libraries/audio/src/PositionalAudioRingBuffer.h +++ b/libraries/audio/src/PositionalAudioRingBuffer.h @@ -1,13 +1,16 @@ // // PositionalAudioRingBuffer.h -// hifi +// libraries/audio/src // // Created by Stephen Birarda on 6/5/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__PositionalAudioRingBuffer__ -#define __hifi__PositionalAudioRingBuffer__ +#ifndef hifi_PositionalAudioRingBuffer_h +#define hifi_PositionalAudioRingBuffer_h #include #include @@ -57,4 +60,4 @@ protected: float _nextOutputTrailingLoudness; }; -#endif /* defined(__hifi__PositionalAudioRingBuffer__) */ +#endif // hifi_PositionalAudioRingBuffer_h diff --git a/libraries/audio/src/Sound.cpp b/libraries/audio/src/Sound.cpp index 91a47b7d2c..420576ece9 100644 --- a/libraries/audio/src/Sound.cpp +++ b/libraries/audio/src/Sound.cpp @@ -1,10 +1,12 @@ // // Sound.cpp -// hifi +// libraries/audio/src // // Created by Stephen Birarda on 1/2/2014. -// Modified by Athanasios Gaitatzes to add WAVE file support. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include @@ -152,20 +154,17 @@ void Sound::downSample(const QByteArray& rawAudioByteArray) { // Sample values are given above for a 16-bit stereo source. // -struct chunk -{ +struct chunk { char id[4]; quint32 size; }; -struct RIFFHeader -{ +struct RIFFHeader { chunk descriptor; // "RIFF" char type[4]; // "WAVE" }; -struct WAVEHeader -{ +struct WAVEHeader { chunk descriptor; quint16 audioFormat; // Format type: 1=PCM, 257=Mu-Law, 258=A-Law, 259=ADPCM quint16 numChannels; // Number of channels: 1=mono, 2=stereo @@ -175,13 +174,11 @@ struct WAVEHeader quint16 bitsPerSample; }; -struct DATAHeader -{ +struct DATAHeader { chunk descriptor; }; -struct CombinedHeader -{ +struct CombinedHeader { RIFFHeader riff; WAVEHeader wave; }; diff --git a/libraries/audio/src/Sound.h b/libraries/audio/src/Sound.h index 7956343d46..e1613fec51 100644 --- a/libraries/audio/src/Sound.h +++ b/libraries/audio/src/Sound.h @@ -1,14 +1,16 @@ // // Sound.h -// hifi +// libraries/audio/src // // Created by Stephen Birarda on 1/2/2014. -// Modified by Athanasios Gaitatzes to add WAVE file support. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__Sound__ -#define __hifi__Sound__ +#ifndef hifi_Sound_h +#define hifi_Sound_h #include @@ -32,4 +34,4 @@ private slots: void replyFinished(QNetworkReply* reply); }; -#endif /* defined(__hifi__Sound__) */ +#endif // hifi_Sound_h diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp index 31639b6836..2f412b5e9a 100644 --- a/libraries/avatars/src/AvatarData.cpp +++ b/libraries/avatars/src/AvatarData.cpp @@ -1,9 +1,12 @@ // // AvatarData.cpp -// hifi +// libraries/avatars/src // // Created by Stephen Birarda on 4/9/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include @@ -32,6 +35,7 @@ using namespace std; QNetworkAccessManager* AvatarData::networkAccessManager = NULL; AvatarData::AvatarData() : + _sessionUUID(), _handPosition(0,0,0), _bodyYaw(-90.f), _bodyPitch(0.0f), @@ -40,6 +44,7 @@ AvatarData::AvatarData() : _handState(0), _keyState(NO_KEY_DOWN), _isChatCirclingEnabled(false), + _hasNewJointRotations(true), _headData(NULL), _handData(NULL), _displayNameBoundingRect(), @@ -483,6 +488,7 @@ int AvatarData::parseDataAtOffset(const QByteArray& packet, int offset) { } } } // numJoints * 8 bytes + _hasNewJointRotations = true; return sourceBuffer - startPosition; } @@ -637,6 +643,8 @@ void AvatarData::setSkeletonModelURL(const QUrl& skeletonModelURL) { _skeletonModelURL = skeletonModelURL.isEmpty() ? DEFAULT_BODY_MODEL_URL : skeletonModelURL; qDebug() << "Changing skeleton model for avatar to" << _skeletonModelURL.toString(); + + updateJointMappings(); } void AvatarData::setDisplayName(const QString& displayName) { @@ -671,6 +679,40 @@ void AvatarData::setBillboardFromURL(const QString &billboardURL) { void AvatarData::setBillboardFromNetworkReply() { QNetworkReply* networkReply = reinterpret_cast(sender()); setBillboard(networkReply->readAll()); + networkReply->deleteLater(); +} + +void AvatarData::setJointMappingsFromNetworkReply() { + QNetworkReply* networkReply = static_cast(sender()); + + QByteArray line; + while (!(line = networkReply->readLine()).isEmpty()) { + if (!(line = line.trimmed()).startsWith("jointIndex")) { + continue; + } + int jointNameIndex = line.indexOf('=') + 1; + if (jointNameIndex == 0) { + continue; + } + int secondSeparatorIndex = line.indexOf('=', jointNameIndex); + if (secondSeparatorIndex == -1) { + continue; + } + QString jointName = line.mid(jointNameIndex, secondSeparatorIndex - jointNameIndex).trimmed(); + bool ok; + int jointIndex = line.mid(secondSeparatorIndex + 1).trimmed().toInt(&ok); + if (ok) { + while (_jointNames.size() < jointIndex + 1) { + _jointNames.append(QString()); + } + _jointNames[jointIndex] = jointName; + } + } + for (int i = 0; i < _jointNames.size(); i++) { + _jointIndices.insert(_jointNames.at(i), i + 1); + } + + networkReply->deleteLater(); } void AvatarData::setClampedTargetScale(float targetScale) { @@ -703,3 +745,13 @@ void AvatarData::sendBillboardPacket() { NodeList::getInstance()->broadcastToNodes(billboardPacket, NodeSet() << NodeType::AvatarMixer); } } + +void AvatarData::updateJointMappings() { + _jointIndices.clear(); + _jointNames.clear(); + + if (networkAccessManager && _skeletonModelURL.fileName().toLower().endsWith(".fst")) { + QNetworkReply* networkReply = networkAccessManager->get(QNetworkRequest(_skeletonModelURL)); + connect(networkReply, SIGNAL(finished()), this, SLOT(setJointMappingsFromNetworkReply())); + } +} diff --git a/libraries/avatars/src/AvatarData.h b/libraries/avatars/src/AvatarData.h index 2ea20c1041..0ac12649cf 100755 --- a/libraries/avatars/src/AvatarData.h +++ b/libraries/avatars/src/AvatarData.h @@ -1,13 +1,16 @@ // // AvatarData.h -// hifi +// libraries/avatars/src // // Created by Stephen Birarda on 4/9/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__AvatarData__ -#define __hifi__AvatarData__ +#ifndef hifi_AvatarData_h +#define hifi_AvatarData_h #include /* VS2010 defines stdint.h, but not inttypes.h */ @@ -30,12 +33,14 @@ typedef unsigned long long quint64; #include #include +#include #include #include #include #include #include #include +#include #include #include @@ -93,10 +98,14 @@ class AvatarData : public QObject { Q_PROPERTY(QString faceModelURL READ getFaceModelURLFromScript WRITE setFaceModelURLFromScript) Q_PROPERTY(QString skeletonModelURL READ getSkeletonModelURLFromScript WRITE setSkeletonModelURLFromScript) Q_PROPERTY(QString billboardURL READ getBillboardURL WRITE setBillboardFromURL) + + Q_PROPERTY(QUuid sessionUUID READ getSessionUUID); public: AvatarData(); virtual ~AvatarData(); + const QUuid& getSessionUUID() { return _sessionUUID; } + const glm::vec3& getPosition() const { return _position; } void setPosition(const glm::vec3 position) { _position = position; } @@ -160,9 +169,9 @@ public: Q_INVOKABLE glm::quat getJointRotation(const QString& name) const; /// Returns the index of the joint with the specified name, or -1 if not found/unknown. - Q_INVOKABLE virtual int getJointIndex(const QString& name) const { return -1; } + Q_INVOKABLE virtual int getJointIndex(const QString& name) const { return _jointIndices.value(name) - 1; } - Q_INVOKABLE virtual QStringList getJointNames() const { return QStringList(); } + Q_INVOKABLE virtual QStringList getJointNames() const { return _jointNames; } // key state void setKeyState(KeyState s) { _keyState = s; } @@ -217,7 +226,10 @@ public slots: void sendIdentityPacket(); void sendBillboardPacket(); void setBillboardFromNetworkReply(); + void setJointMappingsFromNetworkReply(); + void setSessionUUID(const QUuid& id) { _sessionUUID = id; } protected: + QUuid _sessionUUID; glm::vec3 _position; glm::vec3 _handPosition; @@ -242,6 +254,8 @@ protected: bool _isChatCirclingEnabled; + bool _hasNewJointRotations; // set in AvatarData, cleared in Avatar + HeadData* _headData; HandData* _handData; @@ -256,10 +270,16 @@ protected: QByteArray _billboard; QString _billboardURL; + QHash _jointIndices; ///< 1-based, since zero is returned for missing keys + QStringList _jointNames; ///< in order of depth-first traversal + static QNetworkAccessManager* networkAccessManager; quint64 _errorLogExpiry; ///< time in future when to log an error + /// Loads the joint indices, names from the FST file (if any) + virtual void updateJointMappings(); + private: // privatize the copy constructor and assignment operator so they cannot be called AvatarData(const AvatarData&); @@ -272,4 +292,4 @@ public: glm::quat rotation; }; -#endif /* defined(__hifi__AvatarData__) */ +#endif // hifi_AvatarData_h diff --git a/libraries/avatars/src/AvatarHashMap.cpp b/libraries/avatars/src/AvatarHashMap.cpp index 82485691c5..1c2cd4bf92 100644 --- a/libraries/avatars/src/AvatarHashMap.cpp +++ b/libraries/avatars/src/AvatarHashMap.cpp @@ -1,9 +1,12 @@ // // AvatarHashMap.cpp -// hifi +// libraries/avatars/src // // Created by AndrewMeadows on 1/28/2014. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "AvatarHashMap.h" @@ -15,6 +18,7 @@ AvatarHashMap::AvatarHashMap() : void AvatarHashMap::insert(const QUuid& id, AvatarSharedPointer avatar) { _avatarHash.insert(id, avatar); + avatar->setSessionUUID(id); } AvatarHash::iterator AvatarHashMap::erase(const AvatarHash::iterator& iterator) { diff --git a/libraries/avatars/src/AvatarHashMap.h b/libraries/avatars/src/AvatarHashMap.h index 19b6623402..aee9cd09f1 100644 --- a/libraries/avatars/src/AvatarHashMap.h +++ b/libraries/avatars/src/AvatarHashMap.h @@ -1,13 +1,16 @@ // // AvatarHashMap.h -// hifi +// libraries/avatars/src // // Created by Stephen AndrewMeadows on 1/28/2014. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__AvatarHashMap__ -#define __hifi__AvatarHashMap__ +#ifndef hifi_AvatarHashMap_h +#define hifi_AvatarHashMap_h #include #include @@ -33,4 +36,4 @@ protected: AvatarHash _avatarHash; }; -#endif /* defined(__hifi__AvatarHashMap__) */ +#endif // hifi_AvatarHashMap_h diff --git a/libraries/avatars/src/HandData.cpp b/libraries/avatars/src/HandData.cpp index 201d17d3f5..c2e3b51cb3 100644 --- a/libraries/avatars/src/HandData.cpp +++ b/libraries/avatars/src/HandData.cpp @@ -1,9 +1,12 @@ // // HandData.cpp -// hifi +// libraries/avatars/src // // Created by Stephen Birarda on 5/20/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/avatars/src/HandData.h b/libraries/avatars/src/HandData.h index 9ebdc8dcf6..a37e3a5814 100755 --- a/libraries/avatars/src/HandData.h +++ b/libraries/avatars/src/HandData.h @@ -1,13 +1,16 @@ // // HandData.h -// hifi +// libraries/avatars/src // // Created by Eric Johnston on 6/26/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__HandData__ -#define __hifi__HandData__ +#ifndef hifi_HandData_h +#define hifi_HandData_h #include #include @@ -223,4 +226,4 @@ private: quint64 _collisionlessPaddleExpiry; /// Timestamp after which paddle starts colliding }; -#endif /* defined(__hifi__HandData__) */ +#endif // hifi_HandData_h diff --git a/libraries/avatars/src/HeadData.cpp b/libraries/avatars/src/HeadData.cpp index e74ac043fb..c691a2c28a 100644 --- a/libraries/avatars/src/HeadData.cpp +++ b/libraries/avatars/src/HeadData.cpp @@ -1,9 +1,12 @@ // // HeadData.cpp -// hifi +// libraries/avatars/src // // Created by Stephen Birarda on 5/20/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/avatars/src/HeadData.h b/libraries/avatars/src/HeadData.h index c60627e3f9..b76bd189bf 100644 --- a/libraries/avatars/src/HeadData.h +++ b/libraries/avatars/src/HeadData.h @@ -1,13 +1,16 @@ // // HeadData.h -// hifi +// libraries/avatars/src // // Created by Stephen Birarda on 5/20/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__HeadData__ -#define __hifi__HeadData__ +#ifndef hifi_HeadData_h +#define hifi_HeadData_h #include @@ -92,4 +95,4 @@ private: HeadData& operator= (const HeadData&); }; -#endif /* defined(__hifi__HeadData__) */ +#endif // hifi_HeadData_h diff --git a/libraries/embedded-webserver/src/HTTPConnection.cpp b/libraries/embedded-webserver/src/HTTPConnection.cpp index 8fc0a25dca..276b4e7f64 100755 --- a/libraries/embedded-webserver/src/HTTPConnection.cpp +++ b/libraries/embedded-webserver/src/HTTPConnection.cpp @@ -1,9 +1,12 @@ // // HTTPConnection.cpp -// hifi +// libraries/embedded-webserver/src // // Created by Stephen Birarda on 1/16/14. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // diff --git a/libraries/embedded-webserver/src/HTTPConnection.h b/libraries/embedded-webserver/src/HTTPConnection.h index dbf1e31f47..a131a22a9e 100644 --- a/libraries/embedded-webserver/src/HTTPConnection.h +++ b/libraries/embedded-webserver/src/HTTPConnection.h @@ -1,17 +1,20 @@ // // HTTPConnection.h -// hifi +// libraries/embedded-webserver/src // // Created by Stephen Birarda on 1/16/14. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. // // Heavily based on Andrzej Kapolka's original HTTPConnection class // found from another one of his projects. // https://github.com/ey6es/witgap/tree/master/src/cpp/server/http // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// -#ifndef __hifi__HTTPConnection__ -#define __hifi__HTTPConnection__ +#ifndef hifi_HTTPConnection_h +#define hifi_HTTPConnection_h #include #include @@ -118,4 +121,4 @@ protected: QByteArray _requestContent; }; -#endif /* defined(__hifi__HTTPConnection__) */ +#endif // hifi_HTTPConnection_h diff --git a/libraries/embedded-webserver/src/HTTPManager.cpp b/libraries/embedded-webserver/src/HTTPManager.cpp index d106b6df59..1fc859014a 100755 --- a/libraries/embedded-webserver/src/HTTPManager.cpp +++ b/libraries/embedded-webserver/src/HTTPManager.cpp @@ -1,9 +1,12 @@ // // HTTPManager.cpp -// hifi +// libraries/embedded-webserver/src // // Created by Stephen Birarda on 1/16/14. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/embedded-webserver/src/HTTPManager.h b/libraries/embedded-webserver/src/HTTPManager.h index a8f9d723fa..1e3afca1b5 100755 --- a/libraries/embedded-webserver/src/HTTPManager.h +++ b/libraries/embedded-webserver/src/HTTPManager.h @@ -1,17 +1,20 @@ // // HTTPManager.h -// hifi +// libraries/embedded-webserver/src // // Created by Stephen Birarda on 1/16/14. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. // // Heavily based on Andrzej Kapolka's original HTTPManager class // found from another one of his projects. // https://github.com/ey6es/witgap/tree/master/src/cpp/server/http // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// -#ifndef __hifi__HTTPManager__ -#define __hifi__HTTPManager__ +#ifndef hifi_HTTPManager_h +#define hifi_HTTPManager_h #include @@ -40,4 +43,4 @@ protected: HTTPRequestHandler* _requestHandler; }; -#endif /* defined(__hifi__HTTPManager__) */ +#endif // hifi_HTTPManager_h diff --git a/libraries/metavoxels/src/AttributeRegistry.cpp b/libraries/metavoxels/src/AttributeRegistry.cpp index fc448613f9..e7a7f41850 100644 --- a/libraries/metavoxels/src/AttributeRegistry.cpp +++ b/libraries/metavoxels/src/AttributeRegistry.cpp @@ -1,9 +1,12 @@ // // AttributeRegistry.cpp -// metavoxels +// libraries/metavoxels/src // // Created by Andrzej Kapolka on 12/6/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include @@ -144,6 +147,14 @@ void OwnedAttributeValue::mix(const AttributeValue& first, const AttributeValue& _value = _attribute->mix(first.getValue(), second.getValue(), alpha); } +void OwnedAttributeValue::blend(const AttributeValue& source, const AttributeValue& dest) { + if (_attribute) { + _attribute->destroy(_value); + } + _attribute = source.getAttribute(); + _value = _attribute->blend(source.getValue(), dest.getValue()); +} + OwnedAttributeValue& OwnedAttributeValue::operator=(const AttributeValue& other) { if (_attribute) { _attribute->destroy(_value); @@ -243,6 +254,19 @@ void* QRgbAttribute::mix(void* first, void* second, float alpha) const { glm::mix((float)qAlpha(firstValue), (float)qAlpha(secondValue), alpha))); } +const float EIGHT_BIT_MAXIMUM = 255.0f; + +void* QRgbAttribute::blend(void* source, void* dest) const { + QRgb sourceValue = decodeInline(source); + QRgb destValue = decodeInline(dest); + float alpha = qAlpha(sourceValue) / EIGHT_BIT_MAXIMUM; + return encodeInline(qRgba( + glm::mix((float)qRed(destValue), (float)qRed(sourceValue), alpha), + glm::mix((float)qGreen(destValue), (float)qGreen(sourceValue), alpha), + glm::mix((float)qBlue(destValue), (float)qBlue(sourceValue), alpha), + glm::mix((float)qAlpha(destValue), (float)qAlpha(sourceValue), alpha))); +} + void* QRgbAttribute::createFromScript(const QScriptValue& value, QScriptEngine* engine) const { return encodeInline((QRgb)value.toUInt32()); } @@ -287,6 +311,13 @@ void* PackedNormalAttribute::mix(void* first, void* second, float alpha) const { return encodeInline(packNormal(glm::normalize(glm::mix(firstNormal, secondNormal, alpha)))); } +void* PackedNormalAttribute::blend(void* source, void* dest) const { + QRgb sourceValue = decodeInline(source); + QRgb destValue = decodeInline(dest); + float alpha = qAlpha(sourceValue) / EIGHT_BIT_MAXIMUM; + return encodeInline(packNormal(glm::normalize(glm::mix(unpackNormal(destValue), unpackNormal(sourceValue), alpha)))); +} + const float CHAR_SCALE = 127.0f; const float INVERSE_CHAR_SCALE = 1.0f / CHAR_SCALE; diff --git a/libraries/metavoxels/src/AttributeRegistry.h b/libraries/metavoxels/src/AttributeRegistry.h index f7d8d955a5..00d974b8b6 100644 --- a/libraries/metavoxels/src/AttributeRegistry.h +++ b/libraries/metavoxels/src/AttributeRegistry.h @@ -1,13 +1,16 @@ // // AttributeRegistry.h -// metavoxels +// libraries/metavoxels/src // // Created by Andrzej Kapolka on 12/6/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__AttributeRegistry__ -#define __interface__AttributeRegistry__ +#ifndef hifi_AttributeRegistry_h +#define hifi_AttributeRegistry_h #include #include @@ -158,6 +161,9 @@ public: /// Sets this attribute to a mix of the first and second provided. void mix(const AttributeValue& first, const AttributeValue& second, float alpha); + /// Sets this attribute to a blend of the source and destination. + void blend(const AttributeValue& source, const AttributeValue& dest); + /// Destroys the current value, if any, and copies the specified other value. OwnedAttributeValue& operator=(const AttributeValue& other); @@ -218,6 +224,9 @@ public: /// Mixes the first and the second, returning a new value with the result. virtual void* mix(void* first, void* second, float alpha) const = 0; + /// Blends the source with the destination, returning a new value with the result. + virtual void* blend(void* source, void* dest) const = 0; + virtual void* getDefaultValue() const = 0; virtual void* createFromScript(const QScriptValue& value, QScriptEngine* engine) const { return create(); } @@ -249,6 +258,8 @@ public: virtual void* mix(void* first, void* second, float alpha) const { return create(alpha < 0.5f ? first : second); } + virtual void* blend(void* source, void* dest) const { return create(source); } + virtual void* getDefaultValue() const { return encodeInline(_defaultValue); } protected: @@ -315,6 +326,8 @@ public: virtual void* mix(void* first, void* second, float alpha) const; + virtual void* blend(void* source, void* dest) const; + virtual void* createFromScript(const QScriptValue& value, QScriptEngine* engine) const; virtual void* createFromVariant(const QVariant& value) const; @@ -333,6 +346,8 @@ public: virtual bool merge(void*& parent, void* children[], bool postRead = false) const; virtual void* mix(void* first, void* second, float alpha) const; + + virtual void* blend(void* source, void* dest) const; }; /// Packs a normal into an RGB value. @@ -449,4 +464,4 @@ public: virtual void writeMetavoxelSubdivision(const MetavoxelNode& root, MetavoxelStreamState& state); }; -#endif /* defined(__interface__AttributeRegistry__) */ +#endif // hifi_AttributeRegistry_h diff --git a/libraries/metavoxels/src/Bitstream.cpp b/libraries/metavoxels/src/Bitstream.cpp index 077e6c1c69..ad929e533c 100644 --- a/libraries/metavoxels/src/Bitstream.cpp +++ b/libraries/metavoxels/src/Bitstream.cpp @@ -1,9 +1,12 @@ // // Bitstream.cpp -// metavoxels +// libraries/metavoxels/src // // Created by Andrzej Kapolka on 12/2/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include @@ -35,6 +38,7 @@ REGISTER_SIMPLE_TYPE_STREAMER(SharedObjectPointer) // some types don't quite work with our macro static int vec3Streamer = Bitstream::registerTypeStreamer(qMetaTypeId(), new SimpleTypeStreamer()); +static int quatStreamer = Bitstream::registerTypeStreamer(qMetaTypeId(), new SimpleTypeStreamer()); static int metaObjectStreamer = Bitstream::registerTypeStreamer(qMetaTypeId(), new SimpleTypeStreamer()); @@ -352,6 +356,14 @@ Bitstream& Bitstream::operator>>(glm::vec3& value) { return *this >> value.x >> value.y >> value.z; } +Bitstream& Bitstream::operator<<(const glm::quat& value) { + return *this << value.w << value.x << value.y << value.z; +} + +Bitstream& Bitstream::operator>>(glm::quat& value) { + return *this >> value.w >> value.x >> value.y >> value.z; +} + Bitstream& Bitstream::operator<<(const QByteArray& string) { *this << string.size(); return write(string.constData(), string.size() * BITS_IN_BYTE); @@ -869,7 +881,11 @@ Bitstream& Bitstream::operator>(SharedObjectPointer& object) { *this >> rawObject; } pointer = static_cast(rawObject); - pointer->setRemoteID(id); + if (pointer) { + pointer->setRemoteID(id); + } else { + qDebug() << "Null object" << pointer << reference; + } } object = static_cast(pointer.data()); return *this; diff --git a/libraries/metavoxels/src/Bitstream.h b/libraries/metavoxels/src/Bitstream.h index 760154a928..34b66eb9f2 100644 --- a/libraries/metavoxels/src/Bitstream.h +++ b/libraries/metavoxels/src/Bitstream.h @@ -1,13 +1,16 @@ // // Bitstream.h -// metavoxels +// libraries/metavoxels/src // // Created by Andrzej Kapolka on 12/2/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__Bitstream__ -#define __interface__Bitstream__ +#ifndef hifi_Bitstream_h +#define hifi_Bitstream_h #include #include @@ -312,6 +315,9 @@ public: Bitstream& operator<<(const glm::vec3& value); Bitstream& operator>>(glm::vec3& value); + Bitstream& operator<<(const glm::quat& value); + Bitstream& operator>>(glm::quat& value); + Bitstream& operator<<(const QByteArray& string); Bitstream& operator>>(QByteArray& string); @@ -920,6 +926,13 @@ public: _Pragma(STRINGIFY(unused(_TypePtr##X))) #endif +/// Registers a simple type and its streamer. +template int registerSimpleMetaType() { + int type = qRegisterMetaType(); + Bitstream::registerTypeStreamer(type, new SimpleTypeStreamer()); + return type; +} + /// Registers a streamable type and its streamer. template int registerStreamableMetaType() { int type = qRegisterMetaType(); @@ -940,4 +953,4 @@ template int registerStreamableMetaType() { /// Flags a field or base class as streaming. #define STREAM -#endif /* defined(__interface__Bitstream__) */ +#endif // hifi_Bitstream_h diff --git a/libraries/metavoxels/src/DatagramSequencer.cpp b/libraries/metavoxels/src/DatagramSequencer.cpp index 5c605dc0f4..9fadef8afc 100644 --- a/libraries/metavoxels/src/DatagramSequencer.cpp +++ b/libraries/metavoxels/src/DatagramSequencer.cpp @@ -1,9 +1,12 @@ // // DatagramSequencer.cpp -// metavoxels +// libraries/metavoxels/src // // Created by Andrzej Kapolka on 12/20/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/metavoxels/src/DatagramSequencer.h b/libraries/metavoxels/src/DatagramSequencer.h index 30a131390d..ce9f36ba33 100644 --- a/libraries/metavoxels/src/DatagramSequencer.h +++ b/libraries/metavoxels/src/DatagramSequencer.h @@ -1,13 +1,16 @@ // // DatagramSequencer.h -// metavoxels +// libraries/metavoxels/src // // Created by Andrzej Kapolka on 12/20/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__DatagramSequencer__ -#define __interface__DatagramSequencer__ +#ifndef hifi_DatagramSequencer_h +#define hifi_DatagramSequencer_h #include #include @@ -318,4 +321,4 @@ private: bool _messagesEnabled; }; -#endif /* defined(__interface__DatagramSequencer__) */ +#endif // hifi_DatagramSequencer_h diff --git a/libraries/metavoxels/src/MetavoxelData.cpp b/libraries/metavoxels/src/MetavoxelData.cpp index e548de46c7..0d52fc5ed6 100644 --- a/libraries/metavoxels/src/MetavoxelData.cpp +++ b/libraries/metavoxels/src/MetavoxelData.cpp @@ -1,9 +1,12 @@ // // MetavoxelData.cpp -// metavoxels +// libraries/metavoxels/src // // Created by Andrzej Kapolka on 12/6/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include @@ -24,6 +27,8 @@ REGISTER_META_OBJECT(Spanner) REGISTER_META_OBJECT(Sphere) REGISTER_META_OBJECT(StaticModel) +static int metavoxelDataTypeId = registerSimpleMetaType(); + MetavoxelLOD::MetavoxelLOD(const glm::vec3& position, float threshold) : position(position), threshold(threshold) { @@ -327,6 +332,100 @@ const int Y_MAXIMUM_FLAG = 2; const int Z_MAXIMUM_FLAG = 4; const int MAXIMUM_FLAG_MASK = X_MAXIMUM_FLAG | Y_MAXIMUM_FLAG | Z_MAXIMUM_FLAG; +static glm::vec3 getNextMinimum(const glm::vec3& minimum, float nextSize, int index) { + return minimum + glm::vec3( + (index & X_MAXIMUM_FLAG) ? nextSize : 0.0f, + (index & Y_MAXIMUM_FLAG) ? nextSize : 0.0f, + (index & Z_MAXIMUM_FLAG) ? nextSize : 0.0f); +} + +static void setNode(const AttributeValue& value, MetavoxelNode*& node, MetavoxelNode* other, bool blend) { + if (!blend) { + // if we're not blending, we can just make a shallow copy + if (node) { + node->decrementReferenceCount(value.getAttribute()); + } + (node = other)->incrementReferenceCount(); + return; + } + if (node) { + MetavoxelNode* oldNode = node; + node = new MetavoxelNode(value.getAttribute(), oldNode); + oldNode->decrementReferenceCount(value.getAttribute()); + + } else { + node = new MetavoxelNode(value); + } + OwnedAttributeValue oldValue = node->getAttributeValue(value.getAttribute()); + node->blendAttributeValues(other->getAttributeValue(value.getAttribute()), oldValue); + if (!other->isLeaf()) { + for (int i = 0; i < MetavoxelNode::CHILD_COUNT; i++) { + MetavoxelNode* child = node->getChild(i); + setNode(oldValue, child, other->getChild(i), true); + node->setChild(i, child); + } + } + node->mergeChildren(value.getAttribute()); +} + +static void setNode(const AttributeValue& value, MetavoxelNode*& node, const glm::vec3& minimum, float size, + MetavoxelNode* other, const glm::vec3& otherMinimum, float otherSize, bool blend) { + if (otherSize >= size) { + setNode(value, node, other, blend); + return; + } + if (node) { + MetavoxelNode* oldNode = node; + node = new MetavoxelNode(value.getAttribute(), oldNode); + oldNode->decrementReferenceCount(value.getAttribute()); + + } else { + node = new MetavoxelNode(value); + } + int index = 0; + float otherHalfSize = otherSize * 0.5f; + float nextSize = size * 0.5f; + if (otherMinimum.x + otherHalfSize >= minimum.x + nextSize) { + index |= X_MAXIMUM_FLAG; + } + if (otherMinimum.y + otherHalfSize >= minimum.y + nextSize) { + index |= Y_MAXIMUM_FLAG; + } + if (otherMinimum.z + otherHalfSize >= minimum.z + nextSize) { + index |= Z_MAXIMUM_FLAG; + } + if (node->isLeaf()) { + for (int i = 1; i < MetavoxelNode::CHILD_COUNT; i++) { + node->setChild((index + i) % MetavoxelNode::CHILD_COUNT, new MetavoxelNode( + node->getAttributeValue(value.getAttribute()))); + } + } + MetavoxelNode* nextNode = node->getChild(index); + setNode(node->getAttributeValue(value.getAttribute()), nextNode, getNextMinimum(minimum, nextSize, index), + nextSize, other, otherMinimum, otherSize, blend); + node->setChild(index, nextNode); + node->mergeChildren(value.getAttribute()); +} + +void MetavoxelData::set(const glm::vec3& minimum, const MetavoxelData& data, bool blend) { + // expand to fit the entire data + Box bounds(minimum, minimum + glm::vec3(data.getSize(), data.getSize(), data.getSize())); + while (!getBounds().contains(bounds)) { + expand(); + } + + // set/mix each attribute separately + for (QHash::const_iterator it = data._roots.constBegin(); + it != data._roots.constEnd(); it++) { + MetavoxelNode*& root = _roots[it.key()]; + setNode(it.key(), root, getMinimum(), getSize(), it.value(), minimum, data.getSize(), blend); + if (root->isLeaf() && root->getAttributeValue(it.key()).isDefault()) { + _roots.remove(it.key()); + root->decrementReferenceCount(it.key()); + } + } +} + static int getOppositeIndex(int index) { return index ^ MAXIMUM_FLAG_MASK; } @@ -511,6 +610,14 @@ MetavoxelNode* MetavoxelData::createRoot(const AttributePointer& attribute) { return root = new MetavoxelNode(attribute); } +bool MetavoxelData::operator==(const MetavoxelData& other) const { + return _size == other._size && _roots == other._roots; +} + +bool MetavoxelData::operator!=(const MetavoxelData& other) const { + return _size != other._size || _roots != other._roots; +} + void MetavoxelData::incrementRootReferenceCounts() { for (QHash::const_iterator it = _roots.constBegin(); it != _roots.constEnd(); it++) { it.value()->incrementReferenceCount(); @@ -523,11 +630,22 @@ void MetavoxelData::decrementRootReferenceCounts() { } } -static glm::vec3 getNextMinimum(const glm::vec3& minimum, float nextSize, int index) { - return minimum + glm::vec3( - (index & X_MAXIMUM_FLAG) ? nextSize : 0.0f, - (index & Y_MAXIMUM_FLAG) ? nextSize : 0.0f, - (index & Z_MAXIMUM_FLAG) ? nextSize : 0.0f); +Bitstream& operator<<(Bitstream& out, const MetavoxelData& data) { + data.write(out); + return out; +} + +Bitstream& operator>>(Bitstream& in, MetavoxelData& data) { + data.read(in); + return in; +} + +template<> void Bitstream::writeDelta(const MetavoxelData& value, const MetavoxelData& reference) { + value.writeDelta(reference, MetavoxelLOD(), *this, MetavoxelLOD()); +} + +template<> void Bitstream::readDelta(MetavoxelData& value, const MetavoxelData& reference) { + value.readDelta(reference, MetavoxelLOD(), *this, MetavoxelLOD()); } bool MetavoxelStreamState::shouldSubdivide() const { @@ -577,7 +695,11 @@ MetavoxelNode::MetavoxelNode(const AttributePointer& attribute, const MetavoxelN void MetavoxelNode::setAttributeValue(const AttributeValue& attributeValue) { attributeValue.getAttribute()->destroy(_attributeValue); _attributeValue = attributeValue.copy(); - clearChildren(attributeValue.getAttribute()); +} + +void MetavoxelNode::blendAttributeValues(const AttributeValue& source, const AttributeValue& dest) { + source.getAttribute()->destroy(_attributeValue); + _attributeValue = source.getAttribute()->blend(source.getValue(), dest.getValue()); } AttributeValue MetavoxelNode::getAttributeValue(const AttributePointer& attribute) const { @@ -1408,7 +1530,7 @@ void SpannerRenderer::simulate(float deltaTime) { // nothing by default } -void SpannerRenderer::render(float alpha, const glm::vec3& clipMinimum, float clipSize) { +void SpannerRenderer::render(float alpha, Mode mode, const glm::vec3& clipMinimum, float clipSize) { // nothing by default } @@ -1426,7 +1548,7 @@ void Transformable::setTranslation(const glm::vec3& translation) { } } -void Transformable::setRotation(const glm::vec3& rotation) { +void Transformable::setRotation(const glm::quat& rotation) { if (_rotation != rotation) { emit rotationChanged(_rotation = rotation); } diff --git a/libraries/metavoxels/src/MetavoxelData.h b/libraries/metavoxels/src/MetavoxelData.h index fa408aafb7..2e6f6c4437 100644 --- a/libraries/metavoxels/src/MetavoxelData.h +++ b/libraries/metavoxels/src/MetavoxelData.h @@ -1,13 +1,16 @@ // // MetavoxelData.h -// metavoxels +// libraries/metavoxels/src // // Created by Andrzej Kapolka on 12/6/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__MetavoxelData__ -#define __interface__MetavoxelData__ +#ifndef hifi_MetavoxelData_h +#define hifi_MetavoxelData_h #include #include @@ -61,6 +64,7 @@ public: MetavoxelData& operator=(const MetavoxelData& other); + void setSize(float size) { _size = size; } float getSize() const { return _size; } glm::vec3 getMinimum() const { return glm::vec3(_size, _size, _size) * -0.5f; } @@ -90,6 +94,9 @@ public: SharedObjectPointer findFirstRaySpannerIntersection(const glm::vec3& origin, const glm::vec3& direction, const AttributePointer& attribute, float& distance, const MetavoxelLOD& lod = MetavoxelLOD()); + /// Sets part of the data. + void set(const glm::vec3& minimum, const MetavoxelData& data, bool blend = false); + /// Expands the tree, increasing its capacity in all dimensions. void expand(); @@ -103,6 +110,9 @@ public: MetavoxelNode* getRoot(const AttributePointer& attribute) const { return _roots.value(attribute); } MetavoxelNode* createRoot(const AttributePointer& attribute); + bool operator==(const MetavoxelData& other) const; + bool operator!=(const MetavoxelData& other) const; + private: friend class MetavoxelVisitation; @@ -114,6 +124,16 @@ private: QHash _roots; }; +Bitstream& operator<<(Bitstream& out, const MetavoxelData& data); + +Bitstream& operator>>(Bitstream& in, MetavoxelData& data); + +template<> void Bitstream::writeDelta(const MetavoxelData& value, const MetavoxelData& reference); + +template<> void Bitstream::readDelta(MetavoxelData& value, const MetavoxelData& reference); + +Q_DECLARE_METATYPE(MetavoxelData) + /// Holds the state used in streaming metavoxel data. class MetavoxelStreamState { public: @@ -142,6 +162,8 @@ public: void setAttributeValue(const AttributeValue& attributeValue); + void blendAttributeValues(const AttributeValue& source, const AttributeValue& dest); + AttributeValue getAttributeValue(const AttributePointer& attribute) const; void* getAttributeValue() const { return _attributeValue; } @@ -174,13 +196,13 @@ public: void destroy(const AttributePointer& attribute); + void clearChildren(const AttributePointer& attribute); + private: Q_DISABLE_COPY(MetavoxelNode) friend class MetavoxelVisitation; - void clearChildren(const AttributePointer& attribute); - int _referenceCount; void* _attributeValue; MetavoxelNode* _children[CHILD_COUNT]; @@ -499,11 +521,13 @@ class SpannerRenderer : public QObject { public: + enum Mode { DEFAULT_MODE, DIFFUSE_MODE, NORMAL_MODE }; + Q_INVOKABLE SpannerRenderer(); virtual void init(Spanner* spanner); virtual void simulate(float deltaTime); - virtual void render(float alpha, const glm::vec3& clipMinimum, float clipSize); + virtual void render(float alpha, Mode mode, const glm::vec3& clipMinimum, float clipSize); virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, const glm::vec3& clipMinimum, float clipSize, float& distance) const; }; @@ -512,7 +536,7 @@ public: class Transformable : public Spanner { Q_OBJECT Q_PROPERTY(glm::vec3 translation MEMBER _translation WRITE setTranslation NOTIFY translationChanged) - Q_PROPERTY(glm::vec3 rotation MEMBER _rotation WRITE setRotation NOTIFY rotationChanged) + Q_PROPERTY(glm::quat rotation MEMBER _rotation WRITE setRotation NOTIFY rotationChanged) Q_PROPERTY(float scale MEMBER _scale WRITE setScale NOTIFY scaleChanged) public: @@ -522,8 +546,8 @@ public: void setTranslation(const glm::vec3& translation); const glm::vec3& getTranslation() const { return _translation; } - void setRotation(const glm::vec3& rotation); - const glm::vec3& getRotation() const { return _rotation; } + void setRotation(const glm::quat& rotation); + const glm::quat& getRotation() const { return _rotation; } void setScale(float scale); float getScale() const { return _scale; } @@ -531,13 +555,13 @@ public: signals: void translationChanged(const glm::vec3& translation); - void rotationChanged(const glm::vec3& rotation); + void rotationChanged(const glm::quat& rotation); void scaleChanged(float scale); private: glm::vec3 _translation; - glm::vec3 _rotation; // Euler Angles in degrees + glm::quat _rotation; float _scale; }; @@ -592,7 +616,7 @@ public: const QUrl& getURL() const { return _url; } virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, - const glm::vec3& clipMinimum, float clipSize,float& distance) const; + const glm::vec3& clipMinimum, float clipSize, float& distance) const; signals: @@ -607,4 +631,4 @@ private: QUrl _url; }; -#endif /* defined(__interface__MetavoxelData__) */ +#endif // hifi_MetavoxelData_h diff --git a/libraries/metavoxels/src/MetavoxelMessages.cpp b/libraries/metavoxels/src/MetavoxelMessages.cpp index ce0d01ccf2..dba9bc9c5c 100644 --- a/libraries/metavoxels/src/MetavoxelMessages.cpp +++ b/libraries/metavoxels/src/MetavoxelMessages.cpp @@ -1,9 +1,12 @@ // // MetavoxelMessages.cpp -// metavoxels +// libraries/metavoxels/src // // Created by Andrzej Kapolka on 1/24/14. -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "MetavoxelMessages.h" @@ -305,3 +308,13 @@ void SetSpannerEdit::apply(MetavoxelData& data, const WeakSharedObjectHash& obje setIntersectingMasked(spanner->getBounds(), data); } + +SetDataEdit::SetDataEdit(const glm::vec3& minimum, const MetavoxelData& data, bool blend) : + minimum(minimum), + data(data), + blend(blend) { +} + +void SetDataEdit::apply(MetavoxelData& data, const WeakSharedObjectHash& objects) const { + data.set(minimum, this->data, blend); +} diff --git a/libraries/metavoxels/src/MetavoxelMessages.h b/libraries/metavoxels/src/MetavoxelMessages.h index 25db8e5464..8f819fe3d8 100644 --- a/libraries/metavoxels/src/MetavoxelMessages.h +++ b/libraries/metavoxels/src/MetavoxelMessages.h @@ -1,13 +1,16 @@ // // MetavoxelMessages.h -// metavoxels +// libraries/metavoxels/src // // Created by Andrzej Kapolka on 12/31/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__MetavoxelMessages__ -#define __interface__MetavoxelMessages__ +#ifndef hifi_MetavoxelMessages_h +#define hifi_MetavoxelMessages_h #include "MetavoxelData.h" @@ -176,4 +179,21 @@ public: DECLARE_STREAMABLE_METATYPE(SetSpannerEdit) -#endif /* defined(__interface__MetavoxelMessages__) */ +/// An edit that directly sets part of the metavoxel data. +class SetDataEdit : public MetavoxelEdit { + STREAMABLE + +public: + + STREAM glm::vec3 minimum; + STREAM MetavoxelData data; + STREAM bool blend; + + SetDataEdit(const glm::vec3& minimum = glm::vec3(), const MetavoxelData& data = MetavoxelData(), bool blend = false); + + virtual void apply(MetavoxelData& data, const WeakSharedObjectHash& objects) const; +}; + +DECLARE_STREAMABLE_METATYPE(SetDataEdit) + +#endif // hifi_MetavoxelMessages_h diff --git a/libraries/metavoxels/src/MetavoxelUtil.cpp b/libraries/metavoxels/src/MetavoxelUtil.cpp index 7995809f1c..f2f434b24d 100644 --- a/libraries/metavoxels/src/MetavoxelUtil.cpp +++ b/libraries/metavoxels/src/MetavoxelUtil.cpp @@ -1,9 +1,12 @@ // // MetavoxelUtil.cpp -// metavoxels +// libraries/metavoxels/src // // Created by Andrzej Kapolka on 12/30/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include @@ -52,6 +55,7 @@ public: DoubleEditor::DoubleEditor(QWidget* parent) : QDoubleSpinBox(parent) { setMinimum(-FLT_MAX); setMaximum(FLT_MAX); + setSingleStep(0.01); } DelegatingItemEditorFactory::DelegatingItemEditorFactory() : @@ -127,6 +131,12 @@ static QItemEditorCreatorBase* createVec3EditorCreator() { return creator; } +static QItemEditorCreatorBase* createQuatEditorCreator() { + QItemEditorCreatorBase* creator = new LazyItemEditorCreator(); + getItemEditorFactory()->registerEditor(qMetaTypeId(), creator); + return creator; +} + static QItemEditorCreatorBase* createParameterizedURLEditorCreator() { QItemEditorCreatorBase* creator = new LazyItemEditorCreator(); getItemEditorFactory()->registerEditor(qMetaTypeId(), creator); @@ -138,6 +148,7 @@ static QItemEditorCreatorBase* qMetaObjectEditorCreator = createQMetaObjectEdito static QItemEditorCreatorBase* qColorEditorCreator = createQColorEditorCreator(); static QItemEditorCreatorBase* qUrlEditorCreator = createQUrlEditorCreator(); static QItemEditorCreatorBase* vec3EditorCreator = createVec3EditorCreator(); +static QItemEditorCreatorBase* quatEditorCreator = createQuatEditorCreator(); static QItemEditorCreatorBase* parameterizedURLEditorCreator = createParameterizedURLEditorCreator(); QByteArray signal(const char* signature) { @@ -380,7 +391,7 @@ void QUrlEditor::updateSettings() { QSettings().setValue("editorURLs", urls); } -Vec3Editor::Vec3Editor(QWidget* parent) : QWidget(parent) { +BaseVec3Editor::BaseVec3Editor(QWidget* parent) : QWidget(parent) { QHBoxLayout* layout = new QHBoxLayout(); layout->setContentsMargins(QMargins()); setLayout(layout); @@ -390,26 +401,64 @@ Vec3Editor::Vec3Editor(QWidget* parent) : QWidget(parent) { layout->addWidget(_z = createComponentBox()); } -void Vec3Editor::setVector(const glm::vec3& vector) { - _vector = vector; - _x->setValue(vector.x); - _y->setValue(vector.y); - _z->setValue(vector.z); -} - -void Vec3Editor::updateVector() { - emit vectorChanged(_vector = glm::vec3(_x->value(), _y->value(), _z->value())); -} - -QDoubleSpinBox* Vec3Editor::createComponentBox() { +QDoubleSpinBox* BaseVec3Editor::createComponentBox() { QDoubleSpinBox* box = new QDoubleSpinBox(); box->setMinimum(-FLT_MAX); box->setMaximum(FLT_MAX); box->setMinimumWidth(50); - connect(box, SIGNAL(valueChanged(double)), SLOT(updateVector())); + connect(box, SIGNAL(valueChanged(double)), SLOT(updateValue())); return box; } +Vec3Editor::Vec3Editor(QWidget* parent) : BaseVec3Editor(parent) { + _x->setSingleStep(0.01); + _y->setSingleStep(0.01); + _z->setSingleStep(0.01); +} + +static void setComponentValue(QDoubleSpinBox* box, double value) { + box->blockSignals(true); + box->setValue(value); + box->blockSignals(false); +} + +void Vec3Editor::setValue(const glm::vec3& value) { + _value = value; + setComponentValue(_x, value.x); + setComponentValue(_y, value.y); + setComponentValue(_z, value.z); +} + +void Vec3Editor::updateValue() { + emit valueChanged(_value = glm::vec3(_x->value(), _y->value(), _z->value())); +} + +QuatEditor::QuatEditor(QWidget* parent) : BaseVec3Editor(parent) { + _x->setRange(-179.0, 180.0); + _y->setRange(-179.0, 180.0); + _z->setRange(-179.0, 180.0); + + _x->setWrapping(true); + _y->setWrapping(true); + _z->setWrapping(true); +} + +void QuatEditor::setValue(const glm::quat& value) { + if (_value != value) { + glm::vec3 eulers = glm::degrees(safeEulerAngles(_value = value)); + setComponentValue(_x, eulers.x); + setComponentValue(_y, eulers.y); + setComponentValue(_z, eulers.z); + } +} + +void QuatEditor::updateValue() { + glm::quat value(glm::radians(glm::vec3(_x->value(), _y->value(), _z->value()))); + if (_value != value) { + emit valueChanged(_value = value); + } +} + ParameterizedURL::ParameterizedURL(const QUrl& url, const ScriptHash& parameters) : _url(url), _parameters(parameters) { diff --git a/libraries/metavoxels/src/MetavoxelUtil.h b/libraries/metavoxels/src/MetavoxelUtil.h index 9972981bc7..34c2bac6be 100644 --- a/libraries/metavoxels/src/MetavoxelUtil.h +++ b/libraries/metavoxels/src/MetavoxelUtil.h @@ -1,13 +1,16 @@ // // MetavoxelUtil.h -// metavoxels +// libraries/metavoxels/src // // Created by Andrzej Kapolka on 12/30/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__MetavoxelUtil__ -#define __interface__MetavoxelUtil__ +#ifndef hifi_MetavoxelUtil_h +#define hifi_MetavoxelUtil_h #include #include @@ -142,10 +145,31 @@ private: QUrl _url; }; -/// Editor for vector values. -class Vec3Editor : public QWidget { +/// Base class for Vec3Editor and QuatEditor. +class BaseVec3Editor : public QWidget { Q_OBJECT - Q_PROPERTY(glm::vec3 vector MEMBER _vector WRITE setVector NOTIFY vectorChanged USER true) + +public: + + BaseVec3Editor(QWidget* parent); + +protected slots: + + virtual void updateValue() = 0; + +protected: + + QDoubleSpinBox* createComponentBox(); + + QDoubleSpinBox* _x; + QDoubleSpinBox* _y; + QDoubleSpinBox* _z; +}; + +/// Editor for vector values. +class Vec3Editor : public BaseVec3Editor { + Q_OBJECT + Q_PROPERTY(glm::vec3 value MEMBER _value WRITE setValue NOTIFY valueChanged USER true) public: @@ -153,24 +177,45 @@ public: signals: - void vectorChanged(const glm::vec3& vector); + void valueChanged(const glm::vec3& vector); public slots: - void setVector(const glm::vec3& vector); + void setValue(const glm::vec3& vector); -private slots: +protected: - void updateVector(); + virtual void updateValue(); private: - QDoubleSpinBox* createComponentBox(); + glm::vec3 _value; +}; + +/// Editor for quaternion values. +class QuatEditor : public BaseVec3Editor { + Q_OBJECT + Q_PROPERTY(glm::quat value MEMBER _value WRITE setValue NOTIFY valueChanged USER true) + +public: - QDoubleSpinBox* _x; - QDoubleSpinBox* _y; - QDoubleSpinBox* _z; - glm::vec3 _vector; + QuatEditor(QWidget* parent); + +signals: + + void valueChanged(const glm::quat& value); + +public slots: + + void setValue(const glm::quat& value); + +protected: + + virtual void updateValue(); + +private: + + glm::quat _value; }; typedef QHash ScriptHash; @@ -238,4 +283,4 @@ private: QUrlEditor _urlEditor; }; -#endif /* defined(__interface__MetavoxelUtil__) */ +#endif // hifi_MetavoxelUtil_h diff --git a/libraries/metavoxels/src/ScriptCache.cpp b/libraries/metavoxels/src/ScriptCache.cpp index cabf075563..dd090613b7 100644 --- a/libraries/metavoxels/src/ScriptCache.cpp +++ b/libraries/metavoxels/src/ScriptCache.cpp @@ -1,9 +1,12 @@ // // ScriptCache.cpp -// metavoxels +// libraries/metavoxels/src // // Created by Andrzej Kapolka on 2/4/14. -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/metavoxels/src/ScriptCache.h b/libraries/metavoxels/src/ScriptCache.h index ac53e602f8..f393d0e0a8 100644 --- a/libraries/metavoxels/src/ScriptCache.h +++ b/libraries/metavoxels/src/ScriptCache.h @@ -1,13 +1,16 @@ // // ScriptCache.h -// metavoxels +// libraries/metavoxels/src // // Created by Andrzej Kapolka on 2/4/14. -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__ScriptCache__ -#define __interface__ScriptCache__ +#ifndef hifi_ScriptCache_h +#define hifi_ScriptCache_h #include #include @@ -142,4 +145,4 @@ private: ScriptHash _parameters; }; -#endif /* defined(__interface__ScriptCache__) */ +#endif // hifi_ScriptCache_h diff --git a/libraries/metavoxels/src/SharedObject.cpp b/libraries/metavoxels/src/SharedObject.cpp index 36257a740f..b578d70959 100644 --- a/libraries/metavoxels/src/SharedObject.cpp +++ b/libraries/metavoxels/src/SharedObject.cpp @@ -1,9 +1,12 @@ // // SharedObject.cpp -// metavoxels +// libraries/metavoxels/src // // Created by Andrzej Kapolka on 2/5/14. -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include @@ -20,18 +23,17 @@ REGISTER_META_OBJECT(SharedObject) SharedObject::SharedObject() : _id(++_lastID), - _remoteID(0), - _referenceCount(0) { + _remoteID(0) { _weakHash.insert(_id, this); } void SharedObject::incrementReferenceCount() { - _referenceCount++; + _referenceCount.ref(); } void SharedObject::decrementReferenceCount() { - if (--_referenceCount == 0) { + if (!_referenceCount.deref()) { _weakHash.remove(_id); delete this; } diff --git a/libraries/metavoxels/src/SharedObject.h b/libraries/metavoxels/src/SharedObject.h index 435127fffd..aba6b86bea 100644 --- a/libraries/metavoxels/src/SharedObject.h +++ b/libraries/metavoxels/src/SharedObject.h @@ -1,14 +1,18 @@ // // SharedObject.h -// metavoxels +// libraries/metavoxels/src // // Created by Andrzej Kapolka on 2/5/14. -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__SharedObject__ -#define __interface__SharedObject__ +#ifndef hifi_SharedObject_h +#define hifi_SharedObject_h +#include #include #include #include @@ -42,7 +46,7 @@ public: void setRemoteID(int remoteID) { _remoteID = remoteID; } - int getReferenceCount() const { return _referenceCount; } + int getReferenceCount() const { return _referenceCount.load(); } void incrementReferenceCount(); void decrementReferenceCount(); @@ -62,7 +66,7 @@ private: int _id; int _remoteID; - int _referenceCount; + QAtomicInt _referenceCount; static int _lastID; static WeakSharedObjectHash _weakHash; @@ -214,4 +218,4 @@ private: SharedObjectPointer _object; }; -#endif /* defined(__interface__SharedObject__) */ +#endif // hifi_SharedObject_h diff --git a/libraries/octree/src/AABox.cpp b/libraries/octree/src/AABox.cpp index 97fd706c21..51b31d4466 100644 --- a/libraries/octree/src/AABox.cpp +++ b/libraries/octree/src/AABox.cpp @@ -1,11 +1,12 @@ // -// AABox.h - Axis Aligned Boxes -// hifi +// AABox.cpp +// libraries/octree/src // -// Added by Brad Hefta-Gaub on 04/11/13. -// Originally from lighthouse3d. Modified to utilize glm::vec3 and clean up to our coding standards +// Created by Brad Hefta-Gaub on 04/11/13. +// Copyright 2013 High Fidelity, Inc. // -// Simple axis aligned box class. +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "SharedUtil.h" diff --git a/libraries/octree/src/AABox.h b/libraries/octree/src/AABox.h index 731b82be4c..093a111a69 100644 --- a/libraries/octree/src/AABox.h +++ b/libraries/octree/src/AABox.h @@ -1,15 +1,19 @@ // -// AABox.h - Axis Aligned Boxes -// hifi +// AABox.h +// libraries/octree/src +// +// Created by Brad Hefta-Gaub on 04/11/13. +// Copyright 2013 High Fidelity, Inc. // -// Added by Brad Hefta-Gaub on 04/11/13. // Originally from lighthouse3d. Modified to utilize glm::vec3 and clean up to our coding standards -// // Simple axis aligned box class. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// -#ifndef _AABOX_ -#define _AABOX_ +#ifndef hifi_AABox_h +#define hifi_AABox_h #include @@ -22,7 +26,6 @@ enum BoxFace { MAX_Z_FACE }; - enum BoxVertex { BOTTOM_LEFT_NEAR = 0, BOTTOM_RIGHT_NEAR = 1, @@ -79,4 +82,4 @@ private: float _scale; }; -#endif +#endif // hifi_AABox_h diff --git a/libraries/octree/src/CoverageMap.cpp b/libraries/octree/src/CoverageMap.cpp index a7717b8107..65d5734b68 100644 --- a/libraries/octree/src/CoverageMap.cpp +++ b/libraries/octree/src/CoverageMap.cpp @@ -1,9 +1,12 @@ // -// CoverageMap.cpp - -// hifi +// CoverageMap.cpp +// libraries/octree/src // -// Added by Brad Hefta-Gaub on 06/11/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 06/11/13. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include @@ -555,4 +558,4 @@ CoverageMapStorageResult CoverageRegion::checkRegion(OctreeProjectedPolygon* pol } } return result; -} +} \ No newline at end of file diff --git a/libraries/octree/src/CoverageMap.h b/libraries/octree/src/CoverageMap.h index 9cdda579e8..bff6bb1078 100644 --- a/libraries/octree/src/CoverageMap.h +++ b/libraries/octree/src/CoverageMap.h @@ -1,13 +1,18 @@ // -// CoverageMap.h - 2D CoverageMap Quad tree for storage of OctreeProjectedPolygons -// hifi +// CoverageMap.h +// libraries/octree/src // -// Added by Brad Hefta-Gaub on 06/11/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 06/11/13. +// Copyright 2013 High Fidelity, Inc. +// +// 2D CoverageMap Quad tree for storage of OctreeProjectedPolygons +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef _COVERAGE_MAP_ -#define _COVERAGE_MAP_ +#ifndef hifi_CoverageMap_h +#define hifi_CoverageMap_h #include #include "OctreeProjectedPolygon.h" @@ -112,4 +117,4 @@ private: }; -#endif // _COVERAGE_MAP_ +#endif // hifi_CoverageMap_h diff --git a/libraries/octree/src/CoverageMapV2.cpp b/libraries/octree/src/CoverageMapV2.cpp index afb341fcba..1ad800ab6b 100644 --- a/libraries/octree/src/CoverageMapV2.cpp +++ b/libraries/octree/src/CoverageMapV2.cpp @@ -1,9 +1,12 @@ // -// CoverageMapV2.cpp - -// hifi +// CoverageMapV2.cpp +// libraries/octree/src // -// Added by Brad Hefta-Gaub on 06/11/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 06/11/13. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/octree/src/CoverageMapV2.h b/libraries/octree/src/CoverageMapV2.h index e7c2eed4fe..fc9a3ea70e 100644 --- a/libraries/octree/src/CoverageMapV2.h +++ b/libraries/octree/src/CoverageMapV2.h @@ -1,13 +1,16 @@ // -// CoverageMapV2.h - 2D CoverageMapV2 Quad tree for storage of OctreeProjectedPolygons -// hifi +// CoverageMapV2.h +// libraries/octree/src // -// Added by Brad Hefta-Gaub on 06/11/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 06/11/13. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef _COVERAGE_MAP_V2_ -#define _COVERAGE_MAP_V2_ +#ifndef hifi_CoverageMapV2_h +#define hifi_CoverageMapV2_h #include @@ -66,4 +69,4 @@ private: }; -#endif // _COVERAGE_MAP_V2_ +#endif // hifi_CoverageMapV2_h diff --git a/libraries/octree/src/JurisdictionListener.cpp b/libraries/octree/src/JurisdictionListener.cpp index c280b48c99..453ff10a42 100644 --- a/libraries/octree/src/JurisdictionListener.cpp +++ b/libraries/octree/src/JurisdictionListener.cpp @@ -1,11 +1,12 @@ // // JurisdictionListener.cpp -// shared +// libraries/octree/src // // Created by Brad Hefta-Gaub on 8/12/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // -// Threaded or non-threaded jurisdiction Sender for the Application +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/octree/src/JurisdictionListener.h b/libraries/octree/src/JurisdictionListener.h index b3dc9664d7..01f0392796 100644 --- a/libraries/octree/src/JurisdictionListener.h +++ b/libraries/octree/src/JurisdictionListener.h @@ -1,21 +1,23 @@ // // JurisdictionListener.h -// shared +// libraries/octree/src // // Created by Brad Hefta-Gaub on 8/12/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // // Voxel Packet Sender // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// -#ifndef __shared__JurisdictionListener__ -#define __shared__JurisdictionListener__ +#ifndef hifi_JurisdictionListener_h +#define hifi_JurisdictionListener_h #include #include #include - #include "JurisdictionMap.h" /// Sends out PacketType_JURISDICTION_REQUEST packets to all voxel servers and then listens for and processes @@ -59,4 +61,4 @@ private: PacketSender _packetSender; }; -#endif // __shared__JurisdictionListener__ +#endif // hifi_JurisdictionListener_h diff --git a/libraries/octree/src/JurisdictionMap.cpp b/libraries/octree/src/JurisdictionMap.cpp index 0271c77012..747a05e90a 100644 --- a/libraries/octree/src/JurisdictionMap.cpp +++ b/libraries/octree/src/JurisdictionMap.cpp @@ -1,9 +1,12 @@ // // JurisdictionMap.cpp -// hifi +// libraries/octree/src // // Created by Brad Hefta-Gaub on 8/1/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/octree/src/JurisdictionMap.h b/libraries/octree/src/JurisdictionMap.h index 06305254d1..b4174e6432 100644 --- a/libraries/octree/src/JurisdictionMap.h +++ b/libraries/octree/src/JurisdictionMap.h @@ -1,13 +1,16 @@ // // JurisdictionMap.h -// hifi +// libraries/octree/src // // Created by Brad Hefta-Gaub on 8/1/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__JurisdictionMap__ -#define __hifi__JurisdictionMap__ +#ifndef hifi_JurisdictionMap_h +#define hifi_JurisdictionMap_h #include #include @@ -83,6 +86,4 @@ typedef QMap NodeToJurisdictionMap; typedef QMap::iterator NodeToJurisdictionMapIterator; -#endif /* defined(__hifi__JurisdictionMap__) */ - - +#endif // hifi_JurisdictionMap_h diff --git a/libraries/octree/src/JurisdictionSender.cpp b/libraries/octree/src/JurisdictionSender.cpp index 1d26e4a53a..c151999305 100644 --- a/libraries/octree/src/JurisdictionSender.cpp +++ b/libraries/octree/src/JurisdictionSender.cpp @@ -1,11 +1,12 @@ // // JurisdictionSender.cpp -// shared +// libraries/octree/src // // Created by Brad Hefta-Gaub on 8/12/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // -// Threaded or non-threaded jurisdiction Sender for the Application +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/octree/src/JurisdictionSender.h b/libraries/octree/src/JurisdictionSender.h index 18365fda63..bfa370c6ca 100644 --- a/libraries/octree/src/JurisdictionSender.h +++ b/libraries/octree/src/JurisdictionSender.h @@ -1,15 +1,16 @@ // // JurisdictionSender.h -// shared +// libraries/octree/src // // Created by Brad Hefta-Gaub on 8/12/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // -// Jurisdiction Sender +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __shared__JurisdictionSender__ -#define __shared__JurisdictionSender__ +#ifndef hifi_JurisdictionSender_h +#define hifi_JurisdictionSender_h #include #include @@ -54,4 +55,4 @@ private: PacketSender _packetSender; }; -#endif // __shared__JurisdictionSender__ +#endif // hifi_JurisdictionSender_h diff --git a/libraries/octree/src/Octree.cpp b/libraries/octree/src/Octree.cpp index 58cfd9b15d..696a65b4b5 100644 --- a/libraries/octree/src/Octree.cpp +++ b/libraries/octree/src/Octree.cpp @@ -1,9 +1,12 @@ // // Octree.cpp -// hifi +// libraries/octree/src // // Created by Stephen Birarda on 3/13/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #ifdef _WIN32 diff --git a/libraries/octree/src/Octree.h b/libraries/octree/src/Octree.h index f029431d87..839e61d1c2 100644 --- a/libraries/octree/src/Octree.h +++ b/libraries/octree/src/Octree.h @@ -1,13 +1,16 @@ // // Octree.h -// hifi +// libraries/octree/src // // Created by Stephen Birarda on 3/13/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__Octree__ -#define __hifi__Octree__ +#ifndef hifi_Octree_h +#define hifi_Octree_h #include #include @@ -311,4 +314,4 @@ protected: float boundaryDistanceForRenderLevel(unsigned int renderLevel, float voxelSizeScale); -#endif /* defined(__hifi__Octree__) */ +#endif // hifi_Octree_h diff --git a/libraries/octree/src/OctreeConstants.h b/libraries/octree/src/OctreeConstants.h index a78d778f70..18c5eb0108 100644 --- a/libraries/octree/src/OctreeConstants.h +++ b/libraries/octree/src/OctreeConstants.h @@ -1,16 +1,16 @@ // // OctreeConstants.h -// hifi +// libraries/octree/src // // Created by Brad Hefta-Gaub on 4/29/13. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -// Various important constants used throughout the system related to voxels -// -// -#ifndef __hifi_OctreeConstants_h__ -#define __hifi_OctreeConstants_h__ +#ifndef hifi_OctreeConstants_h +#define hifi_OctreeConstants_h #include #include @@ -44,4 +44,4 @@ const int DANGEROUSLY_DEEP_RECURSION = 200; // use this for something that needs const int DEFAULT_MAX_OCTREE_PPS = 600; // the default maximum PPS we think any octree based server should send to a client -#endif \ No newline at end of file +#endif // hifi_OctreeConstants_h diff --git a/libraries/octree/src/OctreeEditPacketSender.cpp b/libraries/octree/src/OctreeEditPacketSender.cpp index bb8ff9d8a0..b606dffe44 100644 --- a/libraries/octree/src/OctreeEditPacketSender.cpp +++ b/libraries/octree/src/OctreeEditPacketSender.cpp @@ -1,11 +1,12 @@ // // OctreeEditPacketSender.cpp -// interface +// libraries/octree/src // // Created by Brad Hefta-Gaub on 8/12/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // -// Threaded or non-threaded packet Sender for the Application +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/octree/src/OctreeEditPacketSender.h b/libraries/octree/src/OctreeEditPacketSender.h index 75ad02a1c6..f9326b6ed3 100644 --- a/libraries/octree/src/OctreeEditPacketSender.h +++ b/libraries/octree/src/OctreeEditPacketSender.h @@ -1,15 +1,16 @@ // // OctreeEditPacketSender.h -// shared +// libraries/octree/src // // Created by Brad Hefta-Gaub on 8/12/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // -// Octree Edit Packet Sender +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __shared__OctreeEditPacketSender__ -#define __shared__OctreeEditPacketSender__ +#ifndef hifi_OctreeEditPacketSender_h +#define hifi_OctreeEditPacketSender_h #include #include @@ -114,4 +115,4 @@ protected: unsigned short int _sequenceNumber; int _maxPacketSize; }; -#endif // __shared__OctreeEditPacketSender__ +#endif // hifi_OctreeEditPacketSender_h diff --git a/libraries/octree/src/OctreeElement.cpp b/libraries/octree/src/OctreeElement.cpp index 7697338a28..e21148df5e 100644 --- a/libraries/octree/src/OctreeElement.cpp +++ b/libraries/octree/src/OctreeElement.cpp @@ -1,9 +1,12 @@ // // OctreeElement.cpp -// hifi +// libraries/octree/src // // Created by Stephen Birarda on 3/13/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/octree/src/OctreeElement.h b/libraries/octree/src/OctreeElement.h index a37866bdbe..682516cf0a 100644 --- a/libraries/octree/src/OctreeElement.h +++ b/libraries/octree/src/OctreeElement.h @@ -1,13 +1,16 @@ // // OctreeElement.h -// hifi +// libraries/octree/src // // Created by Stephen Birarda on 3/13/13. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__OctreeElement__ -#define __hifi__OctreeElement__ +#ifndef hifi_OctreeElement_h +#define hifi_OctreeElement_h //#define HAS_AUDIT_CHILDREN //#define SIMPLE_CHILD_ARRAY @@ -316,4 +319,4 @@ protected: static quint64 _childrenCount[NUMBER_OF_CHILDREN + 1]; }; -#endif /* defined(__hifi__OctreeElement__) */ \ No newline at end of file +#endif // hifi_OctreeElement_h diff --git a/libraries/octree/src/OctreeElementBag.cpp b/libraries/octree/src/OctreeElementBag.cpp index 3ecdfaf2e3..f929980a75 100644 --- a/libraries/octree/src/OctreeElementBag.cpp +++ b/libraries/octree/src/OctreeElementBag.cpp @@ -1,9 +1,12 @@ // // OctreeElementBag.cpp -// hifi +// libraries/octree/src // -// Created by Brad Hefta-Gaub on 4/25/2013 -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 4/25/2013. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "OctreeElementBag.h" diff --git a/libraries/octree/src/OctreeElementBag.h b/libraries/octree/src/OctreeElementBag.h index ba74a05516..afc34bf1a6 100644 --- a/libraries/octree/src/OctreeElementBag.h +++ b/libraries/octree/src/OctreeElementBag.h @@ -1,18 +1,21 @@ // // OctreeElementBag.h -// hifi +// libraries/octree/src // -// Created by Brad Hefta-Gaub on 4/25/2013 -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 4/25/2013. +// Copyright 2013 High Fidelity, Inc. // // This class is used by the VoxelTree:encodeTreeBitstream() functions to store extra nodes that need to be sent // it's a generic bag style storage mechanism. But It has the property that you can't put the same node into the bag // more than once (in other words, it de-dupes automatically), also, it supports collapsing it's several peer nodes // into a parent node in cases where you add enough peers that it makes more sense to just add the parent. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// -#ifndef __hifi__OctreeElementBag__ -#define __hifi__OctreeElementBag__ +#ifndef hifi_OctreeElementBag_h +#define hifi_OctreeElementBag_h #include "OctreeElement.h" @@ -37,4 +40,4 @@ private: QSet _bagElements; }; -#endif /* defined(__hifi__OctreeElementBag__) */ +#endif // hifi_OctreeElementBag_h diff --git a/libraries/octree/src/OctreeHeadlessViewer.cpp b/libraries/octree/src/OctreeHeadlessViewer.cpp index 5d2ce2d287..b25cb4ff8a 100644 --- a/libraries/octree/src/OctreeHeadlessViewer.cpp +++ b/libraries/octree/src/OctreeHeadlessViewer.cpp @@ -1,10 +1,12 @@ // // OctreeHeadlessViewer.cpp -// hifi +// libraries/octree/src // -// Created by Brad Hefta-Gaub on 2/26/14 -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 2/26/14. +// Copyright 2014 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/octree/src/OctreeHeadlessViewer.h b/libraries/octree/src/OctreeHeadlessViewer.h index fc32dbc682..ebabf1dbad 100644 --- a/libraries/octree/src/OctreeHeadlessViewer.h +++ b/libraries/octree/src/OctreeHeadlessViewer.h @@ -1,14 +1,16 @@ // // OctreeHeadlessViewer.h -// hifi +// libraries/octree/src // -// Created by Brad Hefta-Gaub on 2/26/14 -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 2/26/14. +// Copyright 2014 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__OctreeHeadlessViewer__ -#define __hifi__OctreeHeadlessViewer__ +#ifndef hifi_OctreeHeadlessViewer_h +#define hifi_OctreeHeadlessViewer_h #include #include @@ -70,4 +72,4 @@ private: int _maxPacketsPerSecond; }; -#endif /* defined(__hifi__OctreeHeadlessViewer__) */ \ No newline at end of file +#endif // hifi_OctreeHeadlessViewer_h diff --git a/libraries/octree/src/OctreePacketData.cpp b/libraries/octree/src/OctreePacketData.cpp index 5bd4fdce49..2edf560de6 100644 --- a/libraries/octree/src/OctreePacketData.cpp +++ b/libraries/octree/src/OctreePacketData.cpp @@ -1,9 +1,12 @@ // // OctreePacketData.cpp -// hifi +// libraries/octree/src // // Created by Brad Hefta-Gaub on 11/19/2013. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/octree/src/OctreePacketData.h b/libraries/octree/src/OctreePacketData.h index 5d7a904a4c..d802f8e808 100644 --- a/libraries/octree/src/OctreePacketData.h +++ b/libraries/octree/src/OctreePacketData.h @@ -1,11 +1,11 @@ // // OctreePacketData.h -// hifi +// libraries/octree/src // -// Created by Brad Hefta-Gaub on 11/19/2013 +// Created by Brad Hefta-Gaub on 11/19/2013. +// Copyright 2013 High Fidelity, Inc. // // TO DO: -// // * add stats tracking for number of unique colors and consecutive identical colors. // (as research for color dictionaries and RLE) // @@ -15,9 +15,12 @@ // but wouldn't work with RLE because the colors in the levels would get reordered and RLE would need // to be recalculated // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// -#ifndef __hifi__OctreePacketData__ -#define __hifi__OctreePacketData__ +#ifndef hifi_OctreePacketData_h +#define hifi_OctreePacketData_h #include #include "OctreeConstants.h" @@ -224,4 +227,4 @@ private: static quint64 _totalBytesOfRawData; }; -#endif /* defined(__hifi__OctreePacketData__) */ +#endif // hifi_OctreePacketData_h diff --git a/libraries/octree/src/OctreePersistThread.cpp b/libraries/octree/src/OctreePersistThread.cpp index 29715f9d90..7613e2332b 100644 --- a/libraries/octree/src/OctreePersistThread.cpp +++ b/libraries/octree/src/OctreePersistThread.cpp @@ -1,11 +1,12 @@ // // OctreePersistThread.cpp -// Octree-server +// libraries/octree/src // -// Created by Brad Hefta-Gaub on 8/21/13 -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 8/21/13. +// Copyright 2013 High Fidelity, Inc. // -// Threaded or non-threaded Octree persistence +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/octree/src/OctreePersistThread.h b/libraries/octree/src/OctreePersistThread.h index ce6190b0e6..2f86320b2e 100644 --- a/libraries/octree/src/OctreePersistThread.h +++ b/libraries/octree/src/OctreePersistThread.h @@ -1,15 +1,18 @@ // // OctreePersistThread.h -// Octree-server +// libraries/octree/src // -// Created by Brad Hefta-Gaub on 8/21/13 -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 8/21/13. +// Copyright 2013 High Fidelity, Inc. // // Threaded or non-threaded Octree persistence // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// -#ifndef __Octree_server__OctreePersistThread__ -#define __Octree_server__OctreePersistThread__ +#ifndef hifi_OctreePersistThread_h +#define hifi_OctreePersistThread_h #include #include @@ -42,4 +45,4 @@ private: quint64 _lastCheck; }; -#endif // __Octree_server__OctreePersistThread__ +#endif // hifi_OctreePersistThread_h diff --git a/libraries/octree/src/OctreeProjectedPolygon.cpp b/libraries/octree/src/OctreeProjectedPolygon.cpp index 6e5cea28cd..f86d598a87 100644 --- a/libraries/octree/src/OctreeProjectedPolygon.cpp +++ b/libraries/octree/src/OctreeProjectedPolygon.cpp @@ -1,8 +1,12 @@ // -// OctreeProjectedPolygon.cpp - The projected shadow (on the 2D view plane) for a voxel -// hifi +// OctreeProjectedPolygon.cpp +// libraries/octree/src // -// Added by Brad Hefta-Gaub on 06/11/13. +// Created by Brad Hefta-Gaub on 06/11/13. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/octree/src/OctreeProjectedPolygon.h b/libraries/octree/src/OctreeProjectedPolygon.h index 94e55a11d5..5a2a36f280 100644 --- a/libraries/octree/src/OctreeProjectedPolygon.h +++ b/libraries/octree/src/OctreeProjectedPolygon.h @@ -1,12 +1,18 @@ // -// OctreeProjectedPolygon.h - The projected shadow (on the 2D view plane) for a voxel -// hifi +// OctreeProjectedPolygon.h +// libraries/octree/src // -// Added by Brad Hefta-Gaub on 06/11/13. +// Created by Brad Hefta-Gaub on 06/11/13. +// Copyright 2013 High Fidelity, Inc. +// +// The projected shadow (on the 2D view plane) for a voxel +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef _VOXEL_PROJECTED_SHADOW_ -#define _VOXEL_PROJECTED_SHADOW_ +#ifndef hifi_OctreeProjectedPolygon_h +#define hifi_OctreeProjectedPolygon_h #include @@ -126,4 +132,4 @@ private: }; -#endif // _VOXEL_PROJECTED_SHADOW_ +#endif // hifi_OctreeProjectedPolygon_h diff --git a/libraries/octree/src/OctreeQuery.cpp b/libraries/octree/src/OctreeQuery.cpp index 51e235c4e2..687dd18037 100644 --- a/libraries/octree/src/OctreeQuery.cpp +++ b/libraries/octree/src/OctreeQuery.cpp @@ -1,9 +1,12 @@ // // OctreeQuery.cpp -// hifi +// libraries/octree/src // // Created by Brad Hefta-Gaub on 10/24/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/octree/src/OctreeQuery.h b/libraries/octree/src/OctreeQuery.h index 3b53aaa501..8c4460bc73 100644 --- a/libraries/octree/src/OctreeQuery.h +++ b/libraries/octree/src/OctreeQuery.h @@ -1,13 +1,16 @@ // // OctreeQuery.h -// hifi +// libraries/octree/src // // Created by Stephen Birarda on 4/9/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__OctreeQuery__ -#define __hifi__OctreeQuery__ +#ifndef hifi_OctreeQuery_h +#define hifi_OctreeQuery_h /* VS2010 defines stdint.h, but not inttypes.h */ #if defined(_MSC_VER) @@ -113,4 +116,4 @@ private: OctreeQuery& operator= (const OctreeQuery&); }; -#endif /* defined(__hifi__OctreeQuery__) */ +#endif // hifi_OctreeQuery_h diff --git a/libraries/octree/src/OctreeRenderer.cpp b/libraries/octree/src/OctreeRenderer.cpp index 5d4543e3aa..cde1f0923d 100644 --- a/libraries/octree/src/OctreeRenderer.cpp +++ b/libraries/octree/src/OctreeRenderer.cpp @@ -1,10 +1,12 @@ // // OctreeRenderer.cpp -// hifi +// libraries/octree/src // // Created by Brad Hefta-Gaub on 12/6/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/octree/src/OctreeRenderer.h b/libraries/octree/src/OctreeRenderer.h index 2e9762a883..fbd82fad8f 100644 --- a/libraries/octree/src/OctreeRenderer.h +++ b/libraries/octree/src/OctreeRenderer.h @@ -1,14 +1,16 @@ // // OctreeRenderer.h -// hifi +// libraries/octree/src // // Created by Brad Hefta-Gaub on 12/6/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__OctreeRenderer__ -#define __hifi__OctreeRenderer__ +#ifndef hifi_OctreeRenderer_h +#define hifi_OctreeRenderer_h #include #include @@ -69,4 +71,4 @@ protected: ViewFrustum* _viewFrustum; }; -#endif /* defined(__hifi__OctreeRenderer__) */ \ No newline at end of file +#endif // hifi_OctreeRenderer_h diff --git a/libraries/octree/src/OctreeSceneStats.cpp b/libraries/octree/src/OctreeSceneStats.cpp index a21ab60493..ad8702adc2 100644 --- a/libraries/octree/src/OctreeSceneStats.cpp +++ b/libraries/octree/src/OctreeSceneStats.cpp @@ -1,10 +1,12 @@ // // OctreeSceneStats.cpp -// hifi +// libraries/octree/src // // Created by Brad Hefta-Gaub on 7/18/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/octree/src/OctreeSceneStats.h b/libraries/octree/src/OctreeSceneStats.h index 866c5d0b85..140e33aedf 100644 --- a/libraries/octree/src/OctreeSceneStats.h +++ b/libraries/octree/src/OctreeSceneStats.h @@ -1,14 +1,16 @@ // // OctreeSceneStats.h -// hifi +// libraries/octree/src // // Created by Brad Hefta-Gaub on 7/18/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__OctreeSceneStats__ -#define __hifi__OctreeSceneStats__ +#ifndef hifi_OctreeSceneStats_h +#define hifi_OctreeSceneStats_h #include #include @@ -290,4 +292,4 @@ private: typedef std::map NodeToOctreeSceneStats; typedef std::map::iterator NodeToOctreeSceneStatsIterator; -#endif /* defined(__hifi__OctreeSceneStats__) */ +#endif // hifi_OctreeSceneStats_h diff --git a/libraries/octree/src/OctreeScriptingInterface.cpp b/libraries/octree/src/OctreeScriptingInterface.cpp index 982496bc58..97e7f67ff5 100644 --- a/libraries/octree/src/OctreeScriptingInterface.cpp +++ b/libraries/octree/src/OctreeScriptingInterface.cpp @@ -1,9 +1,12 @@ // // OctreeScriptingInterface.cpp -// hifi +// libraries/octree/src // -// Created by Brad Hefta-Gaub on 12/6/13 -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 12/6/13. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/octree/src/OctreeScriptingInterface.h b/libraries/octree/src/OctreeScriptingInterface.h index 3003950bbf..52d7c8be34 100644 --- a/libraries/octree/src/OctreeScriptingInterface.h +++ b/libraries/octree/src/OctreeScriptingInterface.h @@ -1,13 +1,16 @@ // // OctreeScriptingInterface.h -// hifi +// libraries/octree/src // -// Created by Brad Hefta-Gaub on 12/6/13 -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 12/6/13. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__OctreeScriptingInterface__ -#define __hifi__OctreeScriptingInterface__ +#ifndef hifi_OctreeScriptingInterface_h +#define hifi_OctreeScriptingInterface_h #include @@ -96,4 +99,4 @@ protected: bool _initialized; }; -#endif /* defined(__hifi__OctreeScriptingInterface__) */ +#endif // hifi_OctreeScriptingInterface_h diff --git a/libraries/octree/src/Plane.cpp b/libraries/octree/src/Plane.cpp index 6a356784b7..d7cb2c54ff 100755 --- a/libraries/octree/src/Plane.cpp +++ b/libraries/octree/src/Plane.cpp @@ -1,12 +1,16 @@ // -// Plane.h -// hifi +// Plane.cpp +// libraries/octree/src/ // // Created by Brad Hefta-Gaub on 04/11/13. -// Originally from lighthouse3d. Modified to utilize glm::vec3 and clean up to our coding standards +// Copyright 2013 High Fidelity, Inc. // +// Originally from lighthouse3d. Modified to utilize glm::vec3 and clean up to our coding standards // Simple plane class. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// #include "Plane.h" diff --git a/libraries/octree/src/Plane.h b/libraries/octree/src/Plane.h index 8ce0e5042e..0f481dee57 100755 --- a/libraries/octree/src/Plane.h +++ b/libraries/octree/src/Plane.h @@ -1,20 +1,23 @@ // // Plane.h -// hifi +// libraries/octree/src/ // // Created by Brad Hefta-Gaub on 04/11/13. -// Originally from lighthouse3d. Modified to utilize glm::vec3 and clean up to our coding standards +// Copyright 2013 High Fidelity, Inc. // +// Originally from lighthouse3d. Modified to utilize glm::vec3 and clean up to our coding standards // Simple plane class. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// -#ifndef _PLANE_ -#define _PLANE_ +#ifndef hifi_Plane_h +#define hifi_Plane_h #include -class Plane -{ +class Plane { public: Plane(const glm::vec3 &v1, const glm::vec3 &v2, const glm::vec3 &v3) { set3Points(v1,v2,v3); } Plane() : _normal(0,0,0), _point(0,0,0), _dCoefficient(0) {}; @@ -41,4 +44,4 @@ private: }; -#endif \ No newline at end of file +#endif // hifi_Plane_h \ No newline at end of file diff --git a/libraries/octree/src/ViewFrustum.cpp b/libraries/octree/src/ViewFrustum.cpp index bc617c9bc7..f2d19a66ea 100644 --- a/libraries/octree/src/ViewFrustum.cpp +++ b/libraries/octree/src/ViewFrustum.cpp @@ -1,11 +1,12 @@ // // ViewFrustum.cpp -// hifi +// libraries/octree/src // // Created by Brad Hefta-Gaub on 04/11/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // -// Simple view frustum class. +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/octree/src/ViewFrustum.h b/libraries/octree/src/ViewFrustum.h index 7a1c3b49ba..5c9d7f06c2 100644 --- a/libraries/octree/src/ViewFrustum.h +++ b/libraries/octree/src/ViewFrustum.h @@ -1,15 +1,18 @@ // // ViewFrustum.h -// hifi +// libraries/octree/src // // Created by Brad Hefta-Gaub on 04/11/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // // Simple view frustum class. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// -#ifndef __hifi__ViewFrustum__ -#define __hifi__ViewFrustum__ +#ifndef hifi_ViewFrustum_h +#define hifi_ViewFrustum_h #include #include @@ -172,4 +175,4 @@ private: }; -#endif /* defined(__hifi__ViewFrustum__) */ +#endif // hifi_ViewFrustum_h diff --git a/libraries/particles/src/Particle.cpp b/libraries/particles/src/Particle.cpp index f4a5785bad..a36998aad4 100644 --- a/libraries/particles/src/Particle.cpp +++ b/libraries/particles/src/Particle.cpp @@ -1,10 +1,12 @@ // // Particle.cpp -// hifi +// libraries/particles/src // // Created by Brad Hefta-Gaub on 12/4/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/particles/src/Particle.h b/libraries/particles/src/Particle.h index dbe98c5bf6..c243363241 100644 --- a/libraries/particles/src/Particle.h +++ b/libraries/particles/src/Particle.h @@ -1,14 +1,16 @@ // // Particle.h -// hifi +// libraries/particles/src // // Created by Brad Hefta-Gaub on 12/4/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__Particle__ -#define __hifi__Particle__ +#ifndef hifi_Particle_h +#define hifi_Particle_h #include #include @@ -428,4 +430,4 @@ private: -#endif /* defined(__hifi__Particle__) */ +#endif // hifi_Particle_h diff --git a/libraries/particles/src/ParticleCollisionSystem.cpp b/libraries/particles/src/ParticleCollisionSystem.cpp index c827e28c78..57a339d81f 100644 --- a/libraries/particles/src/ParticleCollisionSystem.cpp +++ b/libraries/particles/src/ParticleCollisionSystem.cpp @@ -1,10 +1,12 @@ // // ParticleCollisionSystem.cpp -// hifi +// libraries/particles/src // // Created by Brad Hefta-Gaub on 12/4/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include @@ -72,17 +74,17 @@ void ParticleCollisionSystem::checkParticle(Particle* particle) { } void ParticleCollisionSystem::emitGlobalParticleCollisionWithVoxel(Particle* particle, - VoxelDetail* voxelDetails, const glm::vec3& penetration) { + VoxelDetail* voxelDetails, const CollisionInfo& collision) { ParticleID particleID = particle->getParticleID(); - emit particleCollisionWithVoxel(particleID, *voxelDetails, penetration); + emit particleCollisionWithVoxel(particleID, *voxelDetails, collision); } void ParticleCollisionSystem::emitGlobalParticleCollisionWithParticle(Particle* particleA, - Particle* particleB, const glm::vec3& penetration) { + Particle* particleB, const CollisionInfo& collision) { ParticleID idA = particleA->getParticleID(); ParticleID idB = particleB->getParticleID(); - emit particleCollisionWithParticle(idA, idB, penetration); + emit particleCollisionWithParticle(idA, idB, collision); } void ParticleCollisionSystem::updateCollisionWithVoxels(Particle* particle) { @@ -100,11 +102,17 @@ void ParticleCollisionSystem::updateCollisionWithVoxels(Particle* particle) { // let the particles run their collision scripts if they have them particle->collisionWithVoxel(voxelDetails, collisionInfo._penetration); - // let the global script run their collision scripts for particles if they have them - emitGlobalParticleCollisionWithVoxel(particle, voxelDetails, collisionInfo._penetration); - + // findSpherePenetration() only computes the penetration but we also want some other collision info + // so we compute it ourselves here. Note that we must multiply scale by TREE_SCALE when feeding + // the results to systems outside of this octree reference frame. updateCollisionSound(particle, collisionInfo._penetration, COLLISION_FREQUENCY); + collisionInfo._contactPoint = (float)TREE_SCALE * (particle->getPosition() + particle->getRadius() * glm::normalize(collisionInfo._penetration)); + // let the global script run their collision scripts for particles if they have them + emitGlobalParticleCollisionWithVoxel(particle, voxelDetails, collisionInfo); + + // we must scale back down to the octree reference frame before updating the particle properties collisionInfo._penetration /= (float)(TREE_SCALE); + collisionInfo._contactPoint /= (float)(TREE_SCALE); particle->applyHardCollision(collisionInfo); queueParticlePropertiesUpdate(particle); @@ -121,8 +129,7 @@ void ParticleCollisionSystem::updateCollisionWithParticles(Particle* particleA) glm::vec3 penetration; Particle* particleB; if (_particles->findSpherePenetration(center, radius, penetration, (void**)&particleB, Octree::NoLock)) { - // NOTE: 'penetration' is the depth that 'particleA' overlaps 'particleB'. - // That is, it points from A into B. + // NOTE: 'penetration' is the depth that 'particleA' overlaps 'particleB'. It points from A into B. // Even if the particles overlap... when the particles are already moving appart // we don't want to count this as a collision. @@ -130,7 +137,12 @@ void ParticleCollisionSystem::updateCollisionWithParticles(Particle* particleA) if (glm::dot(relativeVelocity, penetration) > 0.0f) { particleA->collisionWithParticle(particleB, penetration); particleB->collisionWithParticle(particleA, penetration * -1.0f); // the penetration is reversed - emitGlobalParticleCollisionWithParticle(particleA, particleB, penetration); + + CollisionInfo collision; + collision._penetration = penetration; + // for now the contactPoint is the average between the the two paricle centers + collision._contactPoint = (0.5f * (float)TREE_SCALE) * (particleA->getPosition() + particleB->getPosition()); + emitGlobalParticleCollisionWithParticle(particleA, particleB, collision); glm::vec3 axis = glm::normalize(penetration); glm::vec3 axialVelocity = glm::dot(relativeVelocity, axis) * axis; @@ -142,25 +154,25 @@ void ParticleCollisionSystem::updateCollisionWithParticles(Particle* particleA) float massB = (particleB->getInHand()) ? MAX_MASS : particleB->getMass(); float totalMass = massA + massB; - // handle A particle + // handle particle A particleA->setVelocity(particleA->getVelocity() - axialVelocity * (2.0f * massB / totalMass)); particleA->setPosition(particleA->getPosition() - 0.5f * penetration); ParticleProperties propertiesA; - ParticleID particleAid(particleA->getID()); + ParticleID idA(particleA->getID()); propertiesA.copyFromParticle(*particleA); propertiesA.setVelocity(particleA->getVelocity() * (float)TREE_SCALE); propertiesA.setPosition(particleA->getPosition() * (float)TREE_SCALE); - _packetSender->queueParticleEditMessage(PacketTypeParticleAddOrEdit, particleAid, propertiesA); + _packetSender->queueParticleEditMessage(PacketTypeParticleAddOrEdit, idA, propertiesA); - // handle B particle + // handle particle B particleB->setVelocity(particleB->getVelocity() + axialVelocity * (2.0f * massA / totalMass)); particleA->setPosition(particleB->getPosition() + 0.5f * penetration); ParticleProperties propertiesB; - ParticleID particleBid(particleB->getID()); + ParticleID idB(particleB->getID()); propertiesB.copyFromParticle(*particleB); propertiesB.setVelocity(particleB->getVelocity() * (float)TREE_SCALE); propertiesB.setPosition(particleB->getPosition() * (float)TREE_SCALE); - _packetSender->queueParticleEditMessage(PacketTypeParticleAddOrEdit, particleBid, propertiesB); + _packetSender->queueParticleEditMessage(PacketTypeParticleAddOrEdit, idB, propertiesB); _packetSender->releaseQueuedMessages(); diff --git a/libraries/particles/src/ParticleCollisionSystem.h b/libraries/particles/src/ParticleCollisionSystem.h index 1b30fd31ac..cf9c4b938c 100644 --- a/libraries/particles/src/ParticleCollisionSystem.h +++ b/libraries/particles/src/ParticleCollisionSystem.h @@ -1,14 +1,16 @@ // // ParticleCollisionSystem.h -// hifi +// libraries/particles/src // // Created by Brad Hefta-Gaub on 12/4/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__ParticleCollisionSystem__ -#define __hifi__ParticleCollisionSystem__ +#ifndef hifi_ParticleCollisionSystem_h +#define hifi_ParticleCollisionSystem_h #include #include @@ -53,13 +55,13 @@ public: void updateCollisionSound(Particle* particle, const glm::vec3 &penetration, float frequency); signals: - void particleCollisionWithVoxel(const ParticleID& particleID, const VoxelDetail& voxel, const glm::vec3& penetration); - void particleCollisionWithParticle(const ParticleID& idA, const ParticleID& idB, const glm::vec3& penetration); + void particleCollisionWithVoxel(const ParticleID& particleID, const VoxelDetail& voxel, const CollisionInfo& penetration); + void particleCollisionWithParticle(const ParticleID& idA, const ParticleID& idB, const CollisionInfo& penetration); private: static bool updateOperation(OctreeElement* element, void* extraData); - void emitGlobalParticleCollisionWithVoxel(Particle* particle, VoxelDetail* voxelDetails, const glm::vec3& penetration); - void emitGlobalParticleCollisionWithParticle(Particle* particleA, Particle* particleB, const glm::vec3& penetration); + void emitGlobalParticleCollisionWithVoxel(Particle* particle, VoxelDetail* voxelDetails, const CollisionInfo& penetration); + void emitGlobalParticleCollisionWithParticle(Particle* particleA, Particle* particleB, const CollisionInfo& penetration); ParticleEditPacketSender* _packetSender; ParticleTree* _particles; @@ -69,4 +71,4 @@ private: CollisionList _collisions; }; -#endif /* defined(__hifi__ParticleCollisionSystem__) */ +#endif // hifi_ParticleCollisionSystem_h diff --git a/libraries/particles/src/ParticleEditPacketSender.cpp b/libraries/particles/src/ParticleEditPacketSender.cpp index f06b19aa2d..21a910ff16 100644 --- a/libraries/particles/src/ParticleEditPacketSender.cpp +++ b/libraries/particles/src/ParticleEditPacketSender.cpp @@ -1,11 +1,12 @@ // // ParticleEditPacketSender.cpp -// interface +// libraries/particles/src // // Created by Brad Hefta-Gaub on 8/12/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // -// Threaded or non-threaded voxel packet Sender for the Application +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/particles/src/ParticleEditPacketSender.h b/libraries/particles/src/ParticleEditPacketSender.h index 3169c5629d..15e3196785 100644 --- a/libraries/particles/src/ParticleEditPacketSender.h +++ b/libraries/particles/src/ParticleEditPacketSender.h @@ -1,15 +1,16 @@ // // ParticleEditPacketSender.h -// shared +// libraries/particles/src // // Created by Brad Hefta-Gaub on 8/12/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // -// Voxel Packet Sender +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __shared__ParticleEditPacketSender__ -#define __shared__ParticleEditPacketSender__ +#ifndef hifi_ParticleEditPacketSender_h +#define hifi_ParticleEditPacketSender_h #include #include "Particle.h" @@ -32,4 +33,4 @@ public: virtual unsigned char getMyNodeType() const { return NodeType::ParticleServer; } virtual void adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, ssize_t length, int clockSkew); }; -#endif // __shared__ParticleEditPacketSender__ +#endif // hifi_ParticleEditPacketSender_h diff --git a/libraries/particles/src/ParticleTree.cpp b/libraries/particles/src/ParticleTree.cpp index 57f6a6e665..aeaf25e23c 100644 --- a/libraries/particles/src/ParticleTree.cpp +++ b/libraries/particles/src/ParticleTree.cpp @@ -1,9 +1,12 @@ // // ParticleTree.cpp -// hifi +// libraries/particles/src // // Created by Brad Hefta-Gaub on 12/4/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "ParticleTree.h" diff --git a/libraries/particles/src/ParticleTree.h b/libraries/particles/src/ParticleTree.h index f3b8f5183d..a31c2d38aa 100644 --- a/libraries/particles/src/ParticleTree.h +++ b/libraries/particles/src/ParticleTree.h @@ -1,13 +1,16 @@ // // ParticleTree.h -// hifi +// libraries/particles/src // // Created by Brad Hefta-Gaub on 12/4/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__ParticleTree__ -#define __hifi__ParticleTree__ +#ifndef hifi_ParticleTree_h +#define hifi_ParticleTree_h #include #include "ParticleTreeElement.h" @@ -92,4 +95,4 @@ private: QMultiMap _recentlyDeletedParticleIDs; }; -#endif /* defined(__hifi__ParticleTree__) */ +#endif // hifi_ParticleTree_h diff --git a/libraries/particles/src/ParticleTreeElement.cpp b/libraries/particles/src/ParticleTreeElement.cpp index ee916dcf2f..19353c427a 100644 --- a/libraries/particles/src/ParticleTreeElement.cpp +++ b/libraries/particles/src/ParticleTreeElement.cpp @@ -1,9 +1,12 @@ // // ParticleTreeElement.cpp -// hifi +// libraries/particles/src // // Created by Brad Hefta-Gaub on 12/4/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/particles/src/ParticleTreeElement.h b/libraries/particles/src/ParticleTreeElement.h index 2854066f3b..59f80d588a 100644 --- a/libraries/particles/src/ParticleTreeElement.h +++ b/libraries/particles/src/ParticleTreeElement.h @@ -1,14 +1,16 @@ // // ParticleTreeElement.h -// hifi +// libraries/particles/src // // Created by Brad Hefta-Gaub on 12/4/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__ParticleTreeElement__ -#define __hifi__ParticleTreeElement__ +#ifndef hifi_ParticleTreeElement_h +#define hifi_ParticleTreeElement_h //#include @@ -127,4 +129,4 @@ protected: QList* _particles; }; -#endif /* defined(__hifi__ParticleTreeElement__) */ +#endif // hifi_ParticleTreeElement_h diff --git a/libraries/particles/src/ParticleTreeHeadlessViewer.cpp b/libraries/particles/src/ParticleTreeHeadlessViewer.cpp index f5384c3fec..1c47447b1a 100644 --- a/libraries/particles/src/ParticleTreeHeadlessViewer.cpp +++ b/libraries/particles/src/ParticleTreeHeadlessViewer.cpp @@ -1,10 +1,12 @@ // // ParticleTreeHeadlessViewer.cpp -// hifi +// libraries/particles/src // -// Created by Brad Hefta-Gaub on 2/26/14 -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 2/26/14. +// Copyright 2014 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "ParticleTreeHeadlessViewer.h" diff --git a/libraries/particles/src/ParticleTreeHeadlessViewer.h b/libraries/particles/src/ParticleTreeHeadlessViewer.h index 08aa12280c..1d539bd46f 100644 --- a/libraries/particles/src/ParticleTreeHeadlessViewer.h +++ b/libraries/particles/src/ParticleTreeHeadlessViewer.h @@ -1,14 +1,16 @@ // // ParticleTreeHeadlessViewer.h -// hifi +// libraries/particles/src // -// Created by Brad Hefta-Gaub on 2/26/14 -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 2/26/14. +// Copyright 2014 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__ParticleTreeHeadlessViewer__ -#define __hifi__ParticleTreeHeadlessViewer__ +#ifndef hifi_ParticleTreeHeadlessViewer_h +#define hifi_ParticleTreeHeadlessViewer_h #include #include @@ -39,4 +41,4 @@ public: virtual void init(); }; -#endif /* defined(__hifi__ParticleTreeHeadlessViewer__) */ \ No newline at end of file +#endif // hifi_ParticleTreeHeadlessViewer_h diff --git a/libraries/particles/src/ParticlesScriptingInterface.cpp b/libraries/particles/src/ParticlesScriptingInterface.cpp index a25dde1b9e..4adfed358e 100644 --- a/libraries/particles/src/ParticlesScriptingInterface.cpp +++ b/libraries/particles/src/ParticlesScriptingInterface.cpp @@ -1,9 +1,12 @@ // // ParticlesScriptingInterface.cpp -// hifi +// libraries/particles/src // -// Created by Brad Hefta-Gaub on 12/6/13 -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 12/6/13. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "ParticlesScriptingInterface.h" diff --git a/libraries/particles/src/ParticlesScriptingInterface.h b/libraries/particles/src/ParticlesScriptingInterface.h index af5f76a6af..e1d628f45a 100644 --- a/libraries/particles/src/ParticlesScriptingInterface.h +++ b/libraries/particles/src/ParticlesScriptingInterface.h @@ -1,16 +1,21 @@ // // ParticlesScriptingInterface.h -// hifi +// libraries/particles/src // -// Created by Brad Hefta-Gaub on 12/6/13 -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 12/6/13. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__ParticlesScriptingInterface__ -#define __hifi__ParticlesScriptingInterface__ +#ifndef hifi_ParticlesScriptingInterface_h +#define hifi_ParticlesScriptingInterface_h #include +#include + #include #include "ParticleEditPacketSender.h" @@ -27,17 +32,6 @@ public: void setParticleTree(ParticleTree* particleTree) { _particleTree = particleTree; } ParticleTree* getParticleTree(ParticleTree*) { return _particleTree; } -private slots: - /// inbound slots for external collision systems - void forwardParticleCollisionWithVoxel(const ParticleID& particleID, - const VoxelDetail& voxel, const glm::vec3& penetration) { - emit particleCollisionWithVoxel(particleID, voxel, penetration); - } - - void forwardParticleCollisionWithParticle(const ParticleID& idA, const ParticleID& idB, const glm::vec3& penetration) { - emit particleCollisionWithParticle(idA, idB, penetration); - } - public slots: /// adds a particle with the specific properties ParticleID addParticle(const ParticleProperties& properties); @@ -66,8 +60,8 @@ public slots: QVector findParticles(const glm::vec3& center, float radius) const; signals: - void particleCollisionWithVoxel(const ParticleID& particleID, const VoxelDetail& voxel, const glm::vec3& penetration); - void particleCollisionWithParticle(const ParticleID& idA, const ParticleID& idB, const glm::vec3& penetration); + void particleCollisionWithVoxel(const ParticleID& particleID, const VoxelDetail& voxel, const CollisionInfo& collision); + void particleCollisionWithParticle(const ParticleID& idA, const ParticleID& idB, const CollisionInfo& collision); private: void queueParticleMessage(PacketType packetType, ParticleID particleID, const ParticleProperties& properties); @@ -76,4 +70,4 @@ private: ParticleTree* _particleTree; }; -#endif /* defined(__hifi__ParticlesScriptingInterface__) */ +#endif // hifi_ParticlesScriptingInterface_h diff --git a/libraries/script-engine/src/AbstractControllerScriptingInterface.h b/libraries/script-engine/src/AbstractControllerScriptingInterface.h index 1878edd4d6..677ca27e04 100644 --- a/libraries/script-engine/src/AbstractControllerScriptingInterface.h +++ b/libraries/script-engine/src/AbstractControllerScriptingInterface.h @@ -1,13 +1,16 @@ // // AbstractControllerScriptingInterface.h -// hifi +// libraries/script-engine/src // -// Created by Brad Hefta-Gaub on 12/17/13 -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 12/17/13. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__AbstractControllerScriptingInterface__ -#define __hifi__AbstractControllerScriptingInterface__ +#ifndef hifi_AbstractControllerScriptingInterface_h +#define hifi_AbstractControllerScriptingInterface_h #include @@ -73,4 +76,4 @@ signals: }; -#endif /* defined(__hifi__AbstractControllerScriptingInterface__) */ +#endif // hifi_AbstractControllerScriptingInterface_h diff --git a/libraries/script-engine/src/EventTypes.cpp b/libraries/script-engine/src/EventTypes.cpp index 9885b8d9dc..e785f53c19 100644 --- a/libraries/script-engine/src/EventTypes.cpp +++ b/libraries/script-engine/src/EventTypes.cpp @@ -1,12 +1,13 @@ // // EventTypes.cpp -// hifi +// libraries/script-engine/src // // Created by Brad Hefta-Gaub on 1/28/14. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -// Used to register meta-types with Qt for very various event types so that they can be exposed to our -// scripting engine #include #include diff --git a/libraries/script-engine/src/EventTypes.h b/libraries/script-engine/src/EventTypes.h index f5a4fa5c9b..6994225fd7 100644 --- a/libraries/script-engine/src/EventTypes.h +++ b/libraries/script-engine/src/EventTypes.h @@ -1,13 +1,16 @@ // // EventTypes.h -// hifi +// libraries/script-engine/src // // Created by Brad Hefta-Gaub on 1/28/14. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi_EventTypes_h__ -#define __hifi_EventTypes_h__ +#ifndef hifi_EventTypes_h +#define hifi_EventTypes_h #include @@ -123,4 +126,4 @@ void touchEventFromScriptValue(const QScriptValue& object, TouchEvent& event); QScriptValue wheelEventToScriptValue(QScriptEngine* engine, const WheelEvent& event); void wheelEventFromScriptValue(const QScriptValue& object, WheelEvent& event); -#endif // __hifi_EventTypes_h__ +#endif // hifi_EventTypes_h diff --git a/libraries/script-engine/src/LocalVoxels.cpp b/libraries/script-engine/src/LocalVoxels.cpp index 075dfb9e9a..1645c229d6 100644 --- a/libraries/script-engine/src/LocalVoxels.cpp +++ b/libraries/script-engine/src/LocalVoxels.cpp @@ -1,9 +1,12 @@ // // LocalVoxels.cpp -// hifi +// libraries/script-engine/src // // Created by Clément Brisset on 2/24/14. -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "LocalVoxels.h" diff --git a/libraries/script-engine/src/LocalVoxels.h b/libraries/script-engine/src/LocalVoxels.h index c64379ab27..c382d35c09 100644 --- a/libraries/script-engine/src/LocalVoxels.h +++ b/libraries/script-engine/src/LocalVoxels.h @@ -1,13 +1,16 @@ // // LocalVoxels.h -// hifi +// libraries/script-engine/src // // Created by Clément Brisset on 2/24/14. -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__LocalVoxels__ -#define __hifi__LocalVoxels__ +#ifndef hifi_LocalVoxels_h +#define hifi_LocalVoxels_h #include @@ -87,4 +90,4 @@ private: -#endif /* defined(__hifi__LocalVoxels__) */ +#endif // hifi_LocalVoxels_h diff --git a/libraries/script-engine/src/MenuItemProperties.cpp b/libraries/script-engine/src/MenuItemProperties.cpp index f071723233..c1f3e92447 100644 --- a/libraries/script-engine/src/MenuItemProperties.cpp +++ b/libraries/script-engine/src/MenuItemProperties.cpp @@ -1,12 +1,13 @@ // // MenuItemProperties.cpp -// hifi +// libraries/script-engine/src // // Created by Brad Hefta-Gaub on 1/28/14. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -// Used to register meta-types with Qt for very various event types so that they can be exposed to our -// scripting engine #include #include diff --git a/libraries/script-engine/src/MenuItemProperties.h b/libraries/script-engine/src/MenuItemProperties.h index 82f00a2bc4..9dd3c6107c 100644 --- a/libraries/script-engine/src/MenuItemProperties.h +++ b/libraries/script-engine/src/MenuItemProperties.h @@ -1,13 +1,16 @@ // // MenuItemProperties.h -// hifi +// libraries/script-engine/src // // Created by Brad Hefta-Gaub on 1/28/14. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi_MenuItemProperties_h__ -#define __hifi_MenuItemProperties_h__ +#ifndef hifi_MenuItemProperties_h +#define hifi_MenuItemProperties_h #include @@ -48,4 +51,4 @@ void registerMenuItemProperties(QScriptEngine* engine); -#endif // __hifi_MenuItemProperties_h__ +#endif // hifi_MenuItemProperties_h diff --git a/libraries/script-engine/src/Quat.cpp b/libraries/script-engine/src/Quat.cpp index c939811db4..4acc60e7b4 100644 --- a/libraries/script-engine/src/Quat.cpp +++ b/libraries/script-engine/src/Quat.cpp @@ -1,12 +1,12 @@ // // Quat.cpp -// hifi +// libraries/script-engine/src // -// Created by Brad Hefta-Gaub on 1/29/14 -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. -// -// Scriptable Quaternion class library. +// Created by Brad Hefta-Gaub on 1/29/14. +// Copyright 2014 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/script-engine/src/Quat.h b/libraries/script-engine/src/Quat.h index 02c0a3e147..c97ccf9a1e 100644 --- a/libraries/script-engine/src/Quat.h +++ b/libraries/script-engine/src/Quat.h @@ -1,16 +1,18 @@ // // Quat.h -// hifi +// libraries/script-engine/src // -// Created by Brad Hefta-Gaub on 1/29/14 -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 1/29/14. +// Copyright 2014 High Fidelity, Inc. // // Scriptable Quaternion class library. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__Quat__ -#define __hifi__Quat__ +#ifndef hifi_Quat_h +#define hifi_Quat_h #include @@ -37,4 +39,4 @@ public slots: void print(const QString& lable, const glm::quat& q); }; -#endif /* defined(__hifi__Quat__) */ +#endif // hifi_Quat_h diff --git a/libraries/script-engine/src/ScriptEngine.cpp b/libraries/script-engine/src/ScriptEngine.cpp index 1f1eab6baf..b5291a6a2f 100644 --- a/libraries/script-engine/src/ScriptEngine.cpp +++ b/libraries/script-engine/src/ScriptEngine.cpp @@ -1,9 +1,12 @@ // // ScriptEngine.cpp -// hifi +// libraries/script-engine/src // // Created by Brad Hefta-Gaub on 12/14/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include @@ -29,7 +32,6 @@ #include "LocalVoxels.h" #include "ScriptEngine.h" -int ScriptEngine::_scriptNumber = 1; VoxelsScriptingInterface ScriptEngine::_voxelsScriptingInterface; ParticlesScriptingInterface ScriptEngine::_particlesScriptingInterface; @@ -41,7 +43,7 @@ static QScriptValue soundConstructor(QScriptContext* context, QScriptEngine* eng } -ScriptEngine::ScriptEngine(const QString& scriptContents, bool wantMenuItems, const QString& fileNameString, +ScriptEngine::ScriptEngine(const QString& scriptContents, const QString& fileNameString, AbstractControllerScriptingInterface* controllerScriptingInterface) : _scriptContents(scriptContents), @@ -58,26 +60,16 @@ ScriptEngine::ScriptEngine(const QString& scriptContents, bool wantMenuItems, co _numAvatarSoundSentBytes(0), _controllerScriptingInterface(controllerScriptingInterface), _avatarData(NULL), - _wantMenuItems(wantMenuItems), - _scriptMenuName(), + _scriptName(), _fileNameString(fileNameString), _quatLibrary(), - _vec3Library() + _vec3Library(), + _uuidLibrary() { - // some clients will use these menu features - if (!fileNameString.isEmpty()) { - _scriptMenuName = "Stop "; - _scriptMenuName.append(qPrintable(fileNameString)); - _scriptMenuName.append(QString(" [%1]").arg(_scriptNumber)); - } else { - _scriptMenuName = "Stop Script "; - _scriptMenuName.append(_scriptNumber); - } - _scriptNumber++; } -ScriptEngine::ScriptEngine(const QUrl& scriptURL, bool wantMenuItems, - AbstractControllerScriptingInterface* controllerScriptingInterface) : +ScriptEngine::ScriptEngine(const QUrl& scriptURL, + AbstractControllerScriptingInterface* controllerScriptingInterface) : _scriptContents(), _isFinished(false), _isRunning(false), @@ -92,32 +84,23 @@ ScriptEngine::ScriptEngine(const QUrl& scriptURL, bool wantMenuItems, _numAvatarSoundSentBytes(0), _controllerScriptingInterface(controllerScriptingInterface), _avatarData(NULL), - _wantMenuItems(wantMenuItems), - _scriptMenuName(), + _scriptName(), _fileNameString(), _quatLibrary(), - _vec3Library() + _vec3Library(), + _uuidLibrary() { QString scriptURLString = scriptURL.toString(); _fileNameString = scriptURLString; - // some clients will use these menu features - if (!scriptURLString.isEmpty()) { - _scriptMenuName = "Stop "; - _scriptMenuName.append(qPrintable(scriptURLString)); - _scriptMenuName.append(QString(" [%1]").arg(_scriptNumber)); - } else { - _scriptMenuName = "Stop Script "; - _scriptMenuName.append(_scriptNumber); - } - _scriptNumber++; - + QUrl url(scriptURL); - - // if the scheme is empty, maybe they typed in a file, let's try - if (url.scheme().isEmpty()) { + + // if the scheme length is one or lower, maybe they typed in a file, let's try + const int WINDOWS_DRIVE_LETTER_SIZE = 1; + if (url.scheme().size() <= WINDOWS_DRIVE_LETTER_SIZE) { url = QUrl::fromLocalFile(scriptURLString); } - + // ok, let's see if it's valid... and if so, load it if (url.isValid()) { if (url.scheme() == "file") { @@ -144,16 +127,16 @@ ScriptEngine::ScriptEngine(const QUrl& scriptURL, bool wantMenuItems, void ScriptEngine::setIsAvatar(bool isAvatar) { _isAvatar = isAvatar; - + if (_isAvatar && !_avatarIdentityTimer) { // set up the avatar timers _avatarIdentityTimer = new QTimer(this); _avatarBillboardTimer = new QTimer(this); - + // connect our slot connect(_avatarIdentityTimer, &QTimer::timeout, this, &ScriptEngine::sendAvatarIdentityPacket); connect(_avatarBillboardTimer, &QTimer::timeout, this, &ScriptEngine::sendAvatarBillboardPacket); - + // start the timers _avatarIdentityTimer->start(AVATAR_IDENTITY_PACKET_SEND_INTERVAL_MSECS); _avatarBillboardTimer->start(AVATAR_BILLBOARD_PACKET_SEND_INTERVAL_MSECS); @@ -162,20 +145,14 @@ void ScriptEngine::setIsAvatar(bool isAvatar) { void ScriptEngine::setAvatarData(AvatarData* avatarData, const QString& objectName) { _avatarData = avatarData; - + // remove the old Avatar property, if it exists _engine.globalObject().setProperty(objectName, QScriptValue()); - + // give the script engine the new Avatar script property registerGlobalObject(objectName, _avatarData); } -void ScriptEngine::cleanupMenuItems() { - if (_wantMenuItems) { - emit cleanupMenuItem(_scriptMenuName); - } -} - bool ScriptEngine::setScriptContents(const QString& scriptContents, const QString& fileNameString) { if (_isRunning) { return false; @@ -203,7 +180,7 @@ void ScriptEngine::init() { registerVoxelMetaTypes(&_engine); registerEventTypes(&_engine); registerMenuItemProperties(&_engine); - + qScriptRegisterMetaType(&_engine, ParticlePropertiesToScriptValue, ParticlePropertiesFromScriptValue); qScriptRegisterMetaType(&_engine, ParticleIDtoScriptValue, ParticleIDfromScriptValue); qScriptRegisterSequenceMetaType >(&_engine); @@ -216,7 +193,7 @@ void ScriptEngine::init() { QScriptValue injectionOptionValue = _engine.scriptValueFromQMetaObject(); _engine.globalObject().setProperty("AudioInjectionOptions", injectionOptionValue); - + QScriptValue localVoxelsValue = _engine.scriptValueFromQMetaObject(); _engine.globalObject().setProperty("LocalVoxels", localVoxelsValue); @@ -226,6 +203,7 @@ void ScriptEngine::init() { registerGlobalObject("Particles", &_particlesScriptingInterface); registerGlobalObject("Quat", &_quatLibrary); registerGlobalObject("Vec3", &_vec3Library); + registerGlobalObject("Uuid", &_uuidLibrary); registerGlobalObject("Voxels", &_voxelsScriptingInterface); @@ -285,9 +263,9 @@ void ScriptEngine::run() { gettimeofday(&startTime, NULL); int thisFrame = 0; - + NodeList* nodeList = NodeList::getInstance(); - + qint64 lastUpdate = usecTimestampNow(); while (!_isFinished) { @@ -325,36 +303,36 @@ void ScriptEngine::run() { _particlesScriptingInterface.getParticlePacketSender()->process(); } } - + if (_isAvatar && _avatarData) { - + const int SCRIPT_AUDIO_BUFFER_SAMPLES = floor(((SCRIPT_DATA_CALLBACK_USECS * SAMPLE_RATE) / (1000 * 1000)) + 0.5); const int SCRIPT_AUDIO_BUFFER_BYTES = SCRIPT_AUDIO_BUFFER_SAMPLES * sizeof(int16_t); - + QByteArray avatarPacket = byteArrayWithPopulatedHeader(PacketTypeAvatarData); avatarPacket.append(_avatarData->toByteArray()); - + nodeList->broadcastToNodes(avatarPacket, NodeSet() << NodeType::AvatarMixer); - + if (_isListeningToAudioStream || _avatarSound) { // if we have an avatar audio stream then send it out to our audio-mixer bool silentFrame = true; - + int16_t numAvailableSamples = SCRIPT_AUDIO_BUFFER_SAMPLES; const int16_t* nextSoundOutput = NULL; - + if (_avatarSound) { - + const QByteArray& soundByteArray = _avatarSound->getByteArray(); nextSoundOutput = reinterpret_cast(soundByteArray.data() + _numAvatarSoundSentBytes); - + int numAvailableBytes = (soundByteArray.size() - _numAvatarSoundSentBytes) > SCRIPT_AUDIO_BUFFER_BYTES ? SCRIPT_AUDIO_BUFFER_BYTES : soundByteArray.size() - _numAvatarSoundSentBytes; numAvailableSamples = numAvailableBytes / sizeof(int16_t); - - + + // check if the all of the _numAvatarAudioBufferSamples to be sent are silence for (int i = 0; i < numAvailableSamples; ++i) { if (nextSoundOutput[i] != 0) { @@ -362,7 +340,7 @@ void ScriptEngine::run() { break; } } - + _numAvatarSoundSentBytes += numAvailableBytes; if (_numAvatarSoundSentBytes == soundByteArray.size()) { // we're done with this sound object - so set our pointer back to NULL @@ -371,24 +349,24 @@ void ScriptEngine::run() { _numAvatarSoundSentBytes = 0; } } - + QByteArray audioPacket = byteArrayWithPopulatedHeader(silentFrame ? PacketTypeSilentAudioFrame : PacketTypeMicrophoneAudioNoEcho); - + QDataStream packetStream(&audioPacket, QIODevice::Append); - + // use the orientation and position of this avatar for the source of this audio packetStream.writeRawData(reinterpret_cast(&_avatarData->getPosition()), sizeof(glm::vec3)); glm::quat headOrientation = _avatarData->getHeadOrientation(); packetStream.writeRawData(reinterpret_cast(&headOrientation), sizeof(glm::quat)); - + if (silentFrame) { if (!_isListeningToAudioStream) { // if we have a silent frame and we're not listening then just send nothing and break out of here break; } - + // write the number of silent samples so the audio-mixer can uphold timing packetStream.writeRawData(reinterpret_cast(&SCRIPT_AUDIO_BUFFER_SAMPLES), sizeof(int16_t)); } else if (nextSoundOutput) { @@ -396,7 +374,7 @@ void ScriptEngine::run() { packetStream.writeRawData(reinterpret_cast(nextSoundOutput), numAvailableSamples * sizeof(int16_t)); } - + nodeList->broadcastToNodes(audioPacket, NodeSet() << NodeType::AudioMixer); } } @@ -412,10 +390,10 @@ void ScriptEngine::run() { } } emit scriptEnding(); - + // kill the avatar identity timer delete _avatarIdentityTimer; - + if (_voxelsScriptingInterface.getVoxelPacketSender()->serversExist()) { // release the queue of edit voxel messages. _voxelsScriptingInterface.getVoxelPacketSender()->releaseQueuedMessages(); @@ -435,8 +413,6 @@ void ScriptEngine::run() { _particlesScriptingInterface.getParticlePacketSender()->process(); } } - - cleanupMenuItems(); // If we were on a thread, then wait till it's done if (thread()) { @@ -444,7 +420,7 @@ void ScriptEngine::run() { } emit finished(_fileNameString); - + _isRunning = false; } @@ -454,13 +430,13 @@ void ScriptEngine::stop() { void ScriptEngine::timerFired() { QTimer* callingTimer = reinterpret_cast(sender()); - + // call the associated JS function, if it exists QScriptValue timerFunction = _timerFunctionMap.value(callingTimer); if (timerFunction.isValid()) { timerFunction.call(); } - + if (!callingTimer->isActive()) { // this timer is done, we can kill it delete callingTimer; @@ -471,14 +447,14 @@ QObject* ScriptEngine::setupTimerWithInterval(const QScriptValue& function, int // create the timer, add it to the map, and start it QTimer* newTimer = new QTimer(this); newTimer->setSingleShot(isSingleShot); - + connect(newTimer, &QTimer::timeout, this, &ScriptEngine::timerFired); - + // make sure the timer stops when the script does connect(this, &ScriptEngine::scriptEnding, newTimer, &QTimer::stop); - + _timerFunctionMap.insert(newTimer, function); - + newTimer->start(intervalMS); return newTimer; } @@ -505,17 +481,17 @@ QUrl ScriptEngine::resolveInclude(const QString& include) const { if (!url.scheme().isEmpty()) { return url; } - - // we apparently weren't a fully qualified url, so, let's assume we're relative + + // we apparently weren't a fully qualified url, so, let's assume we're relative // to the original URL of our script QUrl parentURL(_fileNameString); - + // if the parent URL's scheme is empty, then this is probably a local file... if (parentURL.scheme().isEmpty()) { parentURL = QUrl::fromLocalFile(_fileNameString); } - - // at this point we should have a legitimate fully qualified URL for our parent + + // at this point we should have a legitimate fully qualified URL for our parent url = parentURL.resolved(url); return url; } @@ -543,7 +519,7 @@ void ScriptEngine::include(const QString& includeFile) { loop.exec(); includeContents = reply->readAll(); } - + QScriptValue result = _engine.evaluate(includeContents); if (_engine.hasUncaughtException()) { int line = _engine.uncaughtExceptionLineNumber(); diff --git a/libraries/script-engine/src/ScriptEngine.h b/libraries/script-engine/src/ScriptEngine.h index 4fc90d2959..9719c83107 100644 --- a/libraries/script-engine/src/ScriptEngine.h +++ b/libraries/script-engine/src/ScriptEngine.h @@ -1,13 +1,16 @@ // // ScriptEngine.h -// hifi +// libraries/script-engine/src // // Created by Brad Hefta-Gaub on 12/14/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__ScriptEngine__ -#define __hifi__ScriptEngine__ +#ifndef hifi_ScriptEngine_h +#define hifi_ScriptEngine_h #include @@ -22,6 +25,7 @@ #include "AbstractControllerScriptingInterface.h" #include "Quat.h" +#include "ScriptUUID.h" #include "Vec3.h" class ParticlesScriptingInterface; @@ -33,11 +37,11 @@ const unsigned int SCRIPT_DATA_CALLBACK_USECS = floor(((1.0 / 60.0f) * 1000 * 10 class ScriptEngine : public QObject { Q_OBJECT public: - ScriptEngine(const QUrl& scriptURL, bool wantMenuItems = false, + ScriptEngine(const QUrl& scriptURL, AbstractControllerScriptingInterface* controllerScriptingInterface = NULL); - ScriptEngine(const QString& scriptContents = NO_SCRIPT, bool wantMenuItems = false, - const QString& fileNameString = QString(""), + ScriptEngine(const QString& scriptContents = NO_SCRIPT, + const QString& fileNameString = QString(""), AbstractControllerScriptingInterface* controllerScriptingInterface = NULL); /// Access the VoxelsScriptingInterface in order to initialize it with a custom packet sender and jurisdiction listener @@ -49,39 +53,39 @@ public: /// sets the script contents, will return false if failed, will fail if script is already running bool setScriptContents(const QString& scriptContents, const QString& fileNameString = QString("")); - const QString& getScriptMenuName() const { return _scriptMenuName; } + const QString& getScriptName() const { return _scriptName; } void cleanupMenuItems(); void registerGlobalObject(const QString& name, QObject* object); /// registers a global object by name - + Q_INVOKABLE void setIsAvatar(bool isAvatar); bool isAvatar() const { return _isAvatar; } - + void setAvatarData(AvatarData* avatarData, const QString& objectName); - + bool isListeningToAudioStream() const { return _isListeningToAudioStream; } void setIsListeningToAudioStream(bool isListeningToAudioStream) { _isListeningToAudioStream = isListeningToAudioStream; } - + void setAvatarSound(Sound* avatarSound) { _avatarSound = avatarSound; } bool isPlayingAvatarSound() const { return _avatarSound != NULL; } - + void init(); void run(); /// runs continuously until Agent.stop() is called void evaluate(); /// initializes the engine, and evaluates the script, but then returns control to caller - + void timerFired(); bool hasScript() const { return !_scriptContents.isEmpty(); } public slots: void stop(); - + QObject* setInterval(const QScriptValue& function, int intervalMS); QObject* setTimeout(const QScriptValue& function, int timeoutMS); void clearInterval(QObject* timer) { stopTimer(reinterpret_cast(timer)); } void clearTimeout(QObject* timer) { stopTimer(reinterpret_cast(timer)); } void include(const QString& includeFile); - + signals: void update(float deltaTime); void scriptEnding(); @@ -106,22 +110,21 @@ private: QUrl resolveInclude(const QString& include) const; void sendAvatarIdentityPacket(); void sendAvatarBillboardPacket(); - + QObject* setupTimerWithInterval(const QScriptValue& function, int intervalMS, bool isSingleShot); void stopTimer(QTimer* timer); - + static VoxelsScriptingInterface _voxelsScriptingInterface; static ParticlesScriptingInterface _particlesScriptingInterface; - static int _scriptNumber; - + AbstractControllerScriptingInterface* _controllerScriptingInterface; AudioScriptingInterface _audioScriptingInterface; AvatarData* _avatarData; - bool _wantMenuItems; - QString _scriptMenuName; + QString _scriptName; QString _fileNameString; Quat _quatLibrary; Vec3 _vec3Library; + ScriptUUID _uuidLibrary; }; -#endif /* defined(__hifi__ScriptEngine__) */ +#endif // hifi_ScriptEngine_h diff --git a/libraries/script-engine/src/ScriptUUID.cpp b/libraries/script-engine/src/ScriptUUID.cpp new file mode 100644 index 0000000000..9e00f9c095 --- /dev/null +++ b/libraries/script-engine/src/ScriptUUID.cpp @@ -0,0 +1,40 @@ +// +// ScriptUUID.cpp +// libraries/script-engine/src/ +// +// Created by Andrew Meadows on 2014-04-07 +// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// +// Scriptable interface for a UUID helper class object. Used exclusively in the JavaScript API +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include + +#include "ScriptUUID.h" + +QUuid ScriptUUID::fromString(const QString& s) { + return QUuid(s); +} + +QString ScriptUUID::toString(const QUuid& id) { + return id.toString(); +} + +QUuid ScriptUUID::generate() { + return QUuid::createUuid(); +} + +bool ScriptUUID::isEqual(const QUuid& idA, const QUuid& idB) { + return idA == idB; +} + +bool ScriptUUID::isNull(const QUuid& id) { + return id.isNull(); +} + +void ScriptUUID::print(const QString& lable, const QUuid& id) { + qDebug() << qPrintable(lable) << id.toString(); +} diff --git a/libraries/script-engine/src/ScriptUUID.h b/libraries/script-engine/src/ScriptUUID.h new file mode 100644 index 0000000000..db94b5082b --- /dev/null +++ b/libraries/script-engine/src/ScriptUUID.h @@ -0,0 +1,32 @@ +// +// ScriptUUID.h +// libraries/script-engine/src/ +// +// Created by Andrew Meadows on 2014-04-07 +// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// +// Scriptable interface for a UUID helper class object. Used exclusively in the JavaScript API +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_ScriptUUID_h +#define hifi_ScriptUUID_h + +#include + +/// Scriptable interface for a UUID helper class object. Used exclusively in the JavaScript API +class ScriptUUID : public QObject { + Q_OBJECT + +public slots: + QUuid fromString(const QString& string); + QString toString(const QUuid& id); + QUuid generate(); + bool isEqual(const QUuid& idA, const QUuid& idB); + bool isNull(const QUuid& id); + void print(const QString& lable, const QUuid& id); +}; + +#endif // hifi_ScriptUUID_h diff --git a/libraries/script-engine/src/Vec3.cpp b/libraries/script-engine/src/Vec3.cpp index dc5dcd9773..bab529df1f 100644 --- a/libraries/script-engine/src/Vec3.cpp +++ b/libraries/script-engine/src/Vec3.cpp @@ -1,12 +1,12 @@ // // Vec3.cpp -// hifi +// libraries/script-engine/src // -// Created by Brad Hefta-Gaub on 1/29/14 -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. -// -// Scriptable Vec3 class library. +// Created by Brad Hefta-Gaub on 1/29/14. +// Copyright 2014 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/script-engine/src/Vec3.h b/libraries/script-engine/src/Vec3.h index cbec55b992..b30e274d89 100644 --- a/libraries/script-engine/src/Vec3.h +++ b/libraries/script-engine/src/Vec3.h @@ -1,16 +1,18 @@ // // Vec3.h -// hifi +// libraries/script-engine/src // -// Created by Brad Hefta-Gaub on 1/29/14 -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 1/29/14. +// Copyright 2014 High Fidelity, Inc. // // Scriptable Vec3 class library. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__Vec3__ -#define __hifi__Vec3__ +#ifndef hifi_Vec3_h +#define hifi_Vec3_h #include #include @@ -35,4 +37,4 @@ public slots: -#endif /* defined(__hifi__Vec3__) */ +#endif // hifi_Vec3_h diff --git a/libraries/shared/src/AccountManager.cpp b/libraries/shared/src/AccountManager.cpp index 955ba779d1..6c0bcb33cb 100644 --- a/libraries/shared/src/AccountManager.cpp +++ b/libraries/shared/src/AccountManager.cpp @@ -1,9 +1,12 @@ // // AccountManager.cpp -// hifi +// libraries/shared/src // // Created by Stephen Birarda on 2/18/2014. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include @@ -34,6 +37,16 @@ Q_DECLARE_METATYPE(JSONCallbackParameters) const QString ACCOUNTS_GROUP = "accounts"; +JSONCallbackParameters::JSONCallbackParameters() : + jsonCallbackReceiver(NULL), + jsonCallbackMethod(), + errorCallbackReceiver(NULL), + errorCallbackMethod(), + updateReciever(NULL), + updateSlot() +{ +} + AccountManager::AccountManager() : _authURL(), _networkAccessManager(NULL), @@ -170,18 +183,31 @@ void AccountManager::invokedRequest(const QString& path, QNetworkAccessManager:: if (!callbackParams.isEmpty()) { // if we have information for a callback, insert the callbackParams into our local map _pendingCallbackMap.insert(networkReply, callbackParams); + + if (callbackParams.updateReciever && !callbackParams.updateSlot.isEmpty()) { + callbackParams.updateReciever->connect(networkReply, SIGNAL(uploadProgress(qint64, qint64)), + callbackParams.updateSlot.toStdString().c_str()); + } } // if we ended up firing of a request, hook up to it now - connect(networkReply, SIGNAL(finished()), this, SLOT(passSuccessToCallback())); - connect(networkReply, SIGNAL(error(QNetworkReply::NetworkError)), - this, SLOT(passErrorToCallback(QNetworkReply::NetworkError))); + connect(networkReply, SIGNAL(finished()), SLOT(processReply())); } } } -void AccountManager::passSuccessToCallback() { +void AccountManager::processReply() { QNetworkReply* requestReply = reinterpret_cast(sender()); + + if (requestReply->error() == QNetworkReply::NoError) { + passSuccessToCallback(requestReply); + } else { + passErrorToCallback(requestReply); + } + delete requestReply; +} + +void AccountManager::passSuccessToCallback(QNetworkReply* requestReply) { QJsonDocument jsonResponse = QJsonDocument::fromJson(requestReply->readAll()); JSONCallbackParameters callbackParams = _pendingCallbackMap.value(requestReply); @@ -200,17 +226,15 @@ void AccountManager::passSuccessToCallback() { qDebug() << jsonResponse; } } - delete requestReply; } -void AccountManager::passErrorToCallback(QNetworkReply::NetworkError errorCode) { - QNetworkReply* requestReply = reinterpret_cast(sender()); +void AccountManager::passErrorToCallback(QNetworkReply* requestReply) { JSONCallbackParameters callbackParams = _pendingCallbackMap.value(requestReply); if (callbackParams.errorCallbackReceiver) { // invoke the right method on the callback receiver QMetaObject::invokeMethod(callbackParams.errorCallbackReceiver, qPrintable(callbackParams.errorCallbackMethod), - Q_ARG(QNetworkReply::NetworkError, errorCode), + Q_ARG(QNetworkReply::NetworkError, requestReply->error()), Q_ARG(const QString&, requestReply->errorString())); // remove the related reply-callback group from the map @@ -218,10 +242,9 @@ void AccountManager::passErrorToCallback(QNetworkReply::NetworkError errorCode) } else { if (VERBOSE_HTTP_REQUEST_DEBUGGING) { qDebug() << "Received error response from data-server that has no matching callback."; - qDebug() << "Error" << errorCode << "-" << requestReply->errorString(); + qDebug() << "Error" << requestReply->error() << "-" << requestReply->errorString(); } } - delete requestReply; } bool AccountManager::hasValidAccessToken() { diff --git a/libraries/shared/src/AccountManager.h b/libraries/shared/src/AccountManager.h index bfe84f392e..fed6a61772 100644 --- a/libraries/shared/src/AccountManager.h +++ b/libraries/shared/src/AccountManager.h @@ -1,13 +1,16 @@ // // AccountManager.h -// hifi +// libraries/shared/src // // Created by Stephen Birarda on 2/18/2014. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__AccountManager__ -#define __hifi__AccountManager__ +#ifndef hifi_AccountManager_h +#define hifi_AccountManager_h #include #include @@ -19,9 +22,7 @@ class JSONCallbackParameters { public: - JSONCallbackParameters() : - jsonCallbackReceiver(NULL), jsonCallbackMethod(), - errorCallbackReceiver(NULL), errorCallbackMethod() {}; + JSONCallbackParameters(); bool isEmpty() const { return !jsonCallbackReceiver && !errorCallbackReceiver; } @@ -29,6 +30,8 @@ public: QString jsonCallbackMethod; QObject* errorCallbackReceiver; QString errorCallbackMethod; + QObject* updateReciever; + QString updateSlot; }; class AccountManager : public QObject { @@ -70,13 +73,15 @@ signals: void loginComplete(const QUrl& authURL); void logoutComplete(); private slots: - void passSuccessToCallback(); - void passErrorToCallback(QNetworkReply::NetworkError errorCode); + void processReply(); private: AccountManager(); AccountManager(AccountManager const& other); // not implemented void operator=(AccountManager const& other); // not implemented + void passSuccessToCallback(QNetworkReply* reply); + void passErrorToCallback(QNetworkReply* reply); + Q_INVOKABLE void invokedRequest(const QString& path, QNetworkAccessManager::Operation operation, const JSONCallbackParameters& callbackParams, const QByteArray& dataByteArray, @@ -89,4 +94,4 @@ private: DataServerAccountInfo _accountInfo; }; -#endif /* defined(__hifi__AccountManager__) */ +#endif // hifi_AccountManager_h diff --git a/libraries/shared/src/AngleUtil.h b/libraries/shared/src/AngleUtil.h index cecee31188..d700e41f3d 100644 --- a/libraries/shared/src/AngleUtil.h +++ b/libraries/shared/src/AngleUtil.h @@ -1,13 +1,16 @@ // -// AngleUtils.h -// hifi +// AngleUtil.h +// libraries/shared/src // -// Created by Tobias Schwinger on 3/23/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Tobias Schwinger on 3/23/13. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__AngleUtils__ -#define __hifi__AngleUtils__ +#ifndef hifi_AngleUtil_h +#define hifi_AngleUtil_h #include @@ -95,5 +98,4 @@ void angleHorizontalPolar(float& azimuth, float& altitude) { azimuth = angleUnsignedNormal(azimuth); } -#endif - +#endif // hifi_AngleUtil_h diff --git a/libraries/shared/src/Assignment.cpp b/libraries/shared/src/Assignment.cpp index 992ec96a67..4d6740b400 100644 --- a/libraries/shared/src/Assignment.cpp +++ b/libraries/shared/src/Assignment.cpp @@ -1,9 +1,12 @@ // // Assignment.cpp -// hifi +// libraries/shared/src // // Created by Stephen Birarda on 8/22/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "PacketHeaders.h" diff --git a/libraries/shared/src/Assignment.h b/libraries/shared/src/Assignment.h index a8ab3be4a8..c5a83cf417 100644 --- a/libraries/shared/src/Assignment.h +++ b/libraries/shared/src/Assignment.h @@ -1,13 +1,16 @@ // // Assignment.h -// hifi +// libraries/shared/src // // Created by Stephen Birarda on 8/22/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__Assignment__ -#define __hifi__Assignment__ +#ifndef hifi_Assignment_h +#define hifi_Assignment_h #ifdef _WIN32 #include "Systime.h" @@ -98,4 +101,4 @@ protected: QByteArray _payload; /// an optional payload attached to this assignment, a maximum for 1024 bytes will be packed }; -#endif /* defined(__hifi__Assignment__) */ +#endif // hifi_Assignment_h diff --git a/libraries/shared/src/CapsuleShape.cpp b/libraries/shared/src/CapsuleShape.cpp index bae5f201ca..5055b3636e 100644 --- a/libraries/shared/src/CapsuleShape.cpp +++ b/libraries/shared/src/CapsuleShape.cpp @@ -1,9 +1,12 @@ // // CapsuleShape.cpp -// hifi +// libraries/shared/src // -// Created by Andrew Meadows on 2014.02.20 -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Created by Andrew Meadows on 02/20/2014. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include @@ -14,9 +17,9 @@ // default axis of CapsuleShape is Y-axis -const glm::vec3 localAxis(0.f, 1.f, 0.f); +const glm::vec3 localAxis(0.0f, 1.0f, 0.0f); -CapsuleShape::CapsuleShape() : Shape(Shape::CAPSULE_SHAPE) {} +CapsuleShape::CapsuleShape() : Shape(Shape::CAPSULE_SHAPE), _radius(0.0f), _halfHeight(0.0f) {} CapsuleShape::CapsuleShape(float radius, float halfHeight) : Shape(Shape::CAPSULE_SHAPE), _radius(radius), _halfHeight(halfHeight) { @@ -29,13 +32,13 @@ CapsuleShape::CapsuleShape(float radius, float halfHeight, const glm::vec3& posi } CapsuleShape::CapsuleShape(float radius, const glm::vec3& startPoint, const glm::vec3& endPoint) : - Shape(Shape::CAPSULE_SHAPE), _radius(radius), _halfHeight(0.f) { + Shape(Shape::CAPSULE_SHAPE), _radius(radius), _halfHeight(0.0f) { glm::vec3 axis = endPoint - startPoint; float height = glm::length(axis); if (height > EPSILON) { _halfHeight = 0.5f * height; axis /= height; - glm::vec3 yAxis(0.f, 1.f, 0.f); + glm::vec3 yAxis(0.0f, 1.0f, 0.0f); float angle = glm::angle(axis, yAxis); if (angle > EPSILON) { axis = glm::normalize(glm::cross(yAxis, axis)); @@ -47,17 +50,17 @@ CapsuleShape::CapsuleShape(float radius, const glm::vec3& startPoint, const glm: /// \param[out] startPoint is the center of start cap void CapsuleShape::getStartPoint(glm::vec3& startPoint) const { - startPoint = getPosition() - _rotation * glm::vec3(0.f, _halfHeight, 0.f); + startPoint = getPosition() - _rotation * glm::vec3(0.0f, _halfHeight, 0.0f); } /// \param[out] endPoint is the center of the end cap void CapsuleShape::getEndPoint(glm::vec3& endPoint) const { - endPoint = getPosition() + _rotation * glm::vec3(0.f, _halfHeight, 0.f); + endPoint = getPosition() + _rotation * glm::vec3(0.0f, _halfHeight, 0.0f); } void CapsuleShape::computeNormalizedAxis(glm::vec3& axis) const { // default axis of a capsule is along the yAxis - axis = _rotation * glm::vec3(0.f, 1.f, 0.f); + axis = _rotation * glm::vec3(0.0f, 1.0f, 0.0f); } void CapsuleShape::setRadius(float radius) { diff --git a/libraries/shared/src/CapsuleShape.h b/libraries/shared/src/CapsuleShape.h index 6d7e0a50be..9421bf1789 100644 --- a/libraries/shared/src/CapsuleShape.h +++ b/libraries/shared/src/CapsuleShape.h @@ -1,13 +1,16 @@ // // CapsuleShape.h -// hifi +// libraries/shared/src // -// Created by Andrew Meadows on 2014.02.20 -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Created by Andrew Meadows on 02/20/2014. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__CapsuleShape__ -#define __hifi__CapsuleShape__ +#ifndef hifi_CapsuleShape_h +#define hifi_CapsuleShape_h #include "Shape.h" @@ -43,4 +46,4 @@ protected: float _halfHeight; }; -#endif /* defined(__hifi__CapsuleShape__) */ +#endif // hifi_CapsuleShape_h diff --git a/libraries/shared/src/CollisionInfo.cpp b/libraries/shared/src/CollisionInfo.cpp index f6c0d057a1..5a4188a1ef 100644 --- a/libraries/shared/src/CollisionInfo.cpp +++ b/libraries/shared/src/CollisionInfo.cpp @@ -1,9 +1,12 @@ // // CollisionInfo.cpp -// hifi +// libraries/shared/src // -// Created by Andrew Meadows on 2014.02.14 -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Created by Andrew Meadows on 02/14/2014. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "CollisionInfo.h" diff --git a/libraries/shared/src/CollisionInfo.h b/libraries/shared/src/CollisionInfo.h index 868d259ce3..f575dd8595 100644 --- a/libraries/shared/src/CollisionInfo.h +++ b/libraries/shared/src/CollisionInfo.h @@ -1,13 +1,16 @@ // // CollisionInfo.h -// hifi +// libraries/shared/src // -// Created by Andrew Meadows on 2014.01.13 -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Created by Andrew Meadows on 02/14/2014. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__CollisionInfo__ -#define __hifi__CollisionInfo__ +#ifndef hifi_CollisionInfo_h +#define hifi_CollisionInfo_h #include #include @@ -98,4 +101,4 @@ private: QVector _collisions; }; -#endif /* defined(__hifi__CollisionInfo__) */ +#endif // hifi_CollisionInfo_h diff --git a/libraries/shared/src/DataServerAccountInfo.cpp b/libraries/shared/src/DataServerAccountInfo.cpp index 1884517515..1c53bca30f 100644 --- a/libraries/shared/src/DataServerAccountInfo.cpp +++ b/libraries/shared/src/DataServerAccountInfo.cpp @@ -1,9 +1,12 @@ // // DataServerAccountInfo.cpp -// hifi +// libraries/shared/src // // Created by Stephen Birarda on 2/18/2014. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/shared/src/DataServerAccountInfo.h b/libraries/shared/src/DataServerAccountInfo.h index c840468319..ae5de6de64 100644 --- a/libraries/shared/src/DataServerAccountInfo.h +++ b/libraries/shared/src/DataServerAccountInfo.h @@ -1,13 +1,16 @@ // // DataServerAccountInfo.h -// hifi +// libraries/shared/src // // Created by Stephen Birarda on 2/21/2014. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__DataServerAccountInfo__ -#define __hifi__DataServerAccountInfo__ +#ifndef hifi_DataServerAccountInfo_h +#define hifi_DataServerAccountInfo_h #include @@ -39,4 +42,4 @@ private: QString _xmppPassword; }; -#endif /* defined(__hifi__DataServerAccountInfo__) */ +#endif // hifi_DataServerAccountInfo_h diff --git a/libraries/shared/src/DomainInfo.cpp b/libraries/shared/src/DomainInfo.cpp index bed638bf59..34498f4c50 100644 --- a/libraries/shared/src/DomainInfo.cpp +++ b/libraries/shared/src/DomainInfo.cpp @@ -1,9 +1,12 @@ // // DomainInfo.cpp -// hifi +// libraries/shared/src // // Created by Stephen Birarda on 2/18/2014. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/shared/src/DomainInfo.h b/libraries/shared/src/DomainInfo.h index da65525f9d..b52b2f71c3 100644 --- a/libraries/shared/src/DomainInfo.h +++ b/libraries/shared/src/DomainInfo.h @@ -1,13 +1,16 @@ // // DomainInfo.h -// hifi +// libraries/shared/src // // Created by Stephen Birarda on 2/18/2014. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__DomainInfo__ -#define __hifi__DomainInfo__ +#ifndef hifi_DomainInfo_h +#define hifi_DomainInfo_h #include #include @@ -77,4 +80,4 @@ private: bool _isConnected; }; -#endif /* defined(__hifi__DomainInfo__) */ +#endif // hifi_DomainInfo_h diff --git a/libraries/shared/src/FileDownloader.cpp b/libraries/shared/src/FileDownloader.cpp deleted file mode 100644 index 2b65bbd8df..0000000000 --- a/libraries/shared/src/FileDownloader.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// -// FileDownloader.cpp -// hifi -// -// Created by Clement Brisset on 3/14/14. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. -// -// - -#include -#include -#include -#include - -#include "FileDownloader.h" - -FileDownloader::FileDownloader(const QUrl dataURL, QObject* parent) : - QObject(parent), - _done(false) -{ - connect(&_networkAccessManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(processReply(QNetworkReply*))); - - QNetworkRequest request(dataURL); - _networkAccessManager.get(request); -} - -void FileDownloader::processReply(QNetworkReply *reply) { - if (reply->error() == QNetworkReply::NoError) { - _downloadedData = reply->readAll(); - } - - reply->deleteLater(); - _done = true; - emit done(reply->error()); -} - -void FileDownloader::waitForFile(int timeout) { - QTimer timer; - QEventLoop loop; - connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); - connect(this, SIGNAL(done(QNetworkReply::NetworkError)), &loop, SLOT(quit())); - - if (!_done) { - if (timeout > 0) { - timer.start(timeout); - } - loop.exec(); - } -} - -QByteArray FileDownloader::download(const QUrl dataURL, int timeout) { - QTimer timer; - QEventLoop loop; - connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit)); - - FileDownloader downloader(dataURL); - connect(&downloader, SIGNAL(done(QNetworkReply::NetworkError)), &loop, SLOT(quit())); - - if (timeout > 0) { - timer.start(timeout); - } - loop.exec(); - - return downloader.getData(); -} \ No newline at end of file diff --git a/libraries/shared/src/FileDownloader.h b/libraries/shared/src/FileDownloader.h deleted file mode 100644 index 593b39b013..0000000000 --- a/libraries/shared/src/FileDownloader.h +++ /dev/null @@ -1,44 +0,0 @@ -// -// FileDownloader.h -// hifi -// -// Created by Clement Brisset on 3/14/14. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. -// -// - -#ifndef __hifi__FileDownloader__ -#define __hifi__FileDownloader__ - -#include -#include -#include - -class FileDownloader : public QObject { - Q_OBJECT - -public: - FileDownloader(const QUrl dataURL, QObject* parent = NULL); - - void waitForFile(int timeout = 0); - - QByteArray getData() const { return _downloadedData; } - bool done() { return _done; } - - static QByteArray download(const QUrl dataURL, int timeout = 0); - -signals: - void done(QNetworkReply::NetworkError error); - -private slots: - void processReply(QNetworkReply* reply); - -private: - QNetworkAccessManager _networkAccessManager; - QByteArray _downloadedData; - - bool _done; -}; - - -#endif /* defined(__hifi__FileDownloader__) */ diff --git a/libraries/shared/src/FileUtils.cpp b/libraries/shared/src/FileUtils.cpp index efbe1a189b..b890717a66 100644 --- a/libraries/shared/src/FileUtils.cpp +++ b/libraries/shared/src/FileUtils.cpp @@ -1,9 +1,12 @@ // // FileUtils.cpp -// hifi +// libraries/shared/src // // Created by Stojce Slavkovski on 12/23/13. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "FileUtils.h" diff --git a/libraries/shared/src/FileUtils.h b/libraries/shared/src/FileUtils.h index dd4605218e..8b31d1473b 100644 --- a/libraries/shared/src/FileUtils.h +++ b/libraries/shared/src/FileUtils.h @@ -1,9 +1,12 @@ // // FileUtils.h -// hifi +// libraries/shared/src // // Created by Stojce Slavkovski on 12/23/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #ifndef hifi_FileUtils_h @@ -19,4 +22,4 @@ public: }; -#endif +#endif // hifi_FileUtils_h diff --git a/libraries/shared/src/FloodFill.h b/libraries/shared/src/FloodFill.h index 40a89bfd1b..cd77534697 100644 --- a/libraries/shared/src/FloodFill.h +++ b/libraries/shared/src/FloodFill.h @@ -1,13 +1,15 @@ // // FloodFill.h -// hifi +// libraries/shared/src // -// Created by Tobias Schwinger 3/26/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__FloodFill__ -#define __hifi__FloodFill__ +#ifndef hifi_FloodFill_h +#define hifi_FloodFill_h // // Line scanning, iterative flood fill algorithm. @@ -104,5 +106,4 @@ void floodFill(Cursor const& p, Strategy const& s) { } -#endif /* defined(__hifi__FloodFill__) */ - +#endif // hifi_FloodFill_h diff --git a/libraries/shared/src/FstReader.cpp b/libraries/shared/src/FstReader.cpp deleted file mode 100644 index 14cff957b1..0000000000 --- a/libraries/shared/src/FstReader.cpp +++ /dev/null @@ -1,277 +0,0 @@ -// -// FstReader.cpp -// hifi -// -// Created by Clément Brisset on 3/4/14. -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. -// -// - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "AccountManager.h" -#include "FstReader.h" - - -static const QString NAME_FIELD = "name"; -static const QString FILENAME_FIELD = "filename"; -static const QString TEXDIR_FIELD = "texdir"; -static const QString LOD_FIELD = "lod"; - -static const QString MODEL_URL = "/api/v1/models"; - -static const int MAX_SIZE = 10 * 1024 * 1024; // 10 MB - -// Class providing the QObject parent system to QTemporaryDir -class TemporaryDir : public QTemporaryDir, public QObject { -public: - virtual ~TemporaryDir() { - // ensuring the entire object gets deleted by the QObject parent. - } -}; - -FstReader::FstReader(bool isHead) : - _zipDir(new TemporaryDir()), - _lodCount(-1), - _texturesCount(-1), - _totalSize(0), - _isHead(isHead), - _readyToSend(false), - _dataMultiPart(new QHttpMultiPart(QHttpMultiPart::FormDataType)) -{ - _zipDir->setParent(_dataMultiPart); - -} - -FstReader::~FstReader() { - delete _dataMultiPart; -} - -bool FstReader::zip() { - // File Dialog - QString filename = QFileDialog::getOpenFileName(NULL, - "Select your .fst file ...", - QStandardPaths::writableLocation(QStandardPaths::DownloadLocation), - "*.fst"); - if (filename == "") { - // If the user canceled we return. - return false; - } - - // First we check the FST file - QFile fst(filename); - if (!fst.open(QFile::ReadOnly | QFile::Text)) { - QMessageBox::warning(NULL, - QString("ModelUploader::zip()"), - QString("Could not open FST file."), - QMessageBox::Ok); - qDebug() << "[Warning] " << QString("Could not open FST file."); - return false; - } - qDebug() << "Reading FST file : " << QFileInfo(fst).filePath(); - - // Compress and copy the fst - if (!compressFile(QFileInfo(fst).filePath(), _zipDir->path() + "/" + QFileInfo(fst).fileName())) { - return false; - } - if (!addPart(_zipDir->path() + "/" + QFileInfo(fst).fileName(), - QString("fst"))) { - return false; - } - - // Let's read through the FST file - QTextStream stream(&fst); - QList line; - while (!stream.atEnd()) { - line = stream.readLine().split(QRegExp("[ =]"), QString::SkipEmptyParts); - if (line.isEmpty()) { - continue; - } - - // according to what is read, we modify the command - if (line[0] == NAME_FIELD) { - QHttpPart textPart; - textPart.setHeader(QNetworkRequest::ContentDispositionHeader, "form-data;" - " name=\"model_name\""); - textPart.setBody(line[1].toUtf8()); - _dataMultiPart->append(textPart); - } else if (line[0] == FILENAME_FIELD) { - QFileInfo fbx(QFileInfo(fst).path() + "/" + line[1]); - if (!fbx.exists() || !fbx.isFile()) { // Check existence - QMessageBox::warning(NULL, - QString("ModelUploader::zip()"), - QString("FBX file %1 could not be found.").arg(fbx.fileName()), - QMessageBox::Ok); - qDebug() << "[Warning] " << QString("FBX file %1 could not be found.").arg(fbx.fileName()); - return false; - } - // Compress and copy - if (!compressFile(fbx.filePath(), _zipDir->path() + "/" + line[1])) { - return false; - } - if (!addPart(_zipDir->path() + "/" + line[1], "fbx")) { - return false; - } - } else if (line[0] == TEXDIR_FIELD) { // Check existence - QFileInfo texdir(QFileInfo(fst).path() + "/" + line[1]); - if (!texdir.exists() || !texdir.isDir()) { - QMessageBox::warning(NULL, - QString("ModelUploader::zip()"), - QString("Texture directory could not be found."), - QMessageBox::Ok); - qDebug() << "[Warning] " << QString("Texture directory could not be found."); - return false; - } - if (!addTextures(texdir)) { // Recursive compress and copy - return false; - } - } else if (line[0] == LOD_FIELD) { - QFileInfo lod(QFileInfo(fst).path() + "/" + line[1]); - if (!lod.exists() || !lod.isFile()) { // Check existence - QMessageBox::warning(NULL, - QString("ModelUploader::zip()"), - QString("FBX file %1 could not be found.").arg(lod.fileName()), - QMessageBox::Ok); - qDebug() << "[Warning] " << QString("FBX file %1 could not be found.").arg(lod.fileName()); - return false; - } - // Compress and copy - if (!compressFile(lod.filePath(), _zipDir->path() + "/" + line[1])) { - return false; - } - if (!addPart(_zipDir->path() + "/" + line[1], QString("lod%1").arg(++_lodCount))) { - return false; - } - } - } - - QHttpPart textPart; - textPart.setHeader(QNetworkRequest::ContentDispositionHeader, "form-data;" - " name=\"model_category\""); - if (_isHead) { - textPart.setBody("head"); - } else { - textPart.setBody("skeleton"); - } - _dataMultiPart->append(textPart); - - _readyToSend = true; - return true; -} - -bool FstReader::send() { - if (!_readyToSend) { - return false; - } - - AccountManager::getInstance().authenticatedRequest(MODEL_URL, QNetworkAccessManager::PostOperation, JSONCallbackParameters(), QByteArray(), _dataMultiPart); - _zipDir = NULL; - _dataMultiPart = NULL; - qDebug() << "Model sent."; - - return true; -} - -bool FstReader::addTextures(const QFileInfo& texdir) { - QStringList filter; - filter << "*.png" << "*.tif" << "*.jpg" << "*.jpeg"; - - QFileInfoList list = QDir(texdir.filePath()).entryInfoList(filter, - QDir::Files | - QDir::AllDirs | - QDir::NoDotAndDotDot | - QDir::NoSymLinks); - foreach (QFileInfo info, list) { - if (info.isFile()) { - // Compress and copy - if (!compressFile(info.filePath(), _zipDir->path() + "/" + info.fileName())) { - return false; - } - if (!addPart(_zipDir->path() + "/" + info.fileName(), - QString("texture%1").arg(++_texturesCount))) { - return false; - } - } else if (info.isDir()) { - if (!addTextures(info)) { - return false; - } - } - } - - return true; -} - -bool FstReader::compressFile(const QString &inFileName, const QString &outFileName) { - QFile inFile(inFileName); - inFile.open(QIODevice::ReadOnly); - QByteArray buffer = inFile.readAll(); - - QFile outFile(outFileName); - if (!outFile.open(QIODevice::WriteOnly)) { - QDir(_zipDir->path()).mkpath(QFileInfo(outFileName).path()); - if (!outFile.open(QIODevice::WriteOnly)) { - QMessageBox::warning(NULL, - QString("ModelUploader::compressFile()"), - QString("Could not compress %1").arg(inFileName), - QMessageBox::Ok); - qDebug() << "[Warning] " << QString("Could not compress %1").arg(inFileName); - return false; - } - } - QDataStream out(&outFile); - out << qCompress(buffer); - - return true; -} - - -bool FstReader::addPart(const QString &path, const QString& name) { - QFile* file = new QFile(path); - if (!file->open(QIODevice::ReadOnly)) { - QMessageBox::warning(NULL, - QString("ModelUploader::addPart()"), - QString("Could not open %1").arg(path), - QMessageBox::Ok); - qDebug() << "[Warning] " << QString("Could not open %1").arg(path); - delete file; - return false; - } - - QHttpPart part; - part.setHeader(QNetworkRequest::ContentDispositionHeader, "form-data;" - " name=\"" + name.toUtf8() + "\";" - " filename=\"" + QFileInfo(*file).fileName().toUtf8() + "\""); - part.setHeader(QNetworkRequest::ContentTypeHeader, "application/octet-stream"); - part.setBodyDevice(file); - _dataMultiPart->append(part); - file->setParent(_dataMultiPart); - - - qDebug() << "File " << QFileInfo(*file).fileName() << " added to model."; - _totalSize += file->size(); - if (_totalSize > MAX_SIZE) { - QMessageBox::warning(NULL, - QString("ModelUploader::zip()"), - QString("Model too big, over %1 Bytes.").arg(MAX_SIZE), - QMessageBox::Ok); - qDebug() << "[Warning] " << QString("Model too big, over %1 Bytes.").arg(MAX_SIZE); - return false; - } - qDebug() << "Current model size: " << _totalSize; - - return true; -} - - - - - - diff --git a/libraries/shared/src/FstReader.h b/libraries/shared/src/FstReader.h deleted file mode 100644 index 6d1cac01c4..0000000000 --- a/libraries/shared/src/FstReader.h +++ /dev/null @@ -1,40 +0,0 @@ -// -// FstReader.h -// hifi -// -// Created by Clément Brisset on 3/4/14. -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. -// -// - -#ifndef __hifi__FstReader__ -#define __hifi__FstReader__ - -class TemporaryDir; -class QHttpMultiPart; - -class FstReader : public QObject { -public: - FstReader(bool isHead); - ~FstReader(); - - bool zip(); - bool send(); - -private: - TemporaryDir* _zipDir; - int _lodCount; - int _texturesCount; - int _totalSize; - bool _isHead; - bool _readyToSend; - - QHttpMultiPart* _dataMultiPart; - - - bool addTextures(const QFileInfo& texdir); - bool compressFile(const QString& inFileName, const QString& outFileName); - bool addPart(const QString& path, const QString& name); -}; - -#endif /* defined(__hifi__FstReader__) */ diff --git a/libraries/shared/src/GenericThread.cpp b/libraries/shared/src/GenericThread.cpp index 59f2426bdb..4be253f045 100644 --- a/libraries/shared/src/GenericThread.cpp +++ b/libraries/shared/src/GenericThread.cpp @@ -1,11 +1,12 @@ // // GenericThread.cpp -// shared +// libraries/shared/src // // Created by Brad Hefta-Gaub on 8/12/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // -// Generic Threaded or non-threaded processing class +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/shared/src/GenericThread.h b/libraries/shared/src/GenericThread.h index 1b5b05db5d..bbb01894ed 100644 --- a/libraries/shared/src/GenericThread.h +++ b/libraries/shared/src/GenericThread.h @@ -1,15 +1,18 @@ // // GenericThread.h -// shared +// libraries/shared/src // // Created by Brad Hefta-Gaub on 8/12/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // // Generic Threaded or non-threaded processing class. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// -#ifndef __shared__GenericThread__ -#define __shared__GenericThread__ +#ifndef hifi_GenericThread_h +#define hifi_GenericThread_h #include #include @@ -62,4 +65,4 @@ private: QThread* _thread; }; -#endif // __shared__GenericThread__ +#endif // hifi_GenericThread_h diff --git a/libraries/shared/src/GeometryUtil.cpp b/libraries/shared/src/GeometryUtil.cpp index ac8e4e97c4..cb2e829811 100644 --- a/libraries/shared/src/GeometryUtil.cpp +++ b/libraries/shared/src/GeometryUtil.cpp @@ -1,9 +1,13 @@ // // GeometryUtil.cpp -// interface +// libraries/shared/src // // Created by Andrzej Kapolka on 5/21/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// #include #include @@ -462,4 +466,4 @@ void PolygonClip::copyCleanArray(int& lengthA, glm::vec2* vertexArrayA, int& len vertexArrayA[i] = vertexArrayB[i]; } } -} +} \ No newline at end of file diff --git a/libraries/shared/src/GeometryUtil.h b/libraries/shared/src/GeometryUtil.h index 12afc7c59c..b521a79771 100644 --- a/libraries/shared/src/GeometryUtil.h +++ b/libraries/shared/src/GeometryUtil.h @@ -1,13 +1,16 @@ // // GeometryUtil.h -// interface +// libraries/shared/src // // Created by Andrzej Kapolka on 5/21/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__GeometryUtil__ -#define __interface__GeometryUtil__ +#ifndef hifi_GeometryUtil_h +#define hifi_GeometryUtil_h #include @@ -112,4 +115,4 @@ private: }; -#endif /* defined(__interface__GeometryUtil__) */ +#endif // hifi_GeometryUtil_h diff --git a/libraries/shared/src/HifiSockAddr.cpp b/libraries/shared/src/HifiSockAddr.cpp index cc031525d8..25e9e5637b 100644 --- a/libraries/shared/src/HifiSockAddr.cpp +++ b/libraries/shared/src/HifiSockAddr.cpp @@ -1,9 +1,12 @@ // // HifiSockAddr.cpp -// hifi +// libraries/shared/src // // Created by Stephen Birarda on 11/26/2013. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "HifiSockAddr.h" diff --git a/libraries/shared/src/HifiSockAddr.h b/libraries/shared/src/HifiSockAddr.h index e8f928c36d..f44ebf6dbd 100644 --- a/libraries/shared/src/HifiSockAddr.h +++ b/libraries/shared/src/HifiSockAddr.h @@ -1,13 +1,16 @@ // // HifiSockAddr.h -// hifi +// libraries/shared/src // // Created by Stephen Birarda on 11/26/2013. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__HifiSockAddr__ -#define __hifi__HifiSockAddr__ +#ifndef hifi_HifiSockAddr_h +#define hifi_HifiSockAddr_h #include @@ -49,4 +52,4 @@ quint32 getHostOrderLocalAddress(); Q_DECLARE_METATYPE(HifiSockAddr) -#endif /* defined(__hifi__HifiSockAddr__) */ +#endif // hifi_HifiSockAddr_h diff --git a/libraries/shared/src/ListShape.cpp b/libraries/shared/src/ListShape.cpp index 593304c75a..dcea97826e 100644 --- a/libraries/shared/src/ListShape.cpp +++ b/libraries/shared/src/ListShape.cpp @@ -1,10 +1,12 @@ // // ListShape.cpp +// libraries/shared/src // -// ListShape: A collection of shapes, each with a local transform. +// Created by Andrew Meadows on 02/20/2014. +// Copyright 2014 High Fidelity, Inc. // -// Created by Andrew Meadows on 2014.02.20 -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "ListShape.h" diff --git a/libraries/shared/src/ListShape.h b/libraries/shared/src/ListShape.h index d6005ddfb9..7ba2410a23 100644 --- a/libraries/shared/src/ListShape.h +++ b/libraries/shared/src/ListShape.h @@ -1,14 +1,18 @@ // // ListShape.h +// libraries/shared/src +// +// Created by Andrew Meadows on 02/20/2014. +// Copyright 2014 High Fidelity, Inc. // // ListShape: A collection of shapes, each with a local transform. // -// Created by Andrew Meadows on 2014.02.20 -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__ListShape__ -#define __hifi__ListShape__ +#ifndef hifi_ListShape_h +#define hifi_ListShape_h #include @@ -62,4 +66,4 @@ private: ListShape(const ListShape& otherList); // don't implement this }; -#endif // __hifi__ListShape__ +#endif // hifi_ListShape_h diff --git a/libraries/shared/src/Logging.cpp b/libraries/shared/src/Logging.cpp index f0dcd7b67b..2625cc744a 100644 --- a/libraries/shared/src/Logging.cpp +++ b/libraries/shared/src/Logging.cpp @@ -1,9 +1,12 @@ // // Logging.cpp -// hifi +// libraries/shared/src // // Created by Stephen Birarda on 6/11/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/shared/src/Logging.h b/libraries/shared/src/Logging.h index abd5bfaab1..edbe8f62ee 100644 --- a/libraries/shared/src/Logging.h +++ b/libraries/shared/src/Logging.h @@ -1,13 +1,16 @@ // // Logging.h -// hifi +// libraries/shared/src // // Created by Stephen Birarda on 6/11/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__Logging__ -#define __hifi__Logging__ +#ifndef hifi_Logging_h +#define hifi_Logging_h #ifdef _WIN32 #include "Syssocket.h" @@ -54,4 +57,4 @@ private: static QString _targetName; }; -#endif /* defined(__hifi__Logstash__) */ +#endif // hifi_Logging_h diff --git a/libraries/shared/src/NetworkPacket.cpp b/libraries/shared/src/NetworkPacket.cpp index 1671dc2435..b948b10c96 100644 --- a/libraries/shared/src/NetworkPacket.cpp +++ b/libraries/shared/src/NetworkPacket.cpp @@ -1,11 +1,12 @@ // // NetworkPacket.cpp -// shared +// libraries/shared/src // // Created by Brad Hefta-Gaub on 8/9/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // -// A really simple class that stores a network packet between being received and being processed +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/shared/src/NetworkPacket.h b/libraries/shared/src/NetworkPacket.h index 0875b9f131..6c086e2f5a 100644 --- a/libraries/shared/src/NetworkPacket.h +++ b/libraries/shared/src/NetworkPacket.h @@ -1,15 +1,18 @@ // // NetworkPacket.h -// shared +// libraries/shared/src // // Created by Brad Hefta-Gaub on 8/9/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // // A really simple class that stores a network packet between being received and being processed // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// -#ifndef __shared_NetworkPacket__ -#define __shared_NetworkPacket__ +#ifndef hifi_NetworkPacket_h +#define hifi_NetworkPacket_h #include @@ -43,4 +46,4 @@ private: QByteArray _byteArray; }; -#endif /* defined(__shared_NetworkPacket__) */ +#endif // hifi_NetworkPacket_h diff --git a/libraries/shared/src/Node.cpp b/libraries/shared/src/Node.cpp index a4491fb707..13f700ad5a 100644 --- a/libraries/shared/src/Node.cpp +++ b/libraries/shared/src/Node.cpp @@ -1,9 +1,12 @@ // // Node.cpp -// hifi +// libraries/shared/src // // Created by Stephen Birarda on 2/15/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include @@ -19,6 +22,7 @@ #include "SharedUtil.h" #include +#include #include const QString UNKNOWN_NodeType_t_NAME = "Unknown"; @@ -47,7 +51,7 @@ const QString& NodeType::getNodeTypeName(NodeType_t nodeType) { Node::Node(const QUuid& uuid, char type, const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket) : _type(type), _uuid(uuid), - _wakeMicrostamp(usecTimestampNow()), + _wakeTimestamp(QDateTime::currentMSecsSinceEpoch()), _lastHeardMicrostamp(usecTimestampNow()), _publicSocket(publicSocket), _localSocket(localSocket), diff --git a/libraries/shared/src/Node.h b/libraries/shared/src/Node.h index 79d75629a6..e7ebbcfb13 100644 --- a/libraries/shared/src/Node.h +++ b/libraries/shared/src/Node.h @@ -1,13 +1,16 @@ // // Node.h -// hifi +// libraries/shared/src // // Created by Stephen Birarda on 2/15/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__Node__ -#define __hifi__Node__ +#ifndef hifi_Node_h +#define hifi_Node_h #include #include @@ -60,8 +63,8 @@ public: const QUuid& getUUID() const { return _uuid; } void setUUID(const QUuid& uuid) { _uuid = uuid; } - quint64 getWakeMicrostamp() const { return _wakeMicrostamp; } - void setWakeMicrostamp(quint64 wakeMicrostamp) { _wakeMicrostamp = wakeMicrostamp; } + quint64 getWakeTimestamp() const { return _wakeTimestamp; } + void setWakeTimestamp(quint64 wakeTimestamp) { _wakeTimestamp = wakeTimestamp; } quint64 getLastHeardMicrostamp() const { return _lastHeardMicrostamp; } void setLastHeardMicrostamp(quint64 lastHeardMicrostamp) { _lastHeardMicrostamp = lastHeardMicrostamp; } @@ -109,7 +112,7 @@ private: NodeType_t _type; QUuid _uuid; - quint64 _wakeMicrostamp; + quint64 _wakeTimestamp; quint64 _lastHeardMicrostamp; HifiSockAddr _publicSocket; HifiSockAddr _localSocket; @@ -126,4 +129,4 @@ private: QDebug operator<<(QDebug debug, const Node &message); -#endif /* defined(__hifi__Node__) */ +#endif // hifi_Node_h diff --git a/libraries/shared/src/NodeData.cpp b/libraries/shared/src/NodeData.cpp index e3800f8b93..6b71ef8f37 100644 --- a/libraries/shared/src/NodeData.cpp +++ b/libraries/shared/src/NodeData.cpp @@ -1,9 +1,12 @@ // // NodeData.cpp -// hifi +// libraries/shared/src // // Created by Stephen Birarda on 2/19/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "NodeData.h" @@ -16,4 +19,4 @@ NodeData::NodeData() : NodeData::~NodeData() { -} \ No newline at end of file +} diff --git a/libraries/shared/src/NodeData.h b/libraries/shared/src/NodeData.h index b6b75443a2..3b26d5b6d5 100644 --- a/libraries/shared/src/NodeData.h +++ b/libraries/shared/src/NodeData.h @@ -1,9 +1,12 @@ // // NodeData.h -// hifi +// libraries/shared/src // // Created by Stephen Birarda on 2/19/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #ifndef hifi_NodeData_h @@ -27,4 +30,4 @@ private: QMutex _mutex; }; -#endif +#endif // hifi_NodeData_h diff --git a/libraries/shared/src/NodeList.cpp b/libraries/shared/src/NodeList.cpp index b725914bfd..7ca6202398 100644 --- a/libraries/shared/src/NodeList.cpp +++ b/libraries/shared/src/NodeList.cpp @@ -1,9 +1,12 @@ // // NodeList.cpp -// hifi +// libraries/shared/src // // Created by Stephen Birarda on 2/15/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/shared/src/NodeList.h b/libraries/shared/src/NodeList.h index 34078b6a94..86c487e2d6 100644 --- a/libraries/shared/src/NodeList.h +++ b/libraries/shared/src/NodeList.h @@ -1,13 +1,16 @@ // // NodeList.h -// hifi +// libraries/shared/src // // Created by Stephen Birarda on 2/15/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__NodeList__ -#define __hifi__NodeList__ +#ifndef hifi_NodeList_h +#define hifi_NodeList_h #ifdef _WIN32 #include "Syssocket.h" @@ -180,4 +183,4 @@ private: QElapsedTimer _packetStatTimer; }; -#endif /* defined(__hifi__NodeList__) */ +#endif // hifi_NodeList_h diff --git a/libraries/shared/src/OAuthAccessToken.cpp b/libraries/shared/src/OAuthAccessToken.cpp index 20a9dc3aa5..ab5ec6462a 100644 --- a/libraries/shared/src/OAuthAccessToken.cpp +++ b/libraries/shared/src/OAuthAccessToken.cpp @@ -1,9 +1,12 @@ // // OAuthAccessToken.cpp -// hifi +// libraries/shared/src // // Created by Stephen Birarda on 2/18/2014. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/shared/src/OAuthAccessToken.h b/libraries/shared/src/OAuthAccessToken.h index e2a5eb4ce2..7f7c621231 100644 --- a/libraries/shared/src/OAuthAccessToken.h +++ b/libraries/shared/src/OAuthAccessToken.h @@ -1,13 +1,16 @@ // // OAuthAccessToken.h -// hifi +// libraries/shared/src // // Created by Stephen Birarda on 2/18/2014. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__OAuthAccessToken__ -#define __hifi__OAuthAccessToken__ +#ifndef hifi_OAuthAccessToken_h +#define hifi_OAuthAccessToken_h #include #include @@ -34,4 +37,4 @@ private: void swap(OAuthAccessToken& otherToken); }; -#endif /* defined(__hifi__OAuthAccessToken__) */ +#endif // hifi_OAuthAccessToken_h diff --git a/libraries/shared/src/OctalCode.cpp b/libraries/shared/src/OctalCode.cpp index ba0a001fb9..82bd471975 100644 --- a/libraries/shared/src/OctalCode.cpp +++ b/libraries/shared/src/OctalCode.cpp @@ -1,9 +1,12 @@ // // OctalCode.cpp -// hifi +// libraries/shared/src // // Created by Stephen Birarda on 3/15/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include // std:min diff --git a/libraries/shared/src/OctalCode.h b/libraries/shared/src/OctalCode.h index c80aa82a2d..07895ff67f 100644 --- a/libraries/shared/src/OctalCode.h +++ b/libraries/shared/src/OctalCode.h @@ -1,13 +1,16 @@ // // OctalCode.h -// hifi +// libraries/shared/src // // Created by Stephen Birarda on 3/15/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__OctalCode__ -#define __hifi__OctalCode__ +#ifndef hifi_OctalCode_h +#define hifi_OctalCode_h #include #include @@ -62,4 +65,4 @@ OctalCodeComparison compareOctalCodes(const unsigned char* code1, const unsigned QString octalCodeToHexString(const unsigned char* octalCode); unsigned char* hexStringToOctalCode(const QString& input); -#endif /* defined(__hifi__OctalCode__) */ +#endif // hifi_OctalCode_h diff --git a/libraries/shared/src/PacketHeaders.cpp b/libraries/shared/src/PacketHeaders.cpp index c7518708ce..2832fde56e 100644 --- a/libraries/shared/src/PacketHeaders.cpp +++ b/libraries/shared/src/PacketHeaders.cpp @@ -1,9 +1,12 @@ // // PacketHeaders.cpp -// hifi +// libraries/shared/src // // Created by Stephen Birarda on 6/28/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/shared/src/PacketHeaders.h b/libraries/shared/src/PacketHeaders.h index a9bc5d3763..3183e8f12d 100644 --- a/libraries/shared/src/PacketHeaders.h +++ b/libraries/shared/src/PacketHeaders.h @@ -1,13 +1,13 @@ // // PacketHeaders.h -// hifi +// libraries/shared/src // // Created by Stephen Birarda on 4/8/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -// The packet headers below refer to the first byte of a received UDP packet transmitted between -// any two Hifi components. For example, a packet whose first byte is 'P' is always a ping packet. -// #ifndef hifi_PacketHeaders_h #define hifi_PacketHeaders_h @@ -92,4 +92,4 @@ PacketType packetTypeForPacket(const char* packet); int arithmeticCodingValueFromBuffer(const char* checkValue); int numBytesArithmeticCodingFromBuffer(const char* checkValue); -#endif +#endif // hifi_PacketHeaders_h diff --git a/libraries/shared/src/PacketSender.cpp b/libraries/shared/src/PacketSender.cpp index 9fac115a39..489b083d92 100644 --- a/libraries/shared/src/PacketSender.cpp +++ b/libraries/shared/src/PacketSender.cpp @@ -1,11 +1,12 @@ // // PacketSender.cpp -// shared +// libraries/shared/src // // Created by Brad Hefta-Gaub on 8/12/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // -// Threaded or non-threaded packet sender. +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include @@ -281,4 +282,4 @@ bool PacketSender::nonThreadedProcess() { _lastSendTime = now; } return isStillRunning(); -} \ No newline at end of file +} diff --git a/libraries/shared/src/PacketSender.h b/libraries/shared/src/PacketSender.h index bd8de9a1b1..cc65564461 100644 --- a/libraries/shared/src/PacketSender.h +++ b/libraries/shared/src/PacketSender.h @@ -1,15 +1,18 @@ // // PacketSender.h -// shared +// libraries/shared/src // // Created by Brad Hefta-Gaub on 8/12/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // // Threaded or non-threaded packet sender. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// -#ifndef __shared__PacketSender__ -#define __shared__PacketSender__ +#ifndef hifi_PacketSender_h +#define hifi_PacketSender_h #include @@ -121,4 +124,4 @@ private: QMutex _waitingOnPacketsMutex; }; -#endif // __shared__PacketSender__ +#endif // hifi_PacketSender_h diff --git a/libraries/shared/src/PerfStat.cpp b/libraries/shared/src/PerfStat.cpp index 7bea51dd6e..9235cb3f25 100644 --- a/libraries/shared/src/PerfStat.cpp +++ b/libraries/shared/src/PerfStat.cpp @@ -1,13 +1,12 @@ // -// HiFiPerfStat.cpp -// hifi +// PerfStat.cpp +// libraries/shared/src // // Created by Brad Hefta-Gaub on 3/29/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. -// -// Poor-man's performance stats collector class. Useful for collecting timing -// details from various portions of the code. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/shared/src/PerfStat.h b/libraries/shared/src/PerfStat.h index a7a10b97b8..478c9afead 100644 --- a/libraries/shared/src/PerfStat.h +++ b/libraries/shared/src/PerfStat.h @@ -1,17 +1,19 @@ // -// HiFiPerfStat.h -// hifi +// PerfStat.h +// libraries/shared/src // // Created by Brad Hefta-Gaub on 3/29/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // // Poor-man's performance stats collector class. Useful for collecting timing // details from various portions of the code. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__PerfStat__ -#define __hifi__PerfStat__ +#ifndef hifi_PerfStat_h +#define hifi_PerfStat_h #include #include "SharedUtil.h" @@ -54,4 +56,4 @@ public: }; -#endif /* defined(__hifi__PerfStat__) */ +#endif // hifi_PerfStat_h diff --git a/libraries/shared/src/PlaneShape.cpp b/libraries/shared/src/PlaneShape.cpp new file mode 100644 index 0000000000..a8b4468c93 --- /dev/null +++ b/libraries/shared/src/PlaneShape.cpp @@ -0,0 +1,36 @@ +// +// PlaneShape.cpp +// libraries/shared/src +// +// Created by Andrzej Kapolka on 4/10/2014. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include "PlaneShape.h" +#include "SharedUtil.h" + +const glm::vec3 UNROTATED_NORMAL(0.0f, 1.0f, 0.0f); + +PlaneShape::PlaneShape(const glm::vec4& coefficients) : + Shape(Shape::PLANE_SHAPE) { + + glm::vec3 normal = glm::vec3(coefficients); + _position = -normal * coefficients.w; + + float angle = acosf(glm::dot(normal, UNROTATED_NORMAL)); + if (angle > EPSILON) { + if (angle > PI - EPSILON) { + _rotation = glm::angleAxis(PI, glm::vec3(1.0f, 0.0f, 0.0f)); + } else { + _rotation = glm::angleAxis(angle, glm::normalize(glm::cross(UNROTATED_NORMAL, normal))); + } + } +} + +glm::vec4 PlaneShape::getCoefficients() const { + glm::vec3 normal = _rotation * UNROTATED_NORMAL; + return glm::vec4(normal.x, normal.y, normal.z, -glm::dot(normal, _position)); +} diff --git a/libraries/shared/src/PlaneShape.h b/libraries/shared/src/PlaneShape.h new file mode 100644 index 0000000000..524d53ec73 --- /dev/null +++ b/libraries/shared/src/PlaneShape.h @@ -0,0 +1,24 @@ +// +// PlaneShape.h +// libraries/shared/src +// +// Created by Andrzej Kapolka on 4/9/2014. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_PlaneShape_h +#define hifi_PlaneShape_h + +#include "Shape.h" + +class PlaneShape : public Shape { +public: + PlaneShape(const glm::vec4& coefficients = glm::vec4(0.0f, 1.0f, 0.0f, 0.0f)); + + glm::vec4 getCoefficients() const; +}; + +#endif // hifi_PlaneShape_h diff --git a/libraries/shared/src/Radix2InplaceSort.h b/libraries/shared/src/Radix2InplaceSort.h index abd650b2a6..dfa455a32d 100644 --- a/libraries/shared/src/Radix2InplaceSort.h +++ b/libraries/shared/src/Radix2InplaceSort.h @@ -1,13 +1,16 @@ // -// Radix2InplaceSort.h -// hifi +// Radix2InplaceSort.h +// libraries/shared/src // -// Created by Tobias Schwinger on 3/22/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Tobias Schwinger on 3/22/13. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__Radix2InplaceSort__ -#define __hifi__Radix2InplaceSort__ +#ifndef hifi_Radix2InplaceSort_h +#define hifi_Radix2InplaceSort_h #include @@ -91,4 +94,4 @@ void radix2InplaceSort( BidiIterator from, BidiIterator to, .go(from, to, scanner.initial_state()); } -#endif /* defined(__hifi__Radix2InplaceSort__) */ +#endif // hifi_Radix2InplaceSort_h diff --git a/libraries/shared/src/Radix2IntegerScanner.h b/libraries/shared/src/Radix2IntegerScanner.h index 84e7c7077e..16a6224778 100644 --- a/libraries/shared/src/Radix2IntegerScanner.h +++ b/libraries/shared/src/Radix2IntegerScanner.h @@ -1,13 +1,16 @@ // -// Radix2IntegerScanner.h -// hifi +// Radix2IntegerScanner.h +// libraries/shared/src // -// Created by Tobias Schwinger on 3/23/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Tobias Schwinger on 3/23/13. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__Radix2IntegerScanner__ -#define __hifi__Radix2IntegerScanner__ +#ifndef hifi_Radix2IntegerScanner_h +#define hifi_Radix2IntegerScanner_h #include #include @@ -82,5 +85,4 @@ class Radix2IntegerScanner< Int, true > bool bit(Int const& v, state_type const& s) const { return !!((v-valMsb) & s); } }; -#endif /* defined(__hifi__Radix2IntegerScanner__) */ - +#endif // hifi_Radix2IntegerScanner_h diff --git a/libraries/shared/src/ReceivedPacketProcessor.cpp b/libraries/shared/src/ReceivedPacketProcessor.cpp index df7bfad165..8394559524 100644 --- a/libraries/shared/src/ReceivedPacketProcessor.cpp +++ b/libraries/shared/src/ReceivedPacketProcessor.cpp @@ -1,11 +1,12 @@ // // ReceivedPacketProcessor.cpp -// shared +// libraries/shared/src // // Created by Brad Hefta-Gaub on 8/12/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // -// Threaded or non-threaded packet receiver. +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "NodeList.h" diff --git a/libraries/shared/src/ReceivedPacketProcessor.h b/libraries/shared/src/ReceivedPacketProcessor.h index f88512639b..a34b43626c 100644 --- a/libraries/shared/src/ReceivedPacketProcessor.h +++ b/libraries/shared/src/ReceivedPacketProcessor.h @@ -1,15 +1,16 @@ // // ReceivedPacketProcessor.h -// shared +// libraries/shared/src // // Created by Brad Hefta-Gaub on 8/12/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // -// Threaded or non-threaded received packet processor. +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __shared__ReceivedPacketProcessor__ -#define __shared__ReceivedPacketProcessor__ +#ifndef hifi_ReceivedPacketProcessor_h +#define hifi_ReceivedPacketProcessor_h #include @@ -55,4 +56,4 @@ private: QMutex _waitingOnPacketsMutex; }; -#endif // __shared__PacketReceiver__ +#endif // hifi_ReceivedPacketProcessor_h diff --git a/libraries/shared/src/RegisteredMetaTypes.cpp b/libraries/shared/src/RegisteredMetaTypes.cpp index d106977ae0..3e21a72fd5 100644 --- a/libraries/shared/src/RegisteredMetaTypes.cpp +++ b/libraries/shared/src/RegisteredMetaTypes.cpp @@ -1,12 +1,13 @@ // // RegisteredMetaTypes.cpp -// hifi +// libraries/shared/src // // Created by Stephen Birarda on 10/3/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -// Used to register meta-types with Qt so that they can be used as properties for objects exposed to our -// Agent scripting. #include "RegisteredMetaTypes.h" @@ -16,6 +17,7 @@ static int vec2MetaTypeId = qRegisterMetaType(); static int quatMetaTypeId = qRegisterMetaType(); static int xColorMetaTypeId = qRegisterMetaType(); static int pickRayMetaTypeId = qRegisterMetaType(); +static int collisionMetaTypeId = qRegisterMetaType(); void registerMetaTypes(QScriptEngine* engine) { qScriptRegisterMetaType(engine, vec4toScriptValue, vec4FromScriptValue); @@ -24,6 +26,7 @@ void registerMetaTypes(QScriptEngine* engine) { qScriptRegisterMetaType(engine, quatToScriptValue, quatFromScriptValue); qScriptRegisterMetaType(engine, xColorToScriptValue, xColorFromScriptValue); qScriptRegisterMetaType(engine, pickRayToScriptValue, pickRayFromScriptValue); + qScriptRegisterMetaType(engine, collisionToScriptValue, collisionFromScriptValue); } QScriptValue vec4toScriptValue(QScriptEngine* engine, const glm::vec4& vec4) { @@ -122,3 +125,14 @@ void pickRayFromScriptValue(const QScriptValue& object, PickRay& pickRay) { } } +QScriptValue collisionToScriptValue(QScriptEngine* engine, const CollisionInfo& collision) { + QScriptValue obj = engine->newObject(); + obj.setProperty("penetration", vec3toScriptValue(engine, collision._penetration)); + obj.setProperty("contactPoint", vec3toScriptValue(engine, collision._contactPoint)); + return obj; +} + +void collisionFromScriptValue(const QScriptValue &object, CollisionInfo& collision) { + // TODO: implement this when we know what it means to accept collision events from JS +} + diff --git a/libraries/shared/src/RegisteredMetaTypes.h b/libraries/shared/src/RegisteredMetaTypes.h index ea65e45c95..d876965723 100644 --- a/libraries/shared/src/RegisteredMetaTypes.h +++ b/libraries/shared/src/RegisteredMetaTypes.h @@ -1,12 +1,13 @@ // // RegisteredMetaTypes.h -// hifi +// libraries/shared/src // // Created by Stephen Birarda on 10/3/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -// Used to register meta-types with Qt so that they can be used as properties for objects exposed to our -// Agent scripting. #ifndef hifi_RegisteredMetaTypes_h #define hifi_RegisteredMetaTypes_h @@ -15,6 +16,7 @@ #include +#include "CollisionInfo.h" #include "SharedUtil.h" Q_DECLARE_METATYPE(glm::vec4) @@ -50,4 +52,8 @@ Q_DECLARE_METATYPE(PickRay) QScriptValue pickRayToScriptValue(QScriptEngine* engine, const PickRay& pickRay); void pickRayFromScriptValue(const QScriptValue& object, PickRay& pickRay); -#endif +Q_DECLARE_METATYPE(CollisionInfo) +QScriptValue collisionToScriptValue(QScriptEngine* engine, const CollisionInfo& collision); +void collisionFromScriptValue(const QScriptValue &object, CollisionInfo& collision); + +#endif // hifi_RegisteredMetaTypes_h diff --git a/libraries/shared/src/ResourceCache.cpp b/libraries/shared/src/ResourceCache.cpp index c7858e6e20..30a725c010 100644 --- a/libraries/shared/src/ResourceCache.cpp +++ b/libraries/shared/src/ResourceCache.cpp @@ -1,9 +1,12 @@ // // ResourceCache.cpp -// shared +// libraries/shared/src // // Created by Andrzej Kapolka on 2/27/14. -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/shared/src/ResourceCache.h b/libraries/shared/src/ResourceCache.h index 2fcda0bb98..da217516e1 100644 --- a/libraries/shared/src/ResourceCache.h +++ b/libraries/shared/src/ResourceCache.h @@ -1,13 +1,16 @@ // // ResourceCache.h -// shared +// libraries/shared/src // // Created by Andrzej Kapolka on 2/27/14. -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __shared__ResourceCache__ -#define __shared__ResourceCache__ +#ifndef hifi_ResourceCache_h +#define hifi_ResourceCache_h #include #include @@ -174,4 +177,4 @@ private: uint qHash(const QPointer& value, uint seed = 0); -#endif /* defined(__shared__ResourceCache__) */ +#endif // hifi_ResourceCache_h diff --git a/libraries/shared/src/Shape.h b/libraries/shared/src/Shape.h index 924d13000e..87b84ea73b 100644 --- a/libraries/shared/src/Shape.h +++ b/libraries/shared/src/Shape.h @@ -1,12 +1,16 @@ // // Shape.h +// libraries/shared/src // -// Created by Andrew Meadows on 2014.02.20 -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Created by Andrew Meadows on 2014. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__Shape__ -#define __hifi__Shape__ +#ifndef hifi_Shape_h +#define hifi_Shape_h #include #include @@ -18,6 +22,7 @@ public: UNKNOWN_SHAPE = 0, SPHERE_SHAPE, CAPSULE_SHAPE, + PLANE_SHAPE, BOX_SHAPE, LIST_SHAPE }; @@ -51,4 +56,4 @@ protected: glm::quat _rotation; }; -#endif /* defined(__hifi__Shape__) */ +#endif // hifi_Shape_h diff --git a/libraries/shared/src/ShapeCollider.cpp b/libraries/shared/src/ShapeCollider.cpp index 70f9b9c4bf..c53c7fab7d 100644 --- a/libraries/shared/src/ShapeCollider.cpp +++ b/libraries/shared/src/ShapeCollider.cpp @@ -1,15 +1,19 @@ // // ShapeCollider.cpp -// hifi +// libraries/shared/src // -// Created by Andrew Meadows on 2014.02.20 -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Created by Andrew Meadows on 02/20/2014. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include #include +#include "GeometryUtil.h" #include "ShapeCollider.h" // NOTE: @@ -19,7 +23,7 @@ namespace ShapeCollider { -bool shapeShape(const Shape* shapeA, const Shape* shapeB, CollisionList& collisions) { +bool collideShapes(const Shape* shapeA, const Shape* shapeB, CollisionList& collisions) { // ATM we only have two shape types so we just check every case. // TODO: make a fast lookup for correct method int typeA = shapeA->getType(); @@ -30,6 +34,8 @@ bool shapeShape(const Shape* shapeA, const Shape* shapeB, CollisionList& collisi return sphereSphere(sphereA, static_cast(shapeB), collisions); } else if (typeB == Shape::CAPSULE_SHAPE) { return sphereCapsule(sphereA, static_cast(shapeB), collisions); + } else if (typeB == Shape::PLANE_SHAPE) { + return spherePlane(sphereA, static_cast(shapeB), collisions); } } else if (typeA == Shape::CAPSULE_SHAPE) { const CapsuleShape* capsuleA = static_cast(shapeA); @@ -37,6 +43,17 @@ bool shapeShape(const Shape* shapeA, const Shape* shapeB, CollisionList& collisi return capsuleSphere(capsuleA, static_cast(shapeB), collisions); } else if (typeB == Shape::CAPSULE_SHAPE) { return capsuleCapsule(capsuleA, static_cast(shapeB), collisions); + } else if (typeB == Shape::PLANE_SHAPE) { + return capsulePlane(capsuleA, static_cast(shapeB), collisions); + } + } else if (typeA == Shape::PLANE_SHAPE) { + const PlaneShape* planeA = static_cast(shapeA); + if (typeB == Shape::SPHERE_SHAPE) { + return planeSphere(planeA, static_cast(shapeB), collisions); + } else if (typeB == Shape::CAPSULE_SHAPE) { + return planeCapsule(planeA, static_cast(shapeB), collisions); + } else if (typeB == Shape::PLANE_SHAPE) { + return planePlane(planeA, static_cast(shapeB), collisions); } } else if (typeA == Shape::LIST_SHAPE) { const ListShape* listA = static_cast(shapeA); @@ -44,11 +61,37 @@ bool shapeShape(const Shape* shapeA, const Shape* shapeB, CollisionList& collisi return listSphere(listA, static_cast(shapeB), collisions); } else if (typeB == Shape::CAPSULE_SHAPE) { return listCapsule(listA, static_cast(shapeB), collisions); + } else if (typeB == Shape::PLANE_SHAPE) { + return listPlane(listA, static_cast(shapeB), collisions); } } return false; } +static CollisionList tempCollisions(32); + +bool collideShapesCoarse(const QVector& shapesA, const QVector& shapesB, CollisionInfo& collision) { + tempCollisions.clear(); + foreach (const Shape* shapeA, shapesA) { + foreach (const Shape* shapeB, shapesB) { + ShapeCollider::collideShapes(shapeA, shapeB, tempCollisions); + } + } + if (tempCollisions.size() > 0) { + glm::vec3 totalPenetration(0.0f); + glm::vec3 averageContactPoint(0.0f); + for (int j = 0; j < tempCollisions.size(); ++j) { + CollisionInfo* c = tempCollisions.getCollision(j); + totalPenetration = addPenetrations(totalPenetration, c->_penetration); + averageContactPoint += c->_contactPoint; + } + collision._penetration = totalPenetration; + collision._contactPoint = averageContactPoint / (float)(tempCollisions.size()); + return true; + } + return false; +} + bool sphereSphere(const SphereShape* sphereA, const SphereShape* sphereB, CollisionList& collisions) { glm::vec3 BA = sphereB->getPosition() - sphereA->getPosition(); float distanceSquared = glm::dot(BA, BA); @@ -58,7 +101,7 @@ bool sphereSphere(const SphereShape* sphereA, const SphereShape* sphereB, Collis float distance = sqrtf(distanceSquared); if (distance < EPSILON) { // the spheres are on top of each other, so we pick an arbitrary penetration direction - BA = glm::vec3(0.f, 1.f, 0.f); + BA = glm::vec3(0.0f, 1.0f, 0.0f); distance = totalRadius; } else { BA /= distance; @@ -93,7 +136,7 @@ bool sphereCapsule(const SphereShape* sphereA, const CapsuleShape* capsuleB, Col } if (absAxialDistance > capsuleB->getHalfHeight()) { // sphere hits capsule on a cap --> recompute radialAxis to point from spherA to cap center - float sign = (axialDistance > 0.f) ? 1.f : -1.f; + float sign = (axialDistance > 0.0f) ? 1.0f : -1.0f; radialAxis = BA + (sign * capsuleB->getHalfHeight()) * capsuleAxis; radialDistance2 = glm::length2(radialAxis); if (radialDistance2 > totalRadius2) { @@ -125,12 +168,12 @@ bool sphereCapsule(const SphereShape* sphereA, const CapsuleShape* capsuleB, Col return false; } // ... but still defined for the cap case - if (axialDistance < 0.f) { + if (axialDistance < 0.0f) { // we're hitting the start cap, so we negate the capsuleAxis capsuleAxis *= -1; } // penetration points from A into B - float sign = (axialDistance > 0.f) ? -1.f : 1.f; + float sign = (axialDistance > 0.0f) ? -1.0f : 1.0f; collision->_penetration = (sign * (totalRadius + capsuleB->getHalfHeight() - absAxialDistance)) * capsuleAxis; // contactPoint is on surface of sphereA collision->_contactPoint = sphereA->getPosition() + (sign * sphereA->getRadius()) * capsuleAxis; @@ -140,6 +183,20 @@ bool sphereCapsule(const SphereShape* sphereA, const CapsuleShape* capsuleB, Col return false; } +bool spherePlane(const SphereShape* sphereA, const PlaneShape* planeB, CollisionList& collisions) { + glm::vec3 penetration; + if (findSpherePlanePenetration(sphereA->getPosition(), sphereA->getRadius(), planeB->getCoefficients(), penetration)) { + CollisionInfo* collision = collisions.getNewCollision(); + if (!collision) { + return false; // collision list is full + } + collision->_penetration = penetration; + collision->_contactPoint = sphereA->getPosition() + sphereA->getRadius() * glm::normalize(penetration); + return true; + } + return false; +} + bool capsuleSphere(const CapsuleShape* capsuleA, const SphereShape* sphereB, CollisionList& collisions) { // find sphereB's closest approach to axis of capsuleA glm::vec3 AB = capsuleA->getPosition() - sphereB->getPosition(); @@ -163,7 +220,7 @@ bool capsuleSphere(const CapsuleShape* capsuleA, const SphereShape* sphereB, Col if (absAxialDistance > capsuleA->getHalfHeight()) { // sphere hits capsule on a cap // --> recompute radialAxis and closestApproach - float sign = (axialDistance > 0.f) ? 1.f : -1.f; + float sign = (axialDistance > 0.0f) ? 1.0f : -1.0f; closestApproach = capsuleA->getPosition() + (sign * capsuleA->getHalfHeight()) * capsuleAxis; radialAxis = closestApproach - sphereB->getPosition(); radialDistance2 = glm::length2(radialAxis); @@ -196,11 +253,11 @@ bool capsuleSphere(const CapsuleShape* capsuleA, const SphereShape* sphereB, Col return false; } // ... but still defined for the cap case - if (axialDistance < 0.f) { + if (axialDistance < 0.0f) { // we're hitting the start cap, so we negate the capsuleAxis capsuleAxis *= -1; } - float sign = (axialDistance > 0.f) ? 1.f : -1.f; + float sign = (axialDistance > 0.0f) ? 1.0f : -1.0f; collision->_penetration = (sign * (totalRadius + capsuleA->getHalfHeight() - absAxialDistance)) * capsuleAxis; // contactPoint is on surface of sphereA collision->_contactPoint = closestApproach + (sign * capsuleA->getRadius()) * capsuleAxis; @@ -223,7 +280,7 @@ bool capsuleCapsule(const CapsuleShape* capsuleA, const CapsuleShape* capsuleB, // d = [(B - A) . (a - (a.b)b)] / (1 - (a.b)^2) float aDotB = glm::dot(axisA, axisB); - float denominator = 1.f - aDotB * aDotB; + float denominator = 1.0f - aDotB * aDotB; float totalRadius = capsuleA->getRadius() + capsuleB->getRadius(); if (denominator > EPSILON) { // distances to points of closest approach @@ -233,12 +290,12 @@ bool capsuleCapsule(const CapsuleShape* capsuleA, const CapsuleShape* capsuleB, // clamp the distances to the ends of the capsule line segments float absDistanceA = fabs(distanceA); if (absDistanceA > capsuleA->getHalfHeight() + capsuleA->getRadius()) { - float signA = distanceA < 0.f ? -1.f : 1.f; + float signA = distanceA < 0.0f ? -1.0f : 1.0f; distanceA = signA * capsuleA->getHalfHeight(); } float absDistanceB = fabs(distanceB); if (absDistanceB > capsuleB->getHalfHeight() + capsuleB->getRadius()) { - float signB = distanceB < 0.f ? -1.f : 1.f; + float signB = distanceB < 0.0f ? -1.0f : 1.0f; distanceB = signB * capsuleB->getHalfHeight(); } @@ -265,7 +322,7 @@ bool capsuleCapsule(const CapsuleShape* capsuleA, const CapsuleShape* capsuleB, { // the capsule centers are on top of each other! // give up on a valid penetration direction and just use the yAxis - BA = glm::vec3(0.f, 1.f, 0.f); + BA = glm::vec3(0.0f, 1.0f, 0.0f); distance = glm::max(capsuleB->getRadius(), capsuleA->getRadius()); } } else { @@ -297,7 +354,7 @@ bool capsuleCapsule(const CapsuleShape* capsuleA, const CapsuleShape* capsuleB, float distance = sqrtf(distanceSquared); if (distance < EPSILON) { // the spheres are on top of each other, so we pick an arbitrary penetration direction - BA = glm::vec3(0.f, 1.f, 0.f); + BA = glm::vec3(0.0f, 1.0f, 0.0f); } else { BA /= distance; } @@ -346,6 +403,63 @@ bool capsuleCapsule(const CapsuleShape* capsuleA, const CapsuleShape* capsuleB, return false; } +bool capsulePlane(const CapsuleShape* capsuleA, const PlaneShape* planeB, CollisionList& collisions) { + glm::vec3 start, end, penetration; + capsuleA->getStartPoint(start); + capsuleA->getEndPoint(end); + glm::vec4 plane = planeB->getCoefficients(); + if (findCapsulePlanePenetration(start, end, capsuleA->getRadius(), plane, penetration)) { + CollisionInfo* collision = collisions.getNewCollision(); + if (!collision) { + return false; // collision list is full + } + collision->_penetration = penetration; + glm::vec3 deepestEnd = (glm::dot(start, glm::vec3(plane)) < glm::dot(end, glm::vec3(plane))) ? start : end; + collision->_contactPoint = deepestEnd + capsuleA->getRadius() * glm::normalize(penetration); + return true; + } + return false; +} + +bool planeSphere(const PlaneShape* planeA, const SphereShape* sphereB, CollisionList& collisions) { + glm::vec3 penetration; + if (findSpherePlanePenetration(sphereB->getPosition(), sphereB->getRadius(), planeA->getCoefficients(), penetration)) { + CollisionInfo* collision = collisions.getNewCollision(); + if (!collision) { + return false; // collision list is full + } + collision->_penetration = -penetration; + collision->_contactPoint = sphereB->getPosition() + + (sphereB->getRadius() / glm::length(penetration) - 1.0f) * penetration; + return true; + } + return false; +} + +bool planeCapsule(const PlaneShape* planeA, const CapsuleShape* capsuleB, CollisionList& collisions) { + glm::vec3 start, end, penetration; + capsuleB->getStartPoint(start); + capsuleB->getEndPoint(end); + glm::vec4 plane = planeA->getCoefficients(); + if (findCapsulePlanePenetration(start, end, capsuleB->getRadius(), plane, penetration)) { + CollisionInfo* collision = collisions.getNewCollision(); + if (!collision) { + return false; // collision list is full + } + collision->_penetration = -penetration; + glm::vec3 deepestEnd = (glm::dot(start, glm::vec3(plane)) < glm::dot(end, glm::vec3(plane))) ? start : end; + collision->_contactPoint = deepestEnd + (capsuleB->getRadius() / glm::length(penetration) - 1.0f) * penetration; + return true; + } + return false; +} + +bool planePlane(const PlaneShape* planeA, const PlaneShape* planeB, CollisionList& collisions) { + // technically, planes always collide unless they're parallel and not coincident; however, that's + // not going to give us any useful information + return false; +} + bool sphereList(const SphereShape* sphereA, const ListShape* listB, CollisionList& collisions) { bool touching = false; for (int i = 0; i < listB->size() && !collisions.isFull(); ++i) { @@ -355,6 +469,8 @@ bool sphereList(const SphereShape* sphereA, const ListShape* listB, CollisionLis touching = sphereSphere(sphereA, static_cast(subShape), collisions) || touching; } else if (subType == Shape::CAPSULE_SHAPE) { touching = sphereCapsule(sphereA, static_cast(subShape), collisions) || touching; + } else if (subType == Shape::PLANE_SHAPE) { + touching = spherePlane(sphereA, static_cast(subShape), collisions) || touching; } } return touching; @@ -369,6 +485,24 @@ bool capsuleList(const CapsuleShape* capsuleA, const ListShape* listB, Collision touching = capsuleSphere(capsuleA, static_cast(subShape), collisions) || touching; } else if (subType == Shape::CAPSULE_SHAPE) { touching = capsuleCapsule(capsuleA, static_cast(subShape), collisions) || touching; + } else if (subType == Shape::PLANE_SHAPE) { + touching = capsulePlane(capsuleA, static_cast(subShape), collisions) || touching; + } + } + return touching; +} + +bool planeList(const PlaneShape* planeA, const ListShape* listB, CollisionList& collisions) { + bool touching = false; + for (int i = 0; i < listB->size() && !collisions.isFull(); ++i) { + const Shape* subShape = listB->getSubShape(i); + int subType = subShape->getType(); + if (subType == Shape::SPHERE_SHAPE) { + touching = planeSphere(planeA, static_cast(subShape), collisions) || touching; + } else if (subType == Shape::CAPSULE_SHAPE) { + touching = planeCapsule(planeA, static_cast(subShape), collisions) || touching; + } else if (subType == Shape::PLANE_SHAPE) { + touching = planePlane(planeA, static_cast(subShape), collisions) || touching; } } return touching; @@ -383,6 +517,8 @@ bool listSphere(const ListShape* listA, const SphereShape* sphereB, CollisionLis touching = sphereSphere(static_cast(subShape), sphereB, collisions) || touching; } else if (subType == Shape::CAPSULE_SHAPE) { touching = capsuleSphere(static_cast(subShape), sphereB, collisions) || touching; + } else if (subType == Shape::PLANE_SHAPE) { + touching = planeSphere(static_cast(subShape), sphereB, collisions) || touching; } } return touching; @@ -397,6 +533,24 @@ bool listCapsule(const ListShape* listA, const CapsuleShape* capsuleB, Collision touching = sphereCapsule(static_cast(subShape), capsuleB, collisions) || touching; } else if (subType == Shape::CAPSULE_SHAPE) { touching = capsuleCapsule(static_cast(subShape), capsuleB, collisions) || touching; + } else if (subType == Shape::PLANE_SHAPE) { + touching = planeCapsule(static_cast(subShape), capsuleB, collisions) || touching; + } + } + return touching; +} + +bool listPlane(const ListShape* listA, const PlaneShape* planeB, CollisionList& collisions) { + bool touching = false; + for (int i = 0; i < listA->size() && !collisions.isFull(); ++i) { + const Shape* subShape = listA->getSubShape(i); + int subType = subShape->getType(); + if (subType == Shape::SPHERE_SHAPE) { + touching = spherePlane(static_cast(subShape), planeB, collisions) || touching; + } else if (subType == Shape::CAPSULE_SHAPE) { + touching = capsulePlane(static_cast(subShape), planeB, collisions) || touching; + } else if (subType == Shape::PLANE_SHAPE) { + touching = planePlane(static_cast(subShape), planeB, collisions) || touching; } } return touching; @@ -407,7 +561,7 @@ bool listList(const ListShape* listA, const ListShape* listB, CollisionList& col for (int i = 0; i < listA->size() && !collisions.isFull(); ++i) { const Shape* subShape = listA->getSubShape(i); for (int j = 0; j < listB->size() && !collisions.isFull(); ++j) { - touching = shapeShape(subShape, listB->getSubShape(j), collisions) || touching; + touching = collideShapes(subShape, listB->getSubShape(j), collisions) || touching; } } return touching; diff --git a/libraries/shared/src/ShapeCollider.h b/libraries/shared/src/ShapeCollider.h index e3e044c8fe..d554775e7b 100644 --- a/libraries/shared/src/ShapeCollider.h +++ b/libraries/shared/src/ShapeCollider.h @@ -1,17 +1,21 @@ // // ShapeCollider.h -// hifi +// libraries/shared/src // -// Created by Andrew Meadows on 2014.02.20 -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Created by Andrew Meadows on 02/20/2014. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__ShapeCollider__ -#define __hifi__ShapeCollider__ +#ifndef hifi_ShapeCollider_h +#define hifi_ShapeCollider_h #include "CapsuleShape.h" #include "CollisionInfo.h" #include "ListShape.h" +#include "PlaneShape.h" #include "SharedUtil.h" #include "SphereShape.h" @@ -19,9 +23,15 @@ namespace ShapeCollider { /// \param shapeA pointer to first shape /// \param shapeB pointer to second shape - /// \param[out] collisions where to append collision details + /// \param collisions[out] collision details /// \return true if shapes collide - bool shapeShape(const Shape* shapeA, const Shape* shapeB, CollisionList& collisions); + bool collideShapes(const Shape* shapeA, const Shape* shapeB, CollisionList& collisions); + + /// \param shapesA list of shapes + /// \param shapeB list of shapes + /// \param collisions[out] average collision details + /// \return true if any shapes collide + bool collideShapesCoarse(const QVector& shapesA, const QVector& shapesB, CollisionInfo& collision); /// \param sphereA pointer to first shape /// \param sphereB pointer to second shape @@ -35,6 +45,12 @@ namespace ShapeCollider { /// \return true if shapes collide bool sphereCapsule(const SphereShape* sphereA, const CapsuleShape* capsuleB, CollisionList& collisions); + /// \param sphereA pointer to first shape + /// \param planeB pointer to second shape + /// \param[out] collisions where to append collision details + /// \return true if shapes collide + bool spherePlane(const SphereShape* sphereA, const PlaneShape* planeB, CollisionList& collisions); + /// \param capsuleA pointer to first shape /// \param sphereB pointer to second shape /// \param[out] collisions where to append collision details @@ -47,6 +63,30 @@ namespace ShapeCollider { /// \return true if shapes collide bool capsuleCapsule(const CapsuleShape* capsuleA, const CapsuleShape* capsuleB, CollisionList& collisions); + /// \param capsuleA pointer to first shape + /// \param planeB pointer to second shape + /// \param[out] collisions where to append collision details + /// \return true if shapes collide + bool capsulePlane(const CapsuleShape* capsuleA, const PlaneShape* planeB, CollisionList& collisions); + + /// \param planeA pointer to first shape + /// \param sphereB pointer to second shape + /// \param[out] collisions where to append collision details + /// \return true if shapes collide + bool planeSphere(const PlaneShape* planeA, const SphereShape* sphereB, CollisionList& collisions); + + /// \param planeA pointer to first shape + /// \param capsuleB pointer to second shape + /// \param[out] collisions where to append collision details + /// \return true if shapes collide + bool planeCapsule(const PlaneShape* planeA, const CapsuleShape* capsuleB, CollisionList& collisions); + + /// \param planeA pointer to first shape + /// \param planeB pointer to second shape + /// \param[out] collisions where to append collision details + /// \return true if shapes collide + bool planePlane(const PlaneShape* planeA, const PlaneShape* planeB, CollisionList& collisions); + /// \param sphereA pointer to first shape /// \param listB pointer to second shape /// \param[out] collisions where to append collision details @@ -59,6 +99,12 @@ namespace ShapeCollider { /// \return true if shapes collide bool capsuleList(const CapsuleShape* capsuleA, const ListShape* listB, CollisionList& collisions); + /// \param planeA pointer to first shape + /// \param listB pointer to second shape + /// \param[out] collisions where to append collision details + /// \return true if shapes collide + bool planeList(const PlaneShape* planeA, const ListShape* listB, CollisionList& collisions); + /// \param listA pointer to first shape /// \param sphereB pointer to second shape /// \param[out] collisions where to append collision details @@ -71,6 +117,12 @@ namespace ShapeCollider { /// \return true if shapes collide bool listCapsule(const ListShape* listA, const CapsuleShape* capsuleB, CollisionList& collisions); + /// \param listA pointer to first shape + /// \param planeB pointer to second shape + /// \param[out] collisions where to append collision details + /// \return true if shapes collide + bool listPlane(const ListShape* listA, const PlaneShape* planeB, CollisionList& collisions); + /// \param listA pointer to first shape /// \param capsuleB pointer to second shape /// \param[out] collisions where to append collision details @@ -79,4 +131,4 @@ namespace ShapeCollider { } // namespace ShapeCollider -#endif // __hifi__ShapeCollider__ +#endif // hifi_ShapeCollider_h diff --git a/libraries/shared/src/SharedUtil.cpp b/libraries/shared/src/SharedUtil.cpp index 786302ae2a..d91e01d17f 100644 --- a/libraries/shared/src/SharedUtil.cpp +++ b/libraries/shared/src/SharedUtil.cpp @@ -1,9 +1,12 @@ // // SharedUtil.cpp -// hifi +// libraries/shared/src // // Created by Stephen Birarda on 2/22/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include @@ -661,11 +664,10 @@ glm::vec3 safeEulerAngles(const glm::quat& q) { } } -bool isNaN(float f) { - return f != f; +bool isNaN(float value) { + return value != value; } - bool isSimilarOrientation(const glm::quat& orientionA, const glm::quat& orientionB, float similarEnough) { // Compute the angular distance between the two orientations float angleOrientation = orientionA == orientionB ? 0.0f : glm::degrees(glm::angle(orientionA * glm::inverse(orientionB))); diff --git a/libraries/shared/src/SharedUtil.h b/libraries/shared/src/SharedUtil.h index 91b0054794..236c1f74a1 100644 --- a/libraries/shared/src/SharedUtil.h +++ b/libraries/shared/src/SharedUtil.h @@ -1,13 +1,16 @@ // // SharedUtil.h -// hifi +// libraries/shared/src // // Created by Stephen Birarda on 2/22/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__SharedUtil__ -#define __hifi__SharedUtil__ +#ifndef hifi_SharedUtil_h +#define hifi_SharedUtil_h #include #include @@ -174,7 +177,8 @@ bool isSimilarOrientation(const glm::quat& orientionA, const glm::quat& orientio float similarEnough = ORIENTATION_SIMILAR_ENOUGH); const float POSITION_SIMILAR_ENOUGH = 0.1f; // 0.1 meter bool isSimilarPosition(const glm::vec3& positionA, const glm::vec3& positionB, float similarEnough = POSITION_SIMILAR_ENOUGH); - -bool isNaN(float f); -#endif /* defined(__hifi__SharedUtil__) */ +/// \return bool is the float NaN +bool isNaN(float value); + +#endif // hifi_SharedUtil_h diff --git a/libraries/shared/src/SimpleMovingAverage.cpp b/libraries/shared/src/SimpleMovingAverage.cpp index 676c85598e..9f7e541c9a 100644 --- a/libraries/shared/src/SimpleMovingAverage.cpp +++ b/libraries/shared/src/SimpleMovingAverage.cpp @@ -1,9 +1,12 @@ // // SimpleMovingAverage.cpp -// hifi +// libraries/shared/src // // Created by Stephen Birarda on 4/18/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "SharedUtil.h" @@ -53,4 +56,4 @@ float SimpleMovingAverage::getEventDeltaAverage() const { float SimpleMovingAverage::getAverageSampleValuePerSecond() const { return _average * (1 / getEventDeltaAverage()); -} \ No newline at end of file +} diff --git a/libraries/shared/src/SimpleMovingAverage.h b/libraries/shared/src/SimpleMovingAverage.h index f11cd16e58..3eec9d5be8 100644 --- a/libraries/shared/src/SimpleMovingAverage.h +++ b/libraries/shared/src/SimpleMovingAverage.h @@ -1,15 +1,18 @@ // // SimpleMovingAverage.h -// hifi +// libraries/shared/src // // Created by Stephen Birarda on 4/18/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // // Replaces Brad Hefta-Gaub's CounterStats class (RIP) // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// -#ifndef __hifi__Stats__ -#define __hifi__Stats__ +#ifndef hifi_SimpleMovingAverage_h +#define hifi_SimpleMovingAverage_h #include @@ -34,4 +37,4 @@ private: float ONE_MINUS_WEIGHTING; }; -#endif /* defined(__hifi__Stats__) */ +#endif // hifi_SimpleMovingAverage_h diff --git a/libraries/shared/src/SphereShape.h b/libraries/shared/src/SphereShape.h index d720dd2289..62783ab340 100644 --- a/libraries/shared/src/SphereShape.h +++ b/libraries/shared/src/SphereShape.h @@ -1,13 +1,16 @@ // // SphereShape.h -// hifi +// libraries/shared/src // -// Created by Andrew Meadows on 2014.02.20 -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Created by Andrew Meadows on 2014. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__SphereShape__ -#define __hifi__SphereShape__ +#ifndef hifi_SphereShape_h +#define hifi_SphereShape_h #include "Shape.h" @@ -28,4 +31,4 @@ public: void setRadius(float radius) { _boundingRadius = radius; } }; -#endif /* defined(__hifi__SphereShape__) */ +#endif // hifi_SphereShape_h diff --git a/libraries/shared/src/StdDev.cpp b/libraries/shared/src/StdDev.cpp index 17bf60e8be..4528d0fa4f 100644 --- a/libraries/shared/src/StdDev.cpp +++ b/libraries/shared/src/StdDev.cpp @@ -1,9 +1,12 @@ // // StdDev.cpp -// hifi +// libraries/shared/src // // Created by Philip Rosedale on 3/12/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include @@ -56,4 +59,4 @@ float StDev::getStDev() { return sqrt(stdev/(float)(sampleCount - 1.0)); else return 0; -} \ No newline at end of file +} diff --git a/libraries/shared/src/StdDev.h b/libraries/shared/src/StdDev.h index eea0cff3bb..77873a3549 100644 --- a/libraries/shared/src/StdDev.h +++ b/libraries/shared/src/StdDev.h @@ -1,13 +1,16 @@ // // StdDev.h -// hifi +// libraries/shared/src // // Created by Philip Rosedale on 3/12/13. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__StdDev__ -#define __hifi__StdDev__ +#ifndef hifi_StdDev_h +#define hifi_StdDev_h class StDev { public: @@ -22,4 +25,4 @@ class StDev { int sampleCount; }; -#endif /* defined(__hifi__StdDev__) */ +#endif // hifi_StdDev_h diff --git a/libraries/shared/src/StreamUtils.cpp b/libraries/shared/src/StreamUtils.cpp index 44c81f9464..d7b0c83c1f 100644 --- a/libraries/shared/src/StreamUtils.cpp +++ b/libraries/shared/src/StreamUtils.cpp @@ -1,8 +1,12 @@ // // StreamUtils.cpp +// libraries/shared/src // -// Created by Andrew Meadows on 2014.02.21 -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Created by Andrew Meadows on 2014. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/shared/src/StreamUtils.h b/libraries/shared/src/StreamUtils.h index 1a17a94658..2546d49ffc 100644 --- a/libraries/shared/src/StreamUtils.h +++ b/libraries/shared/src/StreamUtils.h @@ -1,12 +1,16 @@ // // StreamUtils.h +// libraries/shared/src // -// Created by Andrew Meadows on 2014.02.21 -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Created by Andrew Meadows on 2014. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __tests__StreamUtils__ -#define __tests__StreamUtils__ +#ifndef hifi_StreamUtils_h +#define hifi_StreamUtils_h #include @@ -36,4 +40,4 @@ std::ostream& operator<<(std::ostream& s, const CapsuleShape& capsule); #endif // DEBUG -#endif // __tests__StreamUtils__ +#endif // hifi_StreamUtils_h diff --git a/libraries/shared/src/ThreadedAssignment.cpp b/libraries/shared/src/ThreadedAssignment.cpp index fdf2d91c36..1bd79895ab 100644 --- a/libraries/shared/src/ThreadedAssignment.cpp +++ b/libraries/shared/src/ThreadedAssignment.cpp @@ -1,9 +1,12 @@ // // ThreadedAssignment.cpp -// hifi +// libraries/shared/src // // Created by Stephen Birarda on 12/3/2013. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/shared/src/ThreadedAssignment.h b/libraries/shared/src/ThreadedAssignment.h index f9652dd98d..e9241d0272 100644 --- a/libraries/shared/src/ThreadedAssignment.h +++ b/libraries/shared/src/ThreadedAssignment.h @@ -1,13 +1,16 @@ // // ThreadedAssignment.h -// hifi +// libraries/shared/src // // Created by Stephen Birarda on 12/3/2013. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__ThreadedAssignment__ -#define __hifi__ThreadedAssignment__ +#ifndef hifi_ThreadedAssignment_h +#define hifi_ThreadedAssignment_h #include @@ -39,4 +42,4 @@ signals: typedef QSharedPointer SharedAssignmentPointer; -#endif /* defined(__hifi__ThreadedAssignment__) */ +#endif // hifi_ThreadedAssignment_h diff --git a/libraries/shared/src/UUID.cpp b/libraries/shared/src/UUID.cpp index e24c81ebe3..eafd7dd181 100644 --- a/libraries/shared/src/UUID.cpp +++ b/libraries/shared/src/UUID.cpp @@ -1,9 +1,12 @@ // // UUID.cpp -// hifi +// libraries/shared/src // // Created by Stephen Birarda on 10/7/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "UUID.h" @@ -11,4 +14,4 @@ QString uuidStringWithoutCurlyBraces(const QUuid& uuid) { QString uuidStringNoBraces = uuid.toString().mid(1, uuid.toString().length() - 2); return uuidStringNoBraces; -} \ No newline at end of file +} diff --git a/libraries/shared/src/UUID.h b/libraries/shared/src/UUID.h index cacadf5a04..7e7048486f 100644 --- a/libraries/shared/src/UUID.h +++ b/libraries/shared/src/UUID.h @@ -1,13 +1,16 @@ // // UUID.h -// hifi +// libraries/shared/src // // Created by Stephen Birarda on 10/7/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__UUID__ -#define __hifi__UUID__ +#ifndef hifi_UUID_h +#define hifi_UUID_h #include @@ -15,4 +18,4 @@ const int NUM_BYTES_RFC4122_UUID = 16; QString uuidStringWithoutCurlyBraces(const QUuid& uuid); -#endif /* defined(__hifi__UUID__) */ +#endif // hifi_UUID_h diff --git a/libraries/voxels/src/EnvironmentData.cpp b/libraries/voxels/src/EnvironmentData.cpp index 1c9af55abd..b9b64f72d1 100644 --- a/libraries/voxels/src/EnvironmentData.cpp +++ b/libraries/voxels/src/EnvironmentData.cpp @@ -1,9 +1,13 @@ // // EnvironmentData.cpp -// interface +// libraries/voxels/src // // Created by Andrzej Kapolka on 5/6/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// #include diff --git a/libraries/voxels/src/EnvironmentData.h b/libraries/voxels/src/EnvironmentData.h index 627a661e1c..3eac4048c2 100644 --- a/libraries/voxels/src/EnvironmentData.h +++ b/libraries/voxels/src/EnvironmentData.h @@ -1,13 +1,16 @@ // // EnvironmentData.h -// interface +// libraries/voxels/src // // Created by Andrzej Kapolka on 5/6/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__EnvironmentData__ -#define __interface__EnvironmentData__ +#ifndef hifi_EnvironmentData_h +#define hifi_EnvironmentData_h #include @@ -72,4 +75,4 @@ private: float _sunBrightness; }; -#endif /* defined(__interface__EnvironmentData__) */ +#endif // hifi_EnvironmentData_h diff --git a/libraries/voxels/src/LocalVoxelsList.cpp b/libraries/voxels/src/LocalVoxelsList.cpp index e8f5a09d6d..4324306161 100644 --- a/libraries/voxels/src/LocalVoxelsList.cpp +++ b/libraries/voxels/src/LocalVoxelsList.cpp @@ -1,9 +1,12 @@ // // LocalVoxelsList.cpp -// hifi +// libraries/voxels/src // // Created by Clément Brisset on 2/24/14. -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "LocalVoxelsList.h" @@ -61,4 +64,4 @@ void LocalVoxelsList::remove(QString treeName) { } else { qDebug() << "[DEBUG] LocalVoxelsList : tree still in use (" << treeName << ")"; } -} \ No newline at end of file +} diff --git a/libraries/voxels/src/LocalVoxelsList.h b/libraries/voxels/src/LocalVoxelsList.h index e4b4decf8e..d22d72446f 100644 --- a/libraries/voxels/src/LocalVoxelsList.h +++ b/libraries/voxels/src/LocalVoxelsList.h @@ -1,13 +1,16 @@ // // LocalVoxelsList.h -// hifi +// libraries/voxels/src // // Created by Clément Brisset on 2/24/14. -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__LocalVoxelsList__ -#define __hifi__LocalVoxelsList__ +#ifndef hifi_LocalVoxelsList_h +#define hifi_LocalVoxelsList_h #include #include @@ -56,4 +59,4 @@ private: QList _persistantTrees; }; -#endif /* defined(__hifi__LocalVoxelsList__) */ +#endif // hifi_LocalVoxelsList_h diff --git a/libraries/voxels/src/Tags.cpp b/libraries/voxels/src/Tags.cpp index 4d1fb322cd..8f8228faae 100644 --- a/libraries/voxels/src/Tags.cpp +++ b/libraries/voxels/src/Tags.cpp @@ -1,9 +1,12 @@ // // Tags.cpp -// hifi +// libraries/voxels/src // // Created by Clement Brisset on 7/3/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/voxels/src/Tags.h b/libraries/voxels/src/Tags.h index caf4303c51..1ac231f27c 100644 --- a/libraries/voxels/src/Tags.h +++ b/libraries/voxels/src/Tags.h @@ -1,13 +1,16 @@ // // Tags.h -// hifi +// libraries/voxels/src // // Created by Clement Brisset on 7/3/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__Tags__ -#define __hifi__Tags__ +#ifndef hifi_Tags_h +#define hifi_Tags_h #include @@ -177,4 +180,4 @@ private: int* _data; }; -#endif /* defined(__hifi__Tags__) */ +#endif // hifi_Tags_h diff --git a/libraries/voxels/src/VoxelConstants.h b/libraries/voxels/src/VoxelConstants.h index d4cbc54f18..34a7667273 100644 --- a/libraries/voxels/src/VoxelConstants.h +++ b/libraries/voxels/src/VoxelConstants.h @@ -1,16 +1,18 @@ // // VoxelConstants.h -// hifi +// libraries/voxels/src // // Created by Brad Hefta-Gaub on 4/29/13. -// +// Copyright 2013 High Fidelity, Inc. // // Various important constants used throughout the system related to voxels // -// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// -#ifndef __hifi_VoxelConstants_h__ -#define __hifi_VoxelConstants_h__ +#ifndef hifi_VoxelConstants_h +#define hifi_VoxelConstants_h #include #include @@ -45,4 +47,4 @@ const quint64 CLIENT_TO_SERVER_VOXEL_SEND_INTERVAL_USECS = 1000 * 5; // 1 packet const int DEFAULT_MAX_VOXEL_PPS = 600; // the default maximum PPS we think a voxel server should send to a client -#endif \ No newline at end of file +#endif // hifi_VoxelConstants_h diff --git a/libraries/voxels/src/VoxelDetail.cpp b/libraries/voxels/src/VoxelDetail.cpp index 4527f7ca2c..6c385c9387 100644 --- a/libraries/voxels/src/VoxelDetail.cpp +++ b/libraries/voxels/src/VoxelDetail.cpp @@ -1,9 +1,12 @@ // // VoxelDetail.cpp -// hifi +// libraries/voxels/src // -// Created by Brad Hefta-Gaub on 1/29/2014 -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 1/29/2014. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/voxels/src/VoxelDetail.h b/libraries/voxels/src/VoxelDetail.h index 1604a022a0..d30255bbb1 100644 --- a/libraries/voxels/src/VoxelDetail.h +++ b/libraries/voxels/src/VoxelDetail.h @@ -1,14 +1,16 @@ // // VoxelDetail.h -// hifi +// libraries/voxels/src // -// Created by Brad Hefta-Gaub on 1/29/2014 -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 1/29/2014. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__VoxelDetail__ -#define __hifi__VoxelDetail__ +#ifndef hifi_VoxelDetail_h +#define hifi_VoxelDetail_h #include @@ -48,4 +50,4 @@ Q_DECLARE_METATYPE(RayToVoxelIntersectionResult) QScriptValue rayToVoxelIntersectionResultToScriptValue(QScriptEngine* engine, const RayToVoxelIntersectionResult& results); void rayToVoxelIntersectionResultFromScriptValue(const QScriptValue& object, RayToVoxelIntersectionResult& results); -#endif /* defined(__hifi__VoxelDetail__) */ \ No newline at end of file +#endif // hifi_VoxelDetail_h diff --git a/libraries/voxels/src/VoxelEditPacketSender.cpp b/libraries/voxels/src/VoxelEditPacketSender.cpp index 90884f19f4..1832d5436e 100644 --- a/libraries/voxels/src/VoxelEditPacketSender.cpp +++ b/libraries/voxels/src/VoxelEditPacketSender.cpp @@ -1,11 +1,12 @@ // // VoxelEditPacketSender.cpp -// interface +// libraries/voxels/src // // Created by Brad Hefta-Gaub on 8/12/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // -// Threaded or non-threaded voxel packet Sender for the Application +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/voxels/src/VoxelEditPacketSender.h b/libraries/voxels/src/VoxelEditPacketSender.h index 4a1aa87a1c..ff72e5704a 100644 --- a/libraries/voxels/src/VoxelEditPacketSender.h +++ b/libraries/voxels/src/VoxelEditPacketSender.h @@ -1,15 +1,18 @@ // // VoxelEditPacketSender.h -// shared +// libraries/voxels/src // // Created by Brad Hefta-Gaub on 8/12/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // // Voxel Packet Sender // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// -#ifndef __shared__VoxelEditPacketSender__ -#define __shared__VoxelEditPacketSender__ +#ifndef hifi_VoxelEditPacketSender_h +#define hifi_VoxelEditPacketSender_h #include #include "VoxelDetail.h" @@ -47,4 +50,4 @@ public: // My server type is the voxel server virtual unsigned char getMyNodeType() const { return NodeType::VoxelServer; } }; -#endif // __shared__VoxelEditPacketSender__ +#endif // hifi_VoxelEditPacketSender_h diff --git a/libraries/voxels/src/VoxelTree.cpp b/libraries/voxels/src/VoxelTree.cpp index 5c48244a39..bb9de72e9d 100644 --- a/libraries/voxels/src/VoxelTree.cpp +++ b/libraries/voxels/src/VoxelTree.cpp @@ -1,9 +1,12 @@ // // VoxelTree.cpp -// hifi +// libraries/voxels/src // // Created by Stephen Birarda on 3/13/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/voxels/src/VoxelTree.h b/libraries/voxels/src/VoxelTree.h index 2079ab91b2..e0bc1d9a47 100644 --- a/libraries/voxels/src/VoxelTree.h +++ b/libraries/voxels/src/VoxelTree.h @@ -1,13 +1,16 @@ // // VoxelTree.h -// hifi +// libraries/voxels/src // // Created by Stephen Birarda on 3/13/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__VoxelTree__ -#define __hifi__VoxelTree__ +#ifndef hifi_VoxelTree_h +#define hifi_VoxelTree_h #include @@ -54,4 +57,4 @@ private: void readCodeColorBufferToTreeRecursion(VoxelTreeElement* node, ReadCodeColorBufferToTreeArgs& args); }; -#endif /* defined(__hifi__VoxelTree__) */ +#endif // hifi_VoxelTree_h diff --git a/libraries/voxels/src/VoxelTreeCommands.cpp b/libraries/voxels/src/VoxelTreeCommands.cpp new file mode 100644 index 0000000000..f0f092fd04 --- /dev/null +++ b/libraries/voxels/src/VoxelTreeCommands.cpp @@ -0,0 +1,66 @@ +// +// VoxelTreeCommands.cpp +// libraries/voxels/src +// +// Created by Clement on 4/4/14. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include "VoxelTree.h" + +#include "VoxelTreeCommands.h" + +AddVoxelCommand::AddVoxelCommand(VoxelTree* tree, VoxelDetail& voxel, VoxelEditPacketSender* packetSender, QUndoCommand* parent) : + QUndoCommand("Add Voxel", parent), + _tree(tree), + _packetSender(packetSender), + _voxel(voxel) +{ +} + +void AddVoxelCommand::redo() { + if (_tree) { + _tree->createVoxel(_voxel.x, _voxel.y, _voxel.z, _voxel.s, _voxel.red, _voxel.green, _voxel.blue); + } + if (_packetSender) { + _packetSender->queueVoxelEditMessages(PacketTypeVoxelSet, 1, &_voxel); + } +} + +void AddVoxelCommand::undo() { + if (_tree) { + _tree->deleteVoxelAt(_voxel.x, _voxel.y, _voxel.z, _voxel.s); + } + if (_packetSender) { + _packetSender->queueVoxelEditMessages(PacketTypeVoxelErase, 1, &_voxel); + } +} + +DeleteVoxelCommand::DeleteVoxelCommand(VoxelTree* tree, VoxelDetail& voxel, VoxelEditPacketSender* packetSender, QUndoCommand* parent) : + QUndoCommand("Delete Voxel", parent), + _tree(tree), + _packetSender(packetSender), + _voxel(voxel) +{ +} + +void DeleteVoxelCommand::redo() { + if (_tree) { + _tree->deleteVoxelAt(_voxel.x, _voxel.y, _voxel.z, _voxel.s); + } + if (_packetSender) { + _packetSender->queueVoxelEditMessages(PacketTypeVoxelErase, 1, &_voxel); + } +} + +void DeleteVoxelCommand::undo() { + if (_tree) { + _tree->createVoxel(_voxel.x, _voxel.y, _voxel.z, _voxel.s, _voxel.red, _voxel.green, _voxel.blue); + } + if (_packetSender) { + _packetSender->queueVoxelEditMessages(PacketTypeVoxelSet, 1, &_voxel); + } +} diff --git a/libraries/voxels/src/VoxelTreeCommands.h b/libraries/voxels/src/VoxelTreeCommands.h new file mode 100644 index 0000000000..4f2610577e --- /dev/null +++ b/libraries/voxels/src/VoxelTreeCommands.h @@ -0,0 +1,49 @@ +// +// VoxelTreeCommands.h +// libraries/voxels/src +// +// Created by Clement on 4/4/14. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_VoxelTreeCommands_h +#define hifi_VoxelTreeCommands_h + +#include +#include + +#include "VoxelDetail.h" +#include "VoxelEditPacketSender.h" + +class VoxelTree; + +class AddVoxelCommand : public QUndoCommand { +public: + AddVoxelCommand(VoxelTree* tree, VoxelDetail& voxel, VoxelEditPacketSender* packetSender = NULL, QUndoCommand* parent = NULL); + + virtual void redo(); + virtual void undo(); + +private: + VoxelTree* _tree; + VoxelEditPacketSender* _packetSender; + VoxelDetail _voxel; +}; + +class DeleteVoxelCommand : public QUndoCommand { +public: + DeleteVoxelCommand(VoxelTree* tree, VoxelDetail& voxel, VoxelEditPacketSender* packetSender = NULL, QUndoCommand* parent = NULL); + + virtual void redo(); + virtual void undo(); + +private: + VoxelTree* _tree; + VoxelEditPacketSender* _packetSender; + VoxelDetail _voxel; +}; + +#endif // hifi_VoxelTreeCommands_h diff --git a/libraries/voxels/src/VoxelTreeElement.cpp b/libraries/voxels/src/VoxelTreeElement.cpp index debcfee987..2582980816 100644 --- a/libraries/voxels/src/VoxelTreeElement.cpp +++ b/libraries/voxels/src/VoxelTreeElement.cpp @@ -1,9 +1,12 @@ // // VoxelTreeElement.cpp -// hifi +// libraries/voxels/src // // Created by Stephen Birarda on 3/13/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/libraries/voxels/src/VoxelTreeElement.h b/libraries/voxels/src/VoxelTreeElement.h index c88fd6d207..140744afb0 100644 --- a/libraries/voxels/src/VoxelTreeElement.h +++ b/libraries/voxels/src/VoxelTreeElement.h @@ -1,13 +1,16 @@ // // VoxelTreeElement.h -// hifi +// libraries/voxels/src // // Created by Stephen Birarda on 3/13/13. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__VoxelTreeElement__ -#define __hifi__VoxelTreeElement__ +#ifndef hifi_VoxelTreeElement_h +#define hifi_VoxelTreeElement_h //#define HAS_AUDIT_CHILDREN //#define SIMPLE_CHILD_ARRAY @@ -117,5 +120,4 @@ inline unsigned char VoxelTreeElement::getExteriorOcclusions() const { return _exteriorOcclusions; } -#endif /* defined(__hifi__VoxelTreeElement__) */ - +#endif // hifi_VoxelTreeElement_h diff --git a/libraries/voxels/src/VoxelTreeHeadlessViewer.cpp b/libraries/voxels/src/VoxelTreeHeadlessViewer.cpp index 999ef4fa36..5aaa8c8d97 100644 --- a/libraries/voxels/src/VoxelTreeHeadlessViewer.cpp +++ b/libraries/voxels/src/VoxelTreeHeadlessViewer.cpp @@ -1,10 +1,12 @@ // // VoxelTreeHeadlessViewer.cpp -// hifi +// libraries/voxels/src // -// Created by Brad Hefta-Gaub on 2/26/14 -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 2/26/14. +// Copyright 2014 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "VoxelTreeHeadlessViewer.h" diff --git a/libraries/voxels/src/VoxelTreeHeadlessViewer.h b/libraries/voxels/src/VoxelTreeHeadlessViewer.h index 9c7481c929..3a9f00d754 100644 --- a/libraries/voxels/src/VoxelTreeHeadlessViewer.h +++ b/libraries/voxels/src/VoxelTreeHeadlessViewer.h @@ -1,14 +1,16 @@ // // VoxelTreeHeadlessViewer.h -// hifi +// libraries/voxels/src // -// Created by Brad Hefta-Gaub on 2/26/14 -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Created by Brad Hefta-Gaub on 2/26/14. +// Copyright 2014 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__VoxelTreeHeadlessViewer__ -#define __hifi__VoxelTreeHeadlessViewer__ +#ifndef hifi_VoxelTreeHeadlessViewer_h +#define hifi_VoxelTreeHeadlessViewer_h #include #include @@ -35,4 +37,4 @@ public: virtual void init(); }; -#endif /* defined(__hifi__VoxelTreeHeadlessViewer__) */ \ No newline at end of file +#endif // hifi_VoxelTreeHeadlessViewer_h diff --git a/libraries/voxels/src/VoxelsScriptingInterface.cpp b/libraries/voxels/src/VoxelsScriptingInterface.cpp index 2aecb2d457..08dcfd3f47 100644 --- a/libraries/voxels/src/VoxelsScriptingInterface.cpp +++ b/libraries/voxels/src/VoxelsScriptingInterface.cpp @@ -1,10 +1,15 @@ // // VoxelsScriptingInterface.cpp -// hifi +// libraries/voxels/src // // Created by Stephen Birarda on 9/17/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include "VoxelTreeCommands.h" #include "VoxelsScriptingInterface.h" @@ -37,17 +42,26 @@ VoxelDetail VoxelsScriptingInterface::getVoxelAt(float x, float y, float z, floa } void VoxelsScriptingInterface::setVoxelNonDestructive(float x, float y, float z, float scale, - uchar red, uchar green, uchar blue) { + uchar red, uchar green, uchar blue) { // setup a VoxelDetail struct with the data - VoxelDetail addVoxelDetail = {x / (float)TREE_SCALE, y / (float)TREE_SCALE, z / (float)TREE_SCALE, + VoxelDetail addVoxelDetail = {x / (float)TREE_SCALE, y / (float)TREE_SCALE, z / (float)TREE_SCALE, scale / (float)TREE_SCALE, red, green, blue}; - // queue the add packet - queueVoxelAdd(PacketTypeVoxelSet, addVoxelDetail); // handle the local tree also... if (_tree) { - _tree->createVoxel(addVoxelDetail.x, addVoxelDetail.y, addVoxelDetail.z, addVoxelDetail.s, red, green, blue, false); + if (_undoStack) { + AddVoxelCommand* command = new AddVoxelCommand(_tree, + addVoxelDetail, + getVoxelPacketSender()); + + // As QUndoStack automatically executes redo() on push, we don't need to execute the command ourselves. + _undoStack->push(command); + } else { + // queue the add packet + queueVoxelAdd(PacketTypeVoxelSet, addVoxelDetail); + _tree->createVoxel(addVoxelDetail.x, addVoxelDetail.y, addVoxelDetail.z, addVoxelDetail.s, red, green, blue, false); + } } } @@ -57,26 +71,70 @@ void VoxelsScriptingInterface::setVoxel(float x, float y, float z, float scale, VoxelDetail addVoxelDetail = {x / (float)TREE_SCALE, y / (float)TREE_SCALE, z / (float)TREE_SCALE, scale / (float)TREE_SCALE, red, green, blue}; - // queue the destructive add - queueVoxelAdd(PacketTypeVoxelSetDestructive, addVoxelDetail); // handle the local tree also... if (_tree) { - _tree->createVoxel(addVoxelDetail.x, addVoxelDetail.y, addVoxelDetail.z, addVoxelDetail.s, red, green, blue, true); + if (_undoStack) { + AddVoxelCommand* addCommand = new AddVoxelCommand(_tree, + addVoxelDetail, + getVoxelPacketSender()); + + VoxelTreeElement* deleteVoxelElement = _tree->getVoxelAt(addVoxelDetail.x, addVoxelDetail.y, addVoxelDetail.z, addVoxelDetail.s); + if (deleteVoxelElement) { + nodeColor color; + memcpy(&color, &deleteVoxelElement->getColor(), sizeof(nodeColor)); + VoxelDetail deleteVoxelDetail = {addVoxelDetail.x, + addVoxelDetail.y, + addVoxelDetail.z, + addVoxelDetail.s, + color[0], + color[1], + color[2]}; + DeleteVoxelCommand* delCommand = new DeleteVoxelCommand(_tree, + deleteVoxelDetail, + getVoxelPacketSender()); + _undoStack->beginMacro(addCommand->text()); + // As QUndoStack automatically executes redo() on push, we don't need to execute the command ourselves. + _undoStack->push(delCommand); + _undoStack->push(addCommand); + _undoStack->endMacro(); + } else { + // As QUndoStack automatically executes redo() on push, we don't need to execute the command ourselves. + _undoStack->push(addCommand); + } + } else { + // queue the destructive add + queueVoxelAdd(PacketTypeVoxelSetDestructive, addVoxelDetail); + _tree->createVoxel(addVoxelDetail.x, addVoxelDetail.y, addVoxelDetail.z, addVoxelDetail.s, red, green, blue, true); + } } } void VoxelsScriptingInterface::eraseVoxel(float x, float y, float z, float scale) { - // setup a VoxelDetail struct with data - VoxelDetail deleteVoxelDetail = {x / (float)TREE_SCALE, y / (float)TREE_SCALE, z / (float)TREE_SCALE, - scale / (float)TREE_SCALE, 0, 0, 0}; + VoxelDetail deleteVoxelDetail = {x / (float)TREE_SCALE, y / (float)TREE_SCALE, z / (float)TREE_SCALE, + scale / (float)TREE_SCALE}; - getVoxelPacketSender()->queueVoxelEditMessages(PacketTypeVoxelErase, 1, &deleteVoxelDetail); // handle the local tree also... if (_tree) { - _tree->deleteVoxelAt(deleteVoxelDetail.x, deleteVoxelDetail.y, deleteVoxelDetail.z, deleteVoxelDetail.s); + VoxelTreeElement* deleteVoxelElement = _tree->getVoxelAt(deleteVoxelDetail.x, deleteVoxelDetail.y, deleteVoxelDetail.z, deleteVoxelDetail.s); + if (deleteVoxelElement) { + deleteVoxelDetail.red = deleteVoxelElement->getColor()[0]; + deleteVoxelDetail.green = deleteVoxelElement->getColor()[1]; + deleteVoxelDetail.blue = deleteVoxelElement->getColor()[2]; + } + + if (_undoStack) { + DeleteVoxelCommand* command = new DeleteVoxelCommand(_tree, + deleteVoxelDetail, + getVoxelPacketSender()); + // As QUndoStack automatically executes redo() on push, we don't need to execute the command ourselves. + _undoStack->push(command); + } else { + getVoxelPacketSender()->queueVoxelEditMessages(PacketTypeVoxelErase, 1, &deleteVoxelDetail); + _tree->deleteVoxelAt(deleteVoxelDetail.x, deleteVoxelDetail.y, deleteVoxelDetail.z, deleteVoxelDetail.s); + } } } diff --git a/libraries/voxels/src/VoxelsScriptingInterface.h b/libraries/voxels/src/VoxelsScriptingInterface.h index d07d2a785c..71a8405be6 100644 --- a/libraries/voxels/src/VoxelsScriptingInterface.h +++ b/libraries/voxels/src/VoxelsScriptingInterface.h @@ -1,13 +1,16 @@ // // VoxelsScriptingInterface.h -// hifi +// libraries/voxels/src // // Created by Stephen Birarda on 9/17/13. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__VoxelsScriptingInterface__ -#define __hifi__VoxelsScriptingInterface__ +#ifndef hifi_VoxelsScriptingInterface_h +#define hifi_VoxelsScriptingInterface_h #include @@ -18,16 +21,19 @@ #include "VoxelEditPacketSender.h" #include "VoxelTree.h" +class QUndoStack; + /// handles scripting of voxel commands from JS passed to assigned clients class VoxelsScriptingInterface : public OctreeScriptingInterface { Q_OBJECT public: - VoxelsScriptingInterface() : _tree(NULL) {}; + VoxelsScriptingInterface() : _tree(NULL), _undoStack(NULL) {}; VoxelEditPacketSender* getVoxelPacketSender() { return (VoxelEditPacketSender*)getPacketSender(); } virtual NodeType_t getServerNodeType() const { return NodeType::VoxelServer; } virtual OctreeEditPacketSender* createPacketSender() { return new VoxelEditPacketSender(); } void setVoxelTree(VoxelTree* tree) { _tree = tree; } + void setUndoStack(QUndoStack* undoStack) { _undoStack = undoStack; } public slots: @@ -79,6 +85,7 @@ public slots: private: void queueVoxelAdd(PacketType addPacketType, VoxelDetail& addVoxelDetails); VoxelTree* _tree; + QUndoStack* _undoStack; }; -#endif /* defined(__hifi__VoxelsScriptingInterface__) */ +#endif // hifi_VoxelsScriptingInterface_h diff --git a/tests/metavoxels/src/MetavoxelTests.cpp b/tests/metavoxels/src/MetavoxelTests.cpp index a1b79319b5..2400e086eb 100644 --- a/tests/metavoxels/src/MetavoxelTests.cpp +++ b/tests/metavoxels/src/MetavoxelTests.cpp @@ -1,9 +1,12 @@ // // MetavoxelTests.cpp -// metavoxel-tests +// tests/metavoxels/src // // Created by Andrzej Kapolka on 2/7/14. -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/tests/metavoxels/src/MetavoxelTests.h b/tests/metavoxels/src/MetavoxelTests.h index 22a680acbb..206c818c6e 100644 --- a/tests/metavoxels/src/MetavoxelTests.h +++ b/tests/metavoxels/src/MetavoxelTests.h @@ -1,13 +1,16 @@ // // MetavoxelTests.h -// metavoxel-tests +// tests/metavoxels/src // // Created by Andrzej Kapolka on 2/7/14. -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __interface__MetavoxelTests__ -#define __interface__MetavoxelTests__ +#ifndef hifi_MetavoxelTests_h +#define hifi_MetavoxelTests_h #include #include @@ -157,4 +160,4 @@ public: DECLARE_STREAMABLE_METATYPE(SequencedTestMessage) -#endif /* defined(__interface__MetavoxelTests__) */ +#endif // hifi_MetavoxelTests_h diff --git a/tests/metavoxels/src/main.cpp b/tests/metavoxels/src/main.cpp index 10bf786957..51d4e565b2 100644 --- a/tests/metavoxels/src/main.cpp +++ b/tests/metavoxels/src/main.cpp @@ -1,9 +1,13 @@ // // main.cpp -// metavoxel-tests +// tests/metavoxels/src // // Created by Andrzej Kapolka on 2/7/14. -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// #include diff --git a/tests/physics/src/CollisionInfoTests.cpp b/tests/physics/src/CollisionInfoTests.cpp index 241204d036..ffc7e94cc4 100644 --- a/tests/physics/src/CollisionInfoTests.cpp +++ b/tests/physics/src/CollisionInfoTests.cpp @@ -1,9 +1,12 @@ // // CollisionInfoTests.cpp -// physics-tests +// tests/physics/src // -// Created by Andrew Meadows on 2014.02.21 -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Created by Andrew Meadows on 2/21/2014. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/tests/physics/src/CollisionInfoTests.h b/tests/physics/src/CollisionInfoTests.h index 51579e8f11..54c4e89e95 100644 --- a/tests/physics/src/CollisionInfoTests.h +++ b/tests/physics/src/CollisionInfoTests.h @@ -1,13 +1,16 @@ // // CollisionInfoTests.h -// physics-tests +// tests/physics/src // -// Created by Andrew Meadows on 2014.02.21 -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Created by Andrew Meadows on 2/21/2014. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __tests__CollisionInfoTests__ -#define __tests__CollisionInfoTests__ +#ifndef hifi_CollisionInfoTests_h +#define hifi_CollisionInfoTests_h namespace CollisionInfoTests { @@ -17,5 +20,4 @@ namespace CollisionInfoTests { void runAllTests(); } -#endif // __tests__CollisionInfoTests__ - +#endif // hifi_CollisionInfoTests_h diff --git a/tests/physics/src/PhysicsTestUtil.cpp b/tests/physics/src/PhysicsTestUtil.cpp index fb940d2043..f176d5e637 100644 --- a/tests/physics/src/PhysicsTestUtil.cpp +++ b/tests/physics/src/PhysicsTestUtil.cpp @@ -1,9 +1,12 @@ // // PhysicsTestUtil.cpp -// physics-tests +// tests/physics/src // -// Created by Andrew Meadows on 2014.02.21 -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Created by Andrew Meadows on 02/21/2014. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/tests/physics/src/PhysicsTestUtil.h b/tests/physics/src/PhysicsTestUtil.h index c4c7962466..998a18ff5d 100644 --- a/tests/physics/src/PhysicsTestUtil.h +++ b/tests/physics/src/PhysicsTestUtil.h @@ -1,13 +1,16 @@ // // PhysicsTestUtil.h -// physics-tests +// tests/physics/src // -// Created by Andrew Meadows on 2014.02.21 -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Created by Andrew Meadows on 02/21/2014. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __tests__PhysicsTestUtil__ -#define __tests__PhysicsTestUtil__ +#ifndef hifi_PhysicsTestUtil_h +#define hifi_PhysicsTestUtil_h #include #include @@ -23,4 +26,4 @@ std::ostream& operator<<(std::ostream& s, const glm::quat& q); std::ostream& operator<<(std::ostream& s, const glm::mat4& m); std::ostream& operator<<(std::ostream& s, const CollisionInfo& c); -#endif // __tests__PhysicsTestUtil__ +#endif // hifi_PhysicsTestUtil_h diff --git a/tests/physics/src/ShapeColliderTests.cpp b/tests/physics/src/ShapeColliderTests.cpp index 7aeec84651..f9e76bac0b 100644 --- a/tests/physics/src/ShapeColliderTests.cpp +++ b/tests/physics/src/ShapeColliderTests.cpp @@ -1,9 +1,12 @@ // // ShapeColliderTests.cpp -// physics-tests +// tests/physics/src // -// Created by Andrew Meadows on 2014.02.21 -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Created by Andrew Meadows on 02/21/2014. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // //#include @@ -40,7 +43,7 @@ void ShapeColliderTests::sphereMissesSphere() { // collide A to B... { - bool touching = ShapeCollider::shapeShape(&sphereA, &sphereB, collisions); + bool touching = ShapeCollider::collideShapes(&sphereA, &sphereB, collisions); if (touching) { std::cout << __FILE__ << ":" << __LINE__ << " ERROR: sphereA and sphereB should NOT touch" << std::endl; @@ -49,7 +52,7 @@ void ShapeColliderTests::sphereMissesSphere() { // collide B to A... { - bool touching = ShapeCollider::shapeShape(&sphereB, &sphereA, collisions); + bool touching = ShapeCollider::collideShapes(&sphereB, &sphereA, collisions); if (touching) { std::cout << __FILE__ << ":" << __LINE__ << " ERROR: sphereA and sphereB should NOT touch" << std::endl; @@ -58,7 +61,7 @@ void ShapeColliderTests::sphereMissesSphere() { // also test shapeShape { - bool touching = ShapeCollider::shapeShape(&sphereB, &sphereA, collisions); + bool touching = ShapeCollider::collideShapes(&sphereB, &sphereA, collisions); if (touching) { std::cout << __FILE__ << ":" << __LINE__ << " ERROR: sphereA and sphereB should NOT touch" << std::endl; @@ -90,7 +93,7 @@ void ShapeColliderTests::sphereTouchesSphere() { // collide A to B... { - bool touching = ShapeCollider::shapeShape(&sphereA, &sphereB, collisions); + bool touching = ShapeCollider::collideShapes(&sphereA, &sphereB, collisions); if (!touching) { std::cout << __FILE__ << ":" << __LINE__ << " ERROR: sphereA and sphereB should touch" << std::endl; @@ -133,7 +136,7 @@ void ShapeColliderTests::sphereTouchesSphere() { // collide B to A... { - bool touching = ShapeCollider::shapeShape(&sphereB, &sphereA, collisions); + bool touching = ShapeCollider::collideShapes(&sphereB, &sphereA, collisions); if (!touching) { std::cout << __FILE__ << ":" << __LINE__ << " ERROR: sphereA and sphereB should touch" << std::endl; @@ -196,7 +199,7 @@ void ShapeColliderTests::sphereMissesCapsule() { sphereA.setPosition(rotation * localPosition + translation); // sphereA agains capsuleB - if (ShapeCollider::shapeShape(&sphereA, &capsuleB, collisions)) + if (ShapeCollider::collideShapes(&sphereA, &capsuleB, collisions)) { std::cout << __FILE__ << ":" << __LINE__ << " ERROR: sphere and capsule should NOT touch" @@ -204,7 +207,7 @@ void ShapeColliderTests::sphereMissesCapsule() { } // capsuleB against sphereA - if (ShapeCollider::shapeShape(&capsuleB, &sphereA, collisions)) + if (ShapeCollider::collideShapes(&capsuleB, &sphereA, collisions)) { std::cout << __FILE__ << ":" << __LINE__ << " ERROR: sphere and capsule should NOT touch" @@ -238,7 +241,7 @@ void ShapeColliderTests::sphereTouchesCapsule() { { // sphereA collides with capsuleB's cylindrical wall sphereA.setPosition(radialOffset * xAxis); - if (!ShapeCollider::shapeShape(&sphereA, &capsuleB, collisions)) + if (!ShapeCollider::collideShapes(&sphereA, &capsuleB, collisions)) { std::cout << __FILE__ << ":" << __LINE__ << " ERROR: sphere and capsule should touch" @@ -269,7 +272,7 @@ void ShapeColliderTests::sphereTouchesCapsule() { } // capsuleB collides with sphereA - if (!ShapeCollider::shapeShape(&capsuleB, &sphereA, collisions)) + if (!ShapeCollider::collideShapes(&capsuleB, &sphereA, collisions)) { std::cout << __FILE__ << ":" << __LINE__ << " ERROR: capsule and sphere should touch" @@ -305,7 +308,7 @@ void ShapeColliderTests::sphereTouchesCapsule() { glm::vec3 axialOffset = (halfHeightB + alpha * radiusA + beta * radiusB) * yAxis; sphereA.setPosition(axialOffset * yAxis); - if (!ShapeCollider::shapeShape(&sphereA, &capsuleB, collisions)) + if (!ShapeCollider::collideShapes(&sphereA, &capsuleB, collisions)) { std::cout << __FILE__ << ":" << __LINE__ << " ERROR: sphere and capsule should touch" @@ -336,7 +339,7 @@ void ShapeColliderTests::sphereTouchesCapsule() { } // capsuleB collides with sphereA - if (!ShapeCollider::shapeShape(&capsuleB, &sphereA, collisions)) + if (!ShapeCollider::collideShapes(&capsuleB, &sphereA, collisions)) { std::cout << __FILE__ << ":" << __LINE__ << " ERROR: capsule and sphere should touch" @@ -372,7 +375,7 @@ void ShapeColliderTests::sphereTouchesCapsule() { glm::vec3 axialOffset = - (halfHeightB + alpha * radiusA + beta * radiusB) * yAxis; sphereA.setPosition(axialOffset * yAxis); - if (!ShapeCollider::shapeShape(&sphereA, &capsuleB, collisions)) + if (!ShapeCollider::collideShapes(&sphereA, &capsuleB, collisions)) { std::cout << __FILE__ << ":" << __LINE__ << " ERROR: sphere and capsule should touch" @@ -403,7 +406,7 @@ void ShapeColliderTests::sphereTouchesCapsule() { } // capsuleB collides with sphereA - if (!ShapeCollider::shapeShape(&capsuleB, &sphereA, collisions)) + if (!ShapeCollider::collideShapes(&capsuleB, &sphereA, collisions)) { std::cout << __FILE__ << ":" << __LINE__ << " ERROR: capsule and sphere should touch" @@ -459,13 +462,13 @@ void ShapeColliderTests::capsuleMissesCapsule() { // side by side capsuleB.setPosition((1.01f * totalRadius) * xAxis); - if (ShapeCollider::shapeShape(&capsuleA, &capsuleB, collisions)) + if (ShapeCollider::collideShapes(&capsuleA, &capsuleB, collisions)) { std::cout << __FILE__ << ":" << __LINE__ << " ERROR: capsule and capsule should NOT touch" << std::endl; } - if (ShapeCollider::shapeShape(&capsuleB, &capsuleA, collisions)) + if (ShapeCollider::collideShapes(&capsuleB, &capsuleA, collisions)) { std::cout << __FILE__ << ":" << __LINE__ << " ERROR: capsule and capsule should NOT touch" @@ -474,13 +477,13 @@ void ShapeColliderTests::capsuleMissesCapsule() { // end to end capsuleB.setPosition((1.01f * totalHalfLength) * xAxis); - if (ShapeCollider::shapeShape(&capsuleA, &capsuleB, collisions)) + if (ShapeCollider::collideShapes(&capsuleA, &capsuleB, collisions)) { std::cout << __FILE__ << ":" << __LINE__ << " ERROR: capsule and capsule should NOT touch" << std::endl; } - if (ShapeCollider::shapeShape(&capsuleB, &capsuleA, collisions)) + if (ShapeCollider::collideShapes(&capsuleB, &capsuleA, collisions)) { std::cout << __FILE__ << ":" << __LINE__ << " ERROR: capsule and capsule should NOT touch" @@ -491,13 +494,13 @@ void ShapeColliderTests::capsuleMissesCapsule() { glm::quat rotation = glm::angleAxis(PI_OVER_TWO, zAxis); capsuleB.setRotation(rotation); capsuleB.setPosition((1.01f * (totalRadius + capsuleB.getHalfHeight())) * xAxis); - if (ShapeCollider::shapeShape(&capsuleA, &capsuleB, collisions)) + if (ShapeCollider::collideShapes(&capsuleA, &capsuleB, collisions)) { std::cout << __FILE__ << ":" << __LINE__ << " ERROR: capsule and capsule should NOT touch" << std::endl; } - if (ShapeCollider::shapeShape(&capsuleB, &capsuleA, collisions)) + if (ShapeCollider::collideShapes(&capsuleB, &capsuleA, collisions)) { std::cout << __FILE__ << ":" << __LINE__ << " ERROR: capsule and capsule should NOT touch" @@ -529,7 +532,7 @@ void ShapeColliderTests::capsuleTouchesCapsule() { { // side by side capsuleB.setPosition((0.99f * totalRadius) * xAxis); - if (!ShapeCollider::shapeShape(&capsuleA, &capsuleB, collisions)) + if (!ShapeCollider::collideShapes(&capsuleA, &capsuleB, collisions)) { std::cout << __FILE__ << ":" << __LINE__ << " ERROR: capsule and capsule should touch" @@ -537,7 +540,7 @@ void ShapeColliderTests::capsuleTouchesCapsule() { } else { ++numCollisions; } - if (!ShapeCollider::shapeShape(&capsuleB, &capsuleA, collisions)) + if (!ShapeCollider::collideShapes(&capsuleB, &capsuleA, collisions)) { std::cout << __FILE__ << ":" << __LINE__ << " ERROR: capsule and capsule should touch" @@ -550,7 +553,7 @@ void ShapeColliderTests::capsuleTouchesCapsule() { { // end to end capsuleB.setPosition((0.99f * totalHalfLength) * yAxis); - if (!ShapeCollider::shapeShape(&capsuleA, &capsuleB, collisions)) + if (!ShapeCollider::collideShapes(&capsuleA, &capsuleB, collisions)) { std::cout << __FILE__ << ":" << __LINE__ << " ERROR: capsule and capsule should touch" @@ -558,7 +561,7 @@ void ShapeColliderTests::capsuleTouchesCapsule() { } else { ++numCollisions; } - if (!ShapeCollider::shapeShape(&capsuleB, &capsuleA, collisions)) + if (!ShapeCollider::collideShapes(&capsuleB, &capsuleA, collisions)) { std::cout << __FILE__ << ":" << __LINE__ << " ERROR: capsule and capsule should touch" @@ -573,7 +576,7 @@ void ShapeColliderTests::capsuleTouchesCapsule() { capsuleB.setRotation(rotation); capsuleB.setPosition((0.99f * (totalRadius + capsuleB.getHalfHeight())) * xAxis); - if (!ShapeCollider::shapeShape(&capsuleA, &capsuleB, collisions)) + if (!ShapeCollider::collideShapes(&capsuleA, &capsuleB, collisions)) { std::cout << __FILE__ << ":" << __LINE__ << " ERROR: capsule and capsule should touch" @@ -581,7 +584,7 @@ void ShapeColliderTests::capsuleTouchesCapsule() { } else { ++numCollisions; } - if (!ShapeCollider::shapeShape(&capsuleB, &capsuleA, collisions)) + if (!ShapeCollider::collideShapes(&capsuleB, &capsuleA, collisions)) { std::cout << __FILE__ << ":" << __LINE__ << " ERROR: capsule and capsule should touch" @@ -599,7 +602,7 @@ void ShapeColliderTests::capsuleTouchesCapsule() { capsuleB.setPosition(positionB); // capsuleA vs capsuleB - if (!ShapeCollider::shapeShape(&capsuleA, &capsuleB, collisions)) + if (!ShapeCollider::collideShapes(&capsuleA, &capsuleB, collisions)) { std::cout << __FILE__ << ":" << __LINE__ << " ERROR: capsule and capsule should touch" @@ -628,7 +631,7 @@ void ShapeColliderTests::capsuleTouchesCapsule() { } // capsuleB vs capsuleA - if (!ShapeCollider::shapeShape(&capsuleB, &capsuleA, collisions)) + if (!ShapeCollider::collideShapes(&capsuleB, &capsuleA, collisions)) { std::cout << __FILE__ << ":" << __LINE__ << " ERROR: capsule and capsule should touch" @@ -666,7 +669,7 @@ void ShapeColliderTests::capsuleTouchesCapsule() { capsuleB.setPosition(positionB); // capsuleA vs capsuleB - if (!ShapeCollider::shapeShape(&capsuleA, &capsuleB, collisions)) + if (!ShapeCollider::collideShapes(&capsuleA, &capsuleB, collisions)) { std::cout << __FILE__ << ":" << __LINE__ << " ERROR: capsule and capsule should touch" diff --git a/tests/physics/src/ShapeColliderTests.h b/tests/physics/src/ShapeColliderTests.h index ecd4a7f045..1d468a65d2 100644 --- a/tests/physics/src/ShapeColliderTests.h +++ b/tests/physics/src/ShapeColliderTests.h @@ -1,13 +1,16 @@ // // ShapeColliderTests.h -// physics-tests +// tests/physics/src // -// Created by Andrew Meadows on 2014.02.21 -// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// Created by Andrew Meadows on 02/21/2014. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __tests__ShapeColliderTests__ -#define __tests__ShapeColliderTests__ +#ifndef hifi_ShapeColliderTests_h +#define hifi_ShapeColliderTests_h namespace ShapeColliderTests { @@ -23,4 +26,4 @@ namespace ShapeColliderTests { void runAllTests(); } -#endif // __tests__ShapeColliderTests__ +#endif // hifi_ShapeColliderTests_h diff --git a/tests/physics/src/main.cpp b/tests/physics/src/main.cpp index b0a7adde4e..ca98f4d546 100644 --- a/tests/physics/src/main.cpp +++ b/tests/physics/src/main.cpp @@ -1,6 +1,11 @@ // // main.cpp -// physics-tests +// tests/physics/src +// +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "ShapeColliderTests.h" diff --git a/tools/mtc/src/main.cpp b/tools/mtc/src/main.cpp index 9c77851961..096ade4625 100644 --- a/tools/mtc/src/main.cpp +++ b/tools/mtc/src/main.cpp @@ -1,10 +1,12 @@ // // main.cpp -// mtc +// tools/mtc/src // // Created by Andrzej Kapolka on 12/31/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html #include @@ -143,13 +145,15 @@ void generateOutput (QTextStream& out, const QList& streamables) { out << " }\n"; out << " index = nextIndex;\n"; } - out << " switch (index) {\n"; - for (int i = 0; i < str.fields.size(); i++) { - out << " case " << i << ":\n"; - out << " this->" << str.fields.at(i).name << " = value.value<" << str.fields.at(i).type << ">();\n"; - out << " break;\n"; + if (!str.fields.isEmpty()) { + out << " switch (index) {\n"; + for (int i = 0; i < str.fields.size(); i++) { + out << " case " << i << ":\n"; + out << " this->" << str.fields.at(i).name << " = value.value<" << str.fields.at(i).type << ">();\n"; + out << " break;\n"; + } + out << " }\n"; } - out << " }\n"; out << "}\n"; out << "QVariant " << name << "::getField(int index) const {\n"; @@ -162,12 +166,14 @@ void generateOutput (QTextStream& out, const QList& streamables) { out << " }\n"; out << " index = nextIndex;\n"; } - out << " switch (index) {\n"; - for (int i = 0; i < str.fields.size(); i++) { - out << " case " << i << ":\n"; - out << " return QVariant::fromValue(this->" << str.fields.at(i).name << ");\n"; + if (!str.fields.isEmpty()) { + out << " switch (index) {\n"; + for (int i = 0; i < str.fields.size(); i++) { + out << " case " << i << ":\n"; + out << " return QVariant::fromValue(this->" << str.fields.at(i).name << ");\n"; + } + out << " }\n"; } - out << " }\n"; out << " return QVariant();\n"; out << "}\n"; diff --git a/voxel-edit/src/SceneUtils.cpp b/voxel-edit/src/SceneUtils.cpp index 2cbe73c74e..19e227c71a 100644 --- a/voxel-edit/src/SceneUtils.cpp +++ b/voxel-edit/src/SceneUtils.cpp @@ -1,9 +1,12 @@ // // SceneUtils.cpp -// hifi +// voxel-edit/src // // Created by Brad Hefta-Gaub on 5/7/2013. -// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include diff --git a/voxel-edit/src/SceneUtils.h b/voxel-edit/src/SceneUtils.h index 6f52a14f05..26c8130c4b 100644 --- a/voxel-edit/src/SceneUtils.h +++ b/voxel-edit/src/SceneUtils.h @@ -1,13 +1,16 @@ // // SceneUtils.h -// hifi +// voxel-edit/src // // Created by Brad Hefta-Gaub on 5/7/2013. +// Copyright 2013 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef __hifi__SceneUtil__ -#define __hifi__SceneUtil__ +#ifndef hifi_SceneUtils_h +#define hifi_SceneUtils_h #include "VoxelTree.h" #include @@ -16,4 +19,4 @@ void addCornersAndAxisLines(VoxelTree* tree); void addSurfaceScene(VoxelTree * tree); -#endif /* defined(__hifi__SceneUtil__) */ +#endif // hifi_SceneUtils_h diff --git a/voxel-edit/src/main.cpp b/voxel-edit/src/main.cpp index 35401aa1d0..01e4cc0189 100644 --- a/voxel-edit/src/main.cpp +++ b/voxel-edit/src/main.cpp @@ -1,9 +1,12 @@ // // main.cpp -// Voxel Edit +// voxel-edit/src // // Created by Brad Hefta-Gaub on 05/03/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include