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

This commit is contained in:
Roxanne Skelly 2019-01-08 10:50:45 -08:00
commit 910c359443
36 changed files with 637 additions and 397 deletions

View file

@ -14,6 +14,7 @@ link_hifi_libraries(
audio avatars octree gpu graphics shaders fbx hfm entities
networking animation recording shared script-engine embedded-webserver
controllers physics plugins midi image
model-networking ktx shaders
)
add_dependencies(${TARGET_NAME} oven)

View file

@ -23,6 +23,7 @@
#include <EntityEditFilters.h>
#include <NetworkingConstants.h>
#include <AddressManager.h>
#include <hfm/ModelFormatRegistry.h>
#include "../AssignmentDynamicFactory.h"
#include "AssignmentParentFinder.h"
@ -45,6 +46,8 @@ EntityServer::EntityServer(ReceivedMessage& message) :
DependencyManager::registerInheritance<EntityDynamicFactoryInterface, AssignmentDynamicFactory>();
DependencyManager::set<AssignmentDynamicFactory>();
DependencyManager::set<ModelFormatRegistry>(); // ModelFormatRegistry must be defined before ModelCache. See the ModelCache ctor
DependencyManager::set<ModelCache>();
auto& packetReceiver = DependencyManager::get<NodeList>()->getPacketReceiver();
packetReceiver.registerListenerForTypes({ PacketType::EntityAdd,

View file

@ -279,7 +279,7 @@ bool RenderableModelEntityItem::findDetailedParabolaIntersection(const glm::vec3
face, surfaceNormal, extraInfo, precisionPicking, false);
}
void RenderableModelEntityItem::getCollisionGeometryResource() {
void RenderableModelEntityItem::fetchCollisionGeometryResource() {
QUrl hullURL(getCollisionShapeURL());
QUrlQuery queryArgs(hullURL);
queryArgs.addQueryItem("collision-hull", "");
@ -289,7 +289,7 @@ void RenderableModelEntityItem::getCollisionGeometryResource() {
bool RenderableModelEntityItem::computeShapeFailedToLoad() {
if (!_compoundShapeResource) {
getCollisionGeometryResource();
fetchCollisionGeometryResource();
}
return (_compoundShapeResource && _compoundShapeResource->isFailed());
@ -300,7 +300,7 @@ void RenderableModelEntityItem::setShapeType(ShapeType type) {
auto shapeType = getShapeType();
if (shapeType == SHAPE_TYPE_COMPOUND || shapeType == SHAPE_TYPE_SIMPLE_COMPOUND) {
if (!_compoundShapeResource && !getCollisionShapeURL().isEmpty()) {
getCollisionGeometryResource();
fetchCollisionGeometryResource();
}
} else if (_compoundShapeResource && !getCompoundShapeURL().isEmpty()) {
// the compoundURL has been set but the shapeType does not agree
@ -317,7 +317,7 @@ void RenderableModelEntityItem::setCompoundShapeURL(const QString& url) {
ModelEntityItem::setCompoundShapeURL(url);
if (getCompoundShapeURL() != currentCompoundShapeURL || !getModel()) {
if (getShapeType() == SHAPE_TYPE_COMPOUND) {
getCollisionGeometryResource();
fetchCollisionGeometryResource();
}
}
}
@ -340,7 +340,7 @@ bool RenderableModelEntityItem::isReadyToComputeShape() const {
if (model->isLoaded()) {
if (!shapeURL.isEmpty() && !_compoundShapeResource) {
const_cast<RenderableModelEntityItem*>(this)->getCollisionGeometryResource();
const_cast<RenderableModelEntityItem*>(this)->fetchCollisionGeometryResource();
}
if (_compoundShapeResource && _compoundShapeResource->isLoaded()) {
@ -367,8 +367,6 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& shapeInfo) {
const uint32_t QUAD_STRIDE = 4;
ShapeType type = getShapeType();
glm::vec3 dimensions = getScaledDimensions();
auto model = getModel();
if (type == SHAPE_TYPE_COMPOUND) {
updateModelBounds();
@ -450,6 +448,11 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& shapeInfo) {
// to the visual model and apply them to the collision model (without regard for the
// collision model's extents).
auto model = getModel();
// assert we never fall in here when model not fully loaded
assert(model && model->isLoaded());
glm::vec3 dimensions = getScaledDimensions();
glm::vec3 scaleToFit = dimensions / model->getHFMModel().getUnscaledMeshExtents().size();
// multiply each point by scale before handing the point-set off to the physics engine.
// also determine the extents of the collision model.
@ -461,11 +464,12 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& shapeInfo) {
}
}
shapeInfo.setParams(type, dimensions, getCompoundShapeURL());
adjustShapeInfoByRegistration(shapeInfo);
} else if (type >= SHAPE_TYPE_SIMPLE_HULL && type <= SHAPE_TYPE_STATIC_MESH) {
// TODO: assert we never fall in here when model not fully loaded
// assert(_model && _model->isLoaded());
updateModelBounds();
auto model = getModel();
// assert we never fall in here when model not fully loaded
assert(model && model->isLoaded());
model->updateGeometry();
// compute meshPart local transforms
@ -473,6 +477,7 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& shapeInfo) {
const HFMModel& hfmModel = model->getHFMModel();
int numHFMMeshes = hfmModel.meshes.size();
int totalNumVertices = 0;
glm::vec3 dimensions = getScaledDimensions();
glm::mat4 invRegistraionOffset = glm::translate(dimensions * (getRegistrationPoint() - ENTITY_ITEM_DEFAULT_REGISTRATION_POINT));
for (int i = 0; i < numHFMMeshes; i++) {
const HFMMesh& mesh = hfmModel.meshes.at(i);
@ -695,12 +700,10 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& shapeInfo) {
}
shapeInfo.setParams(type, 0.5f * dimensions, getModelURL());
adjustShapeInfoByRegistration(shapeInfo);
} else {
ModelEntityItem::computeShapeInfo(shapeInfo);
shapeInfo.setParams(type, 0.5f * dimensions);
EntityItem::computeShapeInfo(shapeInfo);
}
// finally apply the registration offset to the shapeInfo
adjustShapeInfoByRegistration(shapeInfo);
}
void RenderableModelEntityItem::setJointMap(std::vector<int> jointMap) {
@ -726,7 +729,9 @@ int RenderableModelEntityItem::avatarJointIndex(int modelJointIndex) {
bool RenderableModelEntityItem::contains(const glm::vec3& point) const {
auto model = getModel();
if (EntityItem::contains(point) && model && _compoundShapeResource && _compoundShapeResource->isLoaded()) {
return _compoundShapeResource->getHFMModel().convexHullContains(worldToEntity(point));
glm::mat4 worldToHFMMatrix = model->getWorldToHFMMatrix();
glm::vec3 hfmPoint = worldToHFMMatrix * glm::vec4(point, 1.0f);
return _compoundShapeResource->getHFMModel().convexHullContains(hfmPoint);
}
return false;

View file

@ -122,7 +122,7 @@ private:
void autoResizeJointArrays();
void copyAnimationJointDataToModel();
bool readyToAnimate() const;
void getCollisionGeometryResource();
void fetchCollisionGeometryResource();
GeometryResource::Pointer _compoundShapeResource;
std::vector<int> _jointMap;
@ -179,7 +179,6 @@ private:
bool _hasModel { false };
ModelPointer _model;
GeometryResource::Pointer _compoundShapeResource;
QString _lastTextures;
bool _texturesLoaded { false };
int _lastKnownCurrentFrame { -1 };

View file

@ -546,22 +546,3 @@ void ZoneEntityRenderer::setProceduralUserData(const QString& userData) {
}
}
#if 0
bool RenderableZoneEntityItem::contains(const glm::vec3& point) const {
if (getShapeType() != SHAPE_TYPE_COMPOUND) {
return EntityItem::contains(point);
}
const_cast<RenderableZoneEntityItem*>(this)->updateGeometry();
if (_model && _model->isActive() && EntityItem::contains(point)) {
return _model->convexHullContains(point);
}
return false;
}
void RenderableZoneEntityItem::notifyBoundChanged() {
notifyChangedRenderItem();
}
#endif

View file

@ -6,4 +6,4 @@ include_hifi_library_headers(fbx)
include_hifi_library_headers(gpu)
include_hifi_library_headers(image)
include_hifi_library_headers(ktx)
link_hifi_libraries(shared shaders networking octree avatars graphics model-networking)
link_hifi_libraries(shared shaders networking octree avatars graphics model-networking)

View file

@ -20,6 +20,7 @@
#include <QtNetwork/QNetworkRequest>
#include <glm/gtx/transform.hpp>
#include <glm/gtx/component_wise.hpp>
#include <BufferParser.h>
#include <ByteCountCoding.h>
@ -1679,15 +1680,57 @@ void EntityItem::adjustShapeInfoByRegistration(ShapeInfo& info) const {
}
bool EntityItem::contains(const glm::vec3& point) const {
if (getShapeType() == SHAPE_TYPE_COMPOUND) {
bool success;
bool result = getAABox(success).contains(point);
return result && success;
} else {
ShapeInfo info;
info.setParams(getShapeType(), glm::vec3(0.5f));
adjustShapeInfoByRegistration(info);
return info.contains(worldToEntity(point));
ShapeType shapeType = getShapeType();
if (shapeType == SHAPE_TYPE_SPHERE) {
// SPHERE case is special:
// anything with shapeType == SPHERE must collide as a bounding sphere in the world-frame regardless of dimensions
// therefore we must do math using an unscaled localPoint relative to sphere center
glm::vec3 dimensions = getScaledDimensions();
glm::vec3 localPoint = point - (getWorldPosition() + getWorldOrientation() * (dimensions * (ENTITY_ITEM_DEFAULT_REGISTRATION_POINT - getRegistrationPoint())));
const float HALF_SQUARED = 0.25f;
return glm::length2(localPoint) < HALF_SQUARED * glm::length2(dimensions);
}
// we transform into the "normalized entity-frame" where the bounding box is centered on the origin
// and has dimensions <1,1,1>
glm::vec3 localPoint = glm::vec3(glm::inverse(getEntityToWorldMatrix()) * glm::vec4(point, 1.0f));
const float NORMALIZED_HALF_SIDE = 0.5f;
const float NORMALIZED_RADIUS_SQUARED = NORMALIZED_HALF_SIDE * NORMALIZED_HALF_SIDE;
switch(shapeType) {
case SHAPE_TYPE_NONE:
return false;
case SHAPE_TYPE_CAPSULE_X:
case SHAPE_TYPE_CAPSULE_Y:
case SHAPE_TYPE_CAPSULE_Z:
case SHAPE_TYPE_HULL:
case SHAPE_TYPE_PLANE:
case SHAPE_TYPE_COMPOUND:
case SHAPE_TYPE_SIMPLE_HULL:
case SHAPE_TYPE_SIMPLE_COMPOUND:
case SHAPE_TYPE_STATIC_MESH:
case SHAPE_TYPE_CIRCLE:
// the above cases not yet supported --> fall through to BOX case
case SHAPE_TYPE_BOX: {
localPoint = glm::abs(localPoint);
return glm::any(glm::lessThanEqual(localPoint, glm::vec3(NORMALIZED_HALF_SIDE)));
}
case SHAPE_TYPE_ELLIPSOID: {
// since we've transformed into the normalized space this is just a sphere-point intersection test
return glm::length2(localPoint) <= NORMALIZED_RADIUS_SQUARED;
}
case SHAPE_TYPE_CYLINDER_X:
return fabsf(localPoint.x) <= NORMALIZED_HALF_SIDE &&
localPoint.y * localPoint.y + localPoint.z * localPoint.z <= NORMALIZED_RADIUS_SQUARED;
case SHAPE_TYPE_CYLINDER_Y:
return fabsf(localPoint.y) <= NORMALIZED_HALF_SIDE &&
localPoint.z * localPoint.z + localPoint.x * localPoint.x <= NORMALIZED_RADIUS_SQUARED;
case SHAPE_TYPE_CYLINDER_Z:
return fabsf(localPoint.z) <= NORMALIZED_HALF_SIDE &&
localPoint.x * localPoint.x + localPoint.y * localPoint.y <= NORMALIZED_RADIUS_SQUARED;
default:
return false;
}
}
@ -1704,7 +1747,8 @@ float EntityItem::getVolumeEstimate() const {
void EntityItem::setRegistrationPoint(const glm::vec3& value) {
if (value != _registrationPoint) {
withWriteLock([&] {
_registrationPoint = glm::clamp(value, 0.0f, 1.0f);
_registrationPoint = glm::clamp(value, glm::vec3(ENTITY_ITEM_MIN_REGISTRATION_POINT),
glm::vec3(ENTITY_ITEM_MAX_REGISTRATION_POINT));
});
dimensionsChanged(); // Registration Point affects the bounding box
markDirtyFlags(Simulation::DIRTY_SHAPE);
@ -1869,7 +1913,7 @@ void EntityItem::setVelocity(const glm::vec3& value) {
}
void EntityItem::setDamping(float value) {
auto clampedDamping = glm::clamp(value, 0.0f, 1.0f);
auto clampedDamping = glm::clamp(value, ENTITY_ITEM_MIN_DAMPING, ENTITY_ITEM_MAX_DAMPING);
withWriteLock([&] {
if (_damping != clampedDamping) {
_damping = clampedDamping;
@ -1924,7 +1968,7 @@ void EntityItem::setAngularVelocity(const glm::vec3& value) {
}
void EntityItem::setAngularDamping(float value) {
auto clampedDamping = glm::clamp(value, 0.0f, 1.0f);
auto clampedDamping = glm::clamp(value, ENTITY_ITEM_MIN_DAMPING, ENTITY_ITEM_MAX_DAMPING);
withWriteLock([&] {
if (_angularDamping != clampedDamping) {
_angularDamping = clampedDamping;

View file

@ -113,6 +113,7 @@ void buildStringToShapeTypeLookup() {
addShapeType(SHAPE_TYPE_SIMPLE_HULL);
addShapeType(SHAPE_TYPE_SIMPLE_COMPOUND);
addShapeType(SHAPE_TYPE_STATIC_MESH);
addShapeType(SHAPE_TYPE_ELLIPSOID);
}
QHash<QString, MaterialMappingMode> stringToMaterialMappingModeLookup;
@ -2254,8 +2255,6 @@ void EntityItemPropertiesFromScriptValueHonorReadOnly(const QScriptValue &object
QScriptValue EntityPropertyFlagsToScriptValue(QScriptEngine* engine, const EntityPropertyFlags& flags) {
return EntityItemProperties::entityPropertyFlagsToScriptValue(engine, flags);
QScriptValue result = engine->newObject();
return result;
}
void EntityPropertyFlagsFromScriptValue(const QScriptValue& object, EntityPropertyFlags& flags) {
@ -2268,10 +2267,29 @@ QScriptValue EntityItemProperties::entityPropertyFlagsToScriptValue(QScriptEngin
return result;
}
static QHash<QString, EntityPropertyList> _propertyStringsToEnums;
void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue& object, EntityPropertyFlags& flags) {
if (object.isString()) {
EntityPropertyInfo propertyInfo;
if (getPropertyInfo(object.toString(), propertyInfo)) {
flags << propertyInfo.propertyEnum;
}
}
else if (object.isArray()) {
quint32 length = object.property("length").toInt32();
for (quint32 i = 0; i < length; i++) {
QString propertyName = object.property(i).toString();
EntityPropertyInfo propertyInfo;
if (getPropertyInfo(propertyName, propertyInfo)) {
flags << propertyInfo.propertyEnum;
}
}
}
}
static QHash<QString, EntityPropertyInfo> _propertyInfos;
static QHash<EntityPropertyList, QString> _enumsToPropertyStrings;
void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue& object, EntityPropertyFlags& flags) {
bool EntityItemProperties::getPropertyInfo(const QString& propertyName, EntityPropertyInfo& propertyInfo) {
static std::once_flag initMap;
@ -2285,9 +2303,10 @@ void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue
ADD_PROPERTY_TO_MAP(PROP_HREF, Href, href, QString);
ADD_PROPERTY_TO_MAP(PROP_DESCRIPTION, Description, description, QString);
ADD_PROPERTY_TO_MAP(PROP_POSITION, Position, position, vec3);
ADD_PROPERTY_TO_MAP(PROP_DIMENSIONS, Dimensions, dimensions, vec3);
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_DIMENSIONS, Dimensions, dimensions, vec3, ENTITY_ITEM_MIN_DIMENSION, FLT_MAX);
ADD_PROPERTY_TO_MAP(PROP_ROTATION, Rotation, rotation, quat);
ADD_PROPERTY_TO_MAP(PROP_REGISTRATION_POINT, RegistrationPoint, registrationPoint, vec3);
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_REGISTRATION_POINT, RegistrationPoint, registrationPoint, vec3,
ENTITY_ITEM_MIN_REGISTRATION_POINT, ENTITY_ITEM_MAX_REGISTRATION_POINT);
ADD_PROPERTY_TO_MAP(PROP_CREATED, Created, created, quint64);
ADD_PROPERTY_TO_MAP(PROP_LAST_EDITED_BY, LastEditedBy, lastEditedBy, QUuid);
ADD_PROPERTY_TO_MAP(PROP_ENTITY_HOST_TYPE, EntityHostType, entityHostType, entity::HostType);
@ -2321,15 +2340,20 @@ void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue
}
// Physics
ADD_PROPERTY_TO_MAP(PROP_DENSITY, Density, density, float);
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_DENSITY, Density, density, float,
ENTITY_ITEM_MIN_DENSITY, ENTITY_ITEM_MAX_DENSITY);
ADD_PROPERTY_TO_MAP(PROP_VELOCITY, Velocity, velocity, vec3);
ADD_PROPERTY_TO_MAP(PROP_ANGULAR_VELOCITY, AngularVelocity, angularVelocity, vec3);
ADD_PROPERTY_TO_MAP(PROP_GRAVITY, Gravity, gravity, vec3);
ADD_PROPERTY_TO_MAP(PROP_ACCELERATION, Acceleration, acceleration, vec3);
ADD_PROPERTY_TO_MAP(PROP_DAMPING, Damping, damping, float);
ADD_PROPERTY_TO_MAP(PROP_ANGULAR_DAMPING, AngularDamping, angularDamping, float);
ADD_PROPERTY_TO_MAP(PROP_RESTITUTION, Restitution, restitution, float);
ADD_PROPERTY_TO_MAP(PROP_FRICTION, Friction, friction, float);
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_DAMPING, Damping, damping, float,
ENTITY_ITEM_MIN_DAMPING, ENTITY_ITEM_MAX_DAMPING);
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_ANGULAR_DAMPING, AngularDamping, angularDamping, float,
ENTITY_ITEM_MIN_DAMPING, ENTITY_ITEM_MAX_DAMPING);
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_RESTITUTION, Restitution, restitution, float,
ENTITY_ITEM_MIN_RESTITUTION, ENTITY_ITEM_MAX_RESTITUTION);
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_FRICTION, Friction, friction, float,
ENTITY_ITEM_MIN_FRICTION, ENTITY_ITEM_MAX_FRICTION);
ADD_PROPERTY_TO_MAP(PROP_LIFETIME, Lifetime, lifetime, float);
ADD_PROPERTY_TO_MAP(PROP_COLLISIONLESS, Collisionless, collisionless, bool);
ADD_PROPERTY_TO_MAP(PROP_COLLISIONLESS, unused, ignoreForCollisions, unused); // legacy support
@ -2371,46 +2395,71 @@ void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue
ADD_PROPERTY_TO_MAP(PROP_LOCAL_ROTATION, LocalRotation, localRotation, quat);
ADD_PROPERTY_TO_MAP(PROP_LOCAL_VELOCITY, LocalVelocity, localVelocity, vec3);
ADD_PROPERTY_TO_MAP(PROP_LOCAL_ANGULAR_VELOCITY, LocalAngularVelocity, localAngularVelocity, vec3);
ADD_PROPERTY_TO_MAP(PROP_LOCAL_DIMENSIONS, LocalDimensions, localDimensions, vec3);
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_LOCAL_DIMENSIONS, LocalDimensions, localDimensions, vec3,
ENTITY_ITEM_MIN_DIMENSION, FLT_MAX);
// Common
ADD_PROPERTY_TO_MAP(PROP_SHAPE_TYPE, ShapeType, shapeType, ShapeType);
ADD_PROPERTY_TO_MAP(PROP_COMPOUND_SHAPE_URL, CompoundShapeURL, compoundShapeURL, QString);
ADD_PROPERTY_TO_MAP(PROP_COLOR, Color, color, u8vec3Color);
ADD_PROPERTY_TO_MAP(PROP_ALPHA, Alpha, alpha, float);
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_ALPHA, Alpha, alpha, float, particle::MINIMUM_ALPHA, particle::MAXIMUM_ALPHA);
ADD_PROPERTY_TO_MAP(PROP_TEXTURES, Textures, textures, QString);
// Particles
ADD_PROPERTY_TO_MAP(PROP_MAX_PARTICLES, MaxParticles, maxParticles, quint32);
ADD_PROPERTY_TO_MAP(PROP_LIFESPAN, Lifespan, lifespan, float);
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_MAX_PARTICLES, MaxParticles, maxParticles, quint32,
particle::MINIMUM_MAX_PARTICLES, particle::MAXIMUM_MAX_PARTICLES);
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_LIFESPAN, Lifespan, lifespan, float,
particle::MINIMUM_LIFESPAN, particle::MAXIMUM_LIFESPAN);
ADD_PROPERTY_TO_MAP(PROP_EMITTING_PARTICLES, IsEmitting, isEmitting, bool);
ADD_PROPERTY_TO_MAP(PROP_EMIT_RATE, EmitRate, emitRate, float);
ADD_PROPERTY_TO_MAP(PROP_EMIT_SPEED, EmitSpeed, emitSpeed, vec3);
ADD_PROPERTY_TO_MAP(PROP_SPEED_SPREAD, SpeedSpread, speedSpread, vec3);
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_EMIT_RATE, EmitRate, emitRate, float,
particle::MINIMUM_EMIT_RATE, particle::MAXIMUM_EMIT_RATE);
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_EMIT_SPEED, EmitSpeed, emitSpeed, vec3,
particle::MINIMUM_EMIT_SPEED, particle::MAXIMUM_EMIT_SPEED);
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_SPEED_SPREAD, SpeedSpread, speedSpread, vec3,
particle::MINIMUM_EMIT_SPEED, particle::MAXIMUM_EMIT_SPEED);
ADD_PROPERTY_TO_MAP(PROP_EMIT_ORIENTATION, EmitOrientation, emitOrientation, quat);
ADD_PROPERTY_TO_MAP(PROP_EMIT_DIMENSIONS, EmitDimensions, emitDimensions, vec3);
ADD_PROPERTY_TO_MAP(PROP_EMIT_RADIUS_START, EmitRadiusStart, emitRadiusStart, float);
ADD_PROPERTY_TO_MAP(PROP_POLAR_START, EmitPolarStart, polarStart, float);
ADD_PROPERTY_TO_MAP(PROP_POLAR_FINISH, EmitPolarFinish, polarFinish, float);
ADD_PROPERTY_TO_MAP(PROP_AZIMUTH_START, EmitAzimuthStart, azimuthStart, float);
ADD_PROPERTY_TO_MAP(PROP_AZIMUTH_FINISH, EmitAzimuthFinish, azimuthFinish, float);
ADD_PROPERTY_TO_MAP(PROP_EMIT_ACCELERATION, EmitAcceleration, emitAcceleration, vec3);
ADD_PROPERTY_TO_MAP(PROP_ACCELERATION_SPREAD, AccelerationSpread, accelerationSpread, vec3);
ADD_PROPERTY_TO_MAP(PROP_PARTICLE_RADIUS, ParticleRadius, particleRadius, float);
ADD_PROPERTY_TO_MAP(PROP_RADIUS_SPREAD, RadiusSpread, radiusSpread, float);
ADD_PROPERTY_TO_MAP(PROP_RADIUS_START, RadiusStart, radiusStart, float);
ADD_PROPERTY_TO_MAP(PROP_RADIUS_FINISH, RadiusFinish, radiusFinish, float);
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_EMIT_DIMENSIONS, EmitDimensions, emitDimensions, vec3,
particle::MINIMUM_EMIT_DIMENSION, particle::MAXIMUM_EMIT_DIMENSION);
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_EMIT_RADIUS_START, EmitRadiusStart, emitRadiusStart, float,
particle::MINIMUM_EMIT_RADIUS_START, particle::MAXIMUM_EMIT_RADIUS_START);
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_POLAR_START, EmitPolarStart, polarStart, float,
particle::MINIMUM_POLAR, particle::MAXIMUM_POLAR);
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_POLAR_FINISH, EmitPolarFinish, polarFinish, float,
particle::MINIMUM_POLAR, particle::MAXIMUM_POLAR);
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_AZIMUTH_START, EmitAzimuthStart, azimuthStart, float,
particle::MINIMUM_AZIMUTH, particle::MAXIMUM_AZIMUTH);
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_AZIMUTH_FINISH, EmitAzimuthFinish, azimuthFinish, float,
particle::MINIMUM_AZIMUTH, particle::MAXIMUM_AZIMUTH);
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_EMIT_ACCELERATION, EmitAcceleration, emitAcceleration, vec3,
particle::MINIMUM_EMIT_ACCELERATION, particle::MAXIMUM_EMIT_ACCELERATION);
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_ACCELERATION_SPREAD, AccelerationSpread, accelerationSpread, vec3,
particle::MINIMUM_ACCELERATION_SPREAD, particle::MAXIMUM_ACCELERATION_SPREAD);
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_PARTICLE_RADIUS, ParticleRadius, particleRadius, float,
particle::MINIMUM_PARTICLE_RADIUS, particle::MAXIMUM_PARTICLE_RADIUS);
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_RADIUS_SPREAD, RadiusSpread, radiusSpread, float,
particle::MINIMUM_PARTICLE_RADIUS, particle::MAXIMUM_PARTICLE_RADIUS);
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_RADIUS_START, RadiusStart, radiusStart, float,
particle::MINIMUM_PARTICLE_RADIUS, particle::MAXIMUM_PARTICLE_RADIUS);
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_RADIUS_FINISH, RadiusFinish, radiusFinish, float,
particle::MINIMUM_PARTICLE_RADIUS, particle::MAXIMUM_PARTICLE_RADIUS);
ADD_PROPERTY_TO_MAP(PROP_COLOR_SPREAD, ColorSpread, colorSpread, u8vec3Color);
ADD_PROPERTY_TO_MAP(PROP_COLOR_START, ColorStart, colorStart, vec3Color);
ADD_PROPERTY_TO_MAP(PROP_COLOR_FINISH, ColorFinish, colorFinish, vec3Color);
ADD_PROPERTY_TO_MAP(PROP_ALPHA_SPREAD, AlphaSpread, alphaSpread, float);
ADD_PROPERTY_TO_MAP(PROP_ALPHA_START, AlphaStart, alphaStart, float);
ADD_PROPERTY_TO_MAP(PROP_ALPHA_FINISH, AlphaFinish, alphaFinish, float);
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_ALPHA_SPREAD, AlphaSpread, alphaSpread, float,
particle::MINIMUM_ALPHA, particle::MAXIMUM_ALPHA);
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_ALPHA_START, AlphaStart, alphaStart, float,
particle::MINIMUM_ALPHA, particle::MAXIMUM_ALPHA);
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_ALPHA_FINISH, AlphaFinish, alphaFinish, float,
particle::MINIMUM_ALPHA, particle::MAXIMUM_ALPHA);
ADD_PROPERTY_TO_MAP(PROP_EMITTER_SHOULD_TRAIL, EmitterShouldTrail, emitterShouldTrail, bool);
ADD_PROPERTY_TO_MAP(PROP_PARTICLE_SPIN, ParticleSpin, particleSpin, float);
ADD_PROPERTY_TO_MAP(PROP_SPIN_SPREAD, SpinSpread, spinSpread, float);
ADD_PROPERTY_TO_MAP(PROP_SPIN_START, SpinStart, spinStart, float);
ADD_PROPERTY_TO_MAP(PROP_SPIN_FINISH, SpinFinish, spinFinish, float);
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_PARTICLE_SPIN, ParticleSpin, particleSpin, float,
particle::MINIMUM_PARTICLE_SPIN, particle::MAXIMUM_PARTICLE_SPIN);
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_SPIN_SPREAD, SpinSpread, spinSpread, float,
particle::MINIMUM_PARTICLE_SPIN, particle::MAXIMUM_PARTICLE_SPIN);
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_SPIN_START, SpinStart, spinStart, float,
particle::MINIMUM_PARTICLE_SPIN, particle::MAXIMUM_PARTICLE_SPIN);
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_SPIN_FINISH, SpinFinish, spinFinish, float,
particle::MINIMUM_PARTICLE_SPIN, particle::MAXIMUM_PARTICLE_SPIN);
ADD_PROPERTY_TO_MAP(PROP_PARTICLE_ROTATE_WITH_ENTITY, RotateWithEntity, rotateWithEntity, float);
// Model
@ -2436,7 +2485,8 @@ void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue
ADD_PROPERTY_TO_MAP(PROP_IS_SPOTLIGHT, IsSpotlight, isSpotlight, bool);
ADD_PROPERTY_TO_MAP(PROP_INTENSITY, Intensity, intensity, float);
ADD_PROPERTY_TO_MAP(PROP_EXPONENT, Exponent, exponent, float);
ADD_PROPERTY_TO_MAP(PROP_CUTOFF, Cutoff, cutoff, float);
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_CUTOFF, Cutoff, cutoff, float,
LightEntityItem::MIN_CUTOFF, LightEntityItem::MAX_CUTOFF);
ADD_PROPERTY_TO_MAP(PROP_FALLOFF_RADIUS, FalloffRadius, falloffRadius, float);
// Text
@ -2551,20 +2601,27 @@ void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue
ADD_PROPERTY_TO_MAP(PROP_MINOR_GRID_EVERY, MinorGridEvery, minorGridEvery, float);
});
if (object.isString()) {
auto enumIter = _propertyStringsToEnums.find(object.toString());
if (enumIter != _propertyStringsToEnums.end()) {
flags << enumIter.value();
}
} else if (object.isArray()) {
quint32 length = object.property("length").toInt32();
for (quint32 i = 0; i < length; i++) {
auto enumIter = _propertyStringsToEnums.find(object.property(i).toString());
if (enumIter != _propertyStringsToEnums.end()) {
flags << enumIter.value();
}
}
auto iter = _propertyInfos.find(propertyName);
if (iter != _propertyInfos.end()) {
propertyInfo = *iter;
return true;
}
return false;
}
QScriptValue EntityPropertyInfoToScriptValue(QScriptEngine* engine, const EntityPropertyInfo& propertyInfo) {
QScriptValue obj = engine->newObject();
obj.setProperty("propertyEnum", propertyInfo.propertyEnum);
obj.setProperty("minimum", propertyInfo.minimum.toString());
obj.setProperty("maximum", propertyInfo.maximum.toString());
return obj;
}
void EntityPropertyInfoFromScriptValue(const QScriptValue& object, EntityPropertyInfo& propertyInfo) {
propertyInfo.propertyEnum = (EntityPropertyList)object.property("propertyEnum").toVariant().toUInt();
propertyInfo.minimum = object.property("minimum").toVariant();
propertyInfo.maximum = object.property("maximum").toVariant();
}
// TODO: Implement support for edit packets that can span an MTU sized buffer. We need to implement a mechanism for the

