示例#1
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);
        }
    }
}
示例#2
0
void VoxelScriptingInterface::queueVoxelAdd(float x, float y, float z, float scale, uchar red, uchar green, uchar blue) {
    // setup a VoxelDetail struct with the data
    VoxelDetail addVoxelDetail = {x, y, z, scale, red, green, blue};
    
    // queue the packet
    queueVoxelAdd(PACKET_TYPE_SET_VOXEL, addVoxelDetail);
}
示例#3
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};

    // queue the destructive add
    queueVoxelAdd(PacketTypeVoxelSetDestructive, addVoxelDetail);

    // handle the local tree also...
    if (_tree) {
        _tree->lockForWrite();
        _tree->createVoxel(addVoxelDetail.x, addVoxelDetail.y, addVoxelDetail.z, addVoxelDetail.s, red, green, blue, true);
        _tree->unlock();
    }
}