Adding can cast shadow property.

This commit is contained in:
Nissim Hadar 2018-02-14 12:01:30 -08:00
parent 1632ab9782
commit a92765a83a
7 changed files with 62 additions and 32 deletions

View file

@ -290,6 +290,7 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
CHECK_PROPERTY_CHANGE(PROP_MODEL_URL, modelURL);
CHECK_PROPERTY_CHANGE(PROP_COMPOUND_SHAPE_URL, compoundShapeURL);
CHECK_PROPERTY_CHANGE(PROP_VISIBLE, visible);
CHECK_PROPERTY_CHANGE(PROP_CAN_CAST_SHADOW, canCastShadow);
CHECK_PROPERTY_CHANGE(PROP_REGISTRATION_POINT, registrationPoint);
CHECK_PROPERTY_CHANGE(PROP_ANGULAR_VELOCITY, angularVelocity);
CHECK_PROPERTY_CHANGE(PROP_ANGULAR_DAMPING, angularDamping);
@ -625,6 +626,11 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_IS_UV_MODE_STRETCH, isUVModeStretch);
}
// Models and Shapes
if (_type == EntityTypes::Model || _type == EntityTypes::Shape || _type == EntityTypes::Box || _type == EntityTypes::Sphere) {
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_CAN_CAST_SHADOW, canCastShadow);
}
if (!skipDefaults && !strictSemantics) {
AABox aaBox = getAABox();
QScriptValue boundingBox = engine->newObject();
@ -707,6 +713,7 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object, bool
COPY_PROPERTY_FROM_QSCRIPTVALUE(angularVelocity, glmVec3, setAngularVelocity);
COPY_PROPERTY_FROM_QSCRIPTVALUE(angularDamping, float, setAngularDamping);
COPY_PROPERTY_FROM_QSCRIPTVALUE(visible, bool, setVisible);
COPY_PROPERTY_FROM_QSCRIPTVALUE(canCastShadow, bool, setCanCastShadow);
COPY_PROPERTY_FROM_QSCRIPTVALUE(color, xColor, setColor);
COPY_PROPERTY_FROM_QSCRIPTVALUE(colorSpread, xColor, setColorSpread);
COPY_PROPERTY_FROM_QSCRIPTVALUE(colorStart, xColor, setColorStart);
@ -1851,6 +1858,7 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int
properties.getType() == EntityTypes::Box ||
properties.getType() == EntityTypes::Sphere) {
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_SHAPE, QString, setShape);
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_CAN_CAST_SHADOW, bool, setCanCastShadow);
}
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_NAME, QString, setName);
@ -1974,6 +1982,7 @@ void EntityItemProperties::markAllChanged() {
_angularDampingChanged = true;
_nameChanged = true;
_visibleChanged = true;
_canCastShadowChanged = true;
_colorChanged = true;
_alphaChanged = true;
_modelURLChanged = true;

View file

@ -128,7 +128,7 @@ public:
DEFINE_PROPERTY_REF(PROP_SCRIPT, Script, script, QString, ENTITY_ITEM_DEFAULT_SCRIPT);
DEFINE_PROPERTY(PROP_SCRIPT_TIMESTAMP, ScriptTimestamp, scriptTimestamp, quint64, ENTITY_ITEM_DEFAULT_SCRIPT_TIMESTAMP);
DEFINE_PROPERTY_REF(PROP_COLLISION_SOUND_URL, CollisionSoundURL, collisionSoundURL, QString, ENTITY_ITEM_DEFAULT_COLLISION_SOUND_URL);
DEFINE_PROPERTY(PROP_CAST_SHADOW, CanCastShadow, canCastShadow, bool, ENTITY_ITEM_DEFAULT_CAST_SHADOW);
DEFINE_PROPERTY(PROP_CAN_CAST_SHADOW, CanCastShadow, canCastShadow, bool, ENTITY_ITEM_DEFAULT_CAST_SHADOW);
DEFINE_PROPERTY_REF(PROP_COLOR, Color, color, xColor, particle::DEFAULT_COLOR);
DEFINE_PROPERTY_REF(PROP_COLOR_SPREAD, ColorSpread, colorSpread, xColor, particle::DEFAULT_COLOR_SPREAD);
DEFINE_PROPERTY_REF(PROP_COLOR_START, ColorStart, colorStart, xColor, particle::DEFAULT_COLOR);

View file

@ -31,7 +31,7 @@ enum EntityPropertyList {
PROP_SCRIPT,
// these properties are supported by some derived classes
PROP_CAST_SHADOW,
PROP_CAN_CAST_SHADOW,
PROP_COLOR,
// these are used by models only

View file

@ -116,7 +116,7 @@ int ModelEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data,
const unsigned char* dataAt = data;
bool animationPropertiesChanged = false;
READ_ENTITY_PROPERTY(PROP_CAST_SHADOW, bool, setCanCastShadow);
READ_ENTITY_PROPERTY(PROP_CAN_CAST_SHADOW, bool, setCanCastShadow);
READ_ENTITY_PROPERTY(PROP_COLOR, rgbColor, setColor);
READ_ENTITY_PROPERTY(PROP_MODEL_URL, QString, setModelURL);
READ_ENTITY_PROPERTY(PROP_COMPOUND_SHAPE_URL, QString, setCompoundShapeURL);
@ -153,7 +153,7 @@ int ModelEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data,
EntityPropertyFlags ModelEntityItem::getEntityProperties(EncodeBitstreamParams& params) const {
EntityPropertyFlags requestedProperties = EntityItem::getEntityProperties(params);
requestedProperties += PROP_CAST_SHADOW;
requestedProperties += PROP_CAN_CAST_SHADOW;
requestedProperties += PROP_MODEL_URL;
requestedProperties += PROP_COMPOUND_SHAPE_URL;
requestedProperties += PROP_TEXTURES;
@ -178,7 +178,7 @@ void ModelEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBit
bool successPropertyFits = true;
APPEND_ENTITY_PROPERTY(PROP_CAST_SHADOW, getCanCastShadow());
APPEND_ENTITY_PROPERTY(PROP_CAN_CAST_SHADOW, getCanCastShadow());
APPEND_ENTITY_PROPERTY(PROP_COLOR, getColor());
APPEND_ENTITY_PROPERTY(PROP_MODEL_URL, getModelURL());
APPEND_ENTITY_PROPERTY(PROP_COMPOUND_SHAPE_URL, getCompoundShapeURL());
@ -619,6 +619,7 @@ void ModelEntityItem::setColor(const rgbColor& value) {
});
}
#pragma optimize("", off)
void ModelEntityItem::setColor(const xColor& value) {
withWriteLock([&] {
_color[RED_INDEX] = value.red;
@ -666,7 +667,6 @@ bool ModelEntityItem::getAnimationLoop() const {
});
}
void ModelEntityItem::setAnimationHold(bool hold) {
withWriteLock([&] {
_animationProperties.setHold(hold);

View file

@ -157,7 +157,7 @@ int ShapeEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data,
READ_ENTITY_PROPERTY(PROP_SHAPE, QString, setShape);
READ_ENTITY_PROPERTY(PROP_COLOR, rgbColor, setColor);
READ_ENTITY_PROPERTY(PROP_ALPHA, float, setAlpha);
READ_ENTITY_PROPERTY(PROP_CAST_SHADOW, bool, setCanCastShadow);
READ_ENTITY_PROPERTY(PROP_CAN_CAST_SHADOW, bool, setCanCastShadow);
return bytesRead;
}
@ -169,7 +169,7 @@ EntityPropertyFlags ShapeEntityItem::getEntityProperties(EncodeBitstreamParams&
requestedProperties += PROP_SHAPE;
requestedProperties += PROP_COLOR;
requestedProperties += PROP_ALPHA;
requestedProperties += PROP_CAST_SHADOW;
requestedProperties += PROP_CAN_CAST_SHADOW;
return requestedProperties;
}
@ -186,7 +186,7 @@ void ShapeEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBit
APPEND_ENTITY_PROPERTY(PROP_SHAPE, entity::stringFromShape(getShape()));
APPEND_ENTITY_PROPERTY(PROP_COLOR, getColor());
APPEND_ENTITY_PROPERTY(PROP_ALPHA, getAlpha());
APPEND_ENTITY_PROPERTY(PROP_CAST_SHADOW, getCanCastShadow());
APPEND_ENTITY_PROPERTY(PROP_CAN_CAST_SHADOW, getCanCastShadow());
}
void ShapeEntityItem::setColor(const rgbColor& value) {

View file

@ -42,25 +42,28 @@
</div>
</fieldset>
<fieldset id="general" class="major">
<div class="shape-group shape-section property dropdown" id="shape-list">
<label for="property-shape">Shape</label>
<select name="SelectShape" id="property-shape">
<option value="Cube">Box</option>
<option value="Sphere">Sphere</option>
<option value="Tetrahedron">Tetrahedron</option>
<option value="Octahedron">Octahedron</option>
<option value="Icosahedron">Icosahedron</option>
<option value="Dodecahedron">Dodecahedron</option>
<option value="Hexagon">Hexagon</option>
<option value="Triangle">Triangle</option>
<option value="Octagon">Octagon</option>
<option value="Cylinder">Cylinder</option>
<option value="Cone">Cone</option>
<option value="Circle">Circle</option>
<option value="Quad">Quad</option>
</select>
<option value="Cube">Box</option>
<option value="Sphere">Sphere</option>
<option value="Tetrahedron">Tetrahedron</option>
<option value="Octahedron">Octahedron</option>
<option value="Icosahedron">Icosahedron</option>
<option value="Dodecahedron">Dodecahedron</option>
<option value="Hexagon">Hexagon</option>
<option value="Triangle">Triangle</option>
<option value="Octagon">Octagon</option>
<option value="Cylinder">Cylinder</option>
<option value="Cone">Cone</option>
<option value="Circle">Circle</option>
<option value="Quad">Quad</option>
</select>
</div>
<div class="can-cast-shadow-section property checkbox">
<input type="checkbox" id="property-can-cast-shadow">
<label for="property-can-cast-shadow">Can cast shadow</label>
</div>
<div class="property text">
<label for="property-name">Name</label>
@ -293,7 +296,6 @@
</div>
</fieldset>
<fieldset id="behavior" class="major">
<legend class="section-header behavior-group">
Behavior<span>M</span>
@ -365,8 +367,6 @@
</div>
</fieldset>
<fieldset id="light" class="major">
<legend class="section-header light-group light-section">
Light<span>M</span>
@ -400,7 +400,6 @@
</fieldset>
</fieldset>
<fieldset id="model" class="major">
<legend class="section-header model-group model-section zone-section">
Model<span>M</span>
@ -484,7 +483,6 @@
</fieldset>
</fieldset>
<fieldset id="zone" class="major">
<legend class="section-header zone-group zone-section">
Zone<span>M</span>

View file

@ -595,6 +595,8 @@ function loaded() {
var elShape = document.getElementById("property-shape");
var elCanCastShadow = document.getElementById("property-can-cast-shadow");
var elLightSpotLight = document.getElementById("property-light-spot-light");
var elLightColor = document.getElementById("property-light-color");
var elLightColorRed = document.getElementById("property-light-color-red");
@ -799,7 +801,6 @@ function loaded() {
elLocked.checked = properties.locked;
elName.value = properties.name;
elVisible.checked = properties.visible;
@ -966,6 +967,12 @@ function loaded() {
properties.color.green + "," + properties.color.blue + ")";
}
if (properties.type === "Model" ||
properties.type === "Shape" || properties.type === "Box" || properties.type === "Sphere") {
elCanCastShadow = properties.canCastShadow;
}
if (properties.type === "Model") {
elModelURL.value = properties.modelURL;
elShapeType.value = properties.shapeType;
@ -1012,7 +1019,6 @@ function loaded() {
elLightFalloffRadius.value = properties.falloffRadius.toFixed(1);
elLightExponent.value = properties.exponent.toFixed(2);
elLightCutoff.value = properties.cutoff.toFixed(2);
} else if (properties.type === "Zone") {
// Key light
elZoneKeyLightModeInherit.checked = (properties.keyLightMode === 'inherit');
@ -1093,13 +1099,15 @@ function loaded() {
// Show/hide sections as required
showElements(document.getElementsByClassName('skybox-section'),
elZoneSkyboxModeEnabled.checked);
showElements(document.getElementsByClassName('keylight-section'),
elZoneKeyLightModeEnabled.checked);
showElements(document.getElementsByClassName('ambient-section'),
elZoneAmbientLightModeEnabled.checked);
showElements(document.getElementsByClassName('haze-section'),
elZoneHazeModeEnabled.checked);
} else if (properties.type === "PolyVox") {
elVoxelVolumeSizeX.value = properties.voxelVolumeSize.x.toFixed(2);
elVoxelVolumeSizeY.value = properties.voxelVolumeSize.y.toFixed(2);
@ -1111,6 +1119,15 @@ function loaded() {
elZTextureURL.value = properties.zTextureURL;
}
// Only these types can cast a shadow
if (properties.type === "Model" ||
properties.type === "Shape" || properties.type === "Box" || properties.type === "Sphere") {
showElements(document.getElementsByClassName('can-cast-shadow-section'), true);
} else {
showElements(document.getElementsByClassName('can-cast-shadow-section'), false);
}
if (properties.locked) {
disableProperties();
elLocked.removeAttribute('disabled');
@ -1356,6 +1373,12 @@ function loaded() {
elShape.addEventListener('change', createEmitTextPropertyUpdateFunction('shape'));
if (properties.type === "Model" ||
properties.type === "Shape" || properties.type === "Box" || properties.type === "Sphere") {
elCanCastShadow.addEventListener('change', createEmitTextPropertyUpdateFunction('canCastShadow'));
}
elWebSourceURL.addEventListener('change', createEmitTextPropertyUpdateFunction('sourceUrl'));
elWebDPI.addEventListener('change', createEmitNumberPropertyUpdateFunction('dpi', 0));