mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 18:23:54 +02:00
Merge branch 'master' of https://github.com/worklist/hifi into 19705
This commit is contained in:
commit
b3b8e2d775
14 changed files with 91 additions and 43 deletions
|
@ -158,10 +158,11 @@ bool OctreeQueryNode::shouldSuppressDuplicatePacket() {
|
|||
|
||||
void OctreeQueryNode::init() {
|
||||
_myPacketType = getMyPacketType();
|
||||
resetOctreePacket(true); // don't bump sequence
|
||||
resetOctreePacket(); // don't bump sequence
|
||||
}
|
||||
|
||||
void OctreeQueryNode::resetOctreePacket(bool lastWasSurpressed) {
|
||||
|
||||
void OctreeQueryNode::resetOctreePacket() {
|
||||
// if shutting down, return immediately
|
||||
if (_isShuttingDown) {
|
||||
return;
|
||||
|
@ -196,15 +197,12 @@ void OctreeQueryNode::resetOctreePacket(bool lastWasSurpressed) {
|
|||
*flagsAt = flags;
|
||||
_octreePacketAt += sizeof(OCTREE_PACKET_FLAGS);
|
||||
_octreePacketAvailableBytes -= sizeof(OCTREE_PACKET_FLAGS);
|
||||
|
||||
|
||||
// pack in sequence number
|
||||
OCTREE_PACKET_SEQUENCE* sequenceAt = (OCTREE_PACKET_SEQUENCE*)_octreePacketAt;
|
||||
*sequenceAt = _sequenceNumber;
|
||||
_octreePacketAt += sizeof(OCTREE_PACKET_SEQUENCE);
|
||||
_octreePacketAvailableBytes -= sizeof(OCTREE_PACKET_SEQUENCE);
|
||||
if (!(lastWasSurpressed || _lastOctreePacketLength == (numBytesPacketHeader + OCTREE_PACKET_EXTRA_HEADERS_SIZE))) {
|
||||
_sequenceNumber++;
|
||||
}
|
||||
|
||||
// pack in timestamp
|
||||
OCTREE_PACKET_SENT_TIME now = usecTimestampNow();
|
||||
|
@ -365,3 +363,6 @@ void OctreeQueryNode::dumpOutOfView() {
|
|||
}
|
||||
}
|
||||
|
||||
void OctreeQueryNode::incrementSequenceNumber() {
|
||||
_sequenceNumber++;
|
||||
}
|
|
@ -35,7 +35,7 @@ public:
|
|||
void init(); // called after creation to set up some virtual items
|
||||
virtual PacketType getMyPacketType() const = 0;
|
||||
|
||||
void resetOctreePacket(bool lastWasSurpressed = false); // resets octree packet to after "V" header
|
||||
void resetOctreePacket(); // resets octree packet to after "V" header
|
||||
|
||||
void writeToPacket(const unsigned char* buffer, unsigned int bytes); // writes to end of packet
|
||||
|
||||
|
@ -99,6 +99,8 @@ public:
|
|||
void nodeKilled();
|
||||
void forceNodeShutdown();
|
||||
bool isShuttingDown() const { return _isShuttingDown; }
|
||||
|
||||
void incrementSequenceNumber();
|
||||
|
||||
private slots:
|
||||
void sendThreadFinished();
|
||||
|
@ -135,8 +137,9 @@ private:
|
|||
float _lastClientOctreeSizeScale;
|
||||
bool _lodChanged;
|
||||
bool _lodInitialized;
|
||||
|
||||
|
||||
OCTREE_PACKET_SEQUENCE _sequenceNumber;
|
||||
|
||||
quint64 _lastRootTimestamp;
|
||||
|
||||
PacketType _myPacketType;
|
||||
|
|
|
@ -9,8 +9,6 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <QMutexLocker>
|
||||
|
||||
#include <NodeList.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <PerfStat.h>
|
||||
|
@ -139,7 +137,7 @@ int OctreeSendThread::handlePacketSend(OctreeQueryNode* nodeData, int& trueBytes
|
|||
// obscure the packet and not send it. This allows the callers and upper level logic to not need to know about
|
||||
// this rate control savings.
|
||||
if (nodeData->shouldSuppressDuplicatePacket()) {
|
||||
nodeData->resetOctreePacket(true); // we still need to reset it though!
|
||||
nodeData->resetOctreePacket(); // we still need to reset it though!
|
||||
return packetsSent; // without sending...
|
||||
}
|
||||
|
||||
|
@ -244,6 +242,7 @@ int OctreeSendThread::handlePacketSend(OctreeQueryNode* nodeData, int& trueBytes
|
|||
trueBytesSent += nodeData->getPacketLength();
|
||||
truePacketsSent++;
|
||||
packetsSent++;
|
||||
nodeData->incrementSequenceNumber();
|
||||
nodeData->resetOctreePacket();
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
// 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
|
||||
var alwaysLook = false; // if you want the mouse look to happen only when you click, change this to false
|
||||
var isMouseDown = false;
|
||||
var lastX = 0;
|
||||
var lastY = 0;
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
// the diffuse texture
|
||||
uniform sampler2D diffuseMap;
|
||||
|
||||
// the interpolated position
|
||||
varying vec4 position;
|
||||
|
||||
// the interpolated normal
|
||||
varying vec4 normal;
|
||||
|
||||
|
@ -26,7 +29,7 @@ void main(void) {
|
|||
gl_FrontLightProduct[0].diffuse * (diffuse * facingLight));
|
||||
|
||||
// compute the specular component (sans exponent)
|
||||
float specular = facingLight * max(0.0, dot(normalize(gl_LightSource[0].position + vec4(0.0, 0.0, 1.0, 0.0)),
|
||||
float specular = facingLight * max(0.0, dot(normalize(gl_LightSource[0].position - normalize(vec4(position.xyz, 0.0))),
|
||||
normalizedNormal));
|
||||
|
||||
// modulate texture by base color and add specular contribution
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
// the interpolated position
|
||||
varying vec4 position;
|
||||
|
||||
// the interpolated normal
|
||||
varying vec4 normal;
|
||||
|
||||
|
@ -19,6 +22,9 @@ void main(void) {
|
|||
// transform and store the normal for interpolation
|
||||
normal = normalize(gl_ModelViewMatrix * vec4(gl_Normal, 0.0));
|
||||
|
||||
// likewise with the position
|
||||
position = gl_ModelViewMatrix * gl_Vertex;
|
||||
|
||||
// pass along the vertex color
|
||||
gl_FrontColor = gl_Color;
|
||||
|
||||
|
|
|
@ -17,6 +17,9 @@ uniform sampler2D diffuseMap;
|
|||
// the normal map texture
|
||||
uniform sampler2D normalMap;
|
||||
|
||||
// the interpolated position
|
||||
varying vec4 interpolatedPosition;
|
||||
|
||||
// the interpolated normal
|
||||
varying vec4 interpolatedNormal;
|
||||
|
||||
|
@ -38,8 +41,8 @@ void main(void) {
|
|||
gl_FrontLightProduct[0].diffuse * (diffuse * facingLight));
|
||||
|
||||
// compute the specular component (sans exponent)
|
||||
float specular = facingLight * max(0.0, dot(normalize(gl_LightSource[0].position + vec4(0.0, 0.0, 1.0, 0.0)),
|
||||
viewNormal));
|
||||
float specular = facingLight * max(0.0, dot(normalize(gl_LightSource[0].position -
|
||||
normalize(vec4(vec3(interpolatedPosition), 0.0))), viewNormal));
|
||||
|
||||
// modulate texture by base color and add specular contribution
|
||||
gl_FragColor = base * texture2D(diffuseMap, gl_TexCoord[0].st) +
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
// the tangent vector
|
||||
attribute vec3 tangent;
|
||||
|
||||
// the interpolated position
|
||||
varying vec4 interpolatedPosition;
|
||||
|
||||
// the interpolated normal
|
||||
varying vec4 interpolatedNormal;
|
||||
|
||||
|
@ -22,7 +25,8 @@ varying vec4 interpolatedTangent;
|
|||
|
||||
void main(void) {
|
||||
|
||||
// transform and store the normal and tangent for interpolation
|
||||
// transform and store the position, normal and tangent for interpolation
|
||||
interpolatedPosition = gl_ModelViewMatrix * gl_Vertex;
|
||||
interpolatedNormal = gl_ModelViewMatrix * vec4(gl_Normal, 0.0);
|
||||
interpolatedTangent = gl_ModelViewMatrix * vec4(tangent, 0.0);
|
||||
|
||||
|
|
|
@ -20,6 +20,9 @@ uniform sampler2D normalMap;
|
|||
// the specular map texture
|
||||
uniform sampler2D specularMap;
|
||||
|
||||
// the interpolated position
|
||||
varying vec4 interpolatedPosition;
|
||||
|
||||
// the interpolated normal
|
||||
varying vec4 interpolatedNormal;
|
||||
|
||||
|
@ -41,8 +44,8 @@ void main(void) {
|
|||
gl_FrontLightProduct[0].diffuse * (diffuse * facingLight));
|
||||
|
||||
// compute the specular component (sans exponent)
|
||||
float specular = facingLight * max(0.0, dot(normalize(gl_LightSource[0].position + vec4(0.0, 0.0, 1.0, 0.0)),
|
||||
viewNormal));
|
||||
float specular = facingLight * max(0.0, dot(normalize(gl_LightSource[0].position -
|
||||
normalize(vec4(interpolatedPosition.xyz, 0.0))), viewNormal));
|
||||
|
||||
// modulate texture by base color and add specular contribution
|
||||
gl_FragColor = base * texture2D(diffuseMap, gl_TexCoord[0].st) + vec4(pow(specular, gl_FrontMaterial.shininess) *
|
||||
|
|
|
@ -17,6 +17,9 @@ uniform sampler2D diffuseMap;
|
|||
// the specular texture
|
||||
uniform sampler2D specularMap;
|
||||
|
||||
// the interpolated position in view space
|
||||
varying vec4 position;
|
||||
|
||||
// the interpolated normal
|
||||
varying vec4 normal;
|
||||
|
||||
|
@ -29,7 +32,7 @@ void main(void) {
|
|||
gl_FrontLightProduct[0].diffuse * (diffuse * facingLight));
|
||||
|
||||
// compute the specular component (sans exponent)
|
||||
float specular = facingLight * max(0.0, dot(normalize(gl_LightSource[0].position + vec4(0.0, 0.0, 1.0, 0.0)),
|
||||
float specular = facingLight * max(0.0, dot(normalize(gl_LightSource[0].position - normalize(vec4(position.xyz, 0.0))),
|
||||
normalizedNormal));
|
||||
|
||||
// modulate texture by base color and add specular contribution
|
||||
|
|
|
@ -19,11 +19,14 @@ uniform mat4 clusterMatrices[MAX_CLUSTERS];
|
|||
attribute vec4 clusterIndices;
|
||||
attribute vec4 clusterWeights;
|
||||
|
||||
// the interpolated position
|
||||
varying vec4 position;
|
||||
|
||||
// the interpolated normal
|
||||
varying vec4 normal;
|
||||
|
||||
void main(void) {
|
||||
vec4 position = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
position = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
normal = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
for (int i = 0; i < INDICES_PER_VERTEX; i++) {
|
||||
mat4 clusterMatrix = clusterMatrices[int(clusterIndices[i])];
|
||||
|
@ -31,7 +34,7 @@ void main(void) {
|
|||
position += clusterMatrix * gl_Vertex * clusterWeight;
|
||||
normal += clusterMatrix * vec4(gl_Normal, 0.0) * clusterWeight;
|
||||
}
|
||||
position = gl_ModelViewProjectionMatrix * position;
|
||||
position = gl_ModelViewMatrix * position;
|
||||
normal = normalize(gl_ModelViewMatrix * normal);
|
||||
|
||||
// pass along the vertex color
|
||||
|
@ -40,5 +43,5 @@ void main(void) {
|
|||
// and the texture coordinates
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
|
||||
gl_Position = position;
|
||||
gl_Position = gl_ProjectionMatrix * position;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,9 @@ attribute vec3 tangent;
|
|||
attribute vec4 clusterIndices;
|
||||
attribute vec4 clusterWeights;
|
||||
|
||||
// the interpolated position
|
||||
varying vec4 interpolatedPosition;
|
||||
|
||||
// the interpolated normal
|
||||
varying vec4 interpolatedNormal;
|
||||
|
||||
|
@ -29,17 +32,17 @@ varying vec4 interpolatedNormal;
|
|||
varying vec4 interpolatedTangent;
|
||||
|
||||
void main(void) {
|
||||
vec4 position = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
interpolatedPosition = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
interpolatedNormal = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
interpolatedTangent = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
for (int i = 0; i < INDICES_PER_VERTEX; i++) {
|
||||
mat4 clusterMatrix = clusterMatrices[int(clusterIndices[i])];
|
||||
float clusterWeight = clusterWeights[i];
|
||||
position += clusterMatrix * gl_Vertex * clusterWeight;
|
||||
interpolatedPosition += clusterMatrix * gl_Vertex * clusterWeight;
|
||||
interpolatedNormal += clusterMatrix * vec4(gl_Normal, 0.0) * clusterWeight;
|
||||
interpolatedTangent += clusterMatrix * vec4(tangent, 0.0) * clusterWeight;
|
||||
}
|
||||
position = gl_ModelViewProjectionMatrix * position;
|
||||
interpolatedPosition = gl_ModelViewMatrix * interpolatedPosition;
|
||||
interpolatedNormal = gl_ModelViewMatrix * interpolatedNormal;
|
||||
interpolatedTangent = gl_ModelViewMatrix * interpolatedTangent;
|
||||
|
||||
|
@ -49,5 +52,5 @@ void main(void) {
|
|||
// and the texture coordinates
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
|
||||
gl_Position = position;
|
||||
gl_Position = gl_ProjectionMatrix * interpolatedPosition;
|
||||
}
|
||||
|
|
|
@ -39,25 +39,35 @@ void Overlays::init(QGLWidget* parent) {
|
|||
}
|
||||
|
||||
void Overlays::update(float deltatime) {
|
||||
foreach (Overlay* thisOverlay, _overlays2D) {
|
||||
thisOverlay->update(deltatime);
|
||||
|
||||
{
|
||||
QWriteLocker lock(&_lock);
|
||||
foreach(Overlay* thisOverlay, _overlays2D) {
|
||||
thisOverlay->update(deltatime);
|
||||
}
|
||||
foreach(Overlay* thisOverlay, _overlays3D) {
|
||||
thisOverlay->update(deltatime);
|
||||
}
|
||||
}
|
||||
foreach (Overlay* thisOverlay, _overlays3D) {
|
||||
thisOverlay->update(deltatime);
|
||||
}
|
||||
while (!_overlaysToDelete.isEmpty()) {
|
||||
delete _overlaysToDelete.takeLast();
|
||||
|
||||
if (!_overlaysToDelete.isEmpty()) {
|
||||
QWriteLocker lock(&_deleteLock);
|
||||
do {
|
||||
delete _overlaysToDelete.takeLast();
|
||||
} while (!_overlaysToDelete.isEmpty());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Overlays::render2D() {
|
||||
QReadLocker lock(&_lock);
|
||||
foreach(Overlay* thisOverlay, _overlays2D) {
|
||||
thisOverlay->render();
|
||||
}
|
||||
}
|
||||
|
||||
void Overlays::render3D() {
|
||||
QReadLocker lock(&_lock);
|
||||
if (_overlays3D.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -96,7 +106,6 @@ void Overlays::render3D() {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: make multi-threaded safe
|
||||
unsigned int Overlays::addOverlay(const QString& type, const QScriptValue& properties) {
|
||||
unsigned int thisID = 0;
|
||||
bool created = false;
|
||||
|
@ -140,6 +149,7 @@ unsigned int Overlays::addOverlay(const QString& type, const QScriptValue& prope
|
|||
}
|
||||
|
||||
if (created) {
|
||||
QWriteLocker lock(&_lock);
|
||||
thisID = _nextOverlayID;
|
||||
_nextOverlayID++;
|
||||
if (is3D) {
|
||||
|
@ -152,9 +162,9 @@ unsigned int Overlays::addOverlay(const QString& type, const QScriptValue& prope
|
|||
return thisID;
|
||||
}
|
||||
|
||||
// TODO: make multi-threaded safe
|
||||
bool Overlays::editOverlay(unsigned int id, const QScriptValue& properties) {
|
||||
Overlay* thisOverlay = NULL;
|
||||
QWriteLocker lock(&_lock);
|
||||
if (_overlays2D.contains(id)) {
|
||||
thisOverlay = _overlays2D[id];
|
||||
} else if (_overlays3D.contains(id)) {
|
||||
|
@ -167,21 +177,26 @@ bool Overlays::editOverlay(unsigned int id, const QScriptValue& properties) {
|
|||
return false;
|
||||
}
|
||||
|
||||
// TODO: make multi-threaded safe
|
||||
void Overlays::deleteOverlay(unsigned int id) {
|
||||
Overlay* overlayToDelete;
|
||||
if (_overlays2D.contains(id)) {
|
||||
overlayToDelete = _overlays2D.take(id);
|
||||
} else if (_overlays3D.contains(id)) {
|
||||
overlayToDelete = _overlays3D.take(id);
|
||||
} else {
|
||||
return;
|
||||
|
||||
{
|
||||
QWriteLocker lock(&_lock);
|
||||
if (_overlays2D.contains(id)) {
|
||||
overlayToDelete = _overlays2D.take(id);
|
||||
} else if (_overlays3D.contains(id)) {
|
||||
overlayToDelete = _overlays3D.take(id);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QWriteLocker lock(&_deleteLock);
|
||||
_overlaysToDelete.push_back(overlayToDelete);
|
||||
}
|
||||
|
||||
unsigned int Overlays::getOverlayAtPoint(const glm::vec2& point) {
|
||||
QReadLocker lock(&_lock);
|
||||
QMapIterator<unsigned int, Overlay*> i(_overlays2D);
|
||||
i.toBack();
|
||||
while (i.hasPrevious()) {
|
||||
|
|
|
@ -45,6 +45,8 @@ private:
|
|||
QList<Overlay*> _overlaysToDelete;
|
||||
unsigned int _nextOverlayID;
|
||||
QGLWidget* _parent;
|
||||
QReadWriteLock _lock;
|
||||
QReadWriteLock _deleteLock;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue