mirror of
https://github.com/overte-org/overte.git
synced 2025-04-17 11:20:42 +02:00
Merge branch 'edit-entity-filter' into entity-filter-resource
This commit is contained in:
commit
f36b968860
2 changed files with 44 additions and 1 deletions
|
@ -1059,7 +1059,8 @@ int EntityTree::processEditPacketData(ReceivedMessage& message, const unsigned c
|
|||
|
||||
startFilter = usecTimestampNow();
|
||||
bool wasChanged = false;
|
||||
bool allowed = filterProperties(properties, properties, wasChanged);
|
||||
// Having (un)lock rights bypasses the filter.
|
||||
bool allowed = senderNode->isAllowedEditor() || filterProperties(properties, properties, wasChanged);
|
||||
if (!allowed) {
|
||||
properties = EntityItemProperties();
|
||||
}
|
||||
|
|
|
@ -9,6 +9,48 @@ function filter(p) {
|
|||
|
||||
/* Can also reject altogether */
|
||||
if (p.userData) { return false; }
|
||||
|
||||
/* Reject if modifications made to Model properties */
|
||||
if (p.modelURL || p.compoundShapeURL || p.shape || p.shapeType || p.url || p.fps || p.currentFrame || p.running || p.loop || p.firstFrame || p.lastFrame || p.hold || p.textures || p.xTextureURL || p.yTextureURL || p.zTextureURL) { return false; }
|
||||
|
||||
/* Clamp velocity to maxVelocity units/second. Zeroing each component of acceleration keeps us from slamming.*/
|
||||
var maxVelocity = 5;
|
||||
if (p.velocity) {
|
||||
if (Math.abs(p.velocity.x) > maxVelocity) {
|
||||
p.velocity.x = Math.sign(p.velocity.x) * maxVelocity;
|
||||
p.acceleration.x = 0;
|
||||
}
|
||||
if (Math.abs(p.velocity.y) > maxVelocity) {
|
||||
p.velocity.y = Math.sign(p.velocity.y) * maxVelocity;
|
||||
p.acceleration.y = 0;
|
||||
}
|
||||
if (Math.abs(p.velocity.z) > maxVelocity) {
|
||||
p.velocity.z = Math.sign(p.velocity.z) * maxVelocity;
|
||||
p.acceleration.z = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Define an axis-aligned zone in which entities are not allowed to enter. */
|
||||
/* This example zone corresponds to an area to the right of the spawnpoint
|
||||
in your Sandbox. It's an area near the big rock to the right. If an entity
|
||||
enters the zone, it'll move behind the rock.*/
|
||||
var boxMin = {x: 25.5, y: -0.48, z: -9.9};
|
||||
var boxMax = {x: 31.1, y: 4, z: -3.79};
|
||||
var zero = {x: 0.0, y: 0.0, z: 0.0};
|
||||
|
||||
if (p.position) {
|
||||
var x = p.position.x;
|
||||
var y = p.position.y;
|
||||
var z = p.position.z;
|
||||
if ((x > boxMin.x && x < boxMax.x) &&
|
||||
(y > boxMin.y && y < boxMax.y) &&
|
||||
(z > boxMin.z && z < boxMax.z)) {
|
||||
/* Move it to the origin of the zone */
|
||||
p.position = boxMin;
|
||||
p.velocity = zero;
|
||||
p.acceleration = zero;
|
||||
}
|
||||
}
|
||||
|
||||
/* If we make it this far, return the (possibly modified) properties. */
|
||||
return p;
|
||||
|
|
Loading…
Reference in a new issue