View file

@ -64,6 +64,17 @@ const std::array<ComponentPair, COMPONENT_MODE_ITEM_COUNT> COMPONENT_MODES = { {
using vec3Color = glm::vec3;
using u8vec3Color = glm::u8vec3;
struct EntityPropertyInfo {
EntityPropertyInfo(EntityPropertyList propEnum) :
propertyEnum(propEnum) {}
EntityPropertyInfo(EntityPropertyList propEnum, QVariant min, QVariant max) :
propertyEnum(propEnum), minimum(min), maximum(max) {}
EntityPropertyInfo() = default;
EntityPropertyList propertyEnum;
QVariant minimum;
QVariant maximum;
};
/// A collection of properties of an entity item used in the scripting API. Translates between the actual properties of an
/// entity and a JavaScript style hash/QScriptValue storing a set of properties. Used in scripting to set/get the complete
/// set of entity item properties via JavaScript hashes/QScriptValues
@ -102,6 +113,8 @@ public:
static QScriptValue entityPropertyFlagsToScriptValue(QScriptEngine* engine, const EntityPropertyFlags& flags);
static void entityPropertyFlagsFromScriptValue(const QScriptValue& object, EntityPropertyFlags& flags);
static bool getPropertyInfo(const QString& propertyName, EntityPropertyInfo& propertyInfo);
// editing related features supported by all entities
quint64 getLastEdited() const { return _lastEdited; }
float getEditedAgo() const /// Elapsed seconds since this entity was last edited
@ -478,6 +491,9 @@ Q_DECLARE_METATYPE(EntityPropertyFlags);
QScriptValue EntityPropertyFlagsToScriptValue(QScriptEngine* engine, const EntityPropertyFlags& flags);
void EntityPropertyFlagsFromScriptValue(const QScriptValue& object, EntityPropertyFlags& flags);
Q_DECLARE_METATYPE(EntityPropertyInfo);
QScriptValue EntityPropertyInfoToScriptValue(QScriptEngine* engine, const EntityPropertyInfo& propertyInfo);
void EntityPropertyInfoFromScriptValue(const QScriptValue& object, EntityPropertyInfo& propertyInfo);
// define these inline here so the macros work
inline void EntityItemProperties::setPosition(const glm::vec3& value)

View file

@ -52,6 +52,9 @@ const QString ENTITY_ITEM_DEFAULT_SCRIPT = QString("");
const quint64 ENTITY_ITEM_DEFAULT_SCRIPT_TIMESTAMP = 0;
const QString ENTITY_ITEM_DEFAULT_SERVER_SCRIPTS = QString("");
const QString ENTITY_ITEM_DEFAULT_COLLISION_SOUND_URL = QString("");
const float ENTITY_ITEM_MIN_REGISTRATION_POINT = 0.0f;
const float ENTITY_ITEM_MAX_REGISTRATION_POINT = 1.0f;
const glm::vec3 ENTITY_ITEM_DEFAULT_REGISTRATION_POINT = ENTITY_ITEM_HALF_VEC3; // center
const float ENTITY_ITEM_IMMORTAL_LIFETIME = -1.0f; /// special lifetime which means the entity lives for ever
@ -74,6 +77,8 @@ const glm::vec3 ENTITY_ITEM_DEFAULT_VELOCITY = ENTITY_ITEM_ZERO_VEC3;
const glm::vec3 ENTITY_ITEM_DEFAULT_ANGULAR_VELOCITY = ENTITY_ITEM_ZERO_VEC3;
const glm::vec3 ENTITY_ITEM_DEFAULT_GRAVITY = ENTITY_ITEM_ZERO_VEC3;
const glm::vec3 ENTITY_ITEM_DEFAULT_ACCELERATION = ENTITY_ITEM_ZERO_VEC3;
const float ENTITY_ITEM_MIN_DAMPING = 0.0f;
const float ENTITY_ITEM_MAX_DAMPING = 1.0f;
const float ENTITY_ITEM_DEFAULT_DAMPING = 0.39347f; // approx timescale = 2.0 sec (see damping timescale formula in header)
const float ENTITY_ITEM_DEFAULT_ANGULAR_DAMPING = 0.39347f; // approx timescale = 2.0 sec (see damping timescale formula in header)

View file

@ -401,12 +401,32 @@ inline QRect QRect_convertFromScriptValue(const QScriptValue& v, bool& isValid)
static T _static##N;
#define ADD_PROPERTY_TO_MAP(P, N, n, T) \
_propertyStringsToEnums[#n] = P; \
_enumsToPropertyStrings[P] = #n;
{ \
EntityPropertyInfo propertyInfo = EntityPropertyInfo(P); \
_propertyInfos[#n] = propertyInfo; \
_enumsToPropertyStrings[P] = #n; \
}
#define ADD_PROPERTY_TO_MAP_WITH_RANGE(P, N, n, T, M, X) \
{ \
EntityPropertyInfo propertyInfo = EntityPropertyInfo(P, M, X); \
_propertyInfos[#n] = propertyInfo; \
_enumsToPropertyStrings[P] = #n; \
}
#define ADD_GROUP_PROPERTY_TO_MAP(P, G, g, N, n) \
_propertyStringsToEnums[#g "." #n] = P; \
_enumsToPropertyStrings[P] = #g "." #n;
{ \
EntityPropertyInfo propertyInfo = EntityPropertyInfo(P); \
_propertyInfos[#g "." #n] = propertyInfo; \
_enumsToPropertyStrings[P] = #g "." #n; \
}
#define ADD_GROUP_PROPERTY_TO_MAP_WITH_RANGE(P, G, g, N, n, M, X) \
{ \
EntityPropertyInfo propertyInfo = EntityPropertyInfo(P, M, X); \
_propertyInfos[#g "." #n] = propertyInfo; \
_enumsToPropertyStrings[P] = #g "." #n; \
}
#define DEFINE_CORE(N, n, T, V) \
public: \

View file

@ -2266,6 +2266,12 @@ bool EntityScriptingInterface::verifyStaticCertificateProperties(const QUuid& en
return result;
}
const EntityPropertyInfo EntityScriptingInterface::getPropertyInfo(const QString& propertyName) const {
EntityPropertyInfo propertyInfo;
EntityItemProperties::getPropertyInfo(propertyName, propertyInfo);
return propertyInfo;
}
glm::vec3 EntityScriptingInterface::worldToLocalPosition(glm::vec3 worldPosition, const QUuid& parentID,
int parentJointIndex, bool scalesWithParent) {
bool success;

View file

@ -1695,6 +1695,16 @@ public slots:
*/
Q_INVOKABLE bool verifyStaticCertificateProperties(const QUuid& entityID);
/**jsdoc
* Get information about entity properties including a minimum to maximum range for numerical properties
* as well as property enum value.
* @function Entities.getPropertyInfo
* @param {string} propertyName - The name of the property to get the information for.
* @returns {Entities.EntityPropertyInfo} The information data including propertyEnum, minimum, and maximum
* if the property can be found, otherwise an empty object.
*/
Q_INVOKABLE const EntityPropertyInfo getPropertyInfo(const QString& propertyName) const;
signals:
/**jsdoc
* Triggered on the client that is the physics simulation owner during the collision of two entities. Note: Isn't triggered

View file

@ -25,6 +25,8 @@ const bool LightEntityItem::DEFAULT_IS_SPOTLIGHT = false;
const float LightEntityItem::DEFAULT_INTENSITY = 1.0f;
const float LightEntityItem::DEFAULT_FALLOFF_RADIUS = 0.1f;
const float LightEntityItem::DEFAULT_EXPONENT = 0.0f;
const float LightEntityItem::MIN_CUTOFF = 0.0f;
const float LightEntityItem::MAX_CUTOFF = 90.0f;
const float LightEntityItem::DEFAULT_CUTOFF = PI / 2.0f;
bool LightEntityItem::_lightsArePickable = false;
@ -115,7 +117,7 @@ void LightEntityItem::setIsSpotlight(bool value) {
}
void LightEntityItem::setCutoff(float value) {
value = glm::clamp(value, 0.0f, 90.0f);
value = glm::clamp(value, MIN_CUTOFF, MAX_CUTOFF);
if (value == getCutoff()) {
return;
}

View file

@ -20,6 +20,8 @@ public:
static const float DEFAULT_INTENSITY;
static const float DEFAULT_FALLOFF_RADIUS;
static const float DEFAULT_EXPONENT;
static const float MIN_CUTOFF;
static const float MAX_CUTOFF;
static const float DEFAULT_CUTOFF;
static EntityItemPointer factory(const EntityItemID& entityID, const EntityItemProperties& properties);

View file

@ -11,7 +11,9 @@
#include "ZoneEntityItem.h"
#include <glm/gtx/transform.hpp>
#include <QDebug>
#include <QUrlQuery>
#include <ByteCountCoding.h>
@ -275,22 +277,52 @@ void ZoneEntityItem::debugDump() const {
_bloomProperties.debugDump();
}
ShapeType ZoneEntityItem::getShapeType() const {
// Zones are not allowed to have a SHAPE_TYPE_NONE... they are always at least a SHAPE_TYPE_BOX
if (_shapeType == SHAPE_TYPE_COMPOUND) {
return hasCompoundShapeURL() ? SHAPE_TYPE_COMPOUND : DEFAULT_SHAPE_TYPE;
void ZoneEntityItem::setShapeType(ShapeType type) {
ShapeType oldShapeType = _shapeType;
switch(type) {
case SHAPE_TYPE_NONE:
case SHAPE_TYPE_CAPSULE_X:
case SHAPE_TYPE_CAPSULE_Y:
case SHAPE_TYPE_CAPSULE_Z:
case SHAPE_TYPE_HULL:
case SHAPE_TYPE_PLANE:
case SHAPE_TYPE_SIMPLE_HULL:
case SHAPE_TYPE_SIMPLE_COMPOUND:
case SHAPE_TYPE_STATIC_MESH:
case SHAPE_TYPE_CIRCLE:
// these types are unsupported for ZoneEntity
type = DEFAULT_SHAPE_TYPE;
break;
default:
break;
}
_shapeType = type;
if (type == SHAPE_TYPE_COMPOUND) {
if (type != oldShapeType) {
fetchCollisionGeometryResource();
}
} else {
return _shapeType == SHAPE_TYPE_NONE ? DEFAULT_SHAPE_TYPE : _shapeType;
_shapeResource.reset();
}
}
ShapeType ZoneEntityItem::getShapeType() const {
return _shapeType;
}
void ZoneEntityItem::setCompoundShapeURL(const QString& url) {
QString oldCompoundShapeURL = _compoundShapeURL;
withWriteLock([&] {
_compoundShapeURL = url;
if (_compoundShapeURL.isEmpty() && _shapeType == SHAPE_TYPE_COMPOUND) {
_shapeType = DEFAULT_SHAPE_TYPE;
}
});
if (oldCompoundShapeURL != url) {
if (_shapeType == SHAPE_TYPE_COMPOUND) {
fetchCollisionGeometryResource();
} else {
_shapeResource.reset();
}
}
}
bool ZoneEntityItem::findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
@ -307,6 +339,27 @@ bool ZoneEntityItem::findDetailedParabolaIntersection(const glm::vec3& origin, c
return _zonesArePickable;
}
bool ZoneEntityItem::contains(const glm::vec3& point) const {
GeometryResource::Pointer resource = _shapeResource;
if (_shapeType == SHAPE_TYPE_COMPOUND && resource) {
if (resource->isLoaded()) {
const HFMModel& hfmModel = resource->getHFMModel();
Extents meshExtents = hfmModel.getMeshExtents();
glm::vec3 meshExtentsDiagonal = meshExtents.maximum - meshExtents.minimum;
glm::vec3 offset = -meshExtents.minimum- (meshExtentsDiagonal * getRegistrationPoint());
glm::vec3 scale(getScaledDimensions() / meshExtentsDiagonal);
glm::mat4 hfmToEntityMatrix = glm::scale(scale) * glm::translate(offset);
glm::mat4 entityToWorldMatrix = getTransform().getMatrix();
glm::mat4 worldToHFMMatrix = glm::inverse(entityToWorldMatrix * hfmToEntityMatrix);
return hfmModel.convexHullContains(glm::vec3(worldToHFMMatrix * glm::vec4(point, 1.0f)));
}
}
return EntityItem::contains(point);
}
void ZoneEntityItem::setFilterURL(QString url) {
withWriteLock([&] {
_filterURL = url;
@ -326,10 +379,6 @@ QString ZoneEntityItem::getFilterURL() const {
return result;
}
bool ZoneEntityItem::hasCompoundShapeURL() const {
return !getCompoundShapeURL().isEmpty();
}
QString ZoneEntityItem::getCompoundShapeURL() const {
QString result;
withReadLock([&] {
@ -403,3 +452,15 @@ void ZoneEntityItem::setSkyboxMode(const uint32_t value) {
uint32_t ZoneEntityItem::getSkyboxMode() const {
return _skyboxMode;
}
void ZoneEntityItem::fetchCollisionGeometryResource() {
QUrl hullURL(getCompoundShapeURL());
if (hullURL.isEmpty()) {
_shapeResource.reset();
} else {
QUrlQuery queryArgs(hullURL);
queryArgs.addQueryItem("collision-hull", "");
hullURL.setQuery(queryArgs);
_shapeResource = DependencyManager::get<ModelCache>()->getCollisionGeometryResource(hullURL);
}
}

View file

@ -12,6 +12,9 @@
#ifndef hifi_ZoneEntityItem_h
#define hifi_ZoneEntityItem_h
#include <ComponentMode.h>
#include <model-networking/ModelCache.h>
#include "KeyLightPropertyGroup.h"
#include "AmbientLightPropertyGroup.h"
#include "EntityItem.h"
@ -19,7 +22,6 @@
#include "SkyboxPropertyGroup.h"
#include "HazePropertyGroup.h"
#include "BloomPropertyGroup.h"
#include <ComponentMode.h>
class ZoneEntityItem : public EntityItem {
public:
@ -58,10 +60,9 @@ public:
static void setDrawZoneBoundaries(bool value) { _drawZoneBoundaries = value; }
virtual bool isReadyToComputeShape() const override { return false; }
void setShapeType(ShapeType type) override { withWriteLock([&] { _shapeType = type; }); }
virtual void setShapeType(ShapeType type) override;
virtual ShapeType getShapeType() const override;
virtual bool hasCompoundShapeURL() const;
QString getCompoundShapeURL() const;
virtual void setCompoundShapeURL(const QString& url);
@ -115,6 +116,8 @@ public:
BoxFace& face, glm::vec3& surfaceNormal,
QVariantMap& extraInfo, bool precisionPicking) const override;
bool contains(const glm::vec3& point) const override;
virtual void debugDump() const override;
static const ShapeType DEFAULT_SHAPE_TYPE;
@ -156,6 +159,10 @@ protected:
static bool _drawZoneBoundaries;
static bool _zonesArePickable;
void fetchCollisionGeometryResource();
GeometryResource::Pointer _shapeResource;
};
#endif // hifi_ZoneEntityItem_h

View file

@ -189,20 +189,17 @@ bool HFMModel::hasBlendedMeshes() const {
}
Extents HFMModel::getUnscaledMeshExtents() const {
const Extents& extents = meshExtents;
// even though our caller asked for "unscaled" we need to include any fst scaling, translation, and rotation, which
// is captured in the offset matrix
glm::vec3 minimum = glm::vec3(offset * glm::vec4(extents.minimum, 1.0f));
glm::vec3 maximum = glm::vec3(offset * glm::vec4(extents.maximum, 1.0f));
glm::vec3 minimum = glm::vec3(offset * glm::vec4(meshExtents.minimum, 1.0f));
glm::vec3 maximum = glm::vec3(offset * glm::vec4(meshExtents.maximum, 1.0f));
Extents scaledExtents = { minimum, maximum };
return scaledExtents;
}
// TODO: Move to graphics::Mesh when Sam's ready
bool HFMModel::convexHullContains(const glm::vec3& point) const {
if (!getUnscaledMeshExtents().containsPoint(point)) {
if (!meshExtents.containsPoint(point)) {
return false;
}

View file

@ -310,6 +310,7 @@ public:
/// Returns the unscaled extents of the model's mesh
Extents getUnscaledMeshExtents() const;
const Extents& getMeshExtents() const { return meshExtents; }
bool convexHullContains(const glm::vec3& point) const;

View file

@ -1,11 +1,16 @@
set(TARGET_NAME physics)
setup_hifi_library()
link_hifi_libraries(shared task workload fbx entities graphics)
link_hifi_libraries(shared task workload fbx entities graphics shaders)
include_hifi_library_headers(networking)
include_hifi_library_headers(gpu)
include_hifi_library_headers(avatars)
include_hifi_library_headers(audio)
include_hifi_library_headers(octree)
include_hifi_library_headers(animation)
include_hifi_library_headers(model-networking)
include_hifi_library_headers(image)
include_hifi_library_headers(ktx)
include_hifi_library_headers(gpu)
include_hifi_library_headers(hfm)
target_bullet()

View file

@ -91,7 +91,6 @@ EntityMotionState::EntityMotionState(btCollisionShape* shape, EntityItemPointer
_serverRotation = localTransform.getRotation();
_serverAcceleration = _entity->getAcceleration();
_serverActionData = _entity->getDynamicData();
}
EntityMotionState::~EntityMotionState() {

View file

@ -614,58 +614,11 @@ bool Model::findParabolaIntersectionAgainstSubMeshes(const glm::vec3& origin, co
return intersectedSomething;
}
bool Model::convexHullContains(glm::vec3 point) {
// if we aren't active, we can't compute that yet...
if (!isActive()) {
return false;
}
// extents is the entity relative, scaled, centered extents of the entity
glm::vec3 position = _translation;
glm::mat4 rotation = glm::mat4_cast(_rotation);
glm::mat4 translation = glm::translate(position);
glm::mat4 modelToWorldMatrix = translation * rotation;
glm::mat4 worldToModelMatrix = glm::inverse(modelToWorldMatrix);
Extents modelExtents = getMeshExtents(); // NOTE: unrotated
glm::vec3 dimensions = modelExtents.maximum - modelExtents.minimum;
glm::vec3 corner = -(dimensions * _registrationPoint);
AABox modelFrameBox(corner, dimensions);
glm::vec3 modelFramePoint = glm::vec3(worldToModelMatrix * glm::vec4(point, 1.0f));
// we can use the AABox's contains() by mapping our point into the model frame
// and testing there.
if (modelFrameBox.contains(modelFramePoint)){
QMutexLocker locker(&_mutex);
if (!_triangleSetsValid) {
calculateTriangleSets(getHFMModel());
}
// If we are inside the models box, then consider the submeshes...
glm::mat4 meshToModelMatrix = glm::scale(_scale) * glm::translate(_offset);
glm::mat4 meshToWorldMatrix = createMatFromQuatAndPos(_rotation, _translation) * meshToModelMatrix;
glm::mat4 worldToMeshMatrix = glm::inverse(meshToWorldMatrix);
glm::vec3 meshFramePoint = glm::vec3(worldToMeshMatrix * glm::vec4(point, 1.0f));
for (auto& meshTriangleSets : _modelSpaceMeshTriangleSets) {
for (auto &partTriangleSet : meshTriangleSets) {
const AABox& box = partTriangleSet.getBounds();
if (box.contains(meshFramePoint)) {
if (partTriangleSet.convexHullContains(meshFramePoint)) {
// It's inside this mesh, return true.
return true;
}
}
}
}
}
// It wasn't in any mesh, return false.
return false;
glm::mat4 Model::getWorldToHFMMatrix() const {
glm::mat4 hfmToModelMatrix = glm::scale(_scale) * glm::translate(_offset);
glm::mat4 modelToWorldMatrix = createMatFromQuatAndPos(_rotation, _translation);
glm::mat4 worldToHFMMatrix = glm::inverse(modelToWorldMatrix * hfmToModelMatrix);
return worldToHFMMatrix;
}
// TODO: deprecate and remove

View file

@ -192,7 +192,7 @@ public:
bool didVisualGeometryRequestFail() const { return _visualGeometryRequestFailed; }
bool didCollisionGeometryRequestFail() const { return _collisionGeometryRequestFailed; }
bool convexHullContains(glm::vec3 point);
glm::mat4 getWorldToHFMMatrix() const;
QStringList getJointNames() const;

View file

@ -670,6 +670,7 @@ void ScriptEngine::init() {
qScriptRegisterMetaType(this, EntityPropertyFlagsToScriptValue, EntityPropertyFlagsFromScriptValue);
qScriptRegisterMetaType(this, EntityItemPropertiesToScriptValue, EntityItemPropertiesFromScriptValueHonorReadOnly);
qScriptRegisterMetaType(this, EntityPropertyInfoToScriptValue, EntityPropertyInfoFromScriptValue);
qScriptRegisterMetaType(this, EntityItemIDtoScriptValue, EntityItemIDfromScriptValue);
qScriptRegisterMetaType(this, RayToEntityIntersectionResultToScriptValue, RayToEntityIntersectionResultFromScriptValue);
qScriptRegisterMetaType(this, RayToAvatarIntersectionResultToScriptValue, RayToAvatarIntersectionResultFromScriptValue);

View file

@ -58,7 +58,8 @@ const char* shapeTypeNames[] = {
"compound",
"simple-hull",
"simple-compound",
"static-mesh"
"static-mesh",
"ellipsoid"
};
static const size_t SHAPETYPE_NAME_COUNT = (sizeof(shapeTypeNames) / sizeof((shapeTypeNames)[0]));
@ -250,50 +251,6 @@ float ShapeInfo::computeVolume() const {
return volume;
}
bool ShapeInfo::contains(const glm::vec3& point) const {
switch(_type) {
case SHAPE_TYPE_SPHERE:
return glm::length(point) <= _halfExtents.x;
case SHAPE_TYPE_CYLINDER_X:
return glm::length(glm::vec2(point.y, point.z)) <= _halfExtents.z;
case SHAPE_TYPE_CYLINDER_Y:
return glm::length(glm::vec2(point.x, point.z)) <= _halfExtents.x;
case SHAPE_TYPE_CYLINDER_Z:
return glm::length(glm::vec2(point.x, point.y)) <= _halfExtents.y;
case SHAPE_TYPE_CAPSULE_X: {
if (glm::abs(point.x) <= _halfExtents.x - _halfExtents.y) {
return glm::length(glm::vec2(point.y, point.z)) <= _halfExtents.y;
} else {
glm::vec3 absPoint = glm::abs(point) - glm::vec3(_halfExtents.x, 0.0f, 0.0f);
return glm::length(absPoint) <= _halfExtents.y;
}
}
case SHAPE_TYPE_CAPSULE_Y: {
if (glm::abs(point.y) <= _halfExtents.y - _halfExtents.z) {
return glm::length(glm::vec2(point.x, point.z)) <= _halfExtents.z;
} else {
glm::vec3 absPoint = glm::abs(point) - glm::vec3(0.0f, _halfExtents.y, 0.0f);
return glm::length(absPoint) <= _halfExtents.z;
}
}
case SHAPE_TYPE_CAPSULE_Z: {
if (glm::abs(point.z) <= _halfExtents.z - _halfExtents.x) {
return glm::length(glm::vec2(point.x, point.y)) <= _halfExtents.x;
} else {
glm::vec3 absPoint = glm::abs(point) - glm::vec3(0.0f, 0.0f, _halfExtents.z);
return glm::length(absPoint) <= _halfExtents.x;
}
}
case SHAPE_TYPE_BOX:
default: {
glm::vec3 absPoint = glm::abs(point);
return absPoint.x <= _halfExtents.x
&& absPoint.y <= _halfExtents.y
&& absPoint.z <= _halfExtents.z;
}
}
}
const HashKey& ShapeInfo::getHash() const {
// NOTE: we cache the key so we only ever need to compute it once for any valid ShapeInfo instance.
if (_hashKey.isNull() && _type != SHAPE_TYPE_NONE) {

View file

@ -86,10 +86,6 @@ public:
float computeVolume() const;
/// Returns whether point is inside the shape
/// For compound shapes it will only return whether it is inside the bounding box
bool contains(const glm::vec3& point) const;
const HashKey& getHash() const;
protected:

View file

@ -17,9 +17,6 @@
"lineHeight": {
"tooltip": "The height of each line of text. This determines the size of the text."
},
"faceCamera": {
"tooltip": "If enabled, the entity follows the camera of each user, creating a billboard effect."
},
"textBillboardMode": {
"tooltip": "If enabled, determines how the entity will face the camera.",
"jsPropertyName": "billboardMode"
@ -356,6 +353,15 @@
"materialMappingRot": {
"tooltip": "How much to rotate the material within the parent's UV-space, in degrees."
},
"followCamera": {
"tooltip": "If enabled, the grid is always visible even as the camera moves to another position."
},
"majorGridEvery": {
"tooltip": "The number of \"Minor Grid Every\" intervals at which to draw a thick grid line."
},
"minorGridEvery": {
"tooltip": "The real number of meters at which to draw thin grid lines."
},
"id": {
"tooltip": "The unique identifier of this entity."
},

View file

@ -372,6 +372,7 @@ const DEFAULT_ENTITY_PROPERTIES = {
blue: 179
},
},
shapeType: "box",
bloomMode: "inherit"
},
Model: {
@ -421,7 +422,6 @@ const DEFAULT_ENTITY_PROPERTIES = {
emitterShouldTrail: true,
particleRadius: 0.25,
radiusStart: 0,
radiusFinish: 0.1,
radiusSpread: 0,
particleColor: {
red: 255,
@ -435,7 +435,6 @@ const DEFAULT_ENTITY_PROPERTIES = {
},
alpha: 0,
alphaStart: 1,
alphaFinish: 0,
alphaSpread: 0,
emitAcceleration: {
x: 0,
@ -448,12 +447,10 @@ const DEFAULT_ENTITY_PROPERTIES = {
z: 0
},
particleSpin: 0,
spinStart: 0,
spinFinish: 0,
spinSpread: 0,
rotateWithEntity: false,
polarStart: 0,
polarFinish: 0,
polarFinish: Math.PI,
azimuthStart: -Math.PI,
azimuthFinish: Math.PI
},
@ -2479,6 +2476,15 @@ var PropertiesTool = function (opts) {
tooltips: Script.require('./assets/data/createAppTooltips.json'),
hmdActive: HMD.active,
});
} else if (data.type === "propertyRangeRequest") {
var propertyRanges = {};
data.properties.forEach(function (property) {
propertyRanges[property] = Entities.getPropertyInfo(property);
});
emitScriptEvent({
type: 'propertyRangeReply',
propertyRanges: propertyRanges,
});
}
};

View file

@ -19,6 +19,7 @@
<script type="text/javascript" src="js/listView.js"></script>
<script type="text/javascript" src="js/entityListContextMenu.js"></script>
<script type="text/javascript" src="js/utils.js"></script>
<script type="text/javascript" src="js/includes.js"></script>
<script type="text/javascript" src="js/entityList.js"></script>
</head>
<body onload='loaded();' id="entity-list-body">

View file

@ -24,6 +24,7 @@
<script type="text/javascript" src="js/createAppTooltip.js"></script>
<script type="text/javascript" src="js/draggableNumber.js"></script>
<script type="text/javascript" src="js/utils.js"></script>
<script type="text/javascript" src="js/includes.js"></script>
<script type="text/javascript" src="js/entityProperties.js"></script>
<script src="js/jsoneditor.min.js"></script>
</head>

View file

@ -106,7 +106,7 @@ DraggableNumber.prototype = {
stepUp: function() {
if (!this.isDisabled()) {
this.elInput.stepUp();
this.elInput.value = parseFloat(this.elInput.value) + this.step;
this.inputChange();
if (this.valueChangeFunction) {
this.valueChangeFunction();
@ -116,7 +116,7 @@ DraggableNumber.prototype = {
stepDown: function() {
if (!this.isDisabled()) {
this.elInput.stepDown();
this.elInput.value = parseFloat(this.elInput.value) - this.step;
this.inputChange();
if (this.valueChangeFunction) {
this.valueChangeFunction();
@ -139,7 +139,14 @@ DraggableNumber.prototype = {
},
inputChange: function() {
this.setValue(this.elInput.value);
let value = this.elInput.value;
if (this.max !== undefined) {
value = Math.min(this.max, value);
}
if (this.min !== undefined) {
value = Math.max(this.min, value);
}
this.setValue(value);
},
inputBlur: function(ev) {
@ -156,6 +163,17 @@ DraggableNumber.prototype = {
return this.elText.getAttribute("disabled") === "disabled";
},
updateMinMax: function(min, max) {
this.min = min;
this.max = max;
if (this.min !== undefined) {
this.elInput.setAttribute("min", this.min);
}
if (this.max !== undefined) {
this.elInput.setAttribute("max", this.max);
}
},
initialize: function() {
this.onMouseDown = this.mouseDown.bind(this);
this.onMouseUp = this.mouseUp.bind(this);
@ -189,12 +207,7 @@ DraggableNumber.prototype = {
this.elInput = document.createElement('input');
this.elInput.className = "input";
this.elInput.setAttribute("type", "number");
if (this.min !== undefined) {
this.elInput.setAttribute("min", this.min);
}
if (this.max !== undefined) {
this.elInput.setAttribute("max", this.max);
}
this.updateMinMax(this.min, this.max);
if (this.step !== undefined) {
this.elInput.setAttribute("step", this.step);
}

View file

@ -153,22 +153,9 @@ const FILTER_TYPES = [
"PolyLine",
"PolyVox",
"Text",
"Grid",
];
const ICON_FOR_TYPE = {
Shape: "n",
Model: "&#xe008;",
Image: "&#xe02a;",
Light: "p",
Zone: "o",
Web: "q",
Material: "&#xe00b;",
ParticleEffect: "&#xe004;",
PolyLine: "&#xe01b;",
PolyVox: "&#xe005;",
Text: "l",
};
const DOUBLE_CLICK_TIMEOUT = 300; // ms
const RENAME_COOLDOWN = 400; // ms
@ -325,7 +312,7 @@ function loaded() {
let elSpan = document.createElement('span');
elSpan.setAttribute("class", "typeIcon");
elSpan.innerHTML = ICON_FOR_TYPE[type];
elSpan.innerHTML = ENTITY_TYPE_ICON[type];
elLabel.insertBefore(elSpan, elLabel.childNodes[0]);

View file

@ -9,23 +9,6 @@
/* global alert, augmentSpinButtons, clearTimeout, console, document, Element,
EventBridge, JSONEditor, openEventBridge, setTimeout, window, _ $ */
const ICON_FOR_TYPE = {
Box: "V",
Sphere: "n",
Shape: "n",
ParticleEffect: "&#xe004;",
Model: "&#xe008;",
Web: "q",
Image: "&#xe02a;",
Text: "l",
Light: "p",
Zone: "o",
PolyVox: "&#xe005;",
Multiple: "&#xe000;",
PolyLine: "&#xe01b;",
Material: "&#xe00b;"
};
const DEGREES_TO_RADIANS = Math.PI / 180.0;
@ -44,7 +27,7 @@ const GROUPS = [
{
label: NO_SELECTION,
type: "icon",
icons: ICON_FOR_TYPE,
icons: ENTITY_TYPE_ICON,
propertyID: "type",
replaceID: "placeholder-property-type",
},
@ -75,7 +58,7 @@ const GROUPS = [
},
{
label: "Parent Joint Index",
type: "number-draggable",
type: "number",
propertyID: "parentJointIndex",
},
{
@ -137,7 +120,7 @@ const GROUPS = [
label: "Line Height",
type: "number-draggable",
min: 0,
step: 0.005,
step: 0.001,
decimals: 4,
unit: "m",
propertyID: "lineHeight",
@ -187,8 +170,8 @@ const GROUPS = [
label: "Light Intensity",
type: "number-draggable",
min: 0,
max: 10,
step: 0.1,
max: 40,
step: 0.01,
decimals: 2,
propertyID: "keyLight.intensity",
showPropertyRule: { "keyLightMode": "enabled" },
@ -196,6 +179,7 @@ const GROUPS = [
{
label: "Light Horizontal Angle",
type: "number-draggable",
step: 0.1,
multiplier: DEGREES_TO_RADIANS,
decimals: 2,
unit: "deg",
@ -205,6 +189,7 @@ const GROUPS = [
{
label: "Light Vertical Angle",
type: "number-draggable",
step: 0.1,
multiplier: DEGREES_TO_RADIANS,
decimals: 2,
unit: "deg",
@ -245,7 +230,7 @@ const GROUPS = [
label: "Ambient Intensity",
type: "number-draggable",
min: 0,
max: 10,
max: 200,
step: 0.1,
decimals: 2,
propertyID: "ambientLight.ambientIntensity",
@ -273,9 +258,9 @@ const GROUPS = [
{
label: "Range",
type: "number-draggable",
min: 5,
min: 1,
max: 10000,
step: 5,
step: 1,
decimals: 0,
unit: "m",
propertyID: "haze.hazeRange",
@ -292,7 +277,7 @@ const GROUPS = [
type: "number-draggable",
min: -1000,
max: 1000,
step: 10,
step: 1,
decimals: 0,
unit: "m",
propertyID: "haze.hazeBaseRef",
@ -303,7 +288,7 @@ const GROUPS = [
type: "number-draggable",
min: -1000,
max: 5000,
step: 10,
step: 1,
decimals: 0,
unit: "m",
propertyID: "haze.hazeCeiling",
@ -320,8 +305,8 @@ const GROUPS = [
type: "number-draggable",
min: 0,
max: 1,
step: 0.01,
decimals: 2,
step: 0.001,
decimals: 3,
propertyID: "haze.hazeBackgroundBlend",
showPropertyRule: { "hazeMode": "enabled" },
},
@ -358,8 +343,8 @@ const GROUPS = [
type: "number-draggable",
min: 0,
max: 1,
step: 0.01,
decimals: 2,
step: 0.001,
decimals: 3,
propertyID: "bloom.bloomIntensity",
showPropertyRule: { "bloomMode": "enabled" },
},
@ -368,8 +353,8 @@ const GROUPS = [
type: "number-draggable",
min: 0,
max: 1,
step: 0.01,
decimals: 2,
step: 0.001,
decimals: 3,
propertyID: "bloom.bloomThreshold",
showPropertyRule: { "bloomMode": "enabled" },
},
@ -378,8 +363,8 @@ const GROUPS = [
type: "number-draggable",
min: 0,
max: 2,
step: 0.01,
decimals: 2,
step: 0.001,
decimals: 3,
propertyID: "bloom.bloomSize",
showPropertyRule: { "bloomMode": "enabled" },
},
@ -543,16 +528,18 @@ const GROUPS = [
label: "Intensity",
type: "number-draggable",
min: 0,
max: 10000,
step: 0.1,
decimals: 1,
decimals: 2,
propertyID: "intensity",
},
{
label: "Fall-Off Radius",
type: "number-draggable",
min: 0,
max: 10000,
step: 0.1,
decimals: 1,
decimals: 2,
unit: "m",
propertyID: "falloffRadius",
},
@ -564,6 +551,7 @@ const GROUPS = [
{
label: "Spotlight Exponent",
type: "number-draggable",
min: 0,
step: 0.01,
decimals: 2,
propertyID: "exponent",
@ -663,6 +651,39 @@ const GROUPS = [
},
]
},
{
id: "grid",
addToGroup: "base",
properties: [
{
label: "Color",
type: "color",
propertyID: "gridColor",
propertyName: "color", // actual entity property name
},
{
label: "Follow Camera",
type: "bool",
propertyID: "followCamera",
},
{
label: "Major Grid Every",
type: "number-draggable",
min: 0,
step: 1,
decimals: 0,
propertyID: "majorGridEvery",
},
{
label: "Minor Grid Every",
type: "number-draggable",
min: 0,
step: 0.01,
decimals: 2,
propertyID: "minorGridEvery",
},
]
},
{
id: "particles",
addToGroup: "base",
@ -676,8 +697,6 @@ const GROUPS = [
label: "Lifespan",
type: "number-draggable",
unit: "s",
min: 0.01,
max: 10,
step: 0.01,
decimals: 2,
propertyID: "lifespan",
@ -685,8 +704,6 @@ const GROUPS = [
{
label: "Max Particles",
type: "number-draggable",
min: 1,
max: 10000,
step: 1,
propertyID: "maxParticles",
},
@ -706,26 +723,20 @@ const GROUPS = [
{
label: "Emit Rate",
type: "number-draggable",
min: 1,
max: 1000,
step: 1,
propertyID: "emitRate",
},
{
label: "Emit Speed",
type: "number-draggable",
min: 0,
max: 5,
step: 0.01,
step: 0.1,
decimals: 2,
propertyID: "emitSpeed",
},
{
label: "Speed Spread",
type: "number-draggable",
min: 0,
max: 5,
step: 0.01,
step: 0.1,
decimals: 2,
propertyID: "speedSpread",
},
@ -733,7 +744,6 @@ const GROUPS = [
label: "Emit Dimensions",
type: "vec3",
vec3Type: "xyz",
min: 0,
step: 0.01,
round: 100,
subLabels: [ "x", "y", "z" ],
@ -742,10 +752,8 @@ const GROUPS = [
{
label: "Emit Radius Start",
type: "number-draggable",
min: 0,
max: 1,
step: 0.01,
decimals: 2,
step: 0.001,
decimals: 3,
propertyID: "emitRadiusStart"
},
{
@ -778,8 +786,6 @@ const GROUPS = [
{
label: "Start",
type: "number-draggable",
min: 0,
max: 4,
step: 0.01,
decimals: 2,
propertyID: "radiusStart",
@ -788,8 +794,6 @@ const GROUPS = [
{
label: "Middle",
type: "number-draggable",
min: 0,
max: 4,
step: 0.01,
decimals: 2,
propertyID: "particleRadius",
@ -797,8 +801,6 @@ const GROUPS = [
{
label: "Finish",
type: "number-draggable",
min: 0,
max: 4,
step: 0.01,
decimals: 2,
propertyID: "radiusFinish",
@ -809,8 +811,6 @@ const GROUPS = [
{
label: "Size Spread",
type: "number-draggable",
min: 0,
max: 4,
step: 0.01,
decimals: 2,
propertyID: "radiusSpread",
@ -867,29 +867,23 @@ const GROUPS = [
{
label: "Start",
type: "number-draggable",
min: 0,
max: 1,
step: 0.01,
decimals: 2,
step: 0.001,
decimals: 3,
propertyID: "alphaStart",
fallbackProperty: "alpha",
},
{
label: "Middle",
type: "number-draggable",
min: 0,
max: 1,
step: 0.01,
decimals: 2,
step: 0.001,
decimals: 3,
propertyID: "alpha",
},
{
label: "Finish",
type: "number-draggable",
min: 0,
max: 1,
step: 0.01,
decimals: 2,
step: 0.001,
decimals: 3,
propertyID: "alphaFinish",
fallbackProperty: "alpha",
},
@ -898,10 +892,8 @@ const GROUPS = [
{
label: "Alpha Spread",
type: "number-draggable",
min: 0,
max: 1,
step: 0.01,
decimals: 2,
step: 0.001,
decimals: 3,
propertyID: "alphaSpread",
},
]
@ -944,10 +936,8 @@ const GROUPS = [
{
label: "Start",
type: "number-draggable",
min: -360,
max: 360,
step: 1,
decimals: 0,
step: 0.1,
decimals: 2,
multiplier: DEGREES_TO_RADIANS,
unit: "deg",
propertyID: "spinStart",
@ -956,10 +946,8 @@ const GROUPS = [
{
label: "Middle",
type: "number-draggable",
min: -360,
max: 360,
step: 1,
decimals: 0,
step: 0.1,
decimals: 2,
multiplier: DEGREES_TO_RADIANS,
unit: "deg",
propertyID: "particleSpin",
@ -967,10 +955,8 @@ const GROUPS = [
{
label: "Finish",
type: "number-draggable",
min: -360,
max: 360,
step: 1,
decimals: 0,
step: 0.1,
decimals: 2,
multiplier: DEGREES_TO_RADIANS,
unit: "deg",
propertyID: "spinFinish",
@ -981,10 +967,8 @@ const GROUPS = [
{
label: "Spin Spread",
type: "number-draggable",
min: 0,
max: 360,
step: 1,
decimals: 0,
step: 0.1,
decimals: 2,
multiplier: DEGREES_TO_RADIANS,
unit: "deg",
propertyID: "spinSpread",
@ -1009,10 +993,8 @@ const GROUPS = [
{
label: "Start",
type: "number-draggable",
min: 0,
max: 180,
step: 1,
decimals: 0,
step: 0.1,
decimals: 2,
multiplier: DEGREES_TO_RADIANS,
unit: "deg",
propertyID: "polarStart",
@ -1020,10 +1002,8 @@ const GROUPS = [
{
label: "Finish",
type: "number-draggable",
min: 0,
max: 180,
step: 1,
decimals: 0,
step: 0.1,
decimals: 2,
multiplier: DEGREES_TO_RADIANS,
unit: "deg",
propertyID: "polarFinish",
@ -1038,10 +1018,8 @@ const GROUPS = [
{
label: "Start",
type: "number-draggable",
min: -180,
max: 180,
step: 1,
decimals: 0,
step: 0.1,
decimals: 2,
multiplier: DEGREES_TO_RADIANS,
unit: "deg",
propertyID: "azimuthStart",
@ -1049,10 +1027,8 @@ const GROUPS = [
{
label: "Finish",
type: "number-draggable",
min: -180,
max: 180,
step: 1,
decimals: 0,
step: 0.1,
decimals: 2,
multiplier: DEGREES_TO_RADIANS,
unit: "deg",
propertyID: "azimuthFinish",
@ -1069,6 +1045,7 @@ const GROUPS = [
label: "Position",
type: "vec3",
vec3Type: "xyz",
step: 0.1,
decimals: 4,
subLabels: [ "x", "y", "z" ],
unit: "m",
@ -1079,6 +1056,7 @@ const GROUPS = [
label: "Local Position",
type: "vec3",
vec3Type: "xyz",
step: 0.1,
decimals: 4,
subLabels: [ "x", "y", "z" ],
unit: "m",
@ -1111,8 +1089,7 @@ const GROUPS = [
label: "Dimensions",
type: "vec3",
vec3Type: "xyz",
min: 0,
step: 0.1,
step: 0.01,
decimals: 4,
subLabels: [ "x", "y", "z" ],
unit: "m",
@ -1123,8 +1100,7 @@ const GROUPS = [
label: "Local Dimensions",
type: "vec3",
vec3Type: "xyz",
min: 0,
step: 0.1,
step: 0.01,
decimals: 4,
subLabels: [ "x", "y", "z" ],
unit: "m",
@ -1144,7 +1120,7 @@ const GROUPS = [
label: "Pivot",
type: "vec3",
vec3Type: "xyz",
step: 0.1,
step: 0.001,
decimals: 4,
subLabels: [ "x", "y", "z" ],
unit: "(ratio of dimension)",
@ -1176,6 +1152,7 @@ const GROUPS = [
{
label: "Clone Lifetime",
type: "number-draggable",
min: -1,
unit: "s",
propertyID: "cloneLifetime",
showPropertyRule: { "cloneable": "true" },
@ -1183,6 +1160,7 @@ const GROUPS = [
{
label: "Clone Limit",
type: "number-draggable",
min: 0,
propertyID: "cloneLimit",
showPropertyRule: { "cloneable": "true" },
},
@ -1321,6 +1299,24 @@ const GROUPS = [
},
]
},
{
id: "zone_shape",
label: "ZONE SHAPE",
properties: [
{
label: "Shape Type",
type: "dropdown",
options: { "box": "Box", "sphere": "Sphere", "ellipsoid": "Ellipsoid",
"cylinder-y": "Cylinder", "compound": "Use Compound Shape URL" },
propertyID: "shapeType",
},
{
label: "Compound Shape URL",
type: "string",
propertyID: "compoundShapeURL",
},
]
},
{
id: "physics",
label: "PHYSICS",
@ -1329,7 +1325,7 @@ const GROUPS = [
label: "Linear Velocity",
type: "vec3",
vec3Type: "xyz",
step: 0.1,
step: 0.01,
decimals: 4,
subLabels: [ "x", "y", "z" ],
unit: "m/s",
@ -1340,8 +1336,8 @@ const GROUPS = [
type: "number-draggable",
min: 0,
max: 1,
step: 0.01,
decimals: 2,
step: 0.001,
decimals: 4,
propertyID: "damping",
},
{
@ -1359,33 +1355,27 @@ const GROUPS = [
type: "number-draggable",
min: 0,
max: 1,
step: 0.01,
step: 0.001,
decimals: 4,
propertyID: "angularDamping",
},
{
label: "Bounciness",
type: "number-draggable",
min: 0,
max: 1,
step: 0.01,
step: 0.001,
decimals: 4,
propertyID: "restitution",
},
{
label: "Friction",
type: "number-draggable",
min: 0,
max: 10,
step: 0.1,
step: 0.01,
decimals: 4,
propertyID: "friction",
},
{
label: "Density",
type: "number-draggable",
min: 100,
max: 10000,
step: 1,
decimals: 4,
propertyID: "density",
@ -1405,6 +1395,7 @@ const GROUPS = [
type: "vec3",
vec3Type: "xyz",
subLabels: [ "x", "y", "z" ],
step: 0.1,
decimals: 4,
unit: "m/s<sup>2</sup>",
propertyID: "acceleration",
@ -1417,7 +1408,7 @@ const GROUPS_PER_TYPE = {
None: [ 'base', 'spatial', 'behavior', 'collision', 'physics' ],
Shape: [ 'base', 'shape', 'spatial', 'behavior', 'collision', 'physics' ],
Text: [ 'base', 'text', 'spatial', 'behavior', 'collision', 'physics' ],
Zone: [ 'base', 'zone', 'spatial', 'behavior', 'collision', 'physics' ],
Zone: [ 'base', 'zone', 'spatial', 'behavior', 'zone_shape', 'physics' ],
Model: [ 'base', 'model', 'spatial', 'behavior', 'collision', 'physics' ],
Image: [ 'base', 'image', 'spatial', 'behavior', 'collision', 'physics' ],
Web: [ 'base', 'web', 'spatial', 'behavior', 'collision', 'physics' ],
@ -1427,6 +1418,7 @@ const GROUPS_PER_TYPE = {
'particles_acceleration', 'particles_spin', 'particles_constraints', 'spatial', 'behavior', 'physics' ],
PolyLine: [ 'base', 'spatial', 'behavior', 'collision', 'physics' ],
PolyVox: [ 'base', 'spatial', 'behavior', 'collision', 'physics' ],
Grid: [ 'base', 'grid', 'spatial', 'behavior', 'physics' ],
Multiple: [ 'base', 'spatial', 'behavior', 'collision', 'physics' ],
};
@ -1486,6 +1478,7 @@ const JSON_EDITOR_ROW_DIV_INDEX = 2;
let elGroups = {};
let properties = {};
let propertyRangeRequests = [];
let colorPickers = {};
let particlePropertyUpdates = {};
let selectedEntityProperties;
@ -1988,6 +1981,18 @@ function createNumberProperty(property, elProperty) {
return elInput;
}
function updateNumberMinMax(property) {
let elInput = property.elInput;
let min = property.data.min;
let max = property.data.max;
if (min !== undefined) {
elInput.setAttribute("min", min);
}
if (max !== undefined) {
elInput.setAttribute("max", max);
}
}
function createNumberDraggableProperty(property, elProperty) {
let elementID = property.elementID;
let propertyData = property.data;
@ -2017,6 +2022,11 @@ function createNumberDraggableProperty(property, elProperty) {
return elDraggableNumber;
}
function updateNumberDraggableMinMax(property) {
let propertyData = property.data;
property.elNumber.updateMinMax(propertyData.min, propertyData.max);
}
function createRectProperty(property, elProperty) {
let propertyData = property.data;
@ -2055,6 +2065,15 @@ function createRectProperty(property, elProperty) {
return elResult;
}
function updateRectMinMax(property) {
let min = property.data.min;
let max = property.data.max;
property.elNumberX.updateMinMax(min, max);
property.elNumberY.updateMinMax(min, max);
property.elNumberWidth.updateMinMax(min, max);
property.elNumberHeight.updateMinMax(min, max);
}
function createVec3Property(property, elProperty) {
let propertyData = property.data;
@ -2104,6 +2123,16 @@ function createVec2Property(property, elProperty) {
return elResult;
}
function updateVectorMinMax(property) {
let min = property.data.min;
let max = property.data.max;
property.elNumberX.updateMinMax(min, max);
property.elNumberY.updateMinMax(min, max);
if (property.elNumberZ) {
property.elNumberZ.updateMinMax(min, max);
}
}
function createColorProperty(property, elProperty) {
let propertyName = property.name;
let elementID = property.elementID;
@ -3102,6 +3131,9 @@ function loaded() {
if (property.type !== 'placeholder') {
properties[propertyID] = property;
}
if (innerPropertyData.type === 'number' || innerPropertyData.type === 'number-draggable') {
propertyRangeRequests.push(propertyID);
}
}
} else {
let property = createProperty(propertyData, propertyElementID, propertyName, propertyID, elProperty);
@ -3111,6 +3143,10 @@ function loaded() {
if (property.type !== 'placeholder') {
properties[propertyID] = property;
}
if (propertyData.type === 'number' || propertyData.type === 'number-draggable' ||
propertyData.type === 'vec2' || propertyData.type === 'vec3' || propertyData.type === 'rect') {
propertyRangeRequests.push(propertyID);
}
let showPropertyRule = propertyData.showPropertyRule;
@ -3481,11 +3517,48 @@ function loaded() {
} else if (data.type === 'setSpaceMode') {
currentSpaceMode = data.spaceMode === "local" ? PROPERTY_SPACE_MODE.LOCAL : PROPERTY_SPACE_MODE.WORLD;
updateVisibleSpaceModeProperties();
} else if (data.type === 'propertyRangeReply') {
let propertyRanges = data.propertyRanges;
for (let property in propertyRanges) {
let propertyRange = propertyRanges[property];
if (propertyRange !== undefined) {
let propertyData = properties[property].data;
let multiplier = propertyData.multiplier;
if (propertyData.min === undefined && propertyRange.minimum != "") {
propertyData.min = propertyRange.minimum;
if (multiplier !== undefined) {
propertyData.min /= multiplier;
}
}
if (propertyData.max === undefined && propertyRange.maximum != "") {
propertyData.max = propertyRange.maximum;
if (multiplier !== undefined) {
propertyData.max /= multiplier;
}
}
switch (propertyData.type) {
case 'number':
updateNumberMinMax(properties[property]);
break;
case 'number-draggable':
updateNumberDraggableMinMax(properties[property]);
break;
case 'vec3':
case 'vec2':
updateVectorMinMax(properties[property]);
break;
case 'rect':
updateRectMinMax(properties[property]);
break;
}
}
}
}
});
// Request tooltips as soon as we can process a reply:
// Request tooltips and property ranges as soon as we can process a reply:
EventBridge.emitWebEvent(JSON.stringify({ type: 'tooltipsRequest' }));
EventBridge.emitWebEvent(JSON.stringify({ type: 'propertyRangeRequest', properties: propertyRangeRequests }));
}
// Server Script Status

View file

@ -0,0 +1,27 @@
//
// includes.js
//
// Created by David Back on 3 Jan 2019
// Copyright 2016 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
const ENTITY_TYPE_ICON = {
Box: "m",
Grid: "&#xe038;",
Image: "&#xe02a;",
Light: "p",
Material: "&#xe00b;",
Model: "&#xe008;",
ParticleEffect: "&#xe004;",
PolyVox: "&#xe005;",
PolyLine: "&#xe01b;",
Shape: "n",
Sphere: "n",
Text: "l",
Web: "q",
Zone: "o",
Multiple: "&#xe000;",
};

View file

@ -599,12 +599,10 @@ SelectionDisplay = (function() {
const STRETCH_CUBE_OFFSET = 0.06;
const STRETCH_CUBE_CAMERA_DISTANCE_MULTIPLE = 0.02;
const STRETCH_MINIMUM_DIMENSION = 0.001;
const STRETCH_PANEL_WIDTH = 0.01;
const SCALE_OVERLAY_CAMERA_DISTANCE_MULTIPLE = 0.02;
const SCALE_DIMENSIONS_CAMERA_DISTANCE_MULTIPLE = 0.5;
const SCALE_MINIMUM_DIMENSION = 0.01;
const BOUNDING_EDGE_OFFSET = 0.5;
@ -1543,7 +1541,7 @@ SelectionDisplay = (function() {
print(" SpaceMode: " + spaceMode);
print(" DisplayMode: " + getMode());
}
if (SelectionManager.selections.length === 0) {
that.setOverlaysVisible(false);
that.clearDebugPickPlane();
@ -1574,7 +1572,7 @@ SelectionDisplay = (function() {
dimensions: dimensions
};
var isCameraInsideBox = isPointInsideBox(Camera.position, selectionBoxGeometry);
// in HMD if outside the bounding box clamp the overlays to the bounding box for now so lasers can hit them
var maxHandleDimension = 0;
if (HMD.active && !isCameraInsideBox) {
@ -2515,7 +2513,7 @@ SelectionDisplay = (function() {
var newDimensions = Vec3.sum(initialDimensions, changeInDimensions);
var minimumDimension = STRETCH_MINIMUM_DIMENSION;
var minimumDimension = Entities.getPropertyInfo("dimensions").minimum;
if (newDimensions.x < minimumDimension) {
newDimensions.x = minimumDimension;
changeInDimensions.x = minimumDimension - initialDimensions.x;
@ -2634,7 +2632,7 @@ SelectionDisplay = (function() {
newDimensions.y = Math.abs(newDimensions.y);
newDimensions.z = Math.abs(newDimensions.z);
var minimumDimension = SCALE_MINIMUM_DIMENSION;
var minimumDimension = Entities.getPropertyInfo("dimensions").minimum;
if (newDimensions.x < minimumDimension) {
newDimensions.x = minimumDimension;
changeInDimensions.x = minimumDimension - initialDimensions.x;