Merge branch 'atp' of https://github.com/birarda/hifi into protocol

This commit is contained in:
Atlante45 2015-07-08 18:55:14 -07:00
commit 4bc71bb39e
38 changed files with 648 additions and 218 deletions

View file

@ -13,9 +13,8 @@
#include "AssignmentAction.h" #include "AssignmentAction.h"
AssignmentAction::AssignmentAction(EntityActionType type, QUuid id, EntityItemPointer ownerEntity) : AssignmentAction::AssignmentAction(EntityActionType type, const QUuid& id, EntityItemPointer ownerEntity) :
_id(id), EntityActionInterface(type, id),
_type(type),
_data(QByteArray()), _data(QByteArray()),
_active(false), _active(false),
_ownerEntity(ownerEntity) { _ownerEntity(ownerEntity) {
@ -28,7 +27,7 @@ void AssignmentAction::removeFromSimulation(EntitySimulation* simulation) const
simulation->removeAction(_id); simulation->removeAction(_id);
} }
QByteArray AssignmentAction::serialize() { QByteArray AssignmentAction::serialize() const {
return _data; return _data;
} }

View file

@ -21,23 +21,19 @@
class AssignmentAction : public EntityActionInterface { class AssignmentAction : public EntityActionInterface {
public: public:
AssignmentAction(EntityActionType type, QUuid id, EntityItemPointer ownerEntity); AssignmentAction(EntityActionType type, const QUuid& id, EntityItemPointer ownerEntity);
virtual ~AssignmentAction(); virtual ~AssignmentAction();
const QUuid& getID() const { return _id; }
virtual EntityActionType getType() { return _type; }
virtual void removeFromSimulation(EntitySimulation* simulation) const; virtual void removeFromSimulation(EntitySimulation* simulation) const;
virtual EntityItemWeakPointer getOwnerEntity() const { return _ownerEntity; } virtual EntityItemWeakPointer getOwnerEntity() const { return _ownerEntity; }
virtual void setOwnerEntity(const EntityItemPointer ownerEntity) { _ownerEntity = ownerEntity; } virtual void setOwnerEntity(const EntityItemPointer ownerEntity) { _ownerEntity = ownerEntity; }
virtual bool updateArguments(QVariantMap arguments); virtual bool updateArguments(QVariantMap arguments);
virtual QVariantMap getArguments(); virtual QVariantMap getArguments();
virtual QByteArray serialize(); virtual QByteArray serialize() const;
virtual void deserialize(QByteArray serializedArguments); virtual void deserialize(QByteArray serializedArguments);
private: private:
QUuid _id;
EntityActionType _type;
QByteArray _data; QByteArray _data;
protected: protected:

View file

@ -12,14 +12,14 @@
#include "AssignmentActionFactory.h" #include "AssignmentActionFactory.h"
EntityActionPointer assignmentActionFactory(EntityActionType type, QUuid id, EntityItemPointer ownerEntity) { EntityActionPointer assignmentActionFactory(EntityActionType type, const QUuid& id, EntityItemPointer ownerEntity) {
return (EntityActionPointer) new AssignmentAction(type, id, ownerEntity); return (EntityActionPointer) new AssignmentAction(type, id, ownerEntity);
} }
EntityActionPointer AssignmentActionFactory::factory(EntitySimulation* simulation, EntityActionPointer AssignmentActionFactory::factory(EntitySimulation* simulation,
EntityActionType type, EntityActionType type,
QUuid id, const QUuid& id,
EntityItemPointer ownerEntity, EntityItemPointer ownerEntity,
QVariantMap arguments) { QVariantMap arguments) {
EntityActionPointer action = assignmentActionFactory(type, id, ownerEntity); EntityActionPointer action = assignmentActionFactory(type, id, ownerEntity);

View file

@ -21,7 +21,7 @@ public:
virtual ~AssignmentActionFactory() { } virtual ~AssignmentActionFactory() { }
virtual EntityActionPointer factory(EntitySimulation* simulation, virtual EntityActionPointer factory(EntitySimulation* simulation,
EntityActionType type, EntityActionType type,
QUuid id, const QUuid& id,
EntityItemPointer ownerEntity, EntityItemPointer ownerEntity,
QVariantMap arguments); QVariantMap arguments);
virtual EntityActionPointer factoryBA(EntitySimulation* simulation, virtual EntityActionPointer factoryBA(EntitySimulation* simulation,

View file

@ -4,8 +4,8 @@ string(TOUPPER ${EXTERNAL_NAME} EXTERNAL_NAME_UPPER)
include(ExternalProject) include(ExternalProject)
ExternalProject_Add( ExternalProject_Add(
${EXTERNAL_NAME} ${EXTERNAL_NAME}
GIT_REPOSITORY https://github.com/matus-chochlik/oglplus.git URL http://iweb.dl.sourceforge.net/project/oglplus/oglplus-0.63.x/oglplus-0.63.0.zip
GIT_TAG a2681383928b1166f176512cbe0f95e96fe68d08 URL_MD5 de984ab245b185b45c87415c0e052135
CONFIGURE_COMMAND "" CONFIGURE_COMMAND ""
BUILD_COMMAND "" BUILD_COMMAND ""
INSTALL_COMMAND "" INSTALL_COMMAND ""

View file

@ -12,7 +12,6 @@ Script.load("progress.js");
Script.load("edit.js"); Script.load("edit.js");
Script.load("selectAudioDevice.js"); Script.load("selectAudioDevice.js");
Script.load("inspect.js"); Script.load("inspect.js");
Script.load("lobby.js");
Script.load("notifications.js"); Script.load("notifications.js");
Script.load("users.js"); Script.load("users.js");
Script.load("grab.js"); Script.load("grab.js");

View file

@ -0,0 +1,70 @@
//
// make-dummy.js
// examples
//
// Created by Seth Alves on 2015-6-10
// Copyright 2015 High Fidelity, Inc.
//
// Makes a boxing-dummy that responds to collisions.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
//
"use strict";
/*jslint vars: true*/
var Overlays, Entities, Controller, Script, MyAvatar, Vec3; // Referenced globals provided by High Fidelity.
var HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
var rezButton = Overlays.addOverlay("image", {
x: 100,
y: 350,
width: 32,
height: 32,
imageURL: HIFI_PUBLIC_BUCKET + "images/close.png",
color: {
red: 255,
green: 255,
blue: 255
},
alpha: 1
});
function mousePressEvent(event) {
var clickedOverlay = Overlays.getOverlayAtPoint({
x: event.x,
y: event.y
});
if (clickedOverlay === rezButton) {
var boxId;
var position = Vec3.sum(MyAvatar.position, {x: 1.0, y: 0.4, z: 0.0});
boxId = Entities.addEntity({
type: "Box",
name: "dummy",
position: position,
dimensions: {x: 0.3, y: 0.7, z: 0.3},
gravity: {x: 0.0, y: -3.0, z: 0.0},
damping: 0.2,
collisionsWillMove: true
});
var pointToOffsetFrom = Vec3.sum(position, {x: 0.0, y: 2.0, z: 0.0});
Entities.addAction("offset", boxId, {pointToOffsetFrom: pointToOffsetFrom,
linearDistance: 2.0,
// linearTimeScale: 0.005
linearTimeScale: 0.1
});
}
}
function scriptEnding() {
Overlays.deleteOverlay(rezButton);
}
Controller.mousePressEvent.connect(mousePressEvent);
Script.scriptEnding.connect(scriptEnding);

View file

@ -0,0 +1,269 @@
// stick.js
// examples
//
// Created by Seth Alves on 2015-6-10
// Copyright 2015 High Fidelity, Inc.
//
// Allow avatar to hold a stick
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
"use strict";
/*jslint vars: true*/
var Script, Entities, MyAvatar, Window, Overlays, Controller, Vec3, Quat, print, ToolBar; // Referenced globals provided by High Fidelity.
Script.include(["../../libraries/toolBars.js"]);
var hand = "right";
var nullActionID = "00000000-0000-0000-0000-000000000000";
var controllerID;
var controllerActive;
var stickID = null;
var actionID = nullActionID;
var targetIDs = [];
var dimensions = { x: 0.3, y: 0.1, z: 2.0 };
var AWAY_ORIENTATION = Quat.fromPitchYawRollDegrees(-90, 0, 0);
var BUTTON_SIZE = 32;
var stickModel = "https://hifi-public.s3.amazonaws.com/eric/models/stick.fbx";
var swordModel = "https://hifi-public.s3.amazonaws.com/ozan/props/sword/sword.fbx";
var whichModel = "sword";
var attachmentOffset, MOUSE_CONTROLLER_OFFSET = {x: 0.5, y: 0.4, z: 0.0}; // A fudge when using mouse rather than hand-controller, to hit yourself less often.
var toolBar = new ToolBar(0, 0, ToolBar.vertical, "highfidelity.sword.toolbar", function () {
return {x: 100, y: 380};
});
var SWORD_IMAGE = "http://s3.amazonaws.com/hifi-public/images/billiardsReticle.png"; // Toggle between brandishing/sheathing sword (creating if necessary)
var TARGET_IMAGE = "http://s3.amazonaws.com/hifi-public/images/puck.png"; // Create a target dummy
var CLEANUP_IMAGE = "http://s3.amazonaws.com/hifi-public/images/delete.png"; // Remove sword and all target dummies.f
var swordButton = toolBar.addOverlay("image", {
width: BUTTON_SIZE,
height: BUTTON_SIZE,
imageURL: SWORD_IMAGE,
alpha: 1
});
var targetButton = toolBar.addOverlay("image", {
width: BUTTON_SIZE,
height: BUTTON_SIZE,
imageURL: TARGET_IMAGE,
alpha: 1
});
var cleanupButton = toolBar.addOverlay("image", {
width: BUTTON_SIZE,
height: BUTTON_SIZE,
imageURL: CLEANUP_IMAGE,
alpha: 1
});
var flasher;
function clearFlash() {
if (!flasher) {
return;
}
Script.clearTimeout(flasher.timer);
Overlays.deleteOverlay(flasher.overlay);
flasher = null;
}
function flash(color) {
clearFlash();
flasher = {};
flasher.overlay = Overlays.addOverlay("text", {
backgroundColor: color,
backgroundAlpha: 0.7,
width: Window.innerWidth,
height: Window.innerHeight
});
flasher.timer = Script.setTimeout(clearFlash, 500);
}
var health = 100;
var display;
var isAway = false;
function updateDisplay() {
var text = health.toString();
if (!display) {
health = 100;
display = Overlays.addOverlay("text", {
text: text,
font: { size: 20 },
color: {red: 0, green: 255, blue: 0},
backgroundColor: {red: 100, green: 100, blue: 100}, // Why doesn't this and the next work?
backgroundAlpha: 0.9,
x: Window.innerWidth - 50,
y: 50
});
} else {
Overlays.editOverlay(display, {text: text});
}
}
function removeDisplay() {
if (display) {
Overlays.deleteOverlay(display);
display = null;
}
}
function cleanUp(leaveButtons) {
attachmentOffset = {x: 0, y: 0, z: 0};
if (stickID) {
Entities.deleteAction(stickID, actionID);
Entities.deleteEntity(stickID);
stickID = null;
actionID = null;
}
targetIDs.forEach(function (id) {
Entities.deleteAction(id.entity, id.action);
Entities.deleteEntity(id.entity);
});
targetIDs = [];
removeDisplay();
if (!leaveButtons) {
toolBar.cleanup();
}
}
function computeEnergy(collision, entityID) {
var id = entityID || collision.idA || collision.idB;
var entity = id && Entities.getEntityProperties(id);
var mass = entity ? (entity.density * entity.dimensions.x * entity.dimensions.y * entity.dimensions.z) : 1;
var linearVelocityChange = Vec3.length(collision.velocityChange);
var energy = 0.5 * mass * linearVelocityChange * linearVelocityChange;
return Math.min(Math.max(1.0, Math.round(energy)), 20);
}
function gotHit(collision) {
if (isAway) { return; }
var energy = computeEnergy(collision);
health -= energy;
flash({red: 255, green: 0, blue: 0});
updateDisplay();
}
function scoreHit(idA, idB, collision) {
if (isAway) { return; }
var energy = computeEnergy(collision, idA);
health += energy;
flash({red: 0, green: 255, blue: 0});
updateDisplay();
}
function positionStick(stickOrientation) {
var baseOffset = Vec3.sum(attachmentOffset, {x: 0.0, y: 0.0, z: -dimensions.z / 2});
var offset = Vec3.multiplyQbyV(stickOrientation, baseOffset);
Entities.updateAction(stickID, actionID, {relativePosition: offset,
relativeRotation: stickOrientation});
}
function mouseMoveEvent(event) {
attachmentOffset = MOUSE_CONTROLLER_OFFSET;
if (!stickID || actionID === nullActionID || isAway) {
return;
}
var windowCenterX = Window.innerWidth / 2;
var windowCenterY = Window.innerHeight / 2;
var mouseXCenterOffset = event.x - windowCenterX;
var mouseYCenterOffset = event.y - windowCenterY;
var mouseXRatio = mouseXCenterOffset / windowCenterX;
var mouseYRatio = mouseYCenterOffset / windowCenterY;
var stickOrientation = Quat.fromPitchYawRollDegrees(mouseYRatio * -90, mouseXRatio * -90, 0);
positionStick(stickOrientation);
}
function initControls() {
if (hand === "right") {
controllerID = 3; // right handed
} else {
controllerID = 4; // left handed
}
}
function update() {
var palmPosition = Controller.getSpatialControlPosition(controllerID);
controllerActive = (Vec3.length(palmPosition) > 0);
if (!controllerActive) {
return;
}
var stickOrientation = Controller.getSpatialControlRawRotation(controllerID);
var adjustment = Quat.fromPitchYawRollDegrees(180, 0, 0);
stickOrientation = Quat.multiply(stickOrientation, adjustment);
positionStick(stickOrientation);
}
function toggleAway() {
isAway = !isAway;
if (isAway) {
positionStick(AWAY_ORIENTATION);
removeDisplay();
} else {
updateDisplay();
}
}
function onClick(event) {
switch (Overlays.getOverlayAtPoint(event)) {
case swordButton:
if (!stickID) {
initControls();
stickID = Entities.addEntity({
type: "Model",
modelURL: (whichModel === "sword") ? swordModel : stickModel,
//compoundShapeURL: "https://hifi-public.s3.amazonaws.com/eric/models/stick.obj",
shapeType: "box",
dimensions: dimensions,
position: MyAvatar.getRightPalmPosition(), // initial position doesn't matter, as long as it's close
rotation: MyAvatar.orientation,
damping: 0.1,
collisionSoundURL: "http://public.highfidelity.io/sounds/Collisions-hitsandslaps/swordStrike1.wav",
restitution: 0.01,
collisionsWillMove: true
});
actionID = Entities.addAction("hold", stickID, {relativePosition: {x: 0.0, y: 0.0, z: -dimensions.z / 2},
hand: hand,
timeScale: 0.15});
if (actionID === nullActionID) {
print('*** FAILED TO MAKE SWORD ACTION ***');
cleanUp();
}
Script.addEventHandler(stickID, 'collisionWithEntity', scoreHit);
updateDisplay();
} else {
toggleAway();
}
break;
case targetButton:
var position = Vec3.sum(MyAvatar.position, {x: 1.0, y: 0.4, z: 0.0});
var boxId = Entities.addEntity({
type: "Box",
name: "dummy",
position: position,
dimensions: {x: 0.3, y: 0.7, z: 0.3},
gravity: {x: 0.0, y: -3.0, z: 0.0},
damping: 0.2,
collisionsWillMove: true
});
var pointToOffsetFrom = Vec3.sum(position, {x: 0.0, y: 2.0, z: 0.0});
var action = Entities.addAction("offset", boxId, {pointToOffsetFrom: pointToOffsetFrom,
linearDistance: 2.0,
// linearTimeScale: 0.005
linearTimeScale: 0.1
});
targetIDs.push({entity: boxId, action: action});
break;
case cleanupButton:
cleanUp('leaveButtons');
break;
}
}
Script.scriptEnding.connect(cleanUp);
Controller.mouseMoveEvent.connect(mouseMoveEvent);
Controller.mousePressEvent.connect(onClick);
Script.update.connect(update);
MyAvatar.collisionWithEntity.connect(gotHit);

View file

@ -1014,6 +1014,7 @@ void Application::paintGL() {
void Application::runTests() { void Application::runTests() {
runTimingTests(); runTimingTests();
runUnitTests();
} }
void Application::audioMuteToggled() { void Application::audioMuteToggled() {
@ -2308,38 +2309,42 @@ void Application::updateMyAvatarLookAtPosition() {
bool isLookingAtSomeone = false; bool isLookingAtSomeone = false;
glm::vec3 lookAtSpot; glm::vec3 lookAtSpot;
if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
// When I am in mirror mode, just look right at the camera (myself) // When I am in mirror mode, just look right at the camera (myself); don't switch gaze points because when physically
// looking in a mirror one's eyes appear steady.
if (!OculusManager::isConnected()) { if (!OculusManager::isConnected()) {
lookAtSpot = _myCamera.getPosition(); lookAtSpot = _myCamera.getPosition();
} else { } else {
if (_myAvatar->isLookingAtLeftEye()) { lookAtSpot = _myCamera.getPosition() + OculusManager::getMidEyePosition();
lookAtSpot = OculusManager::getLeftEyePosition();
} else {
lookAtSpot = OculusManager::getRightEyePosition();
}
} }
} else { } else {
AvatarSharedPointer lookingAt = _myAvatar->getLookAtTargetAvatar().lock(); AvatarSharedPointer lookingAt = _myAvatar->getLookAtTargetAvatar().lock();
if (lookingAt && _myAvatar != lookingAt.get()) { if (lookingAt && _myAvatar != lookingAt.get()) {
isLookingAtSomeone = true;
// If I am looking at someone else, look directly at one of their eyes // If I am looking at someone else, look directly at one of their eyes
if (tracker && !tracker->isMuted()) { isLookingAtSomeone = true;
// If a face tracker is active, look at the eye for the side my gaze is biased toward Head* lookingAtHead = static_cast<Avatar*>(lookingAt.get())->getHead();
if (tracker->getEstimatedEyeYaw() > _myAvatar->getHead()->getFinalYaw()) {
// Look at their right eye const float MAXIMUM_FACE_ANGLE = 65.0f * RADIANS_PER_DEGREE;
lookAtSpot = static_cast<Avatar*>(lookingAt.get())->getHead()->getRightEyePosition(); glm::vec3 lookingAtFaceOrientation = lookingAtHead->getFinalOrientationInWorldFrame() * IDENTITY_FRONT;
} else { glm::vec3 fromLookingAtToMe = glm::normalize(_myAvatar->getHead()->getEyePosition()
// Look at their left eye - lookingAtHead->getEyePosition());
lookAtSpot = static_cast<Avatar*>(lookingAt.get())->getHead()->getLeftEyePosition(); float faceAngle = glm::angle(lookingAtFaceOrientation, fromLookingAtToMe);
if (faceAngle < MAXIMUM_FACE_ANGLE) {
// Randomly look back and forth between look targets
switch (_myAvatar->getEyeContactTarget()) {
case LEFT_EYE:
lookAtSpot = lookingAtHead->getLeftEyePosition();
break;
case RIGHT_EYE:
lookAtSpot = lookingAtHead->getRightEyePosition();
break;
case MOUTH:
lookAtSpot = lookingAtHead->getMouthPosition();
break;
} }
} else { } else {
// Need to add randomly looking back and forth between left and right eye for case with no tracker // Just look at their head (mid point between eyes)
if (_myAvatar->isLookingAtLeftEye()) { lookAtSpot = lookingAtHead->getEyePosition();
lookAtSpot = static_cast<Avatar*>(lookingAt.get())->getHead()->getLeftEyePosition();
} else {
lookAtSpot = static_cast<Avatar*>(lookingAt.get())->getHead()->getRightEyePosition();
}
} }
} else { } else {
// I am not looking at anyone else, so just look forward // I am not looking at anyone else, so just look forward
@ -2347,14 +2352,13 @@ void Application::updateMyAvatarLookAtPosition() {
(_myAvatar->getHead()->getFinalOrientationInWorldFrame() * glm::vec3(0.0f, 0.0f, -TREE_SCALE)); (_myAvatar->getHead()->getFinalOrientationInWorldFrame() * glm::vec3(0.0f, 0.0f, -TREE_SCALE));
} }
} }
//
// Deflect the eyes a bit to match the detected Gaze from 3D camera if active // Deflect the eyes a bit to match the detected gaze from Faceshift if active.
// // DDE doesn't track eyes.
if (tracker && !tracker->isMuted()) { if (tracker && typeid(*tracker) == typeid(Faceshift) && !tracker->isMuted()) {
float eyePitch = tracker->getEstimatedEyePitch(); float eyePitch = tracker->getEstimatedEyePitch();
float eyeYaw = tracker->getEstimatedEyeYaw(); float eyeYaw = tracker->getEstimatedEyeYaw();
const float GAZE_DEFLECTION_REDUCTION_DURING_EYE_CONTACT = 0.1f; const float GAZE_DEFLECTION_REDUCTION_DURING_EYE_CONTACT = 0.1f;
// deflect using Faceshift gaze data
glm::vec3 origin = _myAvatar->getHead()->getEyePosition(); glm::vec3 origin = _myAvatar->getHead()->getEyePosition();
float pitchSign = (_myCamera.getMode() == CAMERA_MODE_MIRROR) ? -1.0f : 1.0f; float pitchSign = (_myCamera.getMode() == CAMERA_MODE_MIRROR) ? -1.0f : 1.0f;
float deflection = DependencyManager::get<Faceshift>()->getEyeDeflection(); float deflection = DependencyManager::get<Faceshift>()->getEyeDeflection();

View file

@ -18,16 +18,16 @@
#include "InterfaceActionFactory.h" #include "InterfaceActionFactory.h"
EntityActionPointer interfaceActionFactory(EntityActionType type, QUuid id, EntityItemPointer ownerEntity) { EntityActionPointer interfaceActionFactory(EntityActionType type, const QUuid& id, EntityItemPointer ownerEntity) {
switch (type) { switch (type) {
case ACTION_TYPE_NONE: case ACTION_TYPE_NONE:
return nullptr; return nullptr;
case ACTION_TYPE_OFFSET: case ACTION_TYPE_OFFSET:
return (EntityActionPointer) new ObjectActionOffset(type, id, ownerEntity); return (EntityActionPointer) new ObjectActionOffset(id, ownerEntity);
case ACTION_TYPE_SPRING: case ACTION_TYPE_SPRING:
return (EntityActionPointer) new ObjectActionSpring(type, id, ownerEntity); return (EntityActionPointer) new ObjectActionSpring(id, ownerEntity);
case ACTION_TYPE_HOLD: case ACTION_TYPE_HOLD:
return (EntityActionPointer) new AvatarActionHold(type, id, ownerEntity); return (EntityActionPointer) new AvatarActionHold(id, ownerEntity);
} }
assert(false); assert(false);
@ -37,7 +37,7 @@ EntityActionPointer interfaceActionFactory(EntityActionType type, QUuid id, Enti
EntityActionPointer InterfaceActionFactory::factory(EntitySimulation* simulation, EntityActionPointer InterfaceActionFactory::factory(EntitySimulation* simulation,
EntityActionType type, EntityActionType type,
QUuid id, const QUuid& id,
EntityItemPointer ownerEntity, EntityItemPointer ownerEntity,
QVariantMap arguments) { QVariantMap arguments) {
EntityActionPointer action = interfaceActionFactory(type, id, ownerEntity); EntityActionPointer action = interfaceActionFactory(type, id, ownerEntity);

View file

@ -20,7 +20,7 @@ public:
virtual ~InterfaceActionFactory() { } virtual ~InterfaceActionFactory() { }
virtual EntityActionPointer factory(EntitySimulation* simulation, virtual EntityActionPointer factory(EntitySimulation* simulation,
EntityActionType type, EntityActionType type,
QUuid id, const QUuid& id,
EntityItemPointer ownerEntity, EntityItemPointer ownerEntity,
QVariantMap arguments); QVariantMap arguments);
virtual EntityActionPointer factoryBA(EntitySimulation* simulation, virtual EntityActionPointer factoryBA(EntitySimulation* simulation,

View file

@ -21,6 +21,7 @@
#include <QThread> #include <QThread>
#include <ByteCountCoding.h>
#include <SharedUtil.h> #include <SharedUtil.h>
#include <TextRenderer.h> #include <TextRenderer.h>
@ -229,6 +230,43 @@ void runTimingTests() {
elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC; elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC;
qCDebug(interfaceapp, "vec3 assign and dot() usecs: %f, last result:%f", qCDebug(interfaceapp, "vec3 assign and dot() usecs: %f, last result:%f",
(double)(elapsedUsecs / numTests), (double)result); (double)(elapsedUsecs / numTests), (double)result);
quint64 BYTE_CODE_MAX_TEST_VALUE = 99999999;
quint64 BYTE_CODE_TESTS_SKIP = 999;
QByteArray extraJunk;
const int EXTRA_JUNK_SIZE = 200;
extraJunk.append((unsigned char)255);
for (int i = 0; i < EXTRA_JUNK_SIZE; i++) {
extraJunk.append(QString("junk"));
}
{
startTime.start();
quint64 tests = 0;
quint64 failed = 0;
for (quint64 value = 0; value < BYTE_CODE_MAX_TEST_VALUE; value += BYTE_CODE_TESTS_SKIP) {
quint64 valueA = value; // usecTimestampNow();
ByteCountCoded<quint64> codedValueA = valueA;
QByteArray codedValueABuffer = codedValueA;
codedValueABuffer.append(extraJunk);
ByteCountCoded<quint64> decodedValueA;
decodedValueA.decode(codedValueABuffer);
quint64 valueADecoded = decodedValueA;
tests++;
if (valueA != valueADecoded) {
qDebug() << "FAILED! value:" << valueA << "decoded:" << valueADecoded;
failed++;
}
}
elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC;
qCDebug(interfaceapp) << "ByteCountCoded<quint64> usecs: " << elapsedUsecs
<< "per test:" << (double) (elapsedUsecs / tests)
<< "tests:" << tests
<< "failed:" << failed;
}
} }
bool rayIntersectsSphere(const glm::vec3& rayStarting, const glm::vec3& rayNormalizedDirection, bool rayIntersectsSphere(const glm::vec3& rayStarting, const glm::vec3& rayNormalizedDirection,
@ -271,3 +309,39 @@ bool pointInSphere(glm::vec3& point, glm::vec3& sphereCenter, double sphereRadiu
} }
return false; return false;
} }
void runUnitTests() {
quint64 LAST_TEST = 10;
quint64 SKIP_BY = 1;
for (quint64 value = 0; value <= LAST_TEST; value += SKIP_BY) {
qDebug() << "value:" << value;
ByteCountCoded<quint64> codedValue = value;
QByteArray codedValueBuffer = codedValue;
codedValueBuffer.append((unsigned char)255);
codedValueBuffer.append(QString("junk"));
qDebug() << "codedValueBuffer:";
outputBufferBits((const unsigned char*)codedValueBuffer.constData(), codedValueBuffer.size());
ByteCountCoded<quint64> valueDecoder;
size_t bytesConsumed = valueDecoder.decode(codedValueBuffer);
quint64 valueDecoded = valueDecoder;
qDebug() << "valueDecoded:" << valueDecoded;
qDebug() << "bytesConsumed:" << bytesConsumed;
if (value == valueDecoded) {
qDebug() << "SUCCESS!";
} else {
qDebug() << "FAILED!";
}
}
}

View file

@ -30,6 +30,7 @@ void drawText(int x, int y, float scale, float radians, int mono,
void renderCollisionOverlay(int width, int height, float magnitude, float red = 0, float blue = 0, float green = 0); void renderCollisionOverlay(int width, int height, float magnitude, float red = 0, float blue = 0, float green = 0);
void runTimingTests(); void runTimingTests();
void runUnitTests();
bool rayIntersectsSphere(const glm::vec3& rayStarting, const glm::vec3& rayNormalizedDirection, bool rayIntersectsSphere(const glm::vec3& rayStarting, const glm::vec3& rayNormalizedDirection,
const glm::vec3& sphereCenter, float sphereRadius, float& distance); const glm::vec3& sphereCenter, float sphereRadius, float& distance);

View file

@ -17,13 +17,14 @@
const uint16_t AvatarActionHold::holdVersion = 1; const uint16_t AvatarActionHold::holdVersion = 1;
AvatarActionHold::AvatarActionHold(EntityActionType type, QUuid id, EntityItemPointer ownerEntity) : AvatarActionHold::AvatarActionHold(const QUuid& id, EntityItemPointer ownerEntity) :
ObjectActionSpring(type, id, ownerEntity), ObjectActionSpring(id, ownerEntity),
_relativePosition(glm::vec3(0.0f)), _relativePosition(glm::vec3(0.0f)),
_relativeRotation(glm::quat()), _relativeRotation(glm::quat()),
_hand("right"), _hand("right"),
_mine(false) _mine(false)
{ {
_type = ACTION_TYPE_HOLD;
#if WANT_DEBUG #if WANT_DEBUG
qDebug() << "AvatarActionHold::AvatarActionHold"; qDebug() << "AvatarActionHold::AvatarActionHold";
#endif #endif
@ -166,8 +167,7 @@ QVariantMap AvatarActionHold::getArguments() {
void AvatarActionHold::deserialize(QByteArray serializedArguments) { void AvatarActionHold::deserialize(QByteArray serializedArguments) {
if (_mine) { if (!_mine) {
return; ObjectActionSpring::deserialize(serializedArguments);
} }
ObjectActionSpring::deserialize(serializedArguments);
} }

View file

@ -19,11 +19,9 @@
class AvatarActionHold : public ObjectActionSpring { class AvatarActionHold : public ObjectActionSpring {
public: public:
AvatarActionHold(EntityActionType type, QUuid id, EntityItemPointer ownerEntity); AvatarActionHold(const QUuid& id, EntityItemPointer ownerEntity);
virtual ~AvatarActionHold(); virtual ~AvatarActionHold();
virtual EntityActionType getType() { return ACTION_TYPE_HOLD; }
virtual bool updateArguments(QVariantMap arguments); virtual bool updateArguments(QVariantMap arguments);
virtual QVariantMap getArguments(); virtual QVariantMap getArguments();

View file

@ -256,7 +256,6 @@ void AvatarManager::handleOutgoingChanges(VectorOfMotionStates& motionStates) {
} }
void AvatarManager::handleCollisionEvents(CollisionEvents& collisionEvents) { void AvatarManager::handleCollisionEvents(CollisionEvents& collisionEvents) {
// TODO: expose avatar collision events to JS
for (Collision collision : collisionEvents) { for (Collision collision : collisionEvents) {
// TODO: Current physics uses null idA or idB for non-entities. The plan is to handle MOTIONSTATE_TYPE_AVATAR, // TODO: Current physics uses null idA or idB for non-entities. The plan is to handle MOTIONSTATE_TYPE_AVATAR,
// and then MOTIONSTATE_TYPE_MYAVATAR. As it is, this code only covers the case of my avatar (in which case one // and then MOTIONSTATE_TYPE_MYAVATAR. As it is, this code only covers the case of my avatar (in which case one
@ -285,6 +284,7 @@ void AvatarManager::handleCollisionEvents(CollisionEvents& collisionEvents) {
const float AVATAR_STRETCH_FACTOR = 1.0f; const float AVATAR_STRETCH_FACTOR = 1.0f;
AudioInjector::playSound(collisionSoundURL, energyFactorOfFull, AVATAR_STRETCH_FACTOR, myAvatar->getPosition()); AudioInjector::playSound(collisionSoundURL, energyFactorOfFull, AVATAR_STRETCH_FACTOR, myAvatar->getPosition());
myAvatar->collisionWithEntity(collision);
} }
} }
} }

View file

@ -296,7 +296,7 @@ void Head::relaxLean(float deltaTime) {
void Head::render(RenderArgs* renderArgs, float alpha, ViewFrustum* renderFrustum, bool postLighting) { void Head::render(RenderArgs* renderArgs, float alpha, ViewFrustum* renderFrustum, bool postLighting) {
if (_renderLookatVectors) { if (_renderLookatVectors) {
renderLookatVectors(renderArgs, _leftEyePosition, _rightEyePosition, getCorrectedLookAtPosition()); renderLookatVectors(renderArgs, _leftEyePosition, _rightEyePosition, getCorrectedLookAtPosition());
} }
} }
@ -324,7 +324,7 @@ glm::vec3 Head::getCorrectedLookAtPosition() {
} }
void Head::setCorrectedLookAtPosition(glm::vec3 correctedLookAtPosition) { void Head::setCorrectedLookAtPosition(glm::vec3 correctedLookAtPosition) {
_isLookingAtMe = true; _isLookingAtMe = true;
_correctedLookAtPosition = correctedLookAtPosition; _correctedLookAtPosition = correctedLookAtPosition;
} }

View file

@ -22,11 +22,6 @@
#include "InterfaceConfig.h" #include "InterfaceConfig.h"
#include "world.h" #include "world.h"
enum eyeContactTargets {
LEFT_EYE,
RIGHT_EYE,
MOUTH
};
const float EYE_EAR_GAP = 0.08f; const float EYE_EAR_GAP = 0.08f;
@ -77,6 +72,7 @@ public:
const glm::vec3& getLeftEyePosition() const { return _leftEyePosition; } const glm::vec3& getLeftEyePosition() const { return _leftEyePosition; }
glm::vec3 getRightEarPosition() const { return _rightEyePosition + (getRightDirection() * EYE_EAR_GAP) + (getFrontDirection() * -EYE_EAR_GAP); } glm::vec3 getRightEarPosition() const { return _rightEyePosition + (getRightDirection() * EYE_EAR_GAP) + (getFrontDirection() * -EYE_EAR_GAP); }
glm::vec3 getLeftEarPosition() const { return _leftEyePosition + (getRightDirection() * -EYE_EAR_GAP) + (getFrontDirection() * -EYE_EAR_GAP); } glm::vec3 getLeftEarPosition() const { return _leftEyePosition + (getRightDirection() * -EYE_EAR_GAP) + (getFrontDirection() * -EYE_EAR_GAP); }
glm::vec3 getMouthPosition() const { return _eyePosition - getUpDirection() * glm::length(_rightEyePosition - _leftEyePosition); }
FaceModel& getFaceModel() { return _faceModel; } FaceModel& getFaceModel() { return _faceModel; }
const FaceModel& getFaceModel() const { return _faceModel; } const FaceModel& getFaceModel() const { return _faceModel; }
@ -148,7 +144,7 @@ private:
FaceModel _faceModel; FaceModel _faceModel;
glm::vec3 _correctedLookAtPosition; glm::vec3 _correctedLookAtPosition;
int _leftEyeLookAtID; int _leftEyeLookAtID;
int _rightEyeLookAtID; int _rightEyeLookAtID;

View file

@ -34,6 +34,9 @@
#include <TextRenderer.h> #include <TextRenderer.h>
#include <UserActivityLogger.h> #include <UserActivityLogger.h>
#include "devices/Faceshift.h"
#include "devices/OculusManager.h"
#include "Application.h" #include "Application.h"
#include "AvatarManager.h" #include "AvatarManager.h"
#include "Environment.h" #include "Environment.h"
@ -42,7 +45,6 @@
#include "MyAvatar.h" #include "MyAvatar.h"
#include "Physics.h" #include "Physics.h"
#include "Recorder.h" #include "Recorder.h"
#include "devices/Faceshift.h"
#include "Util.h" #include "Util.h"
#include "InterfaceLogging.h" #include "InterfaceLogging.h"
@ -97,7 +99,7 @@ MyAvatar::MyAvatar() :
_shouldRender(true), _shouldRender(true),
_billboardValid(false), _billboardValid(false),
_feetTouchFloor(true), _feetTouchFloor(true),
_isLookingAtLeftEye(true), _eyeContactTarget(LEFT_EYE),
_realWorldFieldOfView("realWorldFieldOfView", _realWorldFieldOfView("realWorldFieldOfView",
DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES), DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES),
_firstPersonSkeletonModel(this), _firstPersonSkeletonModel(this),
@ -883,7 +885,6 @@ void MyAvatar::updateLookAtTargetAvatar() {
const float KEEP_LOOKING_AT_CURRENT_ANGLE_FACTOR = 1.3f; const float KEEP_LOOKING_AT_CURRENT_ANGLE_FACTOR = 1.3f;
const float GREATEST_LOOKING_AT_DISTANCE = 10.0f; const float GREATEST_LOOKING_AT_DISTANCE = 10.0f;
int howManyLookingAtMe = 0;
foreach (const AvatarSharedPointer& avatarPointer, DependencyManager::get<AvatarManager>()->getAvatarHash()) { foreach (const AvatarSharedPointer& avatarPointer, DependencyManager::get<AvatarManager>()->getAvatarHash()) {
Avatar* avatar = static_cast<Avatar*>(avatarPointer.get()); Avatar* avatar = static_cast<Avatar*>(avatarPointer.get());
bool isCurrentTarget = avatar->getIsLookAtTarget(); bool isCurrentTarget = avatar->getIsLookAtTarget();
@ -896,17 +897,22 @@ void MyAvatar::updateLookAtTargetAvatar() {
_targetAvatarPosition = avatarPointer->getPosition(); _targetAvatarPosition = avatarPointer->getPosition();
smallestAngleTo = angleTo; smallestAngleTo = angleTo;
} }
// Check if this avatar is looking at me, and fix their gaze on my camera if so
if (Application::getInstance()->isLookingAtMyAvatar(avatar)) { if (Application::getInstance()->isLookingAtMyAvatar(avatar)) {
howManyLookingAtMe++; // Alter their gaze to look directly at my camera; this looks more natural than looking at my avatar's face.
// Have that avatar look directly at my camera // Offset their gaze according to whether they're looking at one of my eyes or my mouth.
// Philip TODO: correct to look at left/right eye glm::vec3 gazeOffset = avatar->getHead()->getLookAtPosition() - getHead()->getEyePosition();
if (qApp->isHMDMode()) { const float HUMAN_EYE_SEPARATION = 0.065f;
avatar->getHead()->setCorrectedLookAtPosition(Application::getInstance()->getViewFrustum()->getPosition()); float myEyeSeparation = glm::length(getHead()->getLeftEyePosition() - getHead()->getRightEyePosition());
// FIXME what is the point of this? gazeOffset = gazeOffset * HUMAN_EYE_SEPARATION / myEyeSeparation;
// avatar->getHead()->setCorrectedLookAtPosition(OculusManager::getLeftEyePosition());
if (Application::getInstance()->isHMDMode()) {
//avatar->getHead()->setCorrectedLookAtPosition(Application::getInstance()->getCamera()->getPosition()
// + OculusManager::getMidEyePosition() + gazeOffset);
avatar->getHead()->setCorrectedLookAtPosition(Application::getInstance()->getViewFrustum()->getPosition()
+ OculusManager::getMidEyePosition() + gazeOffset);
} else { } else {
avatar->getHead()->setCorrectedLookAtPosition(Application::getInstance()->getViewFrustum()->getPosition()); avatar->getHead()->setCorrectedLookAtPosition(Application::getInstance()->getViewFrustum()->getPosition()
+ gazeOffset);
} }
} else { } else {
avatar->getHead()->clearCorrectedLookAtPosition(); avatar->getHead()->clearCorrectedLookAtPosition();
@ -923,12 +929,24 @@ void MyAvatar::clearLookAtTargetAvatar() {
_lookAtTargetAvatar.reset(); _lookAtTargetAvatar.reset();
} }
bool MyAvatar::isLookingAtLeftEye() { eyeContactTarget MyAvatar::getEyeContactTarget() {
float const CHANCE_OF_CHANGING_EYE = 0.01f; float const CHANCE_OF_CHANGING_TARGET = 0.01f;
if (randFloat() < CHANCE_OF_CHANGING_EYE) { if (randFloat() < CHANCE_OF_CHANGING_TARGET) {
_isLookingAtLeftEye = !_isLookingAtLeftEye; float const FIFTY_FIFTY_CHANCE = 0.5f;
switch (_eyeContactTarget) {
case LEFT_EYE:
_eyeContactTarget = (randFloat() < FIFTY_FIFTY_CHANCE) ? MOUTH : RIGHT_EYE;
break;
case RIGHT_EYE:
_eyeContactTarget = (randFloat() < FIFTY_FIFTY_CHANCE) ? LEFT_EYE : MOUTH;
break;
case MOUTH:
_eyeContactTarget = (randFloat() < FIFTY_FIFTY_CHANCE) ? RIGHT_EYE : LEFT_EYE;
break;
}
} }
return _isLookingAtLeftEye;
return _eyeContactTarget;
} }
glm::vec3 MyAvatar::getDefaultEyePosition() const { glm::vec3 MyAvatar::getDefaultEyePosition() const {

View file

@ -19,6 +19,12 @@
class ModelItemID; class ModelItemID;
enum eyeContactTarget {
LEFT_EYE,
RIGHT_EYE,
MOUTH
};
class MyAvatar : public Avatar { class MyAvatar : public Avatar {
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool shouldRenderLocally READ getShouldRenderLocally WRITE setShouldRenderLocally) Q_PROPERTY(bool shouldRenderLocally READ getShouldRenderLocally WRITE setShouldRenderLocally)
@ -94,7 +100,7 @@ public:
bool isMyAvatar() const { return true; } bool isMyAvatar() const { return true; }
bool isLookingAtLeftEye(); eyeContactTarget getEyeContactTarget();
virtual int parseDataAtOffset(const QByteArray& packet, int offset); virtual int parseDataAtOffset(const QByteArray& packet, int offset);
@ -209,6 +215,7 @@ public slots:
signals: signals:
void transformChanged(); void transformChanged();
void newCollisionSoundURL(const QUrl& url); void newCollisionSoundURL(const QUrl& url);
void collisionWithEntity(const Collision& collision);
private: private:
@ -251,7 +258,7 @@ private:
QList<AnimationHandlePointer> _animationHandles; QList<AnimationHandlePointer> _animationHandles;
bool _feetTouchFloor; bool _feetTouchFloor;
bool _isLookingAtLeftEye; eyeContactTarget _eyeContactTarget;
RecorderPointer _recorder; RecorderPointer _recorder;

View file

@ -283,6 +283,7 @@ static ovrVector3f _eyeOffsets[ovrEye_Count];
glm::vec3 OculusManager::getLeftEyePosition() { return _eyePositions[ovrEye_Left]; } glm::vec3 OculusManager::getLeftEyePosition() { return _eyePositions[ovrEye_Left]; }
glm::vec3 OculusManager::getRightEyePosition() { return _eyePositions[ovrEye_Right]; } glm::vec3 OculusManager::getRightEyePosition() { return _eyePositions[ovrEye_Right]; }
glm::vec3 OculusManager::getMidEyePosition() { return (_eyePositions[ovrEye_Left] + _eyePositions[ovrEye_Right]) / 2.0f; }
void OculusManager::connect(QOpenGLContext* shareContext) { void OculusManager::connect(QOpenGLContext* shareContext) {
qCDebug(interfaceapp) << "Oculus SDK" << OVR_VERSION_STRING; qCDebug(interfaceapp) << "Oculus SDK" << OVR_VERSION_STRING;
@ -692,13 +693,13 @@ void OculusManager::display(QGLWidget * glCanvas, RenderArgs* renderArgs, const
_eyeRenderPoses[eye] = eyePoses[eye]; _eyeRenderPoses[eye] = eyePoses[eye];
// Set the camera rotation for this eye // Set the camera rotation for this eye
vec3 eyePosition = toGlm(_eyeRenderPoses[eye].Position); _eyePositions[eye] = toGlm(_eyeRenderPoses[eye].Position);
eyePosition = whichCamera.getRotation() * eyePosition; _eyePositions[eye] = whichCamera.getRotation() * _eyePositions[eye];
quat eyeRotation = toGlm(_eyeRenderPoses[eye].Orientation); quat eyeRotation = toGlm(_eyeRenderPoses[eye].Orientation);
// Update our camera to what the application camera is doing // Update our camera to what the application camera is doing
_camera->setRotation(whichCamera.getRotation() * eyeRotation); _camera->setRotation(whichCamera.getRotation() * eyeRotation);
_camera->setPosition(whichCamera.getPosition() + eyePosition); _camera->setPosition(whichCamera.getPosition() + _eyePositions[eye]);
configureCamera(*_camera); configureCamera(*_camera);
_camera->update(1.0f / Application::getInstance()->getFps()); _camera->update(1.0f / Application::getInstance()->getFps());

View file

@ -47,6 +47,7 @@ public:
static glm::vec3 getLeftEyePosition(); static glm::vec3 getLeftEyePosition();
static glm::vec3 getRightEyePosition(); static glm::vec3 getRightEyePosition();
static glm::vec3 getMidEyePosition();
static int getHMDScreen(); static int getHMDScreen();

View file

@ -25,7 +25,7 @@ class EntityActionFactoryInterface : public QObject, public Dependency {
virtual ~EntityActionFactoryInterface() { } virtual ~EntityActionFactoryInterface() { }
virtual EntityActionPointer factory(EntitySimulation* simulation, virtual EntityActionPointer factory(EntitySimulation* simulation,
EntityActionType type, EntityActionType type,
QUuid id, const QUuid& id,
EntityItemPointer ownerEntity, EntityItemPointer ownerEntity,
QVariantMap arguments) { assert(false); return nullptr; } QVariantMap arguments) { assert(false); return nullptr; }
virtual EntityActionPointer factoryBA(EntitySimulation* simulation, virtual EntityActionPointer factoryBA(EntitySimulation* simulation,

View file

@ -29,10 +29,10 @@ enum EntityActionType {
class EntityActionInterface { class EntityActionInterface {
public: public:
EntityActionInterface() { } EntityActionInterface(EntityActionType type, const QUuid& id) : _id(id), _type(type) { }
virtual ~EntityActionInterface() { } virtual ~EntityActionInterface() { }
virtual const QUuid& getID() const = 0; const QUuid& getID() const { return _id; }
virtual EntityActionType getType() { assert(false); return ACTION_TYPE_NONE; } EntityActionType getType() const { return _type; }
virtual void removeFromSimulation(EntitySimulation* simulation) const = 0; virtual void removeFromSimulation(EntitySimulation* simulation) const = 0;
virtual EntityItemWeakPointer getOwnerEntity() const = 0; virtual EntityItemWeakPointer getOwnerEntity() const = 0;
@ -40,7 +40,7 @@ public:
virtual bool updateArguments(QVariantMap arguments) = 0; virtual bool updateArguments(QVariantMap arguments) = 0;
virtual QVariantMap getArguments() = 0; virtual QVariantMap getArguments() = 0;
virtual QByteArray serialize() = 0; virtual QByteArray serialize() const = 0;
virtual void deserialize(QByteArray serializedArguments) = 0; virtual void deserialize(QByteArray serializedArguments) = 0;
static EntityActionType actionTypeFromString(QString actionTypeString); static EntityActionType actionTypeFromString(QString actionTypeString);
@ -68,6 +68,8 @@ protected:
static QString extractStringArgument(QString objectName, QVariantMap arguments, static QString extractStringArgument(QString objectName, QVariantMap arguments,
QString argumentName, bool& ok, bool required = true); QString argumentName, bool& ok, bool required = true);
QUuid _id;
EntityActionType _type;
}; };

View file

@ -27,7 +27,7 @@
EntityTree::EntityTree(bool shouldReaverage) : EntityTree::EntityTree(bool shouldReaverage) :
Octree(shouldReaverage), Octree(shouldReaverage),
_fbxService(NULL), _fbxService(NULL),
_simulation(NULL) _simulation(NULL)
{ {
@ -59,7 +59,7 @@ void EntityTree::eraseAllOctreeElements(bool createNewRoot) {
} }
_entityToElementMap.clear(); _entityToElementMap.clear();
Octree::eraseAllOctreeElements(createNewRoot); Octree::eraseAllOctreeElements(createNewRoot);
resetClientEditStats(); resetClientEditStats();
} }
@ -92,13 +92,11 @@ void EntityTree::postAddEntity(EntityItemPointer entity) {
bool EntityTree::updateEntity(const EntityItemID& entityID, const EntityItemProperties& properties, const SharedNodePointer& senderNode) { bool EntityTree::updateEntity(const EntityItemID& entityID, const EntityItemProperties& properties, const SharedNodePointer& senderNode) {
EntityTreeElement* containingElement = getContainingElement(entityID); EntityTreeElement* containingElement = getContainingElement(entityID);
if (!containingElement) { if (!containingElement) {
qCDebug(entities) << "UNEXPECTED!!!! EntityTree::updateEntity() entityID doesn't exist!!! entityID=" << entityID;
return false; return false;
} }
EntityItemPointer existingEntity = containingElement->getEntityWithEntityItemID(entityID); EntityItemPointer existingEntity = containingElement->getEntityWithEntityItemID(entityID);
if (!existingEntity) { if (!existingEntity) {
qCDebug(entities) << "UNEXPECTED!!!! don't call updateEntity() on entity items that don't exist. entityID=" << entityID;
return false; return false;
} }
@ -108,8 +106,6 @@ bool EntityTree::updateEntity(const EntityItemID& entityID, const EntityItemProp
bool EntityTree::updateEntity(EntityItemPointer entity, const EntityItemProperties& properties, const SharedNodePointer& senderNode) { bool EntityTree::updateEntity(EntityItemPointer entity, const EntityItemProperties& properties, const SharedNodePointer& senderNode) {
EntityTreeElement* containingElement = getContainingElement(entity->getEntityItemID()); EntityTreeElement* containingElement = getContainingElement(entity->getEntityItemID());
if (!containingElement) { if (!containingElement) {
qCDebug(entities) << "UNEXPECTED!!!! EntityTree::updateEntity() entity-->element lookup failed!!! entityID="
<< entity->getEntityItemID();
return false; return false;
} }
return updateEntityWithElement(entity, properties, containingElement, senderNode); return updateEntityWithElement(entity, properties, containingElement, senderNode);

View file

@ -219,20 +219,18 @@ bool LimitedNodeList::packetVersionAndHashMatch(const QByteArray& packet) {
return false; return false;
} }
// qint64 LimitedNodeList::readDatagram(char* data, qint64 maxSize, QHostAddress* address = 0, quint16 * port = 0) { qint64 LimitedNodeList::readDatagram(QByteArray& incomingPacket, QHostAddress* address = 0, quint16* port = 0) {
qint64 result = getNodeSocket().readDatagram(incomingPacket.data(), incomingPacket.size(), address, port);
//qint64 LimitedNodeList::readDatagram(QByteArray& incomingPacket, QHostAddress* address = 0, quint16* port = 0) { SharedNodePointer sendingNode = sendingNodeForPacket(incomingPacket);
// qint64 result = getNodeSocket().readDatagram(incomingPacket.data(), incomingPacket.size(), address, port); if (sendingNode) {
// emit dataReceived(sendingNode->getType(), incomingPacket.size());
// SharedNodePointer sendingNode = sendingNodeForPacket(incomingPacket); } else {
// if (sendingNode) { emit dataReceived(NodeType::Unassigned, incomingPacket.size());
// emit dataReceived(sendingNode->getType(), incomingPacket.size()); }
// } else {
// emit dataReceived(NodeType::Unassigned, incomingPacket.size()); return result;
// } }
//
// return result;
//}
qint64 LimitedNodeList::writeDatagram(const QByteArray& datagram, const HifiSockAddr& destinationSockAddr) { qint64 LimitedNodeList::writeDatagram(const QByteArray& datagram, const HifiSockAddr& destinationSockAddr) {
// XXX can BandwidthRecorder be used for this? // XXX can BandwidthRecorder be used for this?
@ -553,7 +551,7 @@ std::unique_ptr<NLPacket> LimitedNodeList::constructPingReplyPacket(const QByteA
return replyPacket; return replyPacket;
} }
std::unique_ptr<NLPacket> constructICEPingPacket(PingType_t pingType, const QUuid& iceID) { std::unique_ptr<NLPacket> LimitedNodeList::constructICEPingPacket(PingType_t pingType, const QUuid& iceID) {
int packetSize = NUM_BYTES_RFC4122_UUID + sizeof(PingType_t); int packetSize = NUM_BYTES_RFC4122_UUID + sizeof(PingType_t);
auto icePingPacket = NLPacket::create(PacketType::ICEPing, packetSize); auto icePingPacket = NLPacket::create(PacketType::ICEPing, packetSize);
@ -564,7 +562,7 @@ std::unique_ptr<NLPacket> constructICEPingPacket(PingType_t pingType, const QUui
return icePingPacket; return icePingPacket;
} }
std::unique_ptr<NLPacket> constructICEPingReplyPacket(const QByteArray& pingPacket, const QUuid& iceID) { std::unique_ptr<NLPacket> LimitedNodeList::constructICEPingReplyPacket(const QByteArray& pingPacket, const QUuid& iceID) {
// pull out the ping type so we can reply back with that // pull out the ping type so we can reply back with that
PingType_t pingType; PingType_t pingType;

View file

@ -32,13 +32,13 @@ template <class T> std::unique_ptr<NLPacket> PacketList<T>::createPacketWithExte
} }
} }
template<typename T> qint64 Packet::readPrimitive(T* data) { template<class T> template<typename U> qint64 PacketList<T>::readPrimitive(U* data) {
return QIODevice::read(reinterpret_cast<char*>(data), sizeof(T)); return QIODevice::read(reinterpret_cast<char*>(data), sizeof(U));
} }
template<typename T> qint64 Packet::writePrimitive(const T& data) { template<class T> template<typename U> qint64 PacketList<T>::writePrimitive(const U& data) {
static_assert(!std::is_pointer<T>::value, "T must not be a pointer"); static_assert(!std::is_pointer<U>::value, "T must not be a pointer");
return QIODevice::write(reinterpret_cast<const char*>(&data), sizeof(T)); return QIODevice::write(reinterpret_cast<const char*>(&data), sizeof(U));
} }
template <class T> qint64 PacketList<T>::writeData(const char* data, qint64 maxSize) { template <class T> qint64 PacketList<T>::writeData(const char* data, qint64 maxSize) {

View file

@ -45,7 +45,7 @@ bool ReceivedPacketProcessor::process() {
quint64 now = usecTimestampNow(); quint64 now = usecTimestampNow();
quint64 sinceLastWindow = now - _lastWindowAt; quint64 sinceLastWindow = now - _lastWindowAt;
if (sinceLastWindow > USECS_PER_SECOND) { if (sinceLastWindow > USECS_PER_SECOND) {
lock(); lock();
float secondsSinceLastWindow = sinceLastWindow / USECS_PER_SECOND; float secondsSinceLastWindow = sinceLastWindow / USECS_PER_SECOND;
@ -80,6 +80,7 @@ bool ReceivedPacketProcessor::process() {
for(auto& packetPair : currentPackets) { for(auto& packetPair : currentPackets) {
// TODO: Replace QByteArray() once NLPacket is coming through on receive side // TODO: Replace QByteArray() once NLPacket is coming through on receive side
processPacket(packetPair.first, QByteArray()); processPacket(packetPair.first, QByteArray());
_lastWindowProcessedPackets++;
midProcess(); midProcess();
} }

View file

@ -13,9 +13,9 @@
#include "ObjectAction.h" #include "ObjectAction.h"
ObjectAction::ObjectAction(EntityActionType type, QUuid id, EntityItemPointer ownerEntity) : ObjectAction::ObjectAction(EntityActionType type, const QUuid& id, EntityItemPointer ownerEntity) :
btActionInterface(), btActionInterface(),
_id(id), EntityActionInterface(type, id),
_active(false), _active(false),
_ownerEntity(ownerEntity) { _ownerEntity(ownerEntity) {
} }
@ -24,15 +24,15 @@ ObjectAction::~ObjectAction() {
} }
void ObjectAction::updateAction(btCollisionWorld* collisionWorld, btScalar deltaTimeStep) { void ObjectAction::updateAction(btCollisionWorld* collisionWorld, btScalar deltaTimeStep) {
if (!_active) {
return;
}
if (_ownerEntity.expired()) { if (_ownerEntity.expired()) {
qDebug() << "warning -- action with no entity removing self from btCollisionWorld."; qDebug() << "warning -- action with no entity removing self from btCollisionWorld.";
btDynamicsWorld* dynamicsWorld = static_cast<btDynamicsWorld*>(collisionWorld); btDynamicsWorld* dynamicsWorld = static_cast<btDynamicsWorld*>(collisionWorld);
dynamicsWorld->removeAction(this); dynamicsWorld->removeAction(this);
return; return;
} }
if (!_active) {
return;
}
updateActionWorker(deltaTimeStep); updateActionWorker(deltaTimeStep);
} }
@ -129,11 +129,3 @@ void ObjectAction::setAngularVelocity(glm::vec3 angularVelocity) {
rigidBody->activate(); rigidBody->activate();
} }
QByteArray ObjectAction::serialize() {
assert(false);
return QByteArray();
}
void ObjectAction::deserialize(QByteArray serializedArguments) {
assert(false);
}

View file

@ -17,8 +17,6 @@
#include <btBulletDynamicsCommon.h> #include <btBulletDynamicsCommon.h>
#include <EntityItem.h>
#include "ObjectMotionState.h" #include "ObjectMotionState.h"
#include "BulletUtil.h" #include "BulletUtil.h"
#include "EntityActionInterface.h" #include "EntityActionInterface.h"
@ -26,31 +24,25 @@
class ObjectAction : public btActionInterface, public EntityActionInterface { class ObjectAction : public btActionInterface, public EntityActionInterface {
public: public:
ObjectAction(EntityActionType type, QUuid id, EntityItemPointer ownerEntity); ObjectAction(EntityActionType type, const QUuid& id, EntityItemPointer ownerEntity);
virtual ~ObjectAction(); virtual ~ObjectAction();
const QUuid& getID() const { return _id; }
virtual EntityActionType getType() { assert(false); return ACTION_TYPE_NONE; }
virtual void removeFromSimulation(EntitySimulation* simulation) const; virtual void removeFromSimulation(EntitySimulation* simulation) const;
virtual EntityItemWeakPointer getOwnerEntity() const { return _ownerEntity; } virtual EntityItemWeakPointer getOwnerEntity() const { return _ownerEntity; }
virtual void setOwnerEntity(const EntityItemPointer ownerEntity) { _ownerEntity = ownerEntity; } virtual void setOwnerEntity(const EntityItemPointer ownerEntity) { _ownerEntity = ownerEntity; }
virtual bool updateArguments(QVariantMap arguments) { return false; } virtual bool updateArguments(QVariantMap arguments) = 0;
virtual QVariantMap getArguments() { return QVariantMap(); } virtual QVariantMap getArguments() = 0;
// this is called from updateAction and should be overridden by subclasses // this is called from updateAction and should be overridden by subclasses
virtual void updateActionWorker(float deltaTimeStep) {} virtual void updateActionWorker(float deltaTimeStep) = 0;
// these are from btActionInterface // these are from btActionInterface
virtual void updateAction(btCollisionWorld* collisionWorld, btScalar deltaTimeStep); virtual void updateAction(btCollisionWorld* collisionWorld, btScalar deltaTimeStep);
virtual void debugDraw(btIDebugDraw* debugDrawer); virtual void debugDraw(btIDebugDraw* debugDrawer);
virtual QByteArray serialize(); virtual QByteArray serialize() const = 0;
virtual void deserialize(QByteArray serializedArguments); virtual void deserialize(QByteArray serializedArguments) = 0;
private:
QUuid _id;
QReadWriteLock _lock;
protected: protected:
@ -70,6 +62,10 @@ protected:
bool tryLockForWrite() { return _lock.tryLockForWrite(); } bool tryLockForWrite() { return _lock.tryLockForWrite(); }
void unlock() { _lock.unlock(); } void unlock() { _lock.unlock(); }
private:
QReadWriteLock _lock;
protected:
bool _active; bool _active;
EntityItemWeakPointer _ownerEntity; EntityItemWeakPointer _ownerEntity;
}; };

View file

@ -15,8 +15,8 @@
const uint16_t ObjectActionOffset::offsetVersion = 1; const uint16_t ObjectActionOffset::offsetVersion = 1;
ObjectActionOffset::ObjectActionOffset(EntityActionType type, QUuid id, EntityItemPointer ownerEntity) : ObjectActionOffset::ObjectActionOffset(const QUuid& id, EntityItemPointer ownerEntity) :
ObjectAction(type, id, ownerEntity) { ObjectAction(ACTION_TYPE_OFFSET, id, ownerEntity) {
#if WANT_DEBUG #if WANT_DEBUG
qDebug() << "ObjectActionOffset::ObjectActionOffset"; qDebug() << "ObjectActionOffset::ObjectActionOffset";
#endif #endif
@ -127,7 +127,7 @@ QVariantMap ObjectActionOffset::getArguments() {
return arguments; return arguments;
} }
QByteArray ObjectActionOffset::serialize() { QByteArray ObjectActionOffset::serialize() const {
QByteArray ba; QByteArray ba;
QDataStream dataStream(&ba, QIODevice::WriteOnly); QDataStream dataStream(&ba, QIODevice::WriteOnly);
dataStream << getType(); dataStream << getType();
@ -146,13 +146,14 @@ void ObjectActionOffset::deserialize(QByteArray serializedArguments) {
QDataStream dataStream(serializedArguments); QDataStream dataStream(serializedArguments);
EntityActionType type; EntityActionType type;
QUuid id;
uint16_t serializationVersion;
dataStream >> type; dataStream >> type;
assert(type == getType()); assert(type == getType());
QUuid id;
dataStream >> id; dataStream >> id;
assert(id == getID()); assert(id == getID());
uint16_t serializationVersion;
dataStream >> serializationVersion; dataStream >> serializationVersion;
if (serializationVersion != ObjectActionOffset::offsetVersion) { if (serializationVersion != ObjectActionOffset::offsetVersion) {
return; return;

View file

@ -19,17 +19,15 @@
class ObjectActionOffset : public ObjectAction { class ObjectActionOffset : public ObjectAction {
public: public:
ObjectActionOffset(EntityActionType type, QUuid id, EntityItemPointer ownerEntity); ObjectActionOffset(const QUuid& id, EntityItemPointer ownerEntity);
virtual ~ObjectActionOffset(); virtual ~ObjectActionOffset();
virtual EntityActionType getType() { return ACTION_TYPE_OFFSET; }
virtual bool updateArguments(QVariantMap arguments); virtual bool updateArguments(QVariantMap arguments);
virtual QVariantMap getArguments(); virtual QVariantMap getArguments();
virtual void updateActionWorker(float deltaTimeStep); virtual void updateActionWorker(float deltaTimeStep);
virtual QByteArray serialize(); virtual QByteArray serialize() const;
virtual void deserialize(QByteArray serializedArguments); virtual void deserialize(QByteArray serializedArguments);
private: private:

View file

@ -17,8 +17,8 @@ const float SPRING_MAX_SPEED = 10.0f;
const uint16_t ObjectActionSpring::springVersion = 1; const uint16_t ObjectActionSpring::springVersion = 1;
ObjectActionSpring::ObjectActionSpring(EntityActionType type, QUuid id, EntityItemPointer ownerEntity) : ObjectActionSpring::ObjectActionSpring(const QUuid& id, EntityItemPointer ownerEntity) :
ObjectAction(type, id, ownerEntity), ObjectAction(ACTION_TYPE_SPRING, id, ownerEntity),
_positionalTarget(glm::vec3(0.0f)), _positionalTarget(glm::vec3(0.0f)),
_linearTimeScale(0.2f), _linearTimeScale(0.2f),
_positionalTargetSet(false), _positionalTargetSet(false),
@ -206,7 +206,7 @@ QVariantMap ObjectActionSpring::getArguments() {
return arguments; return arguments;
} }
QByteArray ObjectActionSpring::serialize() { QByteArray ObjectActionSpring::serialize() const {
QByteArray serializedActionArguments; QByteArray serializedActionArguments;
QDataStream dataStream(&serializedActionArguments, QIODevice::WriteOnly); QDataStream dataStream(&serializedActionArguments, QIODevice::WriteOnly);
@ -229,13 +229,14 @@ void ObjectActionSpring::deserialize(QByteArray serializedArguments) {
QDataStream dataStream(serializedArguments); QDataStream dataStream(serializedArguments);
EntityActionType type; EntityActionType type;
QUuid id;
uint16_t serializationVersion;
dataStream >> type; dataStream >> type;
assert(type == getType()); assert(type == getType());
QUuid id;
dataStream >> id; dataStream >> id;
assert(id == getID()); assert(id == getID());
uint16_t serializationVersion;
dataStream >> serializationVersion; dataStream >> serializationVersion;
if (serializationVersion != ObjectActionSpring::springVersion) { if (serializationVersion != ObjectActionSpring::springVersion) {
return; return;

View file

@ -12,24 +12,19 @@
#ifndef hifi_ObjectActionSpring_h #ifndef hifi_ObjectActionSpring_h
#define hifi_ObjectActionSpring_h #define hifi_ObjectActionSpring_h
#include <QUuid>
#include <EntityItem.h>
#include "ObjectAction.h" #include "ObjectAction.h"
class ObjectActionSpring : public ObjectAction { class ObjectActionSpring : public ObjectAction {
public: public:
ObjectActionSpring(EntityActionType type, QUuid id, EntityItemPointer ownerEntity); ObjectActionSpring(const QUuid& id, EntityItemPointer ownerEntity);
virtual ~ObjectActionSpring(); virtual ~ObjectActionSpring();
virtual EntityActionType getType() { return ACTION_TYPE_SPRING; }
virtual bool updateArguments(QVariantMap arguments); virtual bool updateArguments(QVariantMap arguments);
virtual QVariantMap getArguments(); virtual QVariantMap getArguments();
virtual void updateActionWorker(float deltaTimeStep); virtual void updateActionWorker(float deltaTimeStep);
virtual QByteArray serialize(); virtual QByteArray serialize() const;
virtual void deserialize(QByteArray serializedArguments); virtual void deserialize(QByteArray serializedArguments);
protected: protected:

View file

@ -21,9 +21,13 @@
#include <climits> #include <climits>
#include <limits> #include <limits>
#include <QDebug>
#include <QBitArray> #include <QBitArray>
#include <QByteArray> #include <QByteArray>
#include "SharedUtil.h"
#include "NumericalConstants.h" #include "NumericalConstants.h"
template<typename T> class ByteCountCoded { template<typename T> class ByteCountCoded {
@ -37,7 +41,8 @@ public:
ByteCountCoded(const QByteArray& fromEncoded) : data(0) { decode(fromEncoded); } ByteCountCoded(const QByteArray& fromEncoded) : data(0) { decode(fromEncoded); }
QByteArray encode() const; QByteArray encode() const;
void decode(const QByteArray& fromEncoded); size_t decode(const QByteArray& fromEncoded);
size_t decode(const char* encodedBuffer, int encodedSize);
bool operator==(const ByteCountCoded& other) const { return data == other.data; } bool operator==(const ByteCountCoded& other) const { return data == other.data; }
bool operator!=(const ByteCountCoded& other) const { return data != other.data; } bool operator!=(const ByteCountCoded& other) const { return data != other.data; }
@ -110,52 +115,63 @@ template<typename T> inline QByteArray ByteCountCoded<T>::encode() const {
return output; return output;
} }
template<typename T> inline void ByteCountCoded<T>::decode(const QByteArray& fromEncodedBytes) { template<typename T> inline size_t ByteCountCoded<T>::decode(const QByteArray& fromEncodedBytes) {
return decode(fromEncodedBytes.constData(), fromEncodedBytes.size());
}
// first convert the ByteArray into a BitArray... template<typename T> inline size_t ByteCountCoded<T>::decode(const char* encodedBuffer, int encodedSize) {
QBitArray encodedBits; data = 0; // reset data
int bitCount = BITS_IN_BYTE * fromEncodedBytes.count(); size_t bytesConsumed = 0;
encodedBits.resize(bitCount); int bitCount = BITS_IN_BYTE * encodedSize;
int encodedByteCount = 1; // there is at least 1 byte (after the leadBits)
int leadBits = 1; // there is always at least 1 lead bit
bool inLeadBits = true;
int bitAt = 0;
int expectedBitCount; // unknown at this point
int lastValueBit;
T bitValue = 1;
for(int byte = 0; byte < fromEncodedBytes.count(); byte++) { for(int byte = 0; byte < encodedSize; byte++) {
char originalByte = fromEncodedBytes.at(byte); char originalByte = encodedBuffer[byte];
bytesConsumed++;
unsigned char maskBit = 128; // LEFT MOST BIT set
for(int bit = 0; bit < BITS_IN_BYTE; bit++) { for(int bit = 0; bit < BITS_IN_BYTE; bit++) {
int shiftBy = BITS_IN_BYTE - (bit + 1); bool bitIsSet = originalByte & maskBit;
char maskBit = ( 1 << shiftBy);
bool bitValue = originalByte & maskBit; // Processing of the lead bits
encodedBits.setBit(byte * BITS_IN_BYTE + bit, bitValue); if (inLeadBits) {
if (bitIsSet) {
encodedByteCount++;
leadBits++;
} else {
inLeadBits = false; // once we hit our first 0, we know we're out of the lead bits
expectedBitCount = (encodedByteCount * BITS_IN_BYTE) - leadBits;
lastValueBit = expectedBitCount + bitAt;
// check to see if the remainder of our buffer is sufficient
if (expectedBitCount > (bitCount - leadBits)) {
break;
}
}
} else {
if (bitAt > lastValueBit) {
break;
}
if(bitIsSet) {
data += bitValue;
}
bitValue *= 2;
}
bitAt++;
maskBit = maskBit >> 1;
} }
} if (!inLeadBits && bitAt > lastValueBit) {
// next, read the leading bits to determine the correct number of bytes to decode (may not match the QByteArray)
int encodedByteCount = 0;
int leadBits = 1;
int bitAt;
for (bitAt = 0; bitAt < bitCount; bitAt++) {
if (encodedBits.at(bitAt)) {
encodedByteCount++;
leadBits++;
} else {
break; break;
} }
} }
encodedByteCount++; // always at least one byte return bytesConsumed;
int expectedBitCount = encodedByteCount * BITS_IN_BYTE;
T value = 0;
if (expectedBitCount <= (encodedBits.size() - leadBits)) {
// Now, keep reading...
int valueStartsAt = bitAt + 1;
T bitValue = 1;
for (bitAt = valueStartsAt; bitAt < expectedBitCount; bitAt++) {
if(encodedBits.at(bitAt)) {
value += bitValue;
}
bitValue *= 2;
}
}
data = value;
} }
#endif // hifi_ByteCountCoding_h #endif // hifi_ByteCountCoding_h

View file

@ -20,7 +20,7 @@ QVariantList glmToQList(const glm::quat& g) {
return QVariantList() << g.x << g.y << g.z << g.w; return QVariantList() << g.x << g.y << g.z << g.w;
} }
QVariantList rgbColorToQList(rgbColor& v) { QVariantList rgbColorToQList(const rgbColor& v) {
return QVariantList() << (int)(v[0]) << (int)(v[1]) << (int)(v[2]); return QVariantList() << (int)(v[0]) << (int)(v[1]) << (int)(v[2]);
} }
@ -42,12 +42,12 @@ QVariantMap glmToQMap(const glm::quat& glmQuat) {
} }
glm::vec3 qListToGlmVec3(const QVariant q) { glm::vec3 qListToGlmVec3(const QVariant& q) {
QVariantList qList = q.toList(); QVariantList qList = q.toList();
return glm::vec3(qList[RED_INDEX].toFloat(), qList[GREEN_INDEX].toFloat(), qList[BLUE_INDEX].toFloat()); return glm::vec3(qList[RED_INDEX].toFloat(), qList[GREEN_INDEX].toFloat(), qList[BLUE_INDEX].toFloat());
} }
glm::quat qListToGlmQuat(const QVariant q) { glm::quat qListToGlmQuat(const QVariant& q) {
QVariantList qList = q.toList(); QVariantList qList = q.toList();
float x = qList[0].toFloat(); float x = qList[0].toFloat();
float y = qList[1].toFloat(); float y = qList[1].toFloat();
@ -56,7 +56,7 @@ glm::quat qListToGlmQuat(const QVariant q) {
return glm::quat(w, x, y, z); return glm::quat(w, x, y, z);
} }
void qListtoRgbColor(const QVariant q, rgbColor returnValue) { void qListtoRgbColor(const QVariant& q, rgbColor& returnValue) {
QVariantList qList = q.toList(); QVariantList qList = q.toList();
returnValue[RED_INDEX] = qList[RED_INDEX].toInt(); returnValue[RED_INDEX] = qList[RED_INDEX].toInt();
returnValue[GREEN_INDEX] = qList[GREEN_INDEX].toInt(); returnValue[GREEN_INDEX] = qList[GREEN_INDEX].toInt();

View file

@ -19,11 +19,11 @@
QVariantList glmToQList(const glm::vec3& g); QVariantList glmToQList(const glm::vec3& g);
QVariantList glmToQList(const glm::quat& g); QVariantList glmToQList(const glm::quat& g);
QVariantList rgbColorToQList(rgbColor& v); QVariantList rgbColorToQList(const rgbColor& v);
QVariantMap glmToQMap(const glm::vec3& glmVector); QVariantMap glmToQMap(const glm::vec3& glmVector);
QVariantMap glmToQMap(const glm::quat& glmQuat); QVariantMap glmToQMap(const glm::quat& glmQuat);
glm::vec3 qListToGlmVec3(const QVariant q); glm::vec3 qListToGlmVec3(const QVariant& q);
glm::quat qListToGlmQuat(const QVariant q); glm::quat qListToGlmQuat(const QVariant& q);
void qListtoRgbColor(const QVariant q, rgbColor returnValue); void qListtoRgbColor(const QVariant& q, rgbColor& returnValue);

View file

@ -229,6 +229,7 @@ QScriptValue collisionToScriptValue(QScriptEngine* engine, const Collision& coll
obj.setProperty("idB", quuidToScriptValue(engine, collision.idB)); obj.setProperty("idB", quuidToScriptValue(engine, collision.idB));
obj.setProperty("penetration", vec3toScriptValue(engine, collision.penetration)); obj.setProperty("penetration", vec3toScriptValue(engine, collision.penetration));
obj.setProperty("contactPoint", vec3toScriptValue(engine, collision.contactPoint)); obj.setProperty("contactPoint", vec3toScriptValue(engine, collision.contactPoint));
obj.setProperty("velocityChange", vec3toScriptValue(engine, collision.velocityChange));
return obj; return obj;
} }