mirror of
https://github.com/overte-org/overte.git
synced 2025-07-24 01:23:55 +02:00
Fix undo not coping with cloning with both hands simultaneously
This commit is contained in:
parent
b526ec0d93
commit
21d286b422
3 changed files with 23 additions and 30 deletions
|
@ -405,6 +405,7 @@ CreatePalette = function (side, leftInputs, rightInputs, uiCommandCallback) {
|
||||||
entityID = Entities.addEntity(properties);
|
entityID = Entities.addEntity(properties);
|
||||||
if (entityID !== Uuid.NULL) {
|
if (entityID !== Uuid.NULL) {
|
||||||
History.prePush(
|
History.prePush(
|
||||||
|
otherSide,
|
||||||
{ deleteEntities: [{ entityID: entityID }] },
|
{ deleteEntities: [{ entityID: entityID }] },
|
||||||
{ createEntities: [{ entityID: entityID, properties: properties }] }
|
{ createEntities: [{ entityID: entityID, properties: properties }] }
|
||||||
);
|
);
|
||||||
|
|
|
@ -47,8 +47,8 @@ History = (function () {
|
||||||
],
|
],
|
||||||
MAX_HISTORY_ITEMS = 1000,
|
MAX_HISTORY_ITEMS = 1000,
|
||||||
undoPosition = -1, // The next history item to undo; the next history item to redo = undoIndex + 1.
|
undoPosition = -1, // The next history item to undo; the next history item to redo = undoIndex + 1.
|
||||||
undoData = {},
|
undoData = [{}, {}],
|
||||||
redoData = {};
|
redoData = [{}, {}];
|
||||||
|
|
||||||
function doKick(entityID) {
|
function doKick(entityID) {
|
||||||
var properties,
|
var properties,
|
||||||
|
@ -73,16 +73,16 @@ History = (function () {
|
||||||
}, KICK_DELAY);
|
}, KICK_DELAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
function prePush(undo, redo) {
|
function prePush(side, undo, redo) {
|
||||||
// Stores undo and redo data to include in the next history entry.
|
// Stores undo and redo data to include in the next history entry generated for the side.
|
||||||
undoData = undo;
|
undoData[side] = undo;
|
||||||
redoData = redo;
|
redoData[side] = redo;
|
||||||
}
|
}
|
||||||
|
|
||||||
function push(undo, redo) {
|
function push(side, undo, redo) {
|
||||||
// Add a history entry.
|
// Add a history entry.
|
||||||
undoData = Object.merge(undoData, undo);
|
undoData[side] = Object.merge(undoData[side], undo);
|
||||||
redoData = Object.merge(redoData, redo);
|
redoData[side] = Object.merge(redoData[side], redo);
|
||||||
|
|
||||||
// Wipe any redo history after current undo position.
|
// Wipe any redo history after current undo position.
|
||||||
if (undoPosition < history.length - 1) {
|
if (undoPosition < history.length - 1) {
|
||||||
|
@ -95,11 +95,11 @@ History = (function () {
|
||||||
undoPosition = history.length - 1;
|
undoPosition = history.length - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
history.push({ undoData: undoData, redoData: redoData });
|
history.push({ undoData: undoData[side], redoData: redoData[side] });
|
||||||
undoPosition++;
|
undoPosition++;
|
||||||
|
|
||||||
undoData = {};
|
undoData[side] = {};
|
||||||
redoData = {};
|
redoData[side] = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateEntityIDs(oldEntityID, newEntityID) {
|
function updateEntityIDs(oldEntityID, newEntityID) {
|
||||||
|
|
|
@ -282,6 +282,7 @@ SelectionManager = function (side) {
|
||||||
&& (!Vec3.equal(startPosition, rootPosition) || !Quat.equal(startOrientation, rootOrientation))) {
|
&& (!Vec3.equal(startPosition, rootPosition) || !Quat.equal(startOrientation, rootOrientation))) {
|
||||||
// Positions and orientations can be identical if change grabbing hands when finish scaling.
|
// Positions and orientations can be identical if change grabbing hands when finish scaling.
|
||||||
History.push(
|
History.push(
|
||||||
|
side,
|
||||||
{
|
{
|
||||||
setProperties: [
|
setProperties: [
|
||||||
{ entityID: rootEntityID, properties: { position: startPosition, rotation: startOrientation } }
|
{ entityID: rootEntityID, properties: { position: startPosition, rotation: startOrientation } }
|
||||||
|
@ -331,6 +332,7 @@ SelectionManager = function (side) {
|
||||||
if (Vec3.distance(startPosition, rootPosition) >= MIN_HISTORY_MOVE_DISTANCE
|
if (Vec3.distance(startPosition, rootPosition) >= MIN_HISTORY_MOVE_DISTANCE
|
||||||
|| Quat.rotationBetween(startOrientation, rootOrientation) >= MIN_HISTORY_ROTATE_ANGLE) {
|
|| Quat.rotationBetween(startOrientation, rootOrientation) >= MIN_HISTORY_ROTATE_ANGLE) {
|
||||||
History.push(
|
History.push(
|
||||||
|
side,
|
||||||
{
|
{
|
||||||
setProperties: [
|
setProperties: [
|
||||||
{ entityID: rootEntityID, properties: { position: startPosition, rotation: startOrientation } }
|
{ entityID: rootEntityID, properties: { position: startPosition, rotation: startOrientation } }
|
||||||
|
@ -426,10 +428,7 @@ SelectionManager = function (side) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add history entry.
|
// Add history entry.
|
||||||
History.push(
|
History.push(side, { setProperties: undoData }, { setProperties: redoData });
|
||||||
{ setProperties: undoData },
|
|
||||||
{ setProperties: redoData }
|
|
||||||
);
|
|
||||||
|
|
||||||
// Update grab start data for its undo.
|
// Update grab start data for its undo.
|
||||||
startPosition = rootPosition;
|
startPosition = rootPosition;
|
||||||
|
@ -445,6 +444,7 @@ SelectionManager = function (side) {
|
||||||
if (Vec3.distance(startPosition, rootPosition) >= MIN_HISTORY_MOVE_DISTANCE
|
if (Vec3.distance(startPosition, rootPosition) >= MIN_HISTORY_MOVE_DISTANCE
|
||||||
|| Quat.rotationBetween(startOrientation, rootOrientation) >= MIN_HISTORY_ROTATE_ANGLE) {
|
|| Quat.rotationBetween(startOrientation, rootOrientation) >= MIN_HISTORY_ROTATE_ANGLE) {
|
||||||
History.push(
|
History.push(
|
||||||
|
side,
|
||||||
{
|
{
|
||||||
setProperties: [
|
setProperties: [
|
||||||
{ entityID: rootEntityID, properties: { position: startPosition, rotation: startOrientation } }
|
{ entityID: rootEntityID, properties: { position: startPosition, rotation: startOrientation } }
|
||||||
|
@ -542,10 +542,7 @@ SelectionManager = function (side) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add history entry.
|
// Add history entry.
|
||||||
History.push(
|
History.push(side, { setProperties: undoData }, { setProperties: redoData });
|
||||||
{ setProperties: undoData },
|
|
||||||
{ setProperties: redoData }
|
|
||||||
);
|
|
||||||
|
|
||||||
// Update grab start data for its undo.
|
// Update grab start data for its undo.
|
||||||
startPosition = rootPosition;
|
startPosition = rootPosition;
|
||||||
|
@ -593,10 +590,7 @@ SelectionManager = function (side) {
|
||||||
rootEntityID = selection[0].id;
|
rootEntityID = selection[0].id;
|
||||||
|
|
||||||
// Add history entry.
|
// Add history entry.
|
||||||
History.prePush(
|
History.prePush(side, { deleteEntities: undoData }, { createEntities: redoData });
|
||||||
{ deleteEntities: undoData },
|
|
||||||
{ createEntities: redoData }
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function applyColor(color, isApplyToAll) {
|
function applyColor(color, isApplyToAll) {
|
||||||
|
@ -621,7 +615,7 @@ SelectionManager = function (side) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (undoData.length > 0) {
|
if (undoData.length > 0) {
|
||||||
History.push({ setProperties: undoData }, { setProperties: redoData });
|
History.push(side, { setProperties: undoData }, { setProperties: redoData });
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
properties = Entities.getEntityProperties(intersectedEntityID, ["type", "color"]);
|
properties = Entities.getEntityProperties(intersectedEntityID, ["type", "color"]);
|
||||||
|
@ -630,6 +624,7 @@ SelectionManager = function (side) {
|
||||||
color: color
|
color: color
|
||||||
});
|
});
|
||||||
History.push(
|
History.push(
|
||||||
|
side,
|
||||||
{ setProperties: [{ entityID: intersectedEntityID, properties: { color: properties.color } }] },
|
{ setProperties: [{ entityID: intersectedEntityID, properties: { color: properties.color } }] },
|
||||||
{ setProperties: [{ entityID: intersectedEntityID, properties: { color: color } }] }
|
{ setProperties: [{ entityID: intersectedEntityID, properties: { color: color } }] }
|
||||||
);
|
);
|
||||||
|
@ -740,10 +735,7 @@ SelectionManager = function (side) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add history entry.
|
// Add history entry.
|
||||||
History.push(
|
History.push(side, { setProperties: undoData }, { setProperties: redoData });
|
||||||
{ setProperties: undoData },
|
|
||||||
{ setProperties: redoData }
|
|
||||||
);
|
|
||||||
|
|
||||||
// Kick off physics if necessary.
|
// Kick off physics if necessary.
|
||||||
if (physicsProperties.dynamic) {
|
if (physicsProperties.dynamic) {
|
||||||
|
@ -759,7 +751,7 @@ SelectionManager = function (side) {
|
||||||
|
|
||||||
function deleteEntities() {
|
function deleteEntities() {
|
||||||
if (rootEntityID) {
|
if (rootEntityID) {
|
||||||
History.push({ createEntities: selectionProperties }, { deleteEntities: [{ entityID: rootEntityID }] });
|
History.push(side, { createEntities: selectionProperties }, { deleteEntities: [{ entityID: rootEntityID }] });
|
||||||
Entities.deleteEntity(rootEntityID); // Children are automatically deleted.
|
Entities.deleteEntity(rootEntityID); // Children are automatically deleted.
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue