mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 03:04:33 +02:00
added Clipboard.nudgeVoxel() and added support for calling clipboard opertations with VoxelDetail as well as xyzs
This commit is contained in:
parent
91d79f65f2
commit
0e8cab7349
5 changed files with 72 additions and 20 deletions
|
@ -40,29 +40,33 @@ function keyReleaseEvent(event) {
|
|||
// Note: this sample uses Alt+ as the key codes for these clipboard items
|
||||
if ((event.key == 199 || event.key == 67 || event.text == "C" || event.text == "c") && event.isAlt) {
|
||||
print("the Alt+C key was pressed");
|
||||
Clipboard.copyVoxels(selectedVoxel.x, selectedVoxel.y, selectedVoxel.z, selectedVoxel.s);
|
||||
Clipboard.copyVoxel(selectedVoxel.x, selectedVoxel.y, selectedVoxel.z, selectedVoxel.s);
|
||||
}
|
||||
if ((event.key == 8776 || event.key == 88 || event.text == "X" || event.text == "x") && event.isAlt) {
|
||||
print("the Alt+X key was pressed");
|
||||
Clipboard.cutVoxels(selectedVoxel.x, selectedVoxel.y, selectedVoxel.z, selectedVoxel.s);
|
||||
Clipboard.cutVoxel(selectedVoxel.x, selectedVoxel.y, selectedVoxel.z, selectedVoxel.s);
|
||||
}
|
||||
if ((event.key == 8730 || event.key == 86 || event.text == "V" || event.text == "v") && event.isAlt) {
|
||||
print("the Alt+V key was pressed");
|
||||
Clipboard.pasteVoxels(selectedVoxel.x, selectedVoxel.y, selectedVoxel.z, selectedVoxel.s);
|
||||
Clipboard.pasteVoxel(selectedVoxel.x, selectedVoxel.y, selectedVoxel.z, selectedVoxel.s);
|
||||
}
|
||||
if (event.text == "DELETE" || event.text == "BACKSPACE") {
|
||||
print("the DELETE/BACKSPACE key was pressed");
|
||||
Clipboard.deleteVoxels(selectedVoxel.x, selectedVoxel.y, selectedVoxel.z, selectedVoxel.s);
|
||||
Clipboard.deleteVoxel(selectedVoxel.x, selectedVoxel.y, selectedVoxel.z, selectedVoxel.s);
|
||||
}
|
||||
|
||||
if ((event.text == "E" || event.text == "e") && event.isMeta) {
|
||||
print("the Ctl+E key was pressed");
|
||||
Clipboard.exportVoxels(selectedVoxel.x, selectedVoxel.y, selectedVoxel.z, selectedVoxel.s);
|
||||
Clipboard.exportVoxel(selectedVoxel.x, selectedVoxel.y, selectedVoxel.z, selectedVoxel.s);
|
||||
}
|
||||
if ((event.text == "I" || event.text == "i") && event.isMeta) {
|
||||
print("the Ctl+I key was pressed");
|
||||
Clipboard.importVoxels();
|
||||
}
|
||||
if ((event.key == 78 || event.text == "N" || event.text == "n") && event.isMeta) {
|
||||
print("the Ctl+N key was pressed, nudging to left 1 meter");
|
||||
Clipboard.nudgeVoxel(selectedVoxel.x, selectedVoxel.y, selectedVoxel.z, selectedVoxel.s, { x: -1, y: 0, z: 0 });
|
||||
}
|
||||
}
|
||||
|
||||
// Map keyPress and mouse move events to our callbacks
|
||||
|
|
|
@ -1847,12 +1847,14 @@ void Application::nudgeVoxels() {
|
|||
// calculate nudgeVec
|
||||
glm::vec3 nudgeVec(_nudgeGuidePosition.x - _nudgeVoxel.x, _nudgeGuidePosition.y - _nudgeVoxel.y, _nudgeGuidePosition.z - _nudgeVoxel.z);
|
||||
|
||||
VoxelTreeElement* nodeToNudge = _voxels.getVoxelAt(_nudgeVoxel.x, _nudgeVoxel.y, _nudgeVoxel.z, _nudgeVoxel.s);
|
||||
nudgeVoxelsByVector(_nudgeVoxel, nudgeVec);
|
||||
}
|
||||
}
|
||||
|
||||
if (nodeToNudge) {
|
||||
_voxels.getTree()->nudgeSubTree(nodeToNudge, nudgeVec, _voxelEditSender);
|
||||
_nudgeStarted = false;
|
||||
}
|
||||
void Application::nudgeVoxelsByVector(const VoxelDetail& sourceVoxel, const glm::vec3& nudgeVec) {
|
||||
VoxelTreeElement* nodeToNudge = _voxels.getVoxelAt(sourceVoxel.x, sourceVoxel.y, sourceVoxel.z, sourceVoxel.s);
|
||||
if (nodeToNudge) {
|
||||
_voxels.getTree()->nudgeSubTree(nodeToNudge, nudgeVec, _voxelEditSender);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -240,6 +240,7 @@ public slots:
|
|||
void pasteVoxels(const VoxelDetail& sourceVoxel);
|
||||
void deleteVoxels(const VoxelDetail& sourceVoxel);
|
||||
void exportVoxels(const VoxelDetail& sourceVoxel);
|
||||
void nudgeVoxelsByVector(const VoxelDetail& sourceVoxel, const glm::vec3& nudgeVec);
|
||||
|
||||
void setRenderVoxels(bool renderVoxels);
|
||||
void doKillLocalVoxels();
|
||||
|
|
|
@ -11,7 +11,11 @@
|
|||
ClipboardScriptingInterface::ClipboardScriptingInterface() {
|
||||
}
|
||||
|
||||
void ClipboardScriptingInterface::cutVoxels(float x, float y, float z, float s) {
|
||||
void ClipboardScriptingInterface::cutVoxel(const VoxelDetail& sourceVoxel) {
|
||||
cutVoxel(sourceVoxel.x, sourceVoxel.y, sourceVoxel.z, sourceVoxel.s);
|
||||
}
|
||||
|
||||
void ClipboardScriptingInterface::cutVoxel(float x, float y, float z, float s) {
|
||||
VoxelDetail sourceVoxel = { x / (float)TREE_SCALE,
|
||||
y / (float)TREE_SCALE,
|
||||
z / (float)TREE_SCALE,
|
||||
|
@ -19,7 +23,11 @@ void ClipboardScriptingInterface::cutVoxels(float x, float y, float z, float s)
|
|||
Application::getInstance()->cutVoxels(sourceVoxel);
|
||||
}
|
||||
|
||||
void ClipboardScriptingInterface::copyVoxels(float x, float y, float z, float s) {
|
||||
void ClipboardScriptingInterface::copyVoxel(const VoxelDetail& sourceVoxel) {
|
||||
copyVoxel(sourceVoxel.x, sourceVoxel.y, sourceVoxel.z, sourceVoxel.s);
|
||||
}
|
||||
|
||||
void ClipboardScriptingInterface::copyVoxel(float x, float y, float z, float s) {
|
||||
VoxelDetail sourceVoxel = { x / (float)TREE_SCALE,
|
||||
y / (float)TREE_SCALE,
|
||||
z / (float)TREE_SCALE,
|
||||
|
@ -27,7 +35,11 @@ void ClipboardScriptingInterface::copyVoxels(float x, float y, float z, float s)
|
|||
Application::getInstance()->copyVoxels(sourceVoxel);
|
||||
}
|
||||
|
||||
void ClipboardScriptingInterface::pasteVoxels(float x, float y, float z, float s) {
|
||||
void ClipboardScriptingInterface::pasteVoxel(const VoxelDetail& destinationVoxel) {
|
||||
pasteVoxel(destinationVoxel.x, destinationVoxel.y, destinationVoxel.z, destinationVoxel.s);
|
||||
}
|
||||
|
||||
void ClipboardScriptingInterface::pasteVoxel(float x, float y, float z, float s) {
|
||||
VoxelDetail sourceVoxel = { x / (float)TREE_SCALE,
|
||||
y / (float)TREE_SCALE,
|
||||
z / (float)TREE_SCALE,
|
||||
|
@ -36,7 +48,11 @@ void ClipboardScriptingInterface::pasteVoxels(float x, float y, float z, float s
|
|||
Application::getInstance()->pasteVoxels(sourceVoxel);
|
||||
}
|
||||
|
||||
void ClipboardScriptingInterface::deleteVoxels(float x, float y, float z, float s) {
|
||||
void ClipboardScriptingInterface::deleteVoxel(const VoxelDetail& sourceVoxel) {
|
||||
deleteVoxel(sourceVoxel.x, sourceVoxel.y, sourceVoxel.z, sourceVoxel.s);
|
||||
}
|
||||
|
||||
void ClipboardScriptingInterface::deleteVoxel(float x, float y, float z, float s) {
|
||||
VoxelDetail sourceVoxel = { x / (float)TREE_SCALE,
|
||||
y / (float)TREE_SCALE,
|
||||
z / (float)TREE_SCALE,
|
||||
|
@ -44,7 +60,11 @@ void ClipboardScriptingInterface::deleteVoxels(float x, float y, float z, float
|
|||
Application::getInstance()->deleteVoxels(sourceVoxel);
|
||||
}
|
||||
|
||||
void ClipboardScriptingInterface::exportVoxels(float x, float y, float z, float s) {
|
||||
void ClipboardScriptingInterface::exportVoxel(const VoxelDetail& sourceVoxel) {
|
||||
exportVoxel(sourceVoxel.x, sourceVoxel.y, sourceVoxel.z, sourceVoxel.s);
|
||||
}
|
||||
|
||||
void ClipboardScriptingInterface::exportVoxel(float x, float y, float z, float s) {
|
||||
VoxelDetail sourceVoxel = { x / (float)TREE_SCALE,
|
||||
y / (float)TREE_SCALE,
|
||||
z / (float)TREE_SCALE,
|
||||
|
@ -58,4 +78,17 @@ void ClipboardScriptingInterface::importVoxels() {
|
|||
QMetaObject::invokeMethod(Application::getInstance(), "importVoxels");
|
||||
}
|
||||
|
||||
void ClipboardScriptingInterface::nudgeVoxel(const VoxelDetail& sourceVoxel, const glm::vec3& nudgeVec) {
|
||||
nudgeVoxel(sourceVoxel.x, sourceVoxel.y, sourceVoxel.z, sourceVoxel.s, nudgeVec);
|
||||
}
|
||||
|
||||
void ClipboardScriptingInterface::nudgeVoxel(float x, float y, float z, float s, const glm::vec3& nudgeVec) {
|
||||
glm::vec3 nudgeVecInTreeSpace = nudgeVec / (float)TREE_SCALE;
|
||||
VoxelDetail sourceVoxel = { x / (float)TREE_SCALE,
|
||||
y / (float)TREE_SCALE,
|
||||
z / (float)TREE_SCALE,
|
||||
s / (float)TREE_SCALE };
|
||||
|
||||
Application::getInstance()->nudgeVoxelsByVector(sourceVoxel, nudgeVecInTreeSpace);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,13 +19,25 @@ public:
|
|||
ClipboardScriptingInterface();
|
||||
|
||||
public slots:
|
||||
void cutVoxels(float x, float y, float z, float s);
|
||||
void copyVoxels(float x, float y, float z, float s);
|
||||
void pasteVoxels(float x, float y, float z, float s);
|
||||
void deleteVoxels(float x, float y, float z, float s);
|
||||
void cutVoxel(const VoxelDetail& sourceVoxel);
|
||||
void cutVoxel(float x, float y, float z, float s);
|
||||
|
||||
void copyVoxel(const VoxelDetail& sourceVoxel);
|
||||
void copyVoxel(float x, float y, float z, float s);
|
||||
|
||||
void pasteVoxel(const VoxelDetail& destinationVoxel);
|
||||
void pasteVoxel(float x, float y, float z, float s);
|
||||
|
||||
void deleteVoxel(const VoxelDetail& sourceVoxel);
|
||||
void deleteVoxel(float x, float y, float z, float s);
|
||||
|
||||
void exportVoxel(const VoxelDetail& sourceVoxel);
|
||||
void exportVoxel(float x, float y, float z, float s);
|
||||
|
||||
void exportVoxels(float x, float y, float z, float s);
|
||||
void importVoxels();
|
||||
|
||||
void nudgeVoxel(const VoxelDetail& sourceVoxel, const glm::vec3& nudgeVec);
|
||||
void nudgeVoxel(float x, float y, float z, float s, const glm::vec3& nudgeVec);
|
||||
};
|
||||
|
||||
#endif // __interface__Clipboard__
|
||||
|
|
Loading…
Reference in a new issue