Ejemplo n.º 1
0
void VoxelsScriptingInterface::eraseVoxel(float x, float y, float z, float scale) {
    // setup a VoxelDetail struct with data
    VoxelDetail deleteVoxelDetail = {x / (float)TREE_SCALE, y / (float)TREE_SCALE, z / (float)TREE_SCALE,
                                        scale / (float)TREE_SCALE};


    // handle the local tree also...
    if (_tree) {
        VoxelTreeElement* deleteVoxelElement = _tree->getVoxelAt(deleteVoxelDetail.x, deleteVoxelDetail.y, deleteVoxelDetail.z, deleteVoxelDetail.s);
        if (deleteVoxelElement) {
            deleteVoxelDetail.red = deleteVoxelElement->getColor()[0];
            deleteVoxelDetail.green = deleteVoxelElement->getColor()[1];
            deleteVoxelDetail.blue = deleteVoxelElement->getColor()[2];
        }
        
        if (_undoStack) {
            DeleteVoxelCommand* command = new DeleteVoxelCommand(_tree,
                                                                 deleteVoxelDetail,
                                                                 getVoxelPacketSender());
            // As QUndoStack automatically executes redo() on push, we don't need to execute the command ourselves.
            _undoStack->push(command);
        } else {
            getVoxelPacketSender()->queueVoxelEditMessages(PacketTypeVoxelErase, 1, &deleteVoxelDetail);
            _tree->deleteVoxelAt(deleteVoxelDetail.x, deleteVoxelDetail.y, deleteVoxelDetail.z, deleteVoxelDetail.s);
        }
    }
}
Ejemplo n.º 2
0
void VoxelsScriptingInterface::setVoxel(float x, float y, float z, float scale,
                                                        uchar red, uchar green, uchar blue) {
    // setup a VoxelDetail struct with the data
    VoxelDetail addVoxelDetail = {x / (float)TREE_SCALE, y / (float)TREE_SCALE, z / (float)TREE_SCALE, 
                                    scale / (float)TREE_SCALE, red, green, blue};


    // handle the local tree also...
    if (_tree) {
        if (_undoStack) {
            AddVoxelCommand* addCommand = new AddVoxelCommand(_tree,
                                                              addVoxelDetail,
                                                              getVoxelPacketSender());
            DeleteVoxelCommand* deleteCommand = new DeleteVoxelCommand(_tree,
                                                                       addVoxelDetail,
                                                                       getVoxelPacketSender());
            _undoStack->beginMacro(addCommand->text());
            // As QUndoStack automatically executes redo() on push, we don't need to execute the command ourselves.
            _undoStack->push(deleteCommand);
            _undoStack->push(addCommand);
            _undoStack->endMacro();
        } else {
            // queue the destructive add
            queueVoxelAdd(PacketTypeVoxelSetDestructive, addVoxelDetail);
            _tree->createVoxel(addVoxelDetail.x, addVoxelDetail.y, addVoxelDetail.z, addVoxelDetail.s, red, green, blue, true);
        }
    }
}
Ejemplo n.º 3
0
void VoxelsScriptingInterface::eraseVoxel(float x, float y, float z, float scale) {

    // setup a VoxelDetail struct with data
    VoxelDetail deleteVoxelDetail = {x / (float)TREE_SCALE, y / (float)TREE_SCALE, z / (float)TREE_SCALE, 
                                        scale / (float)TREE_SCALE, 0, 0, 0};

    getVoxelPacketSender()->queueVoxelEditMessages(PacketTypeVoxelErase, 1, &deleteVoxelDetail);

    // handle the local tree also...
    if (_tree) {
        _tree->lockForWrite();
        _tree->deleteVoxelAt(deleteVoxelDetail.x, deleteVoxelDetail.y, deleteVoxelDetail.z, deleteVoxelDetail.s);
        _tree->unlock();
    }
}
Ejemplo n.º 4
0
void VoxelsScriptingInterface::queueVoxelAdd(PacketType addPacketType, VoxelDetail& addVoxelDetails) {
    getVoxelPacketSender()->queueVoxelEditMessages(addPacketType, 1, &addVoxelDetails);
}