mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 12:33:27 +02:00
Merge branch 'atp' of https://github.com/birarda/hifi into protocol
This commit is contained in:
commit
4bc71bb39e
38 changed files with 648 additions and 218 deletions
|
@ -13,9 +13,8 @@
|
|||
|
||||
#include "AssignmentAction.h"
|
||||
|
||||
AssignmentAction::AssignmentAction(EntityActionType type, QUuid id, EntityItemPointer ownerEntity) :
|
||||
_id(id),
|
||||
_type(type),
|
||||
AssignmentAction::AssignmentAction(EntityActionType type, const QUuid& id, EntityItemPointer ownerEntity) :
|
||||
EntityActionInterface(type, id),
|
||||
_data(QByteArray()),
|
||||
_active(false),
|
||||
_ownerEntity(ownerEntity) {
|
||||
|
@ -28,7 +27,7 @@ void AssignmentAction::removeFromSimulation(EntitySimulation* simulation) const
|
|||
simulation->removeAction(_id);
|
||||
}
|
||||
|
||||
QByteArray AssignmentAction::serialize() {
|
||||
QByteArray AssignmentAction::serialize() const {
|
||||
return _data;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,23 +21,19 @@
|
|||
|
||||
class AssignmentAction : public EntityActionInterface {
|
||||
public:
|
||||
AssignmentAction(EntityActionType type, QUuid id, EntityItemPointer ownerEntity);
|
||||
AssignmentAction(EntityActionType type, const QUuid& id, EntityItemPointer ownerEntity);
|
||||
virtual ~AssignmentAction();
|
||||
|
||||
const QUuid& getID() const { return _id; }
|
||||
virtual EntityActionType getType() { return _type; }
|
||||
virtual void removeFromSimulation(EntitySimulation* simulation) const;
|
||||
virtual EntityItemWeakPointer getOwnerEntity() const { return _ownerEntity; }
|
||||
virtual void setOwnerEntity(const EntityItemPointer ownerEntity) { _ownerEntity = ownerEntity; }
|
||||
virtual bool updateArguments(QVariantMap arguments);
|
||||
virtual QVariantMap getArguments();
|
||||
|
||||
virtual QByteArray serialize();
|
||||
virtual QByteArray serialize() const;
|
||||
virtual void deserialize(QByteArray serializedArguments);
|
||||
|
||||
private:
|
||||
QUuid _id;
|
||||
EntityActionType _type;
|
||||
QByteArray _data;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -12,14 +12,14 @@
|
|||
#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);
|
||||
}
|
||||
|
||||
|
||||
EntityActionPointer AssignmentActionFactory::factory(EntitySimulation* simulation,
|
||||
EntityActionType type,
|
||||
QUuid id,
|
||||
const QUuid& id,
|
||||
EntityItemPointer ownerEntity,
|
||||
QVariantMap arguments) {
|
||||
EntityActionPointer action = assignmentActionFactory(type, id, ownerEntity);
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
virtual ~AssignmentActionFactory() { }
|
||||
virtual EntityActionPointer factory(EntitySimulation* simulation,
|
||||
EntityActionType type,
|
||||
QUuid id,
|
||||
const QUuid& id,
|
||||
EntityItemPointer ownerEntity,
|
||||
QVariantMap arguments);
|
||||
virtual EntityActionPointer factoryBA(EntitySimulation* simulation,
|
||||
|
|
4
cmake/externals/oglplus/CMakeLists.txt
vendored
4
cmake/externals/oglplus/CMakeLists.txt
vendored
|
@ -4,8 +4,8 @@ string(TOUPPER ${EXTERNAL_NAME} EXTERNAL_NAME_UPPER)
|
|||
include(ExternalProject)
|
||||
ExternalProject_Add(
|
||||
${EXTERNAL_NAME}
|
||||
GIT_REPOSITORY https://github.com/matus-chochlik/oglplus.git
|
||||
GIT_TAG a2681383928b1166f176512cbe0f95e96fe68d08
|
||||
URL http://iweb.dl.sourceforge.net/project/oglplus/oglplus-0.63.x/oglplus-0.63.0.zip
|
||||
URL_MD5 de984ab245b185b45c87415c0e052135
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
|
|
|
@ -12,7 +12,6 @@ Script.load("progress.js");
|
|||
Script.load("edit.js");
|
||||
Script.load("selectAudioDevice.js");
|
||||
Script.load("inspect.js");
|
||||
Script.load("lobby.js");
|
||||
Script.load("notifications.js");
|
||||
Script.load("users.js");
|
||||
Script.load("grab.js");
|
||||
|
|
70
examples/example/games/make-dummy.js
Normal file
70
examples/example/games/make-dummy.js
Normal 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);
|
269
examples/example/games/sword.js
Normal file
269
examples/example/games/sword.js
Normal 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);
|
|
@ -1014,6 +1014,7 @@ void Application::paintGL() {
|
|||
|
||||
void Application::runTests() {
|
||||
runTimingTests();
|
||||
runUnitTests();
|
||||
}
|
||||
|
||||
void Application::audioMuteToggled() {
|
||||
|
@ -2308,38 +2309,42 @@ void Application::updateMyAvatarLookAtPosition() {
|
|||
bool isLookingAtSomeone = false;
|
||||
glm::vec3 lookAtSpot;
|
||||
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()) {
|
||||
lookAtSpot = _myCamera.getPosition();
|
||||
} else {
|
||||
if (_myAvatar->isLookingAtLeftEye()) {
|
||||
lookAtSpot = OculusManager::getLeftEyePosition();
|
||||
} else {
|
||||
lookAtSpot = OculusManager::getRightEyePosition();
|
||||
lookAtSpot = _myCamera.getPosition() + OculusManager::getMidEyePosition();
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
AvatarSharedPointer lookingAt = _myAvatar->getLookAtTargetAvatar().lock();
|
||||
if (lookingAt && _myAvatar != lookingAt.get()) {
|
||||
isLookingAtSomeone = true;
|
||||
// If I am looking at someone else, look directly at one of their eyes
|
||||
if (tracker && !tracker->isMuted()) {
|
||||
// If a face tracker is active, look at the eye for the side my gaze is biased toward
|
||||
if (tracker->getEstimatedEyeYaw() > _myAvatar->getHead()->getFinalYaw()) {
|
||||
// Look at their right eye
|
||||
lookAtSpot = static_cast<Avatar*>(lookingAt.get())->getHead()->getRightEyePosition();
|
||||
} else {
|
||||
// Look at their left eye
|
||||
lookAtSpot = static_cast<Avatar*>(lookingAt.get())->getHead()->getLeftEyePosition();
|
||||
isLookingAtSomeone = true;
|
||||
Head* lookingAtHead = static_cast<Avatar*>(lookingAt.get())->getHead();
|
||||
|
||||
const float MAXIMUM_FACE_ANGLE = 65.0f * RADIANS_PER_DEGREE;
|
||||
glm::vec3 lookingAtFaceOrientation = lookingAtHead->getFinalOrientationInWorldFrame() * IDENTITY_FRONT;
|
||||
glm::vec3 fromLookingAtToMe = glm::normalize(_myAvatar->getHead()->getEyePosition()
|
||||
- lookingAtHead->getEyePosition());
|
||||
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 {
|
||||
// Need to add randomly looking back and forth between left and right eye for case with no tracker
|
||||
if (_myAvatar->isLookingAtLeftEye()) {
|
||||
lookAtSpot = static_cast<Avatar*>(lookingAt.get())->getHead()->getLeftEyePosition();
|
||||
} else {
|
||||
lookAtSpot = static_cast<Avatar*>(lookingAt.get())->getHead()->getRightEyePosition();
|
||||
}
|
||||
// Just look at their head (mid point between eyes)
|
||||
lookAtSpot = lookingAtHead->getEyePosition();
|
||||
}
|
||||
} else {
|
||||
// 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));
|
||||
}
|
||||
}
|
||||
//
|
||||
// Deflect the eyes a bit to match the detected Gaze from 3D camera if active
|
||||
//
|
||||
if (tracker && !tracker->isMuted()) {
|
||||
|
||||
// Deflect the eyes a bit to match the detected gaze from Faceshift if active.
|
||||
// DDE doesn't track eyes.
|
||||
if (tracker && typeid(*tracker) == typeid(Faceshift) && !tracker->isMuted()) {
|
||||
float eyePitch = tracker->getEstimatedEyePitch();
|
||||
float eyeYaw = tracker->getEstimatedEyeYaw();
|
||||
const float GAZE_DEFLECTION_REDUCTION_DURING_EYE_CONTACT = 0.1f;
|
||||
// deflect using Faceshift gaze data
|
||||
glm::vec3 origin = _myAvatar->getHead()->getEyePosition();
|
||||
float pitchSign = (_myCamera.getMode() == CAMERA_MODE_MIRROR) ? -1.0f : 1.0f;
|
||||
float deflection = DependencyManager::get<Faceshift>()->getEyeDeflection();
|
||||
|
|
|
@ -18,16 +18,16 @@
|
|||
#include "InterfaceActionFactory.h"
|
||||
|
||||
|
||||
EntityActionPointer interfaceActionFactory(EntityActionType type, QUuid id, EntityItemPointer ownerEntity) {
|
||||
EntityActionPointer interfaceActionFactory(EntityActionType type, const QUuid& id, EntityItemPointer ownerEntity) {
|
||||
switch (type) {
|
||||
case ACTION_TYPE_NONE:
|
||||
return nullptr;
|
||||
case ACTION_TYPE_OFFSET:
|
||||
return (EntityActionPointer) new ObjectActionOffset(type, id, ownerEntity);
|
||||
return (EntityActionPointer) new ObjectActionOffset(id, ownerEntity);
|
||||
case ACTION_TYPE_SPRING:
|
||||
return (EntityActionPointer) new ObjectActionSpring(type, id, ownerEntity);
|
||||
return (EntityActionPointer) new ObjectActionSpring(id, ownerEntity);
|
||||
case ACTION_TYPE_HOLD:
|
||||
return (EntityActionPointer) new AvatarActionHold(type, id, ownerEntity);
|
||||
return (EntityActionPointer) new AvatarActionHold(id, ownerEntity);
|
||||
}
|
||||
|
||||
assert(false);
|
||||
|
@ -37,7 +37,7 @@ EntityActionPointer interfaceActionFactory(EntityActionType type, QUuid id, Enti
|
|||
|
||||
EntityActionPointer InterfaceActionFactory::factory(EntitySimulation* simulation,
|
||||
EntityActionType type,
|
||||
QUuid id,
|
||||
const QUuid& id,
|
||||
EntityItemPointer ownerEntity,
|
||||
QVariantMap arguments) {
|
||||
EntityActionPointer action = interfaceActionFactory(type, id, ownerEntity);
|
||||
|
|
|
@ -20,7 +20,7 @@ public:
|
|||
virtual ~InterfaceActionFactory() { }
|
||||
virtual EntityActionPointer factory(EntitySimulation* simulation,
|
||||
EntityActionType type,
|
||||
QUuid id,
|
||||
const QUuid& id,
|
||||
EntityItemPointer ownerEntity,
|
||||
QVariantMap arguments);
|
||||
virtual EntityActionPointer factoryBA(EntitySimulation* simulation,
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include <QThread>
|
||||
|
||||
#include <ByteCountCoding.h>
|
||||
#include <SharedUtil.h>
|
||||
#include <TextRenderer.h>
|
||||
|
||||
|
@ -229,6 +230,43 @@ void runTimingTests() {
|
|||
elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC;
|
||||
qCDebug(interfaceapp, "vec3 assign and dot() usecs: %f, last result:%f",
|
||||
(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,
|
||||
|
@ -271,3 +309,39 @@ bool pointInSphere(glm::vec3& point, glm::vec3& sphereCenter, double sphereRadiu
|
|||
}
|
||||
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!";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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 runTimingTests();
|
||||
void runUnitTests();
|
||||
|
||||
bool rayIntersectsSphere(const glm::vec3& rayStarting, const glm::vec3& rayNormalizedDirection,
|
||||
const glm::vec3& sphereCenter, float sphereRadius, float& distance);
|
||||
|
|
|
@ -17,13 +17,14 @@
|
|||
|
||||
const uint16_t AvatarActionHold::holdVersion = 1;
|
||||
|
||||
AvatarActionHold::AvatarActionHold(EntityActionType type, QUuid id, EntityItemPointer ownerEntity) :
|
||||
ObjectActionSpring(type, id, ownerEntity),
|
||||
AvatarActionHold::AvatarActionHold(const QUuid& id, EntityItemPointer ownerEntity) :
|
||||
ObjectActionSpring(id, ownerEntity),
|
||||
_relativePosition(glm::vec3(0.0f)),
|
||||
_relativeRotation(glm::quat()),
|
||||
_hand("right"),
|
||||
_mine(false)
|
||||
{
|
||||
_type = ACTION_TYPE_HOLD;
|
||||
#if WANT_DEBUG
|
||||
qDebug() << "AvatarActionHold::AvatarActionHold";
|
||||
#endif
|
||||
|
@ -166,8 +167,7 @@ QVariantMap AvatarActionHold::getArguments() {
|
|||
|
||||
|
||||
void AvatarActionHold::deserialize(QByteArray serializedArguments) {
|
||||
if (_mine) {
|
||||
return;
|
||||
}
|
||||
if (!_mine) {
|
||||
ObjectActionSpring::deserialize(serializedArguments);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,11 +19,9 @@
|
|||
|
||||
class AvatarActionHold : public ObjectActionSpring {
|
||||
public:
|
||||
AvatarActionHold(EntityActionType type, QUuid id, EntityItemPointer ownerEntity);
|
||||
AvatarActionHold(const QUuid& id, EntityItemPointer ownerEntity);
|
||||
virtual ~AvatarActionHold();
|
||||
|
||||
virtual EntityActionType getType() { return ACTION_TYPE_HOLD; }
|
||||
|
||||
virtual bool updateArguments(QVariantMap arguments);
|
||||
virtual QVariantMap getArguments();
|
||||
|
||||
|
|
|
@ -256,7 +256,6 @@ void AvatarManager::handleOutgoingChanges(VectorOfMotionStates& motionStates) {
|
|||
}
|
||||
|
||||
void AvatarManager::handleCollisionEvents(CollisionEvents& collisionEvents) {
|
||||
// TODO: expose avatar collision events to JS
|
||||
for (Collision collision : collisionEvents) {
|
||||
// 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
|
||||
|
@ -285,6 +284,7 @@ void AvatarManager::handleCollisionEvents(CollisionEvents& collisionEvents) {
|
|||
const float AVATAR_STRETCH_FACTOR = 1.0f;
|
||||
|
||||
AudioInjector::playSound(collisionSoundURL, energyFactorOfFull, AVATAR_STRETCH_FACTOR, myAvatar->getPosition());
|
||||
myAvatar->collisionWithEntity(collision);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,11 +22,6 @@
|
|||
#include "InterfaceConfig.h"
|
||||
#include "world.h"
|
||||
|
||||
enum eyeContactTargets {
|
||||
LEFT_EYE,
|
||||
RIGHT_EYE,
|
||||
MOUTH
|
||||
};
|
||||
|
||||
const float EYE_EAR_GAP = 0.08f;
|
||||
|
||||
|
@ -77,6 +72,7 @@ public:
|
|||
const glm::vec3& getLeftEyePosition() const { return _leftEyePosition; }
|
||||
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 getMouthPosition() const { return _eyePosition - getUpDirection() * glm::length(_rightEyePosition - _leftEyePosition); }
|
||||
|
||||
FaceModel& getFaceModel() { return _faceModel; }
|
||||
const FaceModel& getFaceModel() const { return _faceModel; }
|
||||
|
|
|
@ -34,6 +34,9 @@
|
|||
#include <TextRenderer.h>
|
||||
#include <UserActivityLogger.h>
|
||||
|
||||
#include "devices/Faceshift.h"
|
||||
#include "devices/OculusManager.h"
|
||||
|
||||
#include "Application.h"
|
||||
#include "AvatarManager.h"
|
||||
#include "Environment.h"
|
||||
|
@ -42,7 +45,6 @@
|
|||
#include "MyAvatar.h"
|
||||
#include "Physics.h"
|
||||
#include "Recorder.h"
|
||||
#include "devices/Faceshift.h"
|
||||
#include "Util.h"
|
||||
#include "InterfaceLogging.h"
|
||||
|
||||
|
@ -97,7 +99,7 @@ MyAvatar::MyAvatar() :
|
|||
_shouldRender(true),
|
||||
_billboardValid(false),
|
||||
_feetTouchFloor(true),
|
||||
_isLookingAtLeftEye(true),
|
||||
_eyeContactTarget(LEFT_EYE),
|
||||
_realWorldFieldOfView("realWorldFieldOfView",
|
||||
DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES),
|
||||
_firstPersonSkeletonModel(this),
|
||||
|
@ -883,7 +885,6 @@ void MyAvatar::updateLookAtTargetAvatar() {
|
|||
const float KEEP_LOOKING_AT_CURRENT_ANGLE_FACTOR = 1.3f;
|
||||
const float GREATEST_LOOKING_AT_DISTANCE = 10.0f;
|
||||
|
||||
int howManyLookingAtMe = 0;
|
||||
foreach (const AvatarSharedPointer& avatarPointer, DependencyManager::get<AvatarManager>()->getAvatarHash()) {
|
||||
Avatar* avatar = static_cast<Avatar*>(avatarPointer.get());
|
||||
bool isCurrentTarget = avatar->getIsLookAtTarget();
|
||||
|
@ -896,17 +897,22 @@ void MyAvatar::updateLookAtTargetAvatar() {
|
|||
_targetAvatarPosition = avatarPointer->getPosition();
|
||||
smallestAngleTo = angleTo;
|
||||
}
|
||||
// Check if this avatar is looking at me, and fix their gaze on my camera if so
|
||||
if (Application::getInstance()->isLookingAtMyAvatar(avatar)) {
|
||||
howManyLookingAtMe++;
|
||||
// Have that avatar look directly at my camera
|
||||
// Philip TODO: correct to look at left/right eye
|
||||
if (qApp->isHMDMode()) {
|
||||
avatar->getHead()->setCorrectedLookAtPosition(Application::getInstance()->getViewFrustum()->getPosition());
|
||||
// FIXME what is the point of this?
|
||||
// avatar->getHead()->setCorrectedLookAtPosition(OculusManager::getLeftEyePosition());
|
||||
// Alter their gaze to look directly at my camera; this looks more natural than looking at my avatar's face.
|
||||
// Offset their gaze according to whether they're looking at one of my eyes or my mouth.
|
||||
glm::vec3 gazeOffset = avatar->getHead()->getLookAtPosition() - getHead()->getEyePosition();
|
||||
const float HUMAN_EYE_SEPARATION = 0.065f;
|
||||
float myEyeSeparation = glm::length(getHead()->getLeftEyePosition() - getHead()->getRightEyePosition());
|
||||
gazeOffset = gazeOffset * HUMAN_EYE_SEPARATION / myEyeSeparation;
|
||||
|
||||
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 {
|
||||
avatar->getHead()->setCorrectedLookAtPosition(Application::getInstance()->getViewFrustum()->getPosition());
|
||||
avatar->getHead()->setCorrectedLookAtPosition(Application::getInstance()->getViewFrustum()->getPosition()
|
||||
+ gazeOffset);
|
||||
}
|
||||
} else {
|
||||
avatar->getHead()->clearCorrectedLookAtPosition();
|
||||
|
@ -923,12 +929,24 @@ void MyAvatar::clearLookAtTargetAvatar() {
|
|||
_lookAtTargetAvatar.reset();
|
||||
}
|
||||
|
||||
bool MyAvatar::isLookingAtLeftEye() {
|
||||
float const CHANCE_OF_CHANGING_EYE = 0.01f;
|
||||
if (randFloat() < CHANCE_OF_CHANGING_EYE) {
|
||||
_isLookingAtLeftEye = !_isLookingAtLeftEye;
|
||||
eyeContactTarget MyAvatar::getEyeContactTarget() {
|
||||
float const CHANCE_OF_CHANGING_TARGET = 0.01f;
|
||||
if (randFloat() < CHANCE_OF_CHANGING_TARGET) {
|
||||
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 {
|
||||
|
|
|
@ -19,6 +19,12 @@
|
|||
|
||||
class ModelItemID;
|
||||
|
||||
enum eyeContactTarget {
|
||||
LEFT_EYE,
|
||||
RIGHT_EYE,
|
||||
MOUTH
|
||||
};
|
||||
|
||||
class MyAvatar : public Avatar {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool shouldRenderLocally READ getShouldRenderLocally WRITE setShouldRenderLocally)
|
||||
|
@ -94,7 +100,7 @@ public:
|
|||
|
||||
bool isMyAvatar() const { return true; }
|
||||
|
||||
bool isLookingAtLeftEye();
|
||||
eyeContactTarget getEyeContactTarget();
|
||||
|
||||
virtual int parseDataAtOffset(const QByteArray& packet, int offset);
|
||||
|
||||
|
@ -209,6 +215,7 @@ public slots:
|
|||
signals:
|
||||
void transformChanged();
|
||||
void newCollisionSoundURL(const QUrl& url);
|
||||
void collisionWithEntity(const Collision& collision);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -251,7 +258,7 @@ private:
|
|||
QList<AnimationHandlePointer> _animationHandles;
|
||||
|
||||
bool _feetTouchFloor;
|
||||
bool _isLookingAtLeftEye;
|
||||
eyeContactTarget _eyeContactTarget;
|
||||
|
||||
RecorderPointer _recorder;
|
||||
|
||||
|
|
|
@ -283,6 +283,7 @@ static ovrVector3f _eyeOffsets[ovrEye_Count];
|
|||
|
||||
glm::vec3 OculusManager::getLeftEyePosition() { return _eyePositions[ovrEye_Left]; }
|
||||
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) {
|
||||
qCDebug(interfaceapp) << "Oculus SDK" << OVR_VERSION_STRING;
|
||||
|
@ -692,13 +693,13 @@ void OculusManager::display(QGLWidget * glCanvas, RenderArgs* renderArgs, const
|
|||
_eyeRenderPoses[eye] = eyePoses[eye];
|
||||
// Set the camera rotation for this eye
|
||||
|
||||
vec3 eyePosition = toGlm(_eyeRenderPoses[eye].Position);
|
||||
eyePosition = whichCamera.getRotation() * eyePosition;
|
||||
_eyePositions[eye] = toGlm(_eyeRenderPoses[eye].Position);
|
||||
_eyePositions[eye] = whichCamera.getRotation() * _eyePositions[eye];
|
||||
quat eyeRotation = toGlm(_eyeRenderPoses[eye].Orientation);
|
||||
|
||||
// Update our camera to what the application camera is doing
|
||||
_camera->setRotation(whichCamera.getRotation() * eyeRotation);
|
||||
_camera->setPosition(whichCamera.getPosition() + eyePosition);
|
||||
_camera->setPosition(whichCamera.getPosition() + _eyePositions[eye]);
|
||||
configureCamera(*_camera);
|
||||
_camera->update(1.0f / Application::getInstance()->getFps());
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ public:
|
|||
|
||||
static glm::vec3 getLeftEyePosition();
|
||||
static glm::vec3 getRightEyePosition();
|
||||
static glm::vec3 getMidEyePosition();
|
||||
|
||||
static int getHMDScreen();
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ class EntityActionFactoryInterface : public QObject, public Dependency {
|
|||
virtual ~EntityActionFactoryInterface() { }
|
||||
virtual EntityActionPointer factory(EntitySimulation* simulation,
|
||||
EntityActionType type,
|
||||
QUuid id,
|
||||
const QUuid& id,
|
||||
EntityItemPointer ownerEntity,
|
||||
QVariantMap arguments) { assert(false); return nullptr; }
|
||||
virtual EntityActionPointer factoryBA(EntitySimulation* simulation,
|
||||
|
|
|
@ -29,10 +29,10 @@ enum EntityActionType {
|
|||
|
||||
class EntityActionInterface {
|
||||
public:
|
||||
EntityActionInterface() { }
|
||||
EntityActionInterface(EntityActionType type, const QUuid& id) : _id(id), _type(type) { }
|
||||
virtual ~EntityActionInterface() { }
|
||||
virtual const QUuid& getID() const = 0;
|
||||
virtual EntityActionType getType() { assert(false); return ACTION_TYPE_NONE; }
|
||||
const QUuid& getID() const { return _id; }
|
||||
EntityActionType getType() const { return _type; }
|
||||
|
||||
virtual void removeFromSimulation(EntitySimulation* simulation) const = 0;
|
||||
virtual EntityItemWeakPointer getOwnerEntity() const = 0;
|
||||
|
@ -40,7 +40,7 @@ public:
|
|||
virtual bool updateArguments(QVariantMap arguments) = 0;
|
||||
virtual QVariantMap getArguments() = 0;
|
||||
|
||||
virtual QByteArray serialize() = 0;
|
||||
virtual QByteArray serialize() const = 0;
|
||||
virtual void deserialize(QByteArray serializedArguments) = 0;
|
||||
|
||||
static EntityActionType actionTypeFromString(QString actionTypeString);
|
||||
|
@ -68,6 +68,8 @@ protected:
|
|||
static QString extractStringArgument(QString objectName, QVariantMap arguments,
|
||||
QString argumentName, bool& ok, bool required = true);
|
||||
|
||||
QUuid _id;
|
||||
EntityActionType _type;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -92,13 +92,11 @@ void EntityTree::postAddEntity(EntityItemPointer entity) {
|
|||
bool EntityTree::updateEntity(const EntityItemID& entityID, const EntityItemProperties& properties, const SharedNodePointer& senderNode) {
|
||||
EntityTreeElement* containingElement = getContainingElement(entityID);
|
||||
if (!containingElement) {
|
||||
qCDebug(entities) << "UNEXPECTED!!!! EntityTree::updateEntity() entityID doesn't exist!!! entityID=" << entityID;
|
||||
return false;
|
||||
}
|
||||
|
||||
EntityItemPointer existingEntity = containingElement->getEntityWithEntityItemID(entityID);
|
||||
if (!existingEntity) {
|
||||
qCDebug(entities) << "UNEXPECTED!!!! don't call updateEntity() on entity items that don't exist. entityID=" << entityID;
|
||||
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) {
|
||||
EntityTreeElement* containingElement = getContainingElement(entity->getEntityItemID());
|
||||
if (!containingElement) {
|
||||
qCDebug(entities) << "UNEXPECTED!!!! EntityTree::updateEntity() entity-->element lookup failed!!! entityID="
|
||||
<< entity->getEntityItemID();
|
||||
return false;
|
||||
}
|
||||
return updateEntityWithElement(entity, properties, containingElement, senderNode);
|
||||
|
|
|
@ -219,20 +219,18 @@ bool LimitedNodeList::packetVersionAndHashMatch(const QByteArray& packet) {
|
|||
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) {
|
||||
// qint64 result = getNodeSocket().readDatagram(incomingPacket.data(), incomingPacket.size(), address, port);
|
||||
//
|
||||
// SharedNodePointer sendingNode = sendingNodeForPacket(incomingPacket);
|
||||
// if (sendingNode) {
|
||||
// emit dataReceived(sendingNode->getType(), incomingPacket.size());
|
||||
// } else {
|
||||
// emit dataReceived(NodeType::Unassigned, incomingPacket.size());
|
||||
// }
|
||||
//
|
||||
// return result;
|
||||
//}
|
||||
SharedNodePointer sendingNode = sendingNodeForPacket(incomingPacket);
|
||||
if (sendingNode) {
|
||||
emit dataReceived(sendingNode->getType(), incomingPacket.size());
|
||||
} else {
|
||||
emit dataReceived(NodeType::Unassigned, incomingPacket.size());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
qint64 LimitedNodeList::writeDatagram(const QByteArray& datagram, const HifiSockAddr& destinationSockAddr) {
|
||||
// XXX can BandwidthRecorder be used for this?
|
||||
|
@ -553,7 +551,7 @@ std::unique_ptr<NLPacket> LimitedNodeList::constructPingReplyPacket(const QByteA
|
|||
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);
|
||||
|
||||
auto icePingPacket = NLPacket::create(PacketType::ICEPing, packetSize);
|
||||
|
@ -564,7 +562,7 @@ std::unique_ptr<NLPacket> constructICEPingPacket(PingType_t pingType, const QUui
|
|||
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
|
||||
PingType_t pingType;
|
||||
|
||||
|
|
|
@ -32,13 +32,13 @@ template <class T> std::unique_ptr<NLPacket> PacketList<T>::createPacketWithExte
|
|||
}
|
||||
}
|
||||
|
||||
template<typename T> qint64 Packet::readPrimitive(T* data) {
|
||||
return QIODevice::read(reinterpret_cast<char*>(data), sizeof(T));
|
||||
template<class T> template<typename U> qint64 PacketList<T>::readPrimitive(U* data) {
|
||||
return QIODevice::read(reinterpret_cast<char*>(data), sizeof(U));
|
||||
}
|
||||
|
||||
template<typename T> qint64 Packet::writePrimitive(const T& data) {
|
||||
static_assert(!std::is_pointer<T>::value, "T must not be a pointer");
|
||||
return QIODevice::write(reinterpret_cast<const char*>(&data), sizeof(T));
|
||||
template<class T> template<typename U> qint64 PacketList<T>::writePrimitive(const U& data) {
|
||||
static_assert(!std::is_pointer<U>::value, "T must not be a pointer");
|
||||
return QIODevice::write(reinterpret_cast<const char*>(&data), sizeof(U));
|
||||
}
|
||||
|
||||
template <class T> qint64 PacketList<T>::writeData(const char* data, qint64 maxSize) {
|
||||
|
|
|
@ -80,6 +80,7 @@ bool ReceivedPacketProcessor::process() {
|
|||
for(auto& packetPair : currentPackets) {
|
||||
// TODO: Replace QByteArray() once NLPacket is coming through on receive side
|
||||
processPacket(packetPair.first, QByteArray());
|
||||
_lastWindowProcessedPackets++;
|
||||
midProcess();
|
||||
}
|
||||
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
|
||||
#include "ObjectAction.h"
|
||||
|
||||
ObjectAction::ObjectAction(EntityActionType type, QUuid id, EntityItemPointer ownerEntity) :
|
||||
ObjectAction::ObjectAction(EntityActionType type, const QUuid& id, EntityItemPointer ownerEntity) :
|
||||
btActionInterface(),
|
||||
_id(id),
|
||||
EntityActionInterface(type, id),
|
||||
_active(false),
|
||||
_ownerEntity(ownerEntity) {
|
||||
}
|
||||
|
@ -24,15 +24,15 @@ ObjectAction::~ObjectAction() {
|
|||
}
|
||||
|
||||
void ObjectAction::updateAction(btCollisionWorld* collisionWorld, btScalar deltaTimeStep) {
|
||||
if (!_active) {
|
||||
return;
|
||||
}
|
||||
if (_ownerEntity.expired()) {
|
||||
qDebug() << "warning -- action with no entity removing self from btCollisionWorld.";
|
||||
btDynamicsWorld* dynamicsWorld = static_cast<btDynamicsWorld*>(collisionWorld);
|
||||
dynamicsWorld->removeAction(this);
|
||||
return;
|
||||
}
|
||||
if (!_active) {
|
||||
return;
|
||||
}
|
||||
|
||||
updateActionWorker(deltaTimeStep);
|
||||
}
|
||||
|
@ -129,11 +129,3 @@ void ObjectAction::setAngularVelocity(glm::vec3 angularVelocity) {
|
|||
rigidBody->activate();
|
||||
}
|
||||
|
||||
QByteArray ObjectAction::serialize() {
|
||||
assert(false);
|
||||
return QByteArray();
|
||||
}
|
||||
|
||||
void ObjectAction::deserialize(QByteArray serializedArguments) {
|
||||
assert(false);
|
||||
}
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
|
||||
#include <btBulletDynamicsCommon.h>
|
||||
|
||||
#include <EntityItem.h>
|
||||
|
||||
#include "ObjectMotionState.h"
|
||||
#include "BulletUtil.h"
|
||||
#include "EntityActionInterface.h"
|
||||
|
@ -26,31 +24,25 @@
|
|||
|
||||
class ObjectAction : public btActionInterface, public EntityActionInterface {
|
||||
public:
|
||||
ObjectAction(EntityActionType type, QUuid id, EntityItemPointer ownerEntity);
|
||||
ObjectAction(EntityActionType type, const QUuid& id, EntityItemPointer ownerEntity);
|
||||
virtual ~ObjectAction();
|
||||
|
||||
const QUuid& getID() const { return _id; }
|
||||
virtual EntityActionType getType() { assert(false); return ACTION_TYPE_NONE; }
|
||||
virtual void removeFromSimulation(EntitySimulation* simulation) const;
|
||||
virtual EntityItemWeakPointer getOwnerEntity() const { return _ownerEntity; }
|
||||
virtual void setOwnerEntity(const EntityItemPointer ownerEntity) { _ownerEntity = ownerEntity; }
|
||||
|
||||
virtual bool updateArguments(QVariantMap arguments) { return false; }
|
||||
virtual QVariantMap getArguments() { return QVariantMap(); }
|
||||
virtual bool updateArguments(QVariantMap arguments) = 0;
|
||||
virtual QVariantMap getArguments() = 0;
|
||||
|
||||
// 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
|
||||
virtual void updateAction(btCollisionWorld* collisionWorld, btScalar deltaTimeStep);
|
||||
virtual void debugDraw(btIDebugDraw* debugDrawer);
|
||||
|
||||
virtual QByteArray serialize();
|
||||
virtual void deserialize(QByteArray serializedArguments);
|
||||
|
||||
private:
|
||||
QUuid _id;
|
||||
QReadWriteLock _lock;
|
||||
virtual QByteArray serialize() const = 0;
|
||||
virtual void deserialize(QByteArray serializedArguments) = 0;
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -70,6 +62,10 @@ protected:
|
|||
bool tryLockForWrite() { return _lock.tryLockForWrite(); }
|
||||
void unlock() { _lock.unlock(); }
|
||||
|
||||
private:
|
||||
QReadWriteLock _lock;
|
||||
|
||||
protected:
|
||||
bool _active;
|
||||
EntityItemWeakPointer _ownerEntity;
|
||||
};
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
|
||||
const uint16_t ObjectActionOffset::offsetVersion = 1;
|
||||
|
||||
ObjectActionOffset::ObjectActionOffset(EntityActionType type, QUuid id, EntityItemPointer ownerEntity) :
|
||||
ObjectAction(type, id, ownerEntity) {
|
||||
ObjectActionOffset::ObjectActionOffset(const QUuid& id, EntityItemPointer ownerEntity) :
|
||||
ObjectAction(ACTION_TYPE_OFFSET, id, ownerEntity) {
|
||||
#if WANT_DEBUG
|
||||
qDebug() << "ObjectActionOffset::ObjectActionOffset";
|
||||
#endif
|
||||
|
@ -127,7 +127,7 @@ QVariantMap ObjectActionOffset::getArguments() {
|
|||
return arguments;
|
||||
}
|
||||
|
||||
QByteArray ObjectActionOffset::serialize() {
|
||||
QByteArray ObjectActionOffset::serialize() const {
|
||||
QByteArray ba;
|
||||
QDataStream dataStream(&ba, QIODevice::WriteOnly);
|
||||
dataStream << getType();
|
||||
|
@ -146,13 +146,14 @@ void ObjectActionOffset::deserialize(QByteArray serializedArguments) {
|
|||
QDataStream dataStream(serializedArguments);
|
||||
|
||||
EntityActionType type;
|
||||
QUuid id;
|
||||
uint16_t serializationVersion;
|
||||
|
||||
dataStream >> type;
|
||||
assert(type == getType());
|
||||
|
||||
QUuid id;
|
||||
dataStream >> id;
|
||||
assert(id == getID());
|
||||
|
||||
uint16_t serializationVersion;
|
||||
dataStream >> serializationVersion;
|
||||
if (serializationVersion != ObjectActionOffset::offsetVersion) {
|
||||
return;
|
||||
|
|
|
@ -19,17 +19,15 @@
|
|||
|
||||
class ObjectActionOffset : public ObjectAction {
|
||||
public:
|
||||
ObjectActionOffset(EntityActionType type, QUuid id, EntityItemPointer ownerEntity);
|
||||
ObjectActionOffset(const QUuid& id, EntityItemPointer ownerEntity);
|
||||
virtual ~ObjectActionOffset();
|
||||
|
||||
virtual EntityActionType getType() { return ACTION_TYPE_OFFSET; }
|
||||
|
||||
virtual bool updateArguments(QVariantMap arguments);
|
||||
virtual QVariantMap getArguments();
|
||||
|
||||
virtual void updateActionWorker(float deltaTimeStep);
|
||||
|
||||
virtual QByteArray serialize();
|
||||
virtual QByteArray serialize() const;
|
||||
virtual void deserialize(QByteArray serializedArguments);
|
||||
|
||||
private:
|
||||
|
|
|
@ -17,8 +17,8 @@ const float SPRING_MAX_SPEED = 10.0f;
|
|||
|
||||
const uint16_t ObjectActionSpring::springVersion = 1;
|
||||
|
||||
ObjectActionSpring::ObjectActionSpring(EntityActionType type, QUuid id, EntityItemPointer ownerEntity) :
|
||||
ObjectAction(type, id, ownerEntity),
|
||||
ObjectActionSpring::ObjectActionSpring(const QUuid& id, EntityItemPointer ownerEntity) :
|
||||
ObjectAction(ACTION_TYPE_SPRING, id, ownerEntity),
|
||||
_positionalTarget(glm::vec3(0.0f)),
|
||||
_linearTimeScale(0.2f),
|
||||
_positionalTargetSet(false),
|
||||
|
@ -206,7 +206,7 @@ QVariantMap ObjectActionSpring::getArguments() {
|
|||
return arguments;
|
||||
}
|
||||
|
||||
QByteArray ObjectActionSpring::serialize() {
|
||||
QByteArray ObjectActionSpring::serialize() const {
|
||||
QByteArray serializedActionArguments;
|
||||
QDataStream dataStream(&serializedActionArguments, QIODevice::WriteOnly);
|
||||
|
||||
|
@ -229,13 +229,14 @@ void ObjectActionSpring::deserialize(QByteArray serializedArguments) {
|
|||
QDataStream dataStream(serializedArguments);
|
||||
|
||||
EntityActionType type;
|
||||
QUuid id;
|
||||
uint16_t serializationVersion;
|
||||
|
||||
dataStream >> type;
|
||||
assert(type == getType());
|
||||
|
||||
QUuid id;
|
||||
dataStream >> id;
|
||||
assert(id == getID());
|
||||
|
||||
uint16_t serializationVersion;
|
||||
dataStream >> serializationVersion;
|
||||
if (serializationVersion != ObjectActionSpring::springVersion) {
|
||||
return;
|
||||
|
|
|
@ -12,24 +12,19 @@
|
|||
#ifndef hifi_ObjectActionSpring_h
|
||||
#define hifi_ObjectActionSpring_h
|
||||
|
||||
#include <QUuid>
|
||||
|
||||
#include <EntityItem.h>
|
||||
#include "ObjectAction.h"
|
||||
|
||||
class ObjectActionSpring : public ObjectAction {
|
||||
public:
|
||||
ObjectActionSpring(EntityActionType type, QUuid id, EntityItemPointer ownerEntity);
|
||||
ObjectActionSpring(const QUuid& id, EntityItemPointer ownerEntity);
|
||||
virtual ~ObjectActionSpring();
|
||||
|
||||
virtual EntityActionType getType() { return ACTION_TYPE_SPRING; }
|
||||
|
||||
virtual bool updateArguments(QVariantMap arguments);
|
||||
virtual QVariantMap getArguments();
|
||||
|
||||
virtual void updateActionWorker(float deltaTimeStep);
|
||||
|
||||
virtual QByteArray serialize();
|
||||
virtual QByteArray serialize() const;
|
||||
virtual void deserialize(QByteArray serializedArguments);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -21,9 +21,13 @@
|
|||
#include <climits>
|
||||
#include <limits>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include <QBitArray>
|
||||
#include <QByteArray>
|
||||
|
||||
#include "SharedUtil.h"
|
||||
|
||||
#include "NumericalConstants.h"
|
||||
|
||||
template<typename T> class ByteCountCoded {
|
||||
|
@ -37,7 +41,8 @@ public:
|
|||
ByteCountCoded(const QByteArray& fromEncoded) : data(0) { decode(fromEncoded); }
|
||||
|
||||
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; }
|
||||
|
@ -110,52 +115,63 @@ template<typename T> inline QByteArray ByteCountCoded<T>::encode() const {
|
|||
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...
|
||||
QBitArray encodedBits;
|
||||
int bitCount = BITS_IN_BYTE * fromEncodedBytes.count();
|
||||
encodedBits.resize(bitCount);
|
||||
template<typename T> inline size_t ByteCountCoded<T>::decode(const char* encodedBuffer, int encodedSize) {
|
||||
data = 0; // reset data
|
||||
size_t bytesConsumed = 0;
|
||||
int bitCount = BITS_IN_BYTE * encodedSize;
|
||||
|
||||
for(int byte = 0; byte < fromEncodedBytes.count(); byte++) {
|
||||
char originalByte = fromEncodedBytes.at(byte);
|
||||
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 < encodedSize; byte++) {
|
||||
char originalByte = encodedBuffer[byte];
|
||||
bytesConsumed++;
|
||||
unsigned char maskBit = 128; // LEFT MOST BIT set
|
||||
for(int bit = 0; bit < BITS_IN_BYTE; bit++) {
|
||||
int shiftBy = BITS_IN_BYTE - (bit + 1);
|
||||
char maskBit = ( 1 << shiftBy);
|
||||
bool bitValue = originalByte & maskBit;
|
||||
encodedBits.setBit(byte * BITS_IN_BYTE + bit, bitValue);
|
||||
}
|
||||
}
|
||||
bool bitIsSet = originalByte & maskBit;
|
||||
|
||||
// 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)) {
|
||||
// Processing of the lead bits
|
||||
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;
|
||||
}
|
||||
}
|
||||
encodedByteCount++; // always at least one byte
|
||||
int expectedBitCount = encodedByteCount * BITS_IN_BYTE;
|
||||
} else {
|
||||
if (bitAt > lastValueBit) {
|
||||
break;
|
||||
}
|
||||
|
||||
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;
|
||||
if(bitIsSet) {
|
||||
data += bitValue;
|
||||
}
|
||||
bitValue *= 2;
|
||||
}
|
||||
bitAt++;
|
||||
maskBit = maskBit >> 1;
|
||||
}
|
||||
data = value;
|
||||
if (!inLeadBits && bitAt > lastValueBit) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return bytesConsumed;
|
||||
}
|
||||
#endif // hifi_ByteCountCoding_h
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ QVariantList glmToQList(const glm::quat& g) {
|
|||
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]);
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
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();
|
||||
float x = qList[0].toFloat();
|
||||
float y = qList[1].toFloat();
|
||||
|
@ -56,7 +56,7 @@ glm::quat qListToGlmQuat(const QVariant q) {
|
|||
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();
|
||||
returnValue[RED_INDEX] = qList[RED_INDEX].toInt();
|
||||
returnValue[GREEN_INDEX] = qList[GREEN_INDEX].toInt();
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
|
||||
QVariantList glmToQList(const glm::vec3& 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::quat& glmQuat);
|
||||
|
||||
glm::vec3 qListToGlmVec3(const QVariant q);
|
||||
glm::quat qListToGlmQuat(const QVariant q);
|
||||
void qListtoRgbColor(const QVariant q, rgbColor returnValue);
|
||||
glm::vec3 qListToGlmVec3(const QVariant& q);
|
||||
glm::quat qListToGlmQuat(const QVariant& q);
|
||||
void qListtoRgbColor(const QVariant& q, rgbColor& returnValue);
|
||||
|
|
|
@ -229,6 +229,7 @@ QScriptValue collisionToScriptValue(QScriptEngine* engine, const Collision& coll
|
|||
obj.setProperty("idB", quuidToScriptValue(engine, collision.idB));
|
||||
obj.setProperty("penetration", vec3toScriptValue(engine, collision.penetration));
|
||||
obj.setProperty("contactPoint", vec3toScriptValue(engine, collision.contactPoint));
|
||||
obj.setProperty("velocityChange", vec3toScriptValue(engine, collision.velocityChange));
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue