Merge branch 'master' of https://github.com/highfidelity/hifi into temp1

This commit is contained in:
samcake 2015-05-01 12:04:34 -07:00
commit 1448ab21b6
18 changed files with 251 additions and 177 deletions

View file

@ -45,10 +45,11 @@ if (WIN32)
# Caveats: http://stackoverflow.com/questions/2288728/drawbacks-of-using-largeaddressaware-for-32-bit-windows-executables
# TODO: Remove when building 64-bit.
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE")
elseif (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -pedantic")
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-unknown-pragmas")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -fno-strict-aliasing -Wno-unused-parameter -ggdb")
else ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -fno-strict-aliasing -Wno-unused-parameter")
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb")
endif ()
endif(WIN32)
if (NOT MSVC12)

View file

@ -1213,6 +1213,9 @@ PropertiesTool = function(opts) {
data.properties.rotation = Quat.fromPitchYawRollDegrees(rotation.x, rotation.y, rotation.z);
}
Entities.editEntity(selectionManager.selections[0], data.properties);
if (data.properties.name != undefined) {
entityListTool.sendUpdate();
}
}
pushCommandForSelections();
selectionManager._update();

View file

@ -5,17 +5,13 @@ var deltaMouse = {
z: 0
}
var entityProps;
var box, box2, ground;
var baseMoveFactor = .001;
var finalMoveMultiplier;
var avatarEntityDistance;
var camYaw, dv;
var prevPosition;
var newPosition;
var flingVelocity;
var flingMultiplier = 10;
var targetPosition;
var moveUpDown = false;
var savedGravity;
var currentPosition, currentVelocity;
var grabSound = SoundCache.getSound("https://hifi-public.s3.amazonaws.com/eric/sounds/CloseClamp.wav");
var releaseSound = SoundCache.getSound("https://hifi-public.s3.amazonaws.com/eric/sounds/ReleaseClamp.wav");
var DROP_DISTANCE = 5.0;
var DROP_COLOR = {
@ -23,14 +19,9 @@ var DROP_COLOR = {
green: 200,
blue: 200
};
var DROP_WIDTH = 4;
var DROP_WIDTH = 2;
var autoBox = false;
if (autoBox) {
setUpTestObjects();
}
var dropLine = Overlays.addOverlay("line3d", {
start: {
x: 0,
@ -50,104 +41,80 @@ var dropLine = Overlays.addOverlay("line3d", {
function mousePressEvent(event) {
if(!event.isLeftButton){
if (!event.isLeftButton) {
return;
}
}
var pickRay = Camera.computePickRay(event.x, event.y);
var intersection = Entities.findRayIntersection(pickRay);
if (intersection.intersects && intersection.properties.collisionsWillMove) {
grabbedEntity = intersection.entityID;
var props = Entities.getEntityProperties(grabbedEntity)
prevPosition = props.position;
isGrabbing = true;
savedGravity = props.gravity;
Overlays.editOverlay(dropLine, {
targetPosition = props.position;
currentPosition = props.position;
currentVelocity = props.velocity;
updateDropLine(targetPosition);
Audio.playSound(grabSound, {
position: props.position,
volume: 0.4
});
}
}
function updateDropLine(position) {
Overlays.editOverlay(dropLine, {
visible: true,
start: props.position,
end: Vec3.sum(props.position, {
start: position,
end: Vec3.sum(position, {
x: 0,
y: -DROP_DISTANCE,
z: 0
})
});
Entities.editEntity(grabbedEntity, {
gravity: {
x: 0,
y: 0,
z: 0
}
});
//We need to store entity's current gravity, and then disable it while we move
}
})
}
function mouseReleaseEvent() {
if (isGrabbing) {
// flingObject();
Entities.editEntity(grabbedEntity, {
gravity: savedGravity
isGrabbing = false;
Overlays.editOverlay(dropLine, {
visible: false
});
targetPosition = null;
Audio.playSound(grabSound, {
position: entityProps.position,
volume: 0.25
});
}
isGrabbing = false;
Overlays.editOverlay(dropLine, {
visible: false
});
}
function flingObject() {
//calculate velocity to give object base on current and previous position
entityProps = Entities.getEntityProperties(grabbedEntity);
flingVelocity = Vec3.subtract(entityProps.position, prevPosition);
flingVelocity = Vec3.multiply(flingMultiplier, flingVelocity);
Entities.editEntity(grabbedEntity, {
velocity: flingVelocity
});
}
function mouseMoveEvent(event) {
if (isGrabbing) {
entityProps = Entities.getEntityProperties(grabbedEntity);
avatarEntityDistance = Vec3.distance(MyAvatar.position, entityProps.position);
finalMoveMultiplier = baseMoveFactor * Math.pow(avatarEntityDistance, 1.5);
deltaMouse.x = event.x - prevMouse.x;
if (!moveUpDown) {
deltaMouse.z = event.y - prevMouse.y;
deltaMouse.y = 0;
} else {
deltaMouse.y = (event.y - prevMouse.y) * -1;
deltaMouse.z = 0;
}
finalMoveMultiplier = baseMoveFactor * Math.pow(avatarEntityDistance, 1.5);
deltaMouse = Vec3.multiply(deltaMouse, finalMoveMultiplier);
camYaw = Quat.safeEulerAngles(Camera.getOrientation()).y;
dv = Vec3.multiplyQbyV(Quat.fromPitchYawRollDegrees(0, camYaw, 0), deltaMouse);
newPosition = Vec3.sum(entityProps.position, dv);
Entities.editEntity(grabbedEntity, {
position: newPosition
});
Overlays.editOverlay(dropLine, {
start: newPosition,
end: Vec3.sum(newPosition, {
x: 0,
y: -DROP_DISTANCE,
z: 0
})
});
flingVelocity = Vec3.subtract(entityProps.position, prevPosition);
flingVelocity = Vec3.multiply(flingMultiplier, flingVelocity);
Entities.editEntity(grabbedEntity, {
velocity: flingVelocity
});
prevPosition = entityProps.position;
// Update the target position by the amount the mouse moved
var camYaw = Quat.safeEulerAngles(Camera.getOrientation()).y;
var dPosition = Vec3.multiplyQbyV(Quat.fromPitchYawRollDegrees(0, camYaw, 0), deltaMouse);
// Adjust target position for the object by the mouse move
var avatarEntityDistance = Vec3.distance(Camera.getPosition(), currentPosition);
// Scale distance we want to move by the distance from the camera to the grabbed object
// TODO: Correct SCREEN_TO_METERS to be correct for the actual FOV, resolution
var SCREEN_TO_METERS = 0.001;
targetPosition = Vec3.sum(targetPosition, Vec3.multiply(dPosition, avatarEntityDistance * SCREEN_TO_METERS));
}
prevMouse.x = event.x;
prevMouse.y = event.y;
}
function keyReleaseEvent(event) {
if (event.text === "SHIFT") {
moveUpDown = false;
@ -160,69 +127,34 @@ function keyPressEvent(event) {
}
}
function update(deltaTime) {
if (isGrabbing) {
function setUpTestObjects() {
var distance = 4;
box = Entities.addEntity({
type: 'Box',
position: Vec3.sum(MyAvatar.position, Vec3.multiply(distance, Quat.getFront(Camera.getOrientation()))),
dimensions: {
x: .5,
y: .5,
z: .5
},
color: {
red: 200,
green: 50,
blue: 192
},
collisionsWillMove: true,
gravity: {
x: 0,
y: -1,
z: 0
}
});
entityProps = Entities.getEntityProperties(grabbedEntity);
currentPosition = entityProps.position;
currentVelocity = entityProps.velocity;
box2 = Entities.addEntity({
type: 'Box',
position: Vec3.sum(MyAvatar.position, Vec3.multiply(distance + 1, Quat.getFront(Camera.getOrientation()))),
dimensions: {
x: .5,
y: .5,
z: .5
},
color: {
red: 200,
green: 50,
blue: 192
},
collisionsWillMove: true,
gravity: {
x: 0,
y: -1,
z: 0
}
});
ground = Entities.addEntity({
type: 'Box',
position: {
x: MyAvatar.position.x,
y: MyAvatar.position.y - 5,
z: MyAvatar.position.z
},
dimensions: {
x: 100,
y: 2,
z: 100
},
color: {
red: 20,
green: 200,
blue: 50
}
});
var dPosition = Vec3.subtract(targetPosition, currentPosition);
var CLOSE_ENOUGH = 0.001;
if (Vec3.length(dPosition) > CLOSE_ENOUGH) {
// compute current velocity in the direction we want to move
var velocityTowardTarget = Vec3.dot(currentVelocity, Vec3.normalize(dPosition));
// compute the speed we would like to be going toward the target position
var SPRING_RATE = 0.35;
var DAMPING_RATE = 0.55;
var desiredVelocity = Vec3.multiply(dPosition, (1.0 / deltaTime) * SPRING_RATE);
// compute how much we want to add to the existing velocity
var addedVelocity = Vec3.subtract(desiredVelocity, velocityTowardTarget);
var newVelocity = Vec3.sum(currentVelocity, addedVelocity);
// Add Damping
newVelocity = Vec3.subtract(newVelocity, Vec3.multiply(newVelocity, DAMPING_RATE));
// Update entity
Entities.editEntity(grabbedEntity, {
velocity: newVelocity
})
}
updateDropLine(currentPosition);
}
}
Controller.mouseMoveEvent.connect(mouseMoveEvent);
@ -230,3 +162,5 @@ Controller.mousePressEvent.connect(mousePressEvent);
Controller.mouseReleaseEvent.connect(mouseReleaseEvent);
Controller.keyPressEvent.connect(keyPressEvent);
Controller.keyReleaseEvent.connect(keyReleaseEvent);
Script.update.connect(update);

View file

@ -13,7 +13,7 @@
var DESC_STRING = ' ▴';
function loaded() {
entityList = new List('entity-list', { valueNames: ['type', 'url']});
entityList = new List('entity-list', { valueNames: ['name', 'type', 'url']});
entityList.clear();
elEntityTable = document.getElementById("entity-table");
elEntityTableBody = document.getElementById("entity-table-body");
@ -22,6 +22,9 @@
elTeleport = document.getElementById("teleport");
elNoEntitiesMessage = document.getElementById("no-entities");
document.getElementById("entity-name").onclick = function() {
setSortColumn('name');
};
document.getElementById("entity-type").onclick = function() {
setSortColumn('type');
};
@ -56,31 +59,34 @@
}));
}
function addEntity(id, type, url) {
function addEntity(id, name, type, url) {
if (entities[id] === undefined) {
var urlParts = url.split('/');
var filename = urlParts[urlParts.length - 1];
entityList.add([{ id: id, type: type, url: filename }], function(items) {
entityList.add([{ id: id, name: name, type: type, url: filename }], function(items) {
var el = items[0].elm;
var id = items[0]._values.id;
entities[id] = {
id: id,
name: id,
name: name,
el: el,
item: items[0],
};
el.setAttribute('id', 'entity_' + id);
el.setAttribute('title', url);
el.dataset.entityId = id;
el.onclick = onRowClicked;
el.ondblclick = onRowDoubleClicked;
el.innerHTML
});
if (refreshEntityListTimer) {
clearTimeout(refreshEntityListTimer);
}
refreshEntityListTimer = setTimeout(refreshEntityListObject, 50);
} else {
var item = entities[id].item;
item.values({ name: name, url: url });
}
}
@ -90,6 +96,7 @@
}
var elSortOrder = {
name: document.querySelector('#entity-name .sort-order'),
type: document.querySelector('#entity-type .sort-order'),
url: document.querySelector('#entity-url .sort-order'),
}
@ -164,7 +171,7 @@
elNoEntitiesMessage.style.display = "none";
for (var i = 0; i < newEntities.length; i++) {
var id = newEntities[i].id;
addEntity(id, newEntities[i].type, newEntities[i].url);
addEntity(id, newEntities[i].name, newEntities[i].type, newEntities[i].url);
}
updateSelectedEntities(data.selectedIDs);
}
@ -190,6 +197,7 @@
<thead>
<tr>
<th id="entity-type" data-sort="type">Type <span class="sort-order" style="display: inline">&nbsp;&#x25BE;</span></th>
<th id="entity-name" data-sort="type">Name <span class="sort-order" style="display: inline">&nbsp;&#x25BE;</span></th>
<th id="entity-url" data-sort="url">URL <span class="sort-order" style="display: none">&nbsp;&#x25BE;</span></th>
</tr>
</thead>
@ -197,6 +205,7 @@
<tr>
<td class="id" style="display: none">Type</td>
<td class="type">Type</td>
<td class="name">Name</td>
<td class="url"><div class='outer'><div class='inner'>URL</div></div></td>
</tr>
</tbody>

View file

@ -98,6 +98,7 @@
var allSections = [];
var elID = document.getElementById("property-id");
var elType = document.getElementById("property-type");
var elName = document.getElementById("property-name");
var elLocked = document.getElementById("property-locked");
var elVisible = document.getElementById("property-visible");
var elPositionX = document.getElementById("property-pos-x");
@ -262,6 +263,8 @@
enableChildren(document.getElementById("properties-list"), 'input');
}
elName.value = properties.name;
elVisible.checked = properties.visible;
elPositionX.value = properties.position.x.toFixed(2);
@ -395,6 +398,7 @@
}
elLocked.addEventListener('change', createEmitCheckedPropertyUpdateFunction('locked'));
elName.addEventListener('change', createEmitTextPropertyUpdateFunction('name'));
elVisible.addEventListener('change', createEmitCheckedPropertyUpdateFunction('visible'));
var positionChangeFunction = createEmitVec3PropertyUpdateFunction(
@ -590,6 +594,12 @@
<label id="property-id" class="selectable"></label>
</div>
</div>
<div class="property">
<span class="label" style="float: left; margin-right: 6px">Name</span>
<div class="value" style="overflow: hidden;">
<input type="text" id="property-name"></input>
</div>
</div>
<div class="property">
<span class="label">Locked</span>
<span class="value">

View file

@ -301,3 +301,7 @@ input[type="number"]::-webkit-inner-spin-button:hover,
input[type="number"]::-webkit-inner-spin-button:active{
opacity: .8;
}
input#property-name {
width: 100%;
}

View file

@ -31,7 +31,7 @@ EntityListTool = function(opts) {
webView.eventBridge.emitScriptEvent(JSON.stringify(data));
});
function sendUpdate() {
that.sendUpdate = function() {
var entities = [];
var ids = Entities.findEntities(MyAvatar.position, 100);
for (var i = 0; i < ids.length; i++) {
@ -39,6 +39,7 @@ EntityListTool = function(opts) {
var properties = Entities.getEntityProperties(id);
entities.push({
id: id.id,
name: properties.name,
type: properties.type,
url: properties.type == "Model" ? properties.modelURL : "",
});
@ -76,7 +77,7 @@ EntityListTool = function(opts) {
Menu.isOptionChecked(MENU_EASE_ON_FOCUS));
}
} else if (data.type == "refresh") {
sendUpdate();
that.sendUpdate();
} else if (data.type == "teleport") {
if (selectionManager.hasSelection()) {
MyAvatar.position = selectionManager.worldPosition;

63
examples/lotsoBlocks.js Normal file
View file

@ -0,0 +1,63 @@
var NUM_BLOCKS = 200;
var size;
var SPAWN_RANGE = 10;
var boxes = [];
var basePosition, avatarRot;
var isAssignmentScript = false;
if(isAssignmentScript){
basePosition = {x: 8000, y: 8000, z: 8000};
}
else {
avatarRot = Quat.fromPitchYawRollDegrees(0, MyAvatar.bodyYaw, 0.0);
basePosition = Vec3.sum(MyAvatar.position, Vec3.multiply(SPAWN_RANGE * 3, Quat.getFront(avatarRot)));
}
basePosition.y -= SPAWN_RANGE;
var ground = Entities.addEntity({
type: "Model",
modelURL: "https://hifi-public.s3.amazonaws.com/eric/models/woodFloor.fbx",
dimensions: {
x: 100,
y: 2,
z: 100
},
position: basePosition,
shapeType: 'box'
});
basePosition.y += SPAWN_RANGE + 2;
for (var i = 0; i < NUM_BLOCKS; i++) {
size = randFloat(-.2, 0.7);
boxes.push(Entities.addEntity({
type: 'Box',
dimensions: {
x: size,
y: size,
z: size
},
position: {
x: basePosition.x + randFloat(-SPAWN_RANGE, SPAWN_RANGE),
y: basePosition.y - randFloat(-SPAWN_RANGE, SPAWN_RANGE),
z: basePosition.z + randFloat(-SPAWN_RANGE, SPAWN_RANGE)
},
color: {red: Math.random() * 255, green: Math.random() * 255, blue: Math.random() * 255},
collisionsWillMove: true,
gravity: {x: 0, y: 0, z: 0}
}));
}
function cleanup() {
Entities.deleteEntity(ground);
boxes.forEach(function(box){
Entities.deleteEntity(box);
});
}
Script.scriptEnding.connect(cleanup);
function randFloat(low, high) {
return low + Math.random() * ( high - low );
}

View file

@ -35,6 +35,14 @@ void RenderableBoxEntityItem::render(RenderArgs* args) {
glm::vec4 cubeColor(getColor()[RED_INDEX] / MAX_COLOR, getColor()[GREEN_INDEX] / MAX_COLOR,
getColor()[BLUE_INDEX] / MAX_COLOR, getLocalRenderAlpha());
bool highlightSimulationOwnership = false;
if (args->_debugFlags & RenderArgs::RENDER_DEBUG_SIMULATION_OWNERSHIP) {
auto nodeList = DependencyManager::get<NodeList>();
const QUuid& myNodeID = nodeList->getSessionUUID();
highlightSimulationOwnership = (getSimulatorID() == myNodeID);
}
glPushMatrix();
glTranslatef(position.x, position.y, position.z);
glm::vec3 axis = glm::axis(rotation);
@ -43,8 +51,11 @@ void RenderableBoxEntityItem::render(RenderArgs* args) {
glm::vec3 positionToCenter = center - position;
glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z);
glScalef(dimensions.x, dimensions.y, dimensions.z);
DependencyManager::get<DeferredLightingEffect>()->renderSolidCube(1.0f, cubeColor);
if (highlightSimulationOwnership) {
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(1.0f, cubeColor);
} else {
DependencyManager::get<DeferredLightingEffect>()->renderSolidCube(1.0f, cubeColor);
}
glPopMatrix();
glPopMatrix();
};

View file

@ -109,6 +109,33 @@ void RenderableModelEntityItem::remapTextures() {
}
void RenderableModelEntityItem::renderBoundingBox(RenderArgs* args) {
glm::vec3 position = getPosition();
glm::vec3 center = getCenter();
glm::vec3 dimensions = getDimensions();
glm::quat rotation = getRotation();
// float size = glm::length(dimensions) / 2.0f;
const float MAX_COLOR = 255.0f;
glm::vec4 cubeColor(getColor()[RED_INDEX] / MAX_COLOR,
getColor()[GREEN_INDEX] / MAX_COLOR,
getColor()[BLUE_INDEX] / MAX_COLOR,
getLocalRenderAlpha());
glPushMatrix();
glTranslatef(position.x, position.y, position.z);
glm::vec3 axis = glm::axis(rotation);
glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
glPushMatrix();
glm::vec3 positionToCenter = center - position;
glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z);
glScalef(dimensions.x, dimensions.y, dimensions.z);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(1.0f, cubeColor);
glPopMatrix();
glPopMatrix();
}
void RenderableModelEntityItem::render(RenderArgs* args) {
PerformanceTimer perfTimer("RMEIrender");
assert(getType() == EntityTypes::Model);
@ -117,7 +144,6 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
glm::vec3 position = getPosition();
glm::vec3 dimensions = getDimensions();
float size = glm::length(dimensions);
bool highlightSimulationOwnership = false;
if (args->_debugFlags & RenderArgs::RENDER_DEBUG_SIMULATION_OWNERSHIP) {
@ -126,6 +152,7 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
highlightSimulationOwnership = (getSimulatorID() == myNodeID);
}
bool didDraw = false;
if (drawAsModel && !highlightSimulationOwnership) {
remapTextures();
glPushMatrix();
@ -179,34 +206,20 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
if (args && (args->_renderMode == RenderArgs::SHADOW_RENDER_MODE)) {
if (movingOrAnimating) {
_model->renderInScene(alpha, args);
didDraw = true;
}
} else {
_model->renderInScene(alpha, args);
didDraw = true;
}
} else {
// if we couldn't get a model, then just draw a cube
glm::vec4 color(getColor()[RED_INDEX]/255, getColor()[GREEN_INDEX]/255, getColor()[BLUE_INDEX]/255, 1.0f);
glPushMatrix();
glTranslatef(position.x, position.y, position.z);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(size, color);
glPopMatrix();
}
} else {
// if we couldn't get a model, then just draw a cube
glm::vec4 color(getColor()[RED_INDEX]/255, getColor()[GREEN_INDEX]/255, getColor()[BLUE_INDEX]/255, 1.0f);
glPushMatrix();
glTranslatef(position.x, position.y, position.z);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(size, color);
glPopMatrix();
}
}
glPopMatrix();
} else {
glm::vec4 color(getColor()[RED_INDEX]/255, getColor()[GREEN_INDEX]/255, getColor()[BLUE_INDEX]/255, 1.0f);
glPushMatrix();
glTranslatef(position.x, position.y, position.z);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(size, color);
glPopMatrix();
}
if (!didDraw) {
renderBoundingBox(args);
}
}

View file

@ -42,6 +42,7 @@ public:
virtual void somethingChangedNotification() { _needsInitialSimulation = true; }
void renderBoundingBox(RenderArgs* args);
virtual void render(RenderArgs* args);
virtual bool supportsDetailedRayIntersection() const { return true; }
virtual bool findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction,

View file

@ -63,6 +63,7 @@ EntityItem::EntityItem(const EntityItemID& entityItemID) :
_simulatorID(ENTITY_ITEM_DEFAULT_SIMULATOR_ID),
_simulatorIDChangedTime(0),
_marketplaceID(ENTITY_ITEM_DEFAULT_MARKETPLACE_ID),
_name(ENTITY_ITEM_DEFAULT_NAME),
_physicsInfo(NULL),
_dirtyFlags(0),
_element(NULL)
@ -105,6 +106,7 @@ EntityPropertyFlags EntityItem::getEntityProperties(EncodeBitstreamParams& param
requestedProperties += PROP_LOCKED;
requestedProperties += PROP_USER_DATA;
requestedProperties += PROP_MARKETPLACE_ID;
requestedProperties += PROP_NAME;
requestedProperties += PROP_SIMULATOR_ID;
return requestedProperties;
@ -231,6 +233,7 @@ OctreeElement::AppendState EntityItem::appendEntityData(OctreePacketData* packet
APPEND_ENTITY_PROPERTY(PROP_USER_DATA, appendValue, getUserData());
APPEND_ENTITY_PROPERTY(PROP_SIMULATOR_ID, appendValue, getSimulatorID());
APPEND_ENTITY_PROPERTY(PROP_MARKETPLACE_ID, appendValue, getMarketplaceID());
APPEND_ENTITY_PROPERTY(PROP_NAME, appendValue, getName());
appendSubclassData(packetData, params, entityTreeElementExtraEncodeData,
requestedProperties,
@ -528,7 +531,7 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
READ_ENTITY_PROPERTY_SETTER(PROP_DIMENSIONS, glm::vec3, updateDimensionsInDomainUnits);
}
}
READ_ENTITY_PROPERTY_QUAT_SETTER(PROP_ROTATION, updateRotation);
READ_ENTITY_PROPERTY_SETTER(PROP_DENSITY, float, updateDensity);
if (useMeters) {
@ -566,6 +569,8 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
READ_ENTITY_PROPERTY_STRING(PROP_MARKETPLACE_ID, setMarketplaceID);
}
READ_ENTITY_PROPERTY_STRING(PROP_NAME, setName);
bytesRead += readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args, propertyFlags, overwriteLocalData);
////////////////////////////////////
@ -897,6 +902,7 @@ EntityItemProperties EntityItem::getProperties() const {
COPY_ENTITY_PROPERTY_TO_PROPERTIES(userData, getUserData);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(simulatorID, getSimulatorID);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(marketplaceID, getMarketplaceID);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(name, getName);
properties._defaultSettings = false;
@ -928,6 +934,7 @@ bool EntityItem::setProperties(const EntityItemProperties& properties) {
SET_ENTITY_PROPERTY_FROM_PROPERTIES(userData, setUserData);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(simulatorID, setSimulatorID);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(marketplaceID, setMarketplaceID);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(name, setName);
if (somethingChanged) {
somethingChangedNotification(); // notify derived classes that something has changed

View file

@ -229,6 +229,9 @@ public:
float getAngularDamping() const { return _angularDamping; }
void setAngularDamping(float value) { _angularDamping = value; }
QString getName() const { return _name; }
void setName(const QString& value) { _name = value; }
bool getVisible() const { return _visible; }
void setVisible(bool value) { _visible = value; }
bool isVisible() const { return _visible; }
@ -348,6 +351,7 @@ protected:
QUuid _simulatorID; // id of Node which is currently responsible for simulating this Entity
quint64 _simulatorIDChangedTime; // when was _simulatorID last updated?
QString _marketplaceID;
QString _name;
// NOTE: Damping is applied like this: v *= pow(1 - damping, dt)
//

View file

@ -86,6 +86,7 @@ EntityItemProperties::EntityItemProperties() :
CONSTRUCT_PROPERTY(stageAltitude, ZoneEntityItem::DEFAULT_STAGE_ALTITUDE),
CONSTRUCT_PROPERTY(stageDay, ZoneEntityItem::DEFAULT_STAGE_DAY),
CONSTRUCT_PROPERTY(stageHour, ZoneEntityItem::DEFAULT_STAGE_HOUR),
CONSTRUCT_PROPERTY(name, ENTITY_ITEM_DEFAULT_NAME),
_id(UNKNOWN_ENTITY_ID),
_idSet(false),
@ -281,6 +282,7 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
CHECK_PROPERTY_CHANGE(PROP_LOCAL_GRAVITY, localGravity);
CHECK_PROPERTY_CHANGE(PROP_PARTICLE_RADIUS, particleRadius);
CHECK_PROPERTY_CHANGE(PROP_MARKETPLACE_ID, marketplaceID);
CHECK_PROPERTY_CHANGE(PROP_NAME, name);
CHECK_PROPERTY_CHANGE(PROP_KEYLIGHT_COLOR, keyLightColor);
CHECK_PROPERTY_CHANGE(PROP_KEYLIGHT_INTENSITY, keyLightIntensity);
CHECK_PROPERTY_CHANGE(PROP_KEYLIGHT_AMBIENT_INTENSITY, keyLightAmbientIntensity);
@ -361,6 +363,7 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool
COPY_PROPERTY_TO_QSCRIPTVALUE(localGravity);
COPY_PROPERTY_TO_QSCRIPTVALUE(particleRadius);
COPY_PROPERTY_TO_QSCRIPTVALUE(marketplaceID);
COPY_PROPERTY_TO_QSCRIPTVALUE(name);
COPY_PROPERTY_TO_QSCRIPTVALUE_COLOR(keyLightColor);
COPY_PROPERTY_TO_QSCRIPTVALUE(keyLightIntensity);
@ -462,6 +465,7 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object) {
COPY_PROPERTY_FROM_QSCRIPTVALUE_FLOAT(localGravity, setLocalGravity);
COPY_PROPERTY_FROM_QSCRIPTVALUE_FLOAT(particleRadius, setParticleRadius);
COPY_PROPERTY_FROM_QSCRIPTVALUE_STRING(marketplaceID, setMarketplaceID);
COPY_PROPERTY_FROM_QSCRIPTVALUE_STRING(name, setName);
COPY_PROPERTY_FROM_QSCRIPTVALUE_COLOR(keyLightColor, setKeyLightColor);
COPY_PROPERTY_FROM_QSCRIPTVALUE_FLOAT(keyLightIntensity, setKeyLightIntensity);
@ -681,6 +685,7 @@ bool EntityItemProperties::encodeEntityEditPacket(PacketType command, EntityItem
}
APPEND_ENTITY_PROPERTY(PROP_MARKETPLACE_ID, appendValue, properties.getMarketplaceID());
APPEND_ENTITY_PROPERTY(PROP_NAME, appendValue, properties.getName());
}
if (propertyCount > 0) {
int endOfEntityItemData = packetData->getUncompressedByteOffset();
@ -929,6 +934,7 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int
}
READ_ENTITY_PROPERTY_STRING_TO_PROPERTIES(PROP_MARKETPLACE_ID, setMarketplaceID);
READ_ENTITY_PROPERTY_STRING_TO_PROPERTIES(PROP_NAME, setName);
return valid;
}
@ -978,6 +984,7 @@ void EntityItemProperties::markAllChanged() {
_registrationPointChanged = true;
_angularVelocityChanged = true;
_angularDampingChanged = true;
_nameChanged = true;
_visibleChanged = true;
_colorChanged = true;
_modelURLChanged = true;

View file

@ -97,6 +97,7 @@ enum EntityPropertyList {
PROP_MARKETPLACE_ID,
PROP_ACCELERATION,
PROP_SIMULATOR_ID,
PROP_NAME,
////////////////////////////////////////////////////////////////////////////////////////////////////
// ATTENTION: add new properties ABOVE this line
@ -239,6 +240,7 @@ public:
DEFINE_PROPERTY(PROP_STAGE_ALTITUDE, StageAltitude, stageAltitude, float);
DEFINE_PROPERTY(PROP_STAGE_DAY, StageDay, stageDay, quint16);
DEFINE_PROPERTY(PROP_STAGE_HOUR, StageHour, stageHour, float);
DEFINE_PROPERTY_REF(PROP_NAME, Name, name, QString);
public:
@ -331,6 +333,7 @@ inline QDebug operator<<(QDebug debug, const EntityItemProperties& properties) {
DEBUG_PROPERTY_IF_CHANGED(debug, properties, Dimensions, dimensions, "in meters");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, Velocity, velocity, "in meters");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, Name, name, "");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, Visible, visible, "");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, Rotation, rotation, "");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, Density, density, "");

View file

@ -55,4 +55,6 @@ const float ENTITY_ITEM_DEFAULT_ANGULAR_DAMPING = 0.39347f; // approx timescale
const bool ENTITY_ITEM_DEFAULT_IGNORE_FOR_COLLISIONS = false;
const bool ENTITY_ITEM_DEFAULT_COLLISIONS_WILL_MOVE = false;
const QString ENTITY_ITEM_DEFAULT_NAME = QString("");
#endif // hifi_EntityItemPropertiesDefaults_h

View file

@ -74,7 +74,7 @@ PacketVersion versionForPacketType(PacketType type) {
return 1;
case PacketTypeEntityAddOrEdit:
case PacketTypeEntityData:
return VERSION_ENTITIES_ZONE_ENTITIES_HAVE_DYNAMIC_SHAPE;
return VERSION_ENTITIES_HAVE_NAMES;
case PacketTypeEntityErase:
return 2;
case PacketTypeAudioStreamStats:

View file

@ -139,5 +139,6 @@ const PacketVersion VERSION_ENTITIES_HAVE_ACCELERATION = 15;
const PacketVersion VERSION_ENTITIES_HAVE_UUIDS = 16;
const PacketVersion VERSION_ENTITIES_ZONE_ENTITIES_EXIST = 17;
const PacketVersion VERSION_ENTITIES_ZONE_ENTITIES_HAVE_DYNAMIC_SHAPE = 18;
const PacketVersion VERSION_ENTITIES_HAVE_NAMES = 19;
#endif // hifi_PacketHeaders_h