From 74625c8d54cf19f4eac4a007cc2a8b3b56f621b2 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 11 Jul 2012 10:41:26 +0000 Subject: [PATCH 01/27] Minor interface change: space between vertex group specials menu and up/down buttons --- release/scripts/startup/bl_ui/properties_data_mesh.py | 1 + 1 file changed, 1 insertion(+) diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py b/release/scripts/startup/bl_ui/properties_data_mesh.py index 7ca464ce055..4f3be914e66 100644 --- a/release/scripts/startup/bl_ui/properties_data_mesh.py +++ b/release/scripts/startup/bl_ui/properties_data_mesh.py @@ -151,6 +151,7 @@ class DATA_PT_vertex_groups(MeshButtonsPanel, Panel): col.operator("object.vertex_group_remove", icon='ZOOMOUT', text="") col.menu("MESH_MT_vertex_group_specials", icon='DOWNARROW_HLT', text="") if group: + col.separator() col.operator("object.vertex_group_move", icon='TRIA_UP', text="").direction = 'UP' col.operator("object.vertex_group_move", icon='TRIA_DOWN', text="").direction = 'DOWN' From c25240ad547e579381b8ae4cdb7b7b961d0af2cb Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Wed, 11 Jul 2012 10:45:56 +0000 Subject: [PATCH 02/27] Compositor read buffers work directly on the memory buffer. This way we can remove the memoryBuffers parameter in the executePixels, and (de)initializeTileData methods --- .../compositor/intern/COM_CPUDevice.cpp | 5 ++- .../compositor/intern/COM_ExecutionGroup.cpp | 17 ---------- .../compositor/intern/COM_ExecutionSystem.cpp | 7 ++++ .../compositor/intern/COM_NodeOperation.h | 2 +- .../compositor/intern/COM_OpenCLDevice.cpp | 9 +++-- .../compositor/intern/COM_OpenCLDevice.h | 2 ++ .../operations/COM_CompositorOperation.cpp | 6 ++-- .../operations/COM_CompositorOperation.h | 2 +- .../operations/COM_OutputFileOperation.cpp | 12 +++---- .../operations/COM_OutputFileOperation.h | 4 +-- .../operations/COM_PreviewOperation.cpp | 4 +-- .../operations/COM_PreviewOperation.h | 2 +- .../operations/COM_ReadBufferOperation.cpp | 34 ++++++++----------- .../operations/COM_ReadBufferOperation.h | 2 ++ .../operations/COM_SplitViewerOperation.cpp | 6 ++-- .../operations/COM_SplitViewerOperation.h | 2 +- .../operations/COM_ViewerOperation.cpp | 6 ++-- .../operations/COM_ViewerOperation.h | 2 +- .../operations/COM_WriteBufferOperation.cpp | 11 +++--- .../operations/COM_WriteBufferOperation.h | 2 +- 20 files changed, 64 insertions(+), 73 deletions(-) diff --git a/source/blender/compositor/intern/COM_CPUDevice.cpp b/source/blender/compositor/intern/COM_CPUDevice.cpp index 95462b3c384..7029aa032cc 100644 --- a/source/blender/compositor/intern/COM_CPUDevice.cpp +++ b/source/blender/compositor/intern/COM_CPUDevice.cpp @@ -29,10 +29,9 @@ void CPUDevice::execute(WorkPackage *work) rcti rect; executionGroup->determineChunkRect(&rect, chunkNumber); - MemoryBuffer **inputBuffers = executionGroup->getInputBuffersCPU(); - executionGroup->getOutputNodeOperation()->executeRegion(&rect, chunkNumber, inputBuffers); + executionGroup->getOutputNodeOperation()->executeRegion(&rect, chunkNumber); - executionGroup->finalizeChunkExecution(chunkNumber, inputBuffers); + executionGroup->finalizeChunkExecution(chunkNumber, NULL); } diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cpp b/source/blender/compositor/intern/COM_ExecutionGroup.cpp index 90f4ba85c78..1e42dba001a 100644 --- a/source/blender/compositor/intern/COM_ExecutionGroup.cpp +++ b/source/blender/compositor/intern/COM_ExecutionGroup.cpp @@ -372,23 +372,6 @@ void ExecutionGroup::execute(ExecutionSystem *graph) delete[] chunkOrder; } -MemoryBuffer **ExecutionGroup::getInputBuffersCPU() -{ - vector memoryproxies; - unsigned int index; - - this->determineDependingMemoryProxies(&memoryproxies); - MemoryBuffer **memoryBuffers = new MemoryBuffer *[this->m_cachedMaxReadBufferOffset]; - for (index = 0; index < this->m_cachedMaxReadBufferOffset; index++) { - memoryBuffers[index] = NULL; - } - for (index = 0; index < this->m_cachedReadOperations.size(); index++) { - ReadBufferOperation *readOperation = (ReadBufferOperation *)this->m_cachedReadOperations[index]; - memoryBuffers[readOperation->getOffset()] = readOperation->getMemoryProxy()->getBuffer(); - } - return memoryBuffers; -} - MemoryBuffer **ExecutionGroup::getInputBuffersOpenCL(int chunkNumber) { rcti rect; diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.cpp b/source/blender/compositor/intern/COM_ExecutionSystem.cpp index ff841092848..801505e9d39 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystem.cpp +++ b/source/blender/compositor/intern/COM_ExecutionSystem.cpp @@ -129,6 +129,13 @@ void ExecutionSystem::execute() operation->setbNodeTree(this->m_context.getbNodeTree()); operation->initExecution(); } + for (index = 0; index < this->m_operations.size(); index++) { + NodeOperation *operation = this->m_operations[index]; + if (operation->isReadBufferOperation()) { + ReadBufferOperation *readOperation = (ReadBufferOperation *)operation; + readOperation->updateMemoryBuffer(); + } + } for (index = 0; index < this->m_groups.size(); index++) { ExecutionGroup *executionGroup = this->m_groups[index]; executionGroup->setChunksize(this->m_context.getChunksize()); diff --git a/source/blender/compositor/intern/COM_NodeOperation.h b/source/blender/compositor/intern/COM_NodeOperation.h index d316cfa0aa4..0de2f6aef5d 100644 --- a/source/blender/compositor/intern/COM_NodeOperation.h +++ b/source/blender/compositor/intern/COM_NodeOperation.h @@ -134,7 +134,7 @@ public: * @param chunkNumber the chunkNumber to be calculated * @param memoryBuffers all input MemoryBuffer's needed */ - virtual void executeRegion(rcti *rect, unsigned int chunkNumber, MemoryBuffer **memoryBuffers) {} + virtual void executeRegion(rcti *rect, unsigned int chunkNumber) {} /** * @brief when a chunk is executed by an OpenCLDevice, this method is called diff --git a/source/blender/compositor/intern/COM_OpenCLDevice.cpp b/source/blender/compositor/intern/COM_OpenCLDevice.cpp index eae1ffeb08a..63f75681779 100644 --- a/source/blender/compositor/intern/COM_OpenCLDevice.cpp +++ b/source/blender/compositor/intern/COM_OpenCLDevice.cpp @@ -65,11 +65,16 @@ void OpenCLDevice::execute(WorkPackage *work) executionGroup->finalizeChunkExecution(chunkNumber, inputBuffers); } - cl_mem OpenCLDevice::COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel, int parameterIndex, int offsetIndex, list *cleanup, MemoryBuffer **inputMemoryBuffers, SocketReader *reader) +{ + return COM_clAttachMemoryBufferToKernelParameter(kernel, parameterIndex, offsetIndex, cleanup, inputMemoryBuffers, (ReadBufferOperation*)reader); +} + +cl_mem OpenCLDevice::COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel, int parameterIndex, int offsetIndex, list *cleanup, MemoryBuffer **inputMemoryBuffers, ReadBufferOperation *reader) { cl_int error; - MemoryBuffer *result = (MemoryBuffer *)reader->initializeTileData(NULL, inputMemoryBuffers); + + MemoryBuffer *result = (MemoryBuffer *)reader->getInputMemoryBuffer(inputMemoryBuffers); const cl_image_format imageFormat = { CL_RGBA, diff --git a/source/blender/compositor/intern/COM_OpenCLDevice.h b/source/blender/compositor/intern/COM_OpenCLDevice.h index 30a90dabc3e..577df5caf77 100644 --- a/source/blender/compositor/intern/COM_OpenCLDevice.h +++ b/source/blender/compositor/intern/COM_OpenCLDevice.h @@ -28,6 +28,7 @@ class OpenCLDevice; #include "COM_Device.h" #include "OCL_opencl.h" #include "COM_WorkScheduler.h" +#include "COM_ReadBufferOperation.h" /** * @brief device representing an GPU OpenCL device. @@ -96,6 +97,7 @@ public: cl_command_queue getQueue(){ return this->m_queue; } cl_mem COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel, int parameterIndex, int offsetIndex, list *cleanup, MemoryBuffer **inputMemoryBuffers, SocketReader *reader); + cl_mem COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel, int parameterIndex, int offsetIndex, list *cleanup, MemoryBuffer **inputMemoryBuffers, ReadBufferOperation *reader); void COM_clAttachMemoryBufferOffsetToKernelParameter(cl_kernel kernel, int offsetIndex, MemoryBuffer *memoryBuffers); void COM_clAttachOutputMemoryBufferToKernelParameter(cl_kernel kernel, int parameterIndex, cl_mem clOutputMemoryBuffer); void COM_clAttachSizeToKernelParameter(cl_kernel kernel, int offsetIndex, NodeOperation* operation); diff --git a/source/blender/compositor/operations/COM_CompositorOperation.cpp b/source/blender/compositor/operations/COM_CompositorOperation.cpp index 717b6ce76cc..a58f77386ea 100644 --- a/source/blender/compositor/operations/COM_CompositorOperation.cpp +++ b/source/blender/compositor/operations/COM_CompositorOperation.cpp @@ -94,7 +94,7 @@ void CompositorOperation::deinitExecution() } -void CompositorOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers) +void CompositorOperation::executeRegion(rcti *rect, unsigned int tileNumber) { float color[8]; // 7 is enough float *buffer = this->m_outputBuffer; @@ -111,9 +111,9 @@ void CompositorOperation::executeRegion(rcti *rect, unsigned int tileNumber, Mem for (y = y1; y < y2 && (!breaked); y++) { for (x = x1; x < x2 && (!breaked); x++) { - this->m_imageInput->read(color, x, y, COM_PS_NEAREST, memoryBuffers); + this->m_imageInput->read(color, x, y, COM_PS_NEAREST, NULL); if (this->m_alphaInput != NULL) { - this->m_alphaInput->read(&(color[3]), x, y, COM_PS_NEAREST, memoryBuffers); + this->m_alphaInput->read(&(color[3]), x, y, COM_PS_NEAREST, NULL); } copy_v4_v4(buffer + offset, color); offset += COM_NUMBER_OF_CHANNELS; diff --git a/source/blender/compositor/operations/COM_CompositorOperation.h b/source/blender/compositor/operations/COM_CompositorOperation.h index 2719d376339..23d34abbfff 100644 --- a/source/blender/compositor/operations/COM_CompositorOperation.h +++ b/source/blender/compositor/operations/COM_CompositorOperation.h @@ -52,7 +52,7 @@ private: SocketReader *m_alphaInput; public: CompositorOperation(); - void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers); + void executeRegion(rcti *rect, unsigned int tileNumber); void setRenderData(const RenderData *rd) { this->m_rd = rd; } bool isOutputOperation(bool rendering) const { return true; } void initExecution(); diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.cpp b/source/blender/compositor/operations/COM_OutputFileOperation.cpp index 087e7a15e39..079c6ff33ec 100644 --- a/source/blender/compositor/operations/COM_OutputFileOperation.cpp +++ b/source/blender/compositor/operations/COM_OutputFileOperation.cpp @@ -59,7 +59,7 @@ static float *init_buffer(unsigned int width, unsigned int height, DataType data return NULL; } -static void write_buffer_rect(rcti *rect, MemoryBuffer **memoryBuffers, const bNodeTree *tree, +static void write_buffer_rect(rcti *rect, const bNodeTree *tree, SocketReader *reader, float *buffer, unsigned int width, DataType datatype) { float color[4]; @@ -77,7 +77,7 @@ static void write_buffer_rect(rcti *rect, MemoryBuffer **memoryBuffers, const bN for (y = y1; y < y2 && (!breaked); y++) { for (x = x1; x < x2 && (!breaked); x++) { - reader->read(color, x, y, COM_PS_NEAREST, memoryBuffers); + reader->read(color, x, y, COM_PS_NEAREST, NULL); for (i = 0; i < size; ++i) buffer[offset + i] = color[i]; @@ -113,9 +113,9 @@ void OutputSingleLayerOperation::initExecution() this->m_outputBuffer = init_buffer(this->getWidth(), this->getHeight(), this->m_datatype); } -void OutputSingleLayerOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers) +void OutputSingleLayerOperation::executeRegion(rcti *rect, unsigned int tileNumber) { - write_buffer_rect(rect, memoryBuffers, this->m_tree, this->m_imageInput, this->m_outputBuffer, this->getWidth(), this->m_datatype); + write_buffer_rect(rect, this->m_tree, this->m_imageInput, this->m_outputBuffer, this->getWidth(), this->m_datatype); } void OutputSingleLayerOperation::deinitExecution() @@ -183,10 +183,10 @@ void OutputOpenExrMultiLayerOperation::initExecution() } } -void OutputOpenExrMultiLayerOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers) +void OutputOpenExrMultiLayerOperation::executeRegion(rcti *rect, unsigned int tileNumber) { for (unsigned int i = 0; i < this->m_layers.size(); ++i) { - write_buffer_rect(rect, memoryBuffers, this->m_tree, this->m_layers[i].imageInput, this->m_layers[i].outputBuffer, this->getWidth(), this->m_layers[i].datatype); + write_buffer_rect(rect, this->m_tree, this->m_layers[i].imageInput, this->m_layers[i].outputBuffer, this->getWidth(), this->m_layers[i].datatype); } } diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.h b/source/blender/compositor/operations/COM_OutputFileOperation.h index 60244a8bf72..0d6e5bfa61a 100644 --- a/source/blender/compositor/operations/COM_OutputFileOperation.h +++ b/source/blender/compositor/operations/COM_OutputFileOperation.h @@ -45,7 +45,7 @@ private: public: OutputSingleLayerOperation(const RenderData *rd, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path); - void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers); + void executeRegion(rcti *rect, unsigned int tileNumber); bool isOutputOperation(bool rendering) const { return true; } void initExecution(); void deinitExecution(); @@ -79,7 +79,7 @@ public: void add_layer(const char *name, DataType datatype); - void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers); + void executeRegion(rcti *rect, unsigned int tileNumber); bool isOutputOperation(bool rendering) const { return true; } void initExecution(); void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_PreviewOperation.cpp b/source/blender/compositor/operations/COM_PreviewOperation.cpp index 55e94568688..80cb6f6801c 100644 --- a/source/blender/compositor/operations/COM_PreviewOperation.cpp +++ b/source/blender/compositor/operations/COM_PreviewOperation.cpp @@ -79,7 +79,7 @@ void PreviewOperation::deinitExecution() this->m_input = NULL; } -void PreviewOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers) +void PreviewOperation::executeRegion(rcti *rect, unsigned int tileNumber) { int offset; float color[4]; @@ -93,7 +93,7 @@ void PreviewOperation::executeRegion(rcti *rect, unsigned int tileNumber, Memory color[1] = 0.0f; color[2] = 0.0f; color[3] = 1.0f; - this->m_input->read(color, rx, ry, COM_PS_NEAREST, memoryBuffers); + this->m_input->read(color, rx, ry, COM_PS_NEAREST, NULL); linearrgb_to_srgb_v4(color, color); F4TOCHAR4(color, this->m_outputBuffer + offset); offset += 4; diff --git a/source/blender/compositor/operations/COM_PreviewOperation.h b/source/blender/compositor/operations/COM_PreviewOperation.h index e7b8ba55ae0..7183ea64fff 100644 --- a/source/blender/compositor/operations/COM_PreviewOperation.h +++ b/source/blender/compositor/operations/COM_PreviewOperation.h @@ -44,7 +44,7 @@ public: void deinitExecution(); const CompositorPriority getRenderPriority() const; - void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers); + void executeRegion(rcti *rect, unsigned int tileNumber); void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]); void setbNode(bNode *node) { this->m_node = node; } bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); diff --git a/source/blender/compositor/operations/COM_ReadBufferOperation.cpp b/source/blender/compositor/operations/COM_ReadBufferOperation.cpp index 76e6921503e..882d302656d 100644 --- a/source/blender/compositor/operations/COM_ReadBufferOperation.cpp +++ b/source/blender/compositor/operations/COM_ReadBufferOperation.cpp @@ -28,11 +28,12 @@ ReadBufferOperation::ReadBufferOperation() : NodeOperation() { this->addOutputSocket(COM_DT_COLOR); this->m_offset = 0; + this->m_buffer = NULL; } void *ReadBufferOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { - return getInputMemoryBuffer(memoryBuffers); + return m_buffer; } void ReadBufferOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) @@ -50,30 +51,17 @@ void ReadBufferOperation::determineResolution(unsigned int resolution[], unsigne } void ReadBufferOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - if (inputBuffers) { - MemoryBuffer *inputBuffer = inputBuffers[this->m_offset]; - if (inputBuffer) { - if (sampler == COM_PS_NEAREST) { - inputBuffer->read(color, x, y); - } - else { - inputBuffer->readCubic(color, x, y); - } - } - } else { - color[0] = 0.0f; - color[1] = 0.0f; - color[2] = 0.0f; - color[3] = 0.0f; + if (sampler == COM_PS_NEAREST) { + m_buffer->read(color, x, y); + } + else { + m_buffer->readCubic(color, x, y); } } void ReadBufferOperation::executePixel(float *color, float x, float y, float dx, float dy, MemoryBuffer *inputBuffers[]) { - MemoryBuffer *inputBuffer = inputBuffers[this->m_offset]; - if (inputBuffer) { - inputBuffer->readEWA(color, x, y, dx, dy); - } + m_buffer->readEWA(color, x, y, dx, dy); } bool ReadBufferOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) @@ -93,3 +81,9 @@ void ReadBufferOperation::readResolutionFromWriteBuffer() this->setHeight(operation->getHeight()); } } + +void ReadBufferOperation::updateMemoryBuffer() +{ + this->m_buffer = this->getMemoryProxy()->getBuffer(); + +} diff --git a/source/blender/compositor/operations/COM_ReadBufferOperation.h b/source/blender/compositor/operations/COM_ReadBufferOperation.h index de0c69c0ecc..32f2a631552 100644 --- a/source/blender/compositor/operations/COM_ReadBufferOperation.h +++ b/source/blender/compositor/operations/COM_ReadBufferOperation.h @@ -30,6 +30,7 @@ class ReadBufferOperation : public NodeOperation { private: MemoryProxy *m_memoryProxy; unsigned int m_offset; + MemoryBuffer *m_buffer; public: ReadBufferOperation(); int isBufferOperation() { return true; } @@ -46,6 +47,7 @@ public: bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); MemoryBuffer *getInputMemoryBuffer(MemoryBuffer **memoryBuffers) { return memoryBuffers[this->m_offset]; } void readResolutionFromWriteBuffer(); + void updateMemoryBuffer(); }; #endif diff --git a/source/blender/compositor/operations/COM_SplitViewerOperation.cpp b/source/blender/compositor/operations/COM_SplitViewerOperation.cpp index 00f854b2ba9..6236a666260 100644 --- a/source/blender/compositor/operations/COM_SplitViewerOperation.cpp +++ b/source/blender/compositor/operations/COM_SplitViewerOperation.cpp @@ -60,7 +60,7 @@ void SplitViewerOperation::deinitExecution() } -void SplitViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers) +void SplitViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber) { float *buffer = this->m_outputBuffer; unsigned char *bufferDisplay = this->m_outputBufferDisplay; @@ -80,10 +80,10 @@ void SplitViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me float srgb[4]; image1 = this->m_xSplit ? x > perc : y > perc; if (image1) { - this->m_image1Input->read(&(buffer[offset]), x, y, COM_PS_NEAREST, memoryBuffers); + this->m_image1Input->read(&(buffer[offset]), x, y, COM_PS_NEAREST, NULL); } else { - this->m_image2Input->read(&(buffer[offset]), x, y, COM_PS_NEAREST, memoryBuffers); + this->m_image2Input->read(&(buffer[offset]), x, y, COM_PS_NEAREST, NULL); } /// @todo: linear conversion only when scene color management is selected, also check predivide. if (this->m_doColorManagement) { diff --git a/source/blender/compositor/operations/COM_SplitViewerOperation.h b/source/blender/compositor/operations/COM_SplitViewerOperation.h index 92275606105..c759e14e1dd 100644 --- a/source/blender/compositor/operations/COM_SplitViewerOperation.h +++ b/source/blender/compositor/operations/COM_SplitViewerOperation.h @@ -35,7 +35,7 @@ private: bool m_xSplit; public: SplitViewerOperation(); - void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers); + void executeRegion(rcti *rect, unsigned int tileNumber); void initExecution(); void deinitExecution(); void setSplitPercentage(float splitPercentage) { this->m_splitPercentage = splitPercentage; } diff --git a/source/blender/compositor/operations/COM_ViewerOperation.cpp b/source/blender/compositor/operations/COM_ViewerOperation.cpp index 9278ddd6ead..fdf9c49b112 100644 --- a/source/blender/compositor/operations/COM_ViewerOperation.cpp +++ b/source/blender/compositor/operations/COM_ViewerOperation.cpp @@ -64,7 +64,7 @@ void ViewerOperation::deinitExecution() } -void ViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers) +void ViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber) { float *buffer = this->m_outputBuffer; unsigned char *bufferDisplay = this->m_outputBufferDisplay; @@ -82,9 +82,9 @@ void ViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryB for (y = y1; y < y2 && (!breaked); y++) { for (x = x1; x < x2; x++) { - this->m_imageInput->read(&(buffer[offset]), x, y, COM_PS_NEAREST, memoryBuffers); + this->m_imageInput->read(&(buffer[offset]), x, y, COM_PS_NEAREST, NULL); if (this->m_alphaInput != NULL) { - this->m_alphaInput->read(alpha, x, y, COM_PS_NEAREST, memoryBuffers); + this->m_alphaInput->read(alpha, x, y, COM_PS_NEAREST, NULL); buffer[offset + 3] = alpha[0]; } /// @todo: linear conversion only when scene color management is selected, also check predivide. diff --git a/source/blender/compositor/operations/COM_ViewerOperation.h b/source/blender/compositor/operations/COM_ViewerOperation.h index fd83c3957f1..d900d8db408 100644 --- a/source/blender/compositor/operations/COM_ViewerOperation.h +++ b/source/blender/compositor/operations/COM_ViewerOperation.h @@ -34,7 +34,7 @@ private: public: ViewerOperation(); - void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers); + void executeRegion(rcti *rect, unsigned int tileNumber); void initExecution(); void deinitExecution(); }; diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp index 8decb73615b..17e51bf08f2 100644 --- a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp +++ b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp @@ -57,13 +57,12 @@ void WriteBufferOperation::deinitExecution() this->m_memoryProxy->free(); } -void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers) +void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber) { - //MemoryBuffer *memoryBuffer = MemoryManager::getMemoryBuffer(this->getMemoryProxy(), tileNumber); MemoryBuffer *memoryBuffer = this->m_memoryProxy->getBuffer(); float *buffer = memoryBuffer->getBuffer(); if (this->m_input->isComplex()) { - void *data = this->m_input->initializeTileData(rect, memoryBuffers); + void *data = this->m_input->initializeTileData(rect, NULL); int x1 = rect->xmin; int y1 = rect->ymin; int x2 = rect->xmax; @@ -74,7 +73,7 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me for (y = y1; y < y2 && (!breaked); y++) { int offset4 = (y * memoryBuffer->getWidth() + x1) * COM_NUMBER_OF_CHANNELS; for (x = x1; x < x2; x++) { - this->m_input->read(&(buffer[offset4]), x, y, memoryBuffers, data); + this->m_input->read(&(buffer[offset4]), x, y, NULL, data); offset4 += COM_NUMBER_OF_CHANNELS; } @@ -84,7 +83,7 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me } if (data) { - this->m_input->deinitializeTileData(rect, memoryBuffers, data); + this->m_input->deinitializeTileData(rect, NULL, data); data = NULL; } } @@ -100,7 +99,7 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me for (y = y1; y < y2 && (!breaked); y++) { int offset4 = (y * memoryBuffer->getWidth() + x1) * COM_NUMBER_OF_CHANNELS; for (x = x1; x < x2; x++) { - this->m_input->read(&(buffer[offset4]), x, y, COM_PS_NEAREST, memoryBuffers); + this->m_input->read(&(buffer[offset4]), x, y, COM_PS_NEAREST, NULL); offset4 += COM_NUMBER_OF_CHANNELS; } if (isBreaked()) { diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.h b/source/blender/compositor/operations/COM_WriteBufferOperation.h index d77814a9dc4..0e0dc279c2c 100644 --- a/source/blender/compositor/operations/COM_WriteBufferOperation.h +++ b/source/blender/compositor/operations/COM_WriteBufferOperation.h @@ -41,7 +41,7 @@ public: void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); const bool isWriteBufferOperation() const { return true; } - void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers); + void executeRegion(rcti *rect, unsigned int tileNumber); void initExecution(); void deinitExecution(); void executeOpenCLRegion(OpenCLDevice* device, rcti *rect, unsigned int chunkNumber, MemoryBuffer **memoryBuffers, MemoryBuffer *outputBuffer); From 70ccdc6daa5619a4080ce2fe89c0f088fe54b80c Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 11 Jul 2012 11:31:14 +0000 Subject: [PATCH 03/27] Style cleanup --- source/blender/blenkernel/intern/depsgraph.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 1092f877283..31621dffdef 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -365,10 +365,10 @@ static void dag_add_material_nodetree_driver_relations(DagForest *dag, DagNode * /* nodetree's nodes... */ for (n = ntree->nodes.first; n; n = n->next) { if (n->id && GS(n->id->name) == ID_MA) { - ma = (Material *)n->id; - if (ma != rootma) { - dag_add_material_driver_relations(dag, node, ma); - } + ma = (Material *)n->id; + if (ma != rootma) { + dag_add_material_driver_relations(dag, node, ma); + } } else if (n->type == NODE_GROUP && n->id) { dag_add_material_nodetree_driver_relations(dag, node, (bNodeTree *)n->id, rootma); From 7620c2755442003470230c540c2389dd545b23e8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 11 Jul 2012 12:35:50 +0000 Subject: [PATCH 04/27] missed this change from patch [#30274] --- source/blender/editors/space_text/text_ops.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index f0275fb6584..1eba2deed96 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -2928,8 +2928,11 @@ static int text_insert_invoke(bContext *C, wmOperator *op, wmEvent *event) // if (!RNA_struct_property_is_set(op->ptr, "text")) { /* always set from keymap XXX */ if (!RNA_string_length(op->ptr, "text")) { - /* if alt/ctrl/super are pressed pass through */ - if (event->ctrl || event->oskey) { + /* if alt/ctrl/super are pressed pass through except for utf8 character event + * (when input method are used for utf8 inputs, the user may assign key event + * including alt/ctrl/super like ctrl+m to commit utf8 string. in such case, + * the modifiers in the utf8 character event make no sense.) */ + if ((event->ctrl || event->oskey) && !event->utf8_buf[0]) { return OPERATOR_PASS_THROUGH; } else { From 81829f5221f24e72658fe89f52cbee73c37fe6f3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 11 Jul 2012 12:42:02 +0000 Subject: [PATCH 05/27] code cleanup: use const for passing vectors --- source/blender/blenlib/BLI_kdopbvh.h | 2 +- source/blender/blenlib/intern/BLI_kdopbvh.c | 4 ++-- source/blender/editors/sculpt_paint/paint_image.c | 10 +++++++--- source/blender/ikplugin/intern/itasc_plugin.cpp | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/source/blender/blenlib/BLI_kdopbvh.h b/source/blender/blenlib/BLI_kdopbvh.h index 5ec8247c03a..a2957b32824 100644 --- a/source/blender/blenlib/BLI_kdopbvh.h +++ b/source/blender/blenlib/BLI_kdopbvh.h @@ -104,7 +104,7 @@ int BLI_bvhtree_find_nearest(BVHTree *tree, const float co[3], BVHTreeNearest *n int BLI_bvhtree_ray_cast(BVHTree *tree, const float co[3], const float *dir, float radius, BVHTreeRayHit *hit, BVHTree_RayCastCallback callback, void *userdata); -float BLI_bvhtree_bb_raycast(float *bv, const float light_start[3], const float light_end[3], float pos[3]); +float BLI_bvhtree_bb_raycast(const float *bv, const float light_start[3], const float light_end[3], float pos[3]); /* range query */ int BLI_bvhtree_range_query(BVHTree *tree, const float co[3], float radius, BVHTree_RangeQuery callback, void *userdata); diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c index d07f19e78e0..a5b5065e023 100644 --- a/source/blender/blenlib/intern/BLI_kdopbvh.c +++ b/source/blender/blenlib/intern/BLI_kdopbvh.c @@ -1343,7 +1343,7 @@ int BLI_bvhtree_find_nearest(BVHTree *tree, const float co[3], BVHTreeNearest *n /* Determines the distance that the ray must travel to hit the bounding volume of the given node */ -static float ray_nearest_hit(BVHRayCastData *data, float *bv) +static float ray_nearest_hit(BVHRayCastData *data, const float *bv) { int i; @@ -1521,7 +1521,7 @@ int BLI_bvhtree_ray_cast(BVHTree *tree, const float co[3], const float dir[3], f return data.hit.index; } -float BLI_bvhtree_bb_raycast(float *bv, const float light_start[3], const float light_end[3], float pos[3]) +float BLI_bvhtree_bb_raycast(const float *bv, const float light_start[3], const float light_end[3], float pos[3]) { BVHRayCastData data; float dist = 0.0; diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index f6c17c97758..70a2ff9e0bc 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -583,7 +583,7 @@ static int project_bucket_offset_safe(const ProjPaintState *ps, const float proj } /* still use 2D X,Y space but this works for verts transformed by a perspective matrix, using their 4th component as a weight */ -static void barycentric_weights_v2_persp(float v1[4], float v2[4], float v3[4], float co[2], float w[3]) +static void barycentric_weights_v2_persp(const float v1[4], const float v2[4], const float v3[4], const float co[2], float w[3]) { float wtot_inv, wtot; @@ -603,13 +603,17 @@ static void barycentric_weights_v2_persp(float v1[4], float v2[4], float v3[4], w[0] = w[1] = w[2] = 1.0f / 3.0f; } -static float VecZDepthOrtho(float pt[2], float v1[3], float v2[3], float v3[3], float w[3]) +static float VecZDepthOrtho(const float pt[2], + const float v1[3], const float v2[3], const float v3[3], + float w[3]) { barycentric_weights_v2(v1, v2, v3, pt, w); return (v1[2] * w[0]) + (v2[2] * w[1]) + (v3[2] * w[2]); } -static float VecZDepthPersp(float pt[2], float v1[4], float v2[4], float v3[4], float w[3]) +static float VecZDepthPersp(const float pt[2], + const float v1[4], const float v2[4], const float v3[4], + float w[3]) { float wtot_inv, wtot; float w_tmp[3]; diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp index a0d7bfbaaf6..652b16a7c65 100644 --- a/source/blender/ikplugin/intern/itasc_plugin.cpp +++ b/source/blender/ikplugin/intern/itasc_plugin.cpp @@ -1618,7 +1618,7 @@ static void execute_scene(Scene *blscene, IK_Scene *ikscene, bItasc *ikparam, fl timestep = sts / 1000.0; } } - // don't cache if we are reiterating because we don't want to distroy the cache unnecessarily + // don't cache if we are reiterating because we don't want to destroy the cache unnecessarily ikscene->scene->update(timestamp, timestep, numstep, false, !reiterate, simulation); if (reiterate) { // how many times do we reiterate? From a87051bd8ee06166ba3878a92ba63ec4d1f1ff27 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 11 Jul 2012 14:48:47 +0000 Subject: [PATCH 06/27] Patch #32074: Fix compilation with boost 1.50 This patch switches from boost's filesystem v2 to v3. This should be completely smooth due to filesystem v3 is pretty old already. Patch by Sven-Hendrik Haase (aka svenstaro), thanks! --- intern/cycles/util/util_cache.cpp | 4 +--- intern/cycles/util/util_path.cpp | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/intern/cycles/util/util_cache.cpp b/intern/cycles/util/util_cache.cpp index 44d784ba741..2924ed30b88 100644 --- a/intern/cycles/util/util_cache.cpp +++ b/intern/cycles/util/util_cache.cpp @@ -26,8 +26,6 @@ #include "util_path.h" #include "util_types.h" -#define BOOST_FILESYSTEM_VERSION 2 - #include #include @@ -117,7 +115,7 @@ void Cache::clear_except(const string& name, const set& except) boost::filesystem::directory_iterator it(dir), it_end; for(; it != it_end; it++) { - string filename = it->path().filename(); + string filename = it->path().filename().string(); if(boost::starts_with(filename, name)) if(except.find(filename) == except.end()) diff --git a/intern/cycles/util/util_path.cpp b/intern/cycles/util/util_path.cpp index 717aa34c426..53dbfe9a42c 100644 --- a/intern/cycles/util/util_path.cpp +++ b/intern/cycles/util/util_path.cpp @@ -26,8 +26,6 @@ OIIO_NAMESPACE_USING #include -#define BOOST_FILESYSTEM_VERSION 2 - #include #include @@ -60,7 +58,7 @@ string path_user_get(const string& sub) string path_filename(const string& path) { - return boost::filesystem::path(path).filename(); + return boost::filesystem::path(path).filename().string(); } string path_dirname(const string& path) From 2070cd5d4929b969046492e55da34736a9d6304c Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Wed, 11 Jul 2012 16:08:04 +0000 Subject: [PATCH 07/27] Fix #32058, Crash when using ParticleInstance with an hidden particle system. The instance modifier needs to access the derived mesh data of the particle parent object to create stuff on the hairs, however the dm does not exist when the particle modifier is hidden. This is a general design problem: Objects accessing another object's derived mesh data is unsafe. For now it just checks valid dm pointer and uses identity transform if NULL. --- source/blender/blenkernel/intern/particle.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index dcd1a797a7a..c8b07e2ec11 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3400,6 +3400,12 @@ void psys_mat_hair_to_object(Object *UNUSED(ob), DerivedMesh *dm, short from, Pa { float vec[3]; + /* can happen when called from a different object's modifier */ + if (!dm) { + unit_m4(hairmat); + return; + } + psys_face_mat(0, dm, pa, hairmat, 0); psys_particle_on_dm(dm, from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, vec, 0, 0, 0, 0, 0); copy_v3_v3(hairmat[3], vec); From a5127dba57490e0c0215e9cabfac1749585c53d1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 11 Jul 2012 18:17:48 +0000 Subject: [PATCH 08/27] vector versions of BLI_in_rctf / BLI_in_rcti, (BLI_in_rctf_v, BLI_in_rcti_v) use where possible. --- source/blender/blenkernel/intern/displist.c | 6 +-- source/blender/blenlib/BLI_rect.h | 28 ++++++----- source/blender/blenlib/BLI_scanfill.h | 3 +- source/blender/blenlib/intern/rct.c | 50 +++++++++++++------ .../editors/animation/keyframes_edit.c | 2 +- .../editors/interface/interface_panel.c | 2 +- source/blender/editors/mask/mask_select.c | 2 +- source/blender/editors/screen/screen_edit.c | 8 +-- source/blender/editors/screen/screen_intern.h | 2 +- source/blender/editors/screen/screen_ops.c | 8 +-- .../editors/sculpt_paint/paint_image.c | 18 +++---- .../editors/space_clip/tracking_select.c | 2 +- .../editors/space_view3d/view3d_select.c | 4 +- source/blender/editors/uvedit/uvedit_ops.c | 12 ++--- source/blender/render/intern/source/shadbuf.c | 2 +- .../windowmanager/intern/wm_event_system.c | 38 +++++++------- .../blender/windowmanager/intern/wm_gesture.c | 2 +- 17 files changed, 104 insertions(+), 85 deletions(-) diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 6e5d6ffb0e9..9b349598db1 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -499,16 +499,14 @@ void BKE_displist_fill(ListBase *dispbase, ListBase *to, int flipnormal) /* vert data */ f1 = dlnew->verts; totvert = 0; - sf_vert = sf_ctx.fillvertbase.first; - while (sf_vert) { + + for (sf_vert = sf_ctx.fillvertbase.first; sf_vert; sf_vert = sf_vert->next) { copy_v3_v3(f1, sf_vert->co); f1 += 3; /* index number */ sf_vert->tmp.l = totvert; totvert++; - - sf_vert = sf_vert->next; } /* index data */ diff --git a/source/blender/blenlib/BLI_rect.h b/source/blender/blenlib/BLI_rect.h index 0cf32eeb276..4d0e54e344c 100644 --- a/source/blender/blenlib/BLI_rect.h +++ b/source/blender/blenlib/BLI_rect.h @@ -48,26 +48,30 @@ extern "C" { * * \return True if \a rect is empty. */ -int BLI_rcti_is_empty(struct rcti *rect); -int BLI_rctf_is_empty(struct rctf *rect); +int BLI_rcti_is_empty(const struct rcti *rect); +int BLI_rctf_is_empty(const struct rctf *rect); void BLI_init_rctf(struct rctf *rect, float xmin, float xmax, float ymin, float ymax); void BLI_init_rcti(struct rcti *rect, int xmin, int xmax, int ymin, int ymax); void BLI_translate_rctf(struct rctf *rect, float x, float y); void BLI_translate_rcti(struct rcti *rect, int x, int y); void BLI_resize_rcti(struct rcti *rect, int x, int y); void BLI_resize_rctf(struct rctf *rect, float x, float y); -int BLI_in_rcti(struct rcti *rect, int x, int y); -int BLI_in_rctf(struct rctf *rect, float x, float y); -int BLI_segment_in_rcti(struct rcti *rect, int s1[2], int s2[2]); -// int BLI_segment_in_rctf(struct rcti *rect, int s1[2], int s2[2]); // NOT NEEDED YET -int BLI_isect_rctf(struct rctf *src1, struct rctf *src2, struct rctf *dest); -int BLI_isect_rcti(struct rcti *src1, struct rcti *src2, struct rcti *dest); -void BLI_union_rctf(struct rctf *rcta, struct rctf *rctb); -void BLI_union_rcti(struct rcti *rcti1, struct rcti *rcti2); +int BLI_in_rcti(const struct rcti *rect, const int x, const int y); +int BLI_in_rcti_v(const struct rcti *rect, const int xy[2]); +int BLI_in_rctf(const struct rctf *rect, const float x, const float y); +int BLI_in_rctf_v(const struct rctf *rect, const float xy[2]); +int BLI_segment_in_rcti(const struct rcti *rect, const int s1[2], const int s2[2]); +#if 0 /* NOT NEEDED YET */ +int BLI_segment_in_rctf(struct rcti *rect, int s1[2], int s2[2]); +#endif +int BLI_isect_rctf(const struct rctf *src1, const struct rctf *src2, struct rctf *dest); +int BLI_isect_rcti(const struct rcti *src1, const struct rcti *src2, struct rcti *dest); +void BLI_union_rctf(struct rctf *rctf1, const struct rctf *rctf2); +void BLI_union_rcti(struct rcti *rcti1, const struct rcti *rcti2); void BLI_copy_rcti_rctf(struct rcti *tar, const struct rctf *src); -void print_rctf(const char *str, struct rctf *rect); -void print_rcti(const char *str, struct rcti *rect); +void print_rctf(const char *str, const struct rctf *rect); +void print_rcti(const char *str, const struct rcti *rect); #ifdef __cplusplus } diff --git a/source/blender/blenlib/BLI_scanfill.h b/source/blender/blenlib/BLI_scanfill.h index ceef378358b..cb996119fff 100644 --- a/source/blender/blenlib/BLI_scanfill.h +++ b/source/blender/blenlib/BLI_scanfill.h @@ -65,7 +65,8 @@ typedef struct ScanFillVert { union { struct ScanFillVert *v; void *p; - intptr_t l; + intptr_t l; + unsigned int u; } tmp; float co[3]; /* vertex location */ float xy[2]; /* 2D copy of vertex location (using dominant axis) */ diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c index b36c3c717c0..b4397ea4546 100644 --- a/source/blender/blenlib/intern/rct.c +++ b/source/blender/blenlib/intern/rct.c @@ -38,17 +38,17 @@ #include "DNA_vec_types.h" #include "BLI_rect.h" -int BLI_rcti_is_empty(rcti *rect) +int BLI_rcti_is_empty(const rcti *rect) { return ((rect->xmax <= rect->xmin) || (rect->ymax <= rect->ymin)); } -int BLI_rctf_is_empty(rctf *rect) +int BLI_rctf_is_empty(const rctf *rect) { return ((rect->xmax <= rect->xmin) || (rect->ymax <= rect->ymin)); } -int BLI_in_rcti(rcti *rect, int x, int y) +int BLI_in_rcti(const rcti *rect, const int x, const int y) { if (x < rect->xmin) return 0; if (x > rect->xmax) return 0; @@ -57,7 +57,16 @@ int BLI_in_rcti(rcti *rect, int x, int y) return 1; } -int BLI_in_rctf(rctf *rect, float x, float y) +int BLI_in_rcti_v(const rcti *rect, const int xy[2]) +{ + if (xy[0] < rect->xmin) return 0; + if (xy[0] > rect->xmax) return 0; + if (xy[1] < rect->ymin) return 0; + if (xy[1] > rect->ymax) return 0; + return 1; +} + +int BLI_in_rctf(const rctf *rect, const float x, const float y) { if (x < rect->xmin) return 0; if (x > rect->xmax) return 0; @@ -66,6 +75,15 @@ int BLI_in_rctf(rctf *rect, float x, float y) return 1; } +int BLI_in_rctf_v(const rctf *rect, const float xy[2]) +{ + if (xy[0] < rect->xmin) return 0; + if (xy[0] > rect->xmax) return 0; + if (xy[1] < rect->ymin) return 0; + if (xy[1] > rect->ymax) return 0; + return 1; +} + /* based closely on 'isect_line_line_v2_int', but in modified so corner cases are treated as intersections */ static int isect_segments(const int v1[2], const int v2[2], const int v3[2], const int v4[2]) { @@ -80,7 +98,7 @@ static int isect_segments(const int v1[2], const int v2[2], const int v3[2], con } } -int BLI_segment_in_rcti(rcti *rect, int s1[2], int s2[2]) +int BLI_segment_in_rcti(const rcti *rect, const int s1[2], const int s2[2]) { /* first do outside-bounds check for both points of the segment */ if (s1[0] < rect->xmin && s2[0] < rect->xmin) return 0; @@ -89,7 +107,7 @@ int BLI_segment_in_rcti(rcti *rect, int s1[2], int s2[2]) if (s1[1] > rect->ymax && s2[1] > rect->ymax) return 0; /* if either points intersect then we definetly intersect */ - if (BLI_in_rcti(rect, s1[0], s1[1]) || BLI_in_rcti(rect, s2[0], s2[1])) { + if (BLI_in_rcti_v(rect, s1) || BLI_in_rcti_v(rect, s2)) { return 1; } else { @@ -115,7 +133,7 @@ int BLI_segment_in_rcti(rcti *rect, int s1[2], int s2[2]) } } -void BLI_union_rctf(rctf *rct1, rctf *rct2) +void BLI_union_rctf(rctf *rct1, const rctf *rct2) { if (rct1->xmin > rct2->xmin) rct1->xmin = rct2->xmin; if (rct1->xmax < rct2->xmax) rct1->xmax = rct2->xmax; @@ -123,7 +141,7 @@ void BLI_union_rctf(rctf *rct1, rctf *rct2) if (rct1->ymax < rct2->ymax) rct1->ymax = rct2->ymax; } -void BLI_union_rcti(rcti *rct1, rcti *rct2) +void BLI_union_rcti(rcti *rct1, const rcti *rct2) { if (rct1->xmin > rct2->xmin) rct1->xmin = rct2->xmin; if (rct1->xmax < rct2->xmax) rct1->xmax = rct2->xmax; @@ -207,7 +225,7 @@ void BLI_resize_rctf(rctf *rect, float x, float y) rect->ymax = rect->ymin + y; } -int BLI_isect_rctf(rctf *src1, rctf *src2, rctf *dest) +int BLI_isect_rctf(const rctf *src1, const rctf *src2, rctf *dest) { float xmin, xmax; float ymin, ymax; @@ -237,7 +255,7 @@ int BLI_isect_rctf(rctf *src1, rctf *src2, rctf *dest) } } -int BLI_isect_rcti(rcti *src1, rcti *src2, rcti *dest) +int BLI_isect_rcti(const rcti *src1, const rcti *src2, rcti *dest) { int xmin, xmax; int ymin, ymax; @@ -269,19 +287,19 @@ int BLI_isect_rcti(rcti *src1, rcti *src2, rcti *dest) void BLI_copy_rcti_rctf(rcti *tar, const rctf *src) { - tar->xmin = floor(src->xmin + 0.5f); - tar->xmax = floor((src->xmax - src->xmin) + 0.5f); - tar->ymin = floor(src->ymin + 0.5f); - tar->ymax = floor((src->ymax - src->ymin) + 0.5f); + tar->xmin = floorf(src->xmin + 0.5f); + tar->xmax = floorf((src->xmax - src->xmin) + 0.5f); + tar->ymin = floorf(src->ymin + 0.5f); + tar->ymax = floorf((src->ymax - src->ymin) + 0.5f); } -void print_rctf(const char *str, rctf *rect) +void print_rctf(const char *str, const rctf *rect) { printf("%s: xmin %.3f, xmax %.3f, ymin %.3f, ymax %.3f (%.3fx%.3f)\n", str, rect->xmin, rect->xmax, rect->ymin, rect->ymax, rect->xmax - rect->xmin, rect->ymax - rect->ymin); } -void print_rcti(const char *str, rcti *rect) +void print_rcti(const char *str, const rcti *rect) { printf("%s: xmin %d, xmax %d, ymin %d, ymax %d (%dx%d)\n", str, rect->xmin, rect->xmax, rect->ymin, rect->ymax, rect->xmax - rect->xmin, rect->ymax - rect->ymin); diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c index 88627a6dabd..78ac729f16e 100644 --- a/source/blender/editors/animation/keyframes_edit.c +++ b/source/blender/editors/animation/keyframes_edit.c @@ -505,7 +505,7 @@ static short ok_bezier_region(KeyframeEditData *ked, BezTriple *bezt) if (ked->data) { short ok = 0; - #define KEY_CHECK_OK(_index) BLI_in_rctf(ked->data, bezt->vec[_index][0], bezt->vec[_index][1]) + #define KEY_CHECK_OK(_index) BLI_in_rctf_v(ked->data, bezt->vec[_index]) KEYFRAME_OK_CHECKS(KEY_CHECK_OK); #undef KEY_CHECK_OK diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 7f9a998e6d0..76485571096 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -978,7 +978,7 @@ static void ui_do_drag(const bContext *C, wmEvent *event, Panel *panel) short align = panel_aligned(sa, ar), dx = 0, dy = 0; /* first clip for window, no dragging outside */ - if (!BLI_in_rcti(&ar->winrct, event->x, event->y)) + if (!BLI_in_rcti_v(&ar->winrct, &event->x)) return; dx = (event->x - data->startx) & ~(PNL_GRID - 1); diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c index e619277456e..a2a7a07d089 100644 --- a/source/blender/editors/mask/mask_select.c +++ b/source/blender/editors/mask/mask_select.c @@ -418,7 +418,7 @@ static int border_select_exec(bContext *C, wmOperator *op) /* TODO: handles? */ /* TODO: uw? */ - if (BLI_in_rctf(&rectf, point_deform->bezt.vec[1][0], point_deform->bezt.vec[1][1])) { + if (BLI_in_rctf_v(&rectf, point_deform->bezt.vec[1])) { BKE_mask_point_select_set(point, mode == GESTURE_MODAL_SELECT); BKE_mask_point_select_set_handle(point, mode == GESTURE_MODAL_SELECT); } diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index a638aac9423..48532c83e4c 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -1219,7 +1219,7 @@ static void screen_cursor_set(wmWindow *win, wmEvent *event) ScrArea *sa; for (sa = win->screen->areabase.first; sa; sa = sa->next) - if ((az = is_in_area_actionzone(sa, event->x, event->y))) + if ((az = is_in_area_actionzone(sa, &event->x))) break; if (sa) { @@ -1262,12 +1262,12 @@ void ED_screen_set_subwinactive(bContext *C, wmEvent *event) for (sa = scr->areabase.first; sa; sa = sa->next) { if (event->x > sa->totrct.xmin && event->x < sa->totrct.xmax) if (event->y > sa->totrct.ymin && event->y < sa->totrct.ymax) - if (NULL == is_in_area_actionzone(sa, event->x, event->y)) + if (NULL == is_in_area_actionzone(sa, &event->x)) break; } if (sa) { for (ar = sa->regionbase.first; ar; ar = ar->next) { - if (BLI_in_rcti(&ar->winrct, event->x, event->y)) + if (BLI_in_rcti_v(&ar->winrct, &event->x)) scr->subwinactive = ar->swinid; } } @@ -1314,7 +1314,7 @@ int ED_screen_area_active(const bContext *C) ScrArea *sa = CTX_wm_area(C); if (win && sc && sa) { - AZone *az = is_in_area_actionzone(sa, win->eventstate->x, win->eventstate->y); + AZone *az = is_in_area_actionzone(sa, &win->eventstate->x); ARegion *ar; if (az && az->type == AZONE_REGION) diff --git a/source/blender/editors/screen/screen_intern.h b/source/blender/editors/screen/screen_intern.h index aa11c3eecdd..86d99777e98 100644 --- a/source/blender/editors/screen/screen_intern.h +++ b/source/blender/editors/screen/screen_intern.h @@ -54,7 +54,7 @@ void removenotused_scredges(bScreen *sc); int scredge_is_horizontal(ScrEdge *se); ScrEdge *screen_find_active_scredge(bScreen *sc, int mx, int my); -struct AZone *is_in_area_actionzone(ScrArea *sa, int x, int y); +struct AZone *is_in_area_actionzone(ScrArea *sa, const int xy[2]); /* screen_context.c */ int ed_screen_context(const bContext *C, const char *member, bContextDataResult *result); diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 6be276dea14..547e7bc8e5a 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -524,15 +524,15 @@ static int actionzone_area_poll(bContext *C) return 0; } -AZone *is_in_area_actionzone(ScrArea *sa, int x, int y) +AZone *is_in_area_actionzone(ScrArea *sa, const int xy[2]) { AZone *az = NULL; for (az = sa->actionzones.first; az; az = az->next) { - if (BLI_in_rcti(&az->rect, x, y)) { + if (BLI_in_rcti_v(&az->rect, xy)) { if (az->type == AZONE_AREA) { /* no triangle intersect but a hotspot circle based on corner */ - int radius = (x - az->x1) * (x - az->x1) + (y - az->y1) * (y - az->y1); + int radius = (xy[0] - az->x1) * (xy[0] - az->x1) + (xy[1] - az->y1) * (xy[1] - az->y1); if (radius <= AZONESPOT * AZONESPOT) break; @@ -577,7 +577,7 @@ static void actionzone_apply(bContext *C, wmOperator *op, int type) static int actionzone_invoke(bContext *C, wmOperator *op, wmEvent *event) { - AZone *az = is_in_area_actionzone(CTX_wm_area(C), event->x, event->y); + AZone *az = is_in_area_actionzone(CTX_wm_area(C), &event->x); sActionzoneData *sad; /* quick escape */ diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 70a2ff9e0bc..5e46a28a3b7 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -1615,7 +1615,7 @@ static int line_clip_rect2f( if (fabsf(l1[0] - l2[0]) < PROJ_GEOM_TOLERANCE) { /* this is a single point (or close to)*/ - if (BLI_in_rctf(rect, l1[0], l1[1])) { + if (BLI_in_rctf_v(rect, l1)) { copy_v2_v2(l1_clip, l1); copy_v2_v2(l2_clip, l2); return 1; @@ -1643,7 +1643,7 @@ static int line_clip_rect2f( } if (fabsf(l1[1] - l2[1]) < PROJ_GEOM_TOLERANCE) { /* this is a single point (or close to)*/ - if (BLI_in_rctf(rect, l1[0], l1[1])) { + if (BLI_in_rctf_v(rect, l1)) { copy_v2_v2(l1_clip, l1); copy_v2_v2(l2_clip, l2); return 1; @@ -1667,12 +1667,12 @@ static int line_clip_rect2f( /* Done with vertical lines */ /* are either of the points inside the rectangle ? */ - if (BLI_in_rctf(rect, l1[0], l1[1])) { + if (BLI_in_rctf_v(rect, l1)) { copy_v2_v2(l1_clip, l1); ok1 = 1; } - if (BLI_in_rctf(rect, l2[0], l2[1])) { + if (BLI_in_rctf_v(rect, l2)) { copy_v2_v2(l2_clip, l2); ok2 = 1; } @@ -1820,7 +1820,7 @@ static int project_bucket_isect_circle(const float cent[2], const float radius_s * this is even less work then an intersection test */ #if 0 - if (BLI_in_rctf(bucket_bounds, cent[0], cent[1])) + if (BLI_in_rctf_v(bucket_bounds, cent)) return 1; #endif @@ -1987,9 +1987,9 @@ static void project_bucket_clip_face( float bucket_bounds_ss[4][2]; /* get the UV space bounding box */ - inside_bucket_flag |= BLI_in_rctf(bucket_bounds, v1coSS[0], v1coSS[1]); - inside_bucket_flag |= BLI_in_rctf(bucket_bounds, v2coSS[0], v2coSS[1]) << 1; - inside_bucket_flag |= BLI_in_rctf(bucket_bounds, v3coSS[0], v3coSS[1]) << 2; + inside_bucket_flag |= BLI_in_rctf_v(bucket_bounds, v1coSS); + inside_bucket_flag |= BLI_in_rctf_v(bucket_bounds, v2coSS) << 1; + inside_bucket_flag |= BLI_in_rctf_v(bucket_bounds, v3coSS) << 2; if (inside_bucket_flag == ISECT_ALL3) { /* all screenspace points are inside the bucket bounding box, this means we don't need to clip and can simply return the UVs */ @@ -2816,7 +2816,7 @@ static int project_bucket_face_isect(ProjPaintState *ps, int bucket_x, int bucke fidx = mf->v4 ? 3 : 2; do { v = ps->screenCoords[(*(&mf->v1 + fidx))]; - if (BLI_in_rctf(&bucket_bounds, v[0], v[1])) { + if (BLI_in_rctf_v(&bucket_bounds, v)) { return 1; } } while (fidx--); diff --git a/source/blender/editors/space_clip/tracking_select.c b/source/blender/editors/space_clip/tracking_select.c index 0ebb84b3953..0d933c1dff3 100644 --- a/source/blender/editors/space_clip/tracking_select.c +++ b/source/blender/editors/space_clip/tracking_select.c @@ -361,7 +361,7 @@ static int border_select_exec(bContext *C, wmOperator *op) MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr); if (MARKER_VISIBLE(sc, track, marker)) { - if (BLI_in_rctf(&rectf, marker->pos[0], marker->pos[1])) { + if (BLI_in_rctf_v(&rectf, marker->pos)) { if (mode == GESTURE_MODAL_SELECT) BKE_tracking_track_flag_set(track, TRACK_AREA_ALL, SELECT); else diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index f12e7683668..43add69987b 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -758,7 +758,7 @@ static void do_lasso_select_node(int mcords[][2], short moves, short select) bNode *node; rcti rect; - short node_cent[2]; + int node_cent[2]; float node_centf[2]; BLI_lasso_boundbox(&rect, mcords, moves); @@ -770,7 +770,7 @@ static void do_lasso_select_node(int mcords[][2], short moves, short select) node_centf[1] = (node->totr.ymin + node->totr.ymax) / 2; ipoco_to_areaco_noclip(G.v2d, node_centf, node_cent); - if (BLI_in_rcti(&rect, node_cent[0], node_cent[1]) && BLI_lasso_is_point_inside(mcords, moves, node_cent[0], node_cent[1])) { + if (BLI_in_rcti_v(&rect, node_cent) && BLI_lasso_is_point_inside(mcords, moves, node_cent[0], node_cent[1])) { if (select) { node->flag |= SELECT; } diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 05bfc8d4a2e..7ef205b69f0 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -2479,7 +2479,7 @@ static int border_select_exec(bContext *C, wmOperator *op) tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); if (uvedit_face_visible_test(scene, ima, efa, tf)) { uv_poly_center(em, efa, cent); - if (BLI_in_rctf(&rectf, cent[0], cent[1])) { + if (BLI_in_rctf_v(&rectf, cent)) { BM_elem_flag_enable(efa, BM_ELEM_TAG); change = 1; } @@ -2504,15 +2504,13 @@ static int border_select_exec(bContext *C, wmOperator *op) if (!pinned || (ts->uv_flag & UV_SYNC_SELECTION) ) { /* UV_SYNC_SELECTION - can't do pinned selection */ - if (BLI_in_rctf(&rectf, luv->uv[0], luv->uv[1])) { + if (BLI_in_rctf_v(&rectf, luv->uv)) { if (select) uvedit_uv_select_enable(em, scene, l, FALSE); else uvedit_uv_select_disable(em, scene, l); } } else if (pinned) { - if ((luv->flag & MLOOPUV_PINNED) && - BLI_in_rctf(&rectf, luv->uv[0], luv->uv[1])) - { + if ((luv->flag & MLOOPUV_PINNED) && BLI_in_rctf_v(&rectf, luv->uv)) { if (select) uvedit_uv_select_enable(em, scene, l, FALSE); else uvedit_uv_select_disable(em, scene, l); } @@ -2685,7 +2683,7 @@ static int do_lasso_select_mesh_uv(bContext *C, int mcords[][2], short moves, sh float cent[2]; uv_poly_center(em, efa, cent); UI_view2d_view_to_region(&ar->v2d, cent[0], cent[1], &screen_uv[0], &screen_uv[1]); - if (BLI_in_rcti(&rect, screen_uv[0], screen_uv[1]) && + if (BLI_in_rcti_v(&rect, screen_uv) && BLI_lasso_is_point_inside(mcords, moves, screen_uv[0], screen_uv[1], V2D_IS_CLIPPED)) { uvedit_face_select_enable(scene, em, efa, FALSE); @@ -2702,7 +2700,7 @@ static int do_lasso_select_mesh_uv(bContext *C, int mcords[][2], short moves, sh if ((select) != (uvedit_uv_select_test(em, scene, l))) { MLoopUV *luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); UI_view2d_view_to_region(&ar->v2d, luv->uv[0], luv->uv[1], &screen_uv[0], &screen_uv[1]); - if (BLI_in_rcti(&rect, screen_uv[0], screen_uv[1]) && + if (BLI_in_rcti_v(&rect, screen_uv) && BLI_lasso_is_point_inside(mcords, moves, screen_uv[0], screen_uv[1], V2D_IS_CLIPPED)) { if (select) { diff --git a/source/blender/render/intern/source/shadbuf.c b/source/blender/render/intern/source/shadbuf.c index f696f95781b..e13da98ecb4 100644 --- a/source/blender/render/intern/source/shadbuf.c +++ b/source/blender/render/intern/source/shadbuf.c @@ -1824,7 +1824,7 @@ static void isb_bsp_face_inside(ISBBranch *bspn, BSPFace *face) if ((samp->facenr!=face->facenr || samp->obi!=face->obi) && samp->shadfac) { if (face->box.zmin < samp->zco[2]) { - if (BLI_in_rctf((rctf *)&face->box, samp->zco[0], samp->zco[1])) { + if (BLI_in_rctf_v((rctf *)&face->box, samp->zco)) { int inshadow= 0; if (face->type) { diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 9795c482af2..4b762f94d34 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -919,7 +919,7 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, P ScrArea *sa = CTX_wm_area(C); if (ar && ar->regiontype == RGN_TYPE_WINDOW && event && - BLI_in_rcti(&ar->winrct, event->x, event->y)) + BLI_in_rcti_v(&ar->winrct, &event->x)) { winrect = &ar->winrct; } @@ -1638,17 +1638,17 @@ static int handler_boundbox_test(wmEventHandler *handler, wmEvent *event) rcti rect = *handler->bblocal; BLI_translate_rcti(&rect, handler->bbwin->xmin, handler->bbwin->ymin); - if (BLI_in_rcti(&rect, event->x, event->y)) + if (BLI_in_rcti_v(&rect, &event->x)) return 1; - else if (event->type == MOUSEMOVE && BLI_in_rcti(&rect, event->prevx, event->prevy)) + else if (event->type == MOUSEMOVE && BLI_in_rcti_v(&rect, &event->prevx)) return 1; else return 0; } else { - if (BLI_in_rcti(handler->bbwin, event->x, event->y)) + if (BLI_in_rcti_v(handler->bbwin, &event->x)) return 1; - else if (event->type == MOUSEMOVE && BLI_in_rcti(handler->bbwin, event->prevx, event->prevy)) + else if (event->type == MOUSEMOVE && BLI_in_rcti_v(handler->bbwin, &event->prevx)) return 1; else return 0; @@ -1826,10 +1826,10 @@ static int wm_event_inside_i(wmEvent *event, rcti *rect) { if (wm_event_always_pass(event)) return 1; - if (BLI_in_rcti(rect, event->x, event->y)) + if (BLI_in_rcti_v(rect, &event->x)) return 1; if (event->type == MOUSEMOVE) { - if (BLI_in_rcti(rect, event->prevx, event->prevy)) { + if (BLI_in_rcti_v(rect, &event->prevx)) { return 1; } return 0; @@ -1837,19 +1837,19 @@ static int wm_event_inside_i(wmEvent *event, rcti *rect) return 0; } -static ScrArea *area_event_inside(bContext *C, int x, int y) +static ScrArea *area_event_inside(bContext *C, const int xy[2]) { bScreen *screen = CTX_wm_screen(C); ScrArea *sa; if (screen) for (sa = screen->areabase.first; sa; sa = sa->next) - if (BLI_in_rcti(&sa->totrct, x, y)) + if (BLI_in_rcti_v(&sa->totrct, xy)) return sa; return NULL; } -static ARegion *region_event_inside(bContext *C, int x, int y) +static ARegion *region_event_inside(bContext *C, const int xy[2]) { bScreen *screen = CTX_wm_screen(C); ScrArea *area = CTX_wm_area(C); @@ -1857,7 +1857,7 @@ static ARegion *region_event_inside(bContext *C, int x, int y) if (screen && area) for (ar = area->regionbase.first; ar; ar = ar->next) - if (BLI_in_rcti(&ar->winrct, x, y)) + if (BLI_in_rcti_v(&ar->winrct, xy)) return ar; return NULL; } @@ -1888,11 +1888,11 @@ static void wm_paintcursor_test(bContext *C, wmEvent *event) wm_paintcursor_tag(C, wm->paintcursors.first, ar); /* if previous position was not in current region, we have to set a temp new context */ - if (ar == NULL || !BLI_in_rcti(&ar->winrct, event->prevx, event->prevy)) { + if (ar == NULL || !BLI_in_rcti_v(&ar->winrct, &event->prevx)) { ScrArea *sa = CTX_wm_area(C); - CTX_wm_area_set(C, area_event_inside(C, event->prevx, event->prevy)); - CTX_wm_region_set(C, region_event_inside(C, event->prevx, event->prevy)); + CTX_wm_area_set(C, area_event_inside(C, &event->prevx)); + CTX_wm_region_set(C, region_event_inside(C, &event->prevx)); wm_paintcursor_tag(C, wm->paintcursors.first, CTX_wm_region(C)); @@ -2000,8 +2000,8 @@ void wm_event_do_handlers(bContext *C) CTX_wm_window_set(C, win); /* we let modal handlers get active area/region, also wm_paintcursor_test needs it */ - CTX_wm_area_set(C, area_event_inside(C, event->x, event->y)); - CTX_wm_region_set(C, region_event_inside(C, event->x, event->y)); + CTX_wm_area_set(C, area_event_inside(C, &event->x)); + CTX_wm_region_set(C, region_event_inside(C, &event->x)); /* MVC demands to not draw in event handlers... but we need to leave it for ogl selecting etc */ wm_window_make_drawable(C, win); @@ -2061,7 +2061,7 @@ void wm_event_do_handlers(bContext *C) if (CTX_wm_window(C) == NULL) return; - doit |= (BLI_in_rcti(&ar->winrct, event->x, event->y)); + doit |= (BLI_in_rcti_v(&ar->winrct, &event->x)); if (action & WM_HANDLER_BREAK) break; @@ -2083,8 +2083,8 @@ void wm_event_do_handlers(bContext *C) if ((action & WM_HANDLER_BREAK) == 0) { /* also some non-modal handlers need active area/region */ - CTX_wm_area_set(C, area_event_inside(C, event->x, event->y)); - CTX_wm_region_set(C, region_event_inside(C, event->x, event->y)); + CTX_wm_area_set(C, area_event_inside(C, &event->x)); + CTX_wm_region_set(C, region_event_inside(C, &event->x)); wm_region_mouse_co(C, event); diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c index b280b979280..c9f1a2587df 100644 --- a/source/blender/windowmanager/intern/wm_gesture.c +++ b/source/blender/windowmanager/intern/wm_gesture.c @@ -253,7 +253,7 @@ static void draw_filled_lasso(wmGesture *gt) /* highly unlikely this will fail, but could crash if (gt->points == 0) */ if (sf_vert_first) { - float zvec[3] = {0.0f, 0.0f, 1.0f}; + const float zvec[3] = {0.0f, 0.0f, 1.0f}; BLI_scanfill_edge_add(&sf_ctx, sf_vert_first, sf_vert); BLI_scanfill_calc_ex(&sf_ctx, FALSE, zvec); From 5aa2670d4ad3f03aed9a853d4af012bd07453c93 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 11 Jul 2012 18:46:27 +0000 Subject: [PATCH 09/27] Fix mistmatched new[] and dlete used in node highlightion --- source/blender/compositor/intern/COM_WorkScheduler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/compositor/intern/COM_WorkScheduler.cpp b/source/blender/compositor/intern/COM_WorkScheduler.cpp index c7544be1bb4..b10e99697e4 100644 --- a/source/blender/compositor/intern/COM_WorkScheduler.cpp +++ b/source/blender/compositor/intern/COM_WorkScheduler.cpp @@ -94,7 +94,7 @@ void ** g_highlightedNodesRead; } void COM_startReadHighlights() { if (g_highlightedNodesRead) { - delete g_highlightedNodesRead; + delete [] g_highlightedNodesRead; } g_highlightedNodesRead = g_highlightedNodes; From b63b8ea69df1eff52d9a4cc8c4b320c1bc3f63b8 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Wed, 11 Jul 2012 19:32:32 +0000 Subject: [PATCH 10/27] Compositor: Added OpenCL kernel for the directional blur. This operation always uses the full input image. In the current implementation this input image is not cached on the device. Future enhancement could be to cache it on the available opencl devices --- .../nodes/COM_DirectionalBlurNode.cpp | 1 + .../COM_DirectionalBlurOperation.cpp | 31 ++++++++- .../operations/COM_DirectionalBlurOperation.h | 6 ++ .../operations/COM_OpenCLKernels.cl | 66 +++++++++++++++++- .../operations/COM_OpenCLKernels.cl.h | 68 ++++++++++++++++++- 5 files changed, 167 insertions(+), 5 deletions(-) diff --git a/source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp b/source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp index dee0e6a88da..85fc63ae8cb 100644 --- a/source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp +++ b/source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp @@ -37,6 +37,7 @@ void DirectionalBlurNode::convertToOperations(ExecutionSystem *graph, Compositor DirectionalBlurOperation *operation = new DirectionalBlurOperation(); operation->setQuality(context->getQuality()); operation->setData(data); + operation->setbNode(this->getbNode()); this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); graph->addOperation(operation); diff --git a/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp b/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp index da7336afc07..76ee5b2c2a1 100644 --- a/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp @@ -22,7 +22,7 @@ #include "COM_DirectionalBlurOperation.h" #include "BLI_math.h" - +#include "COM_OpenCLDevice.h" extern "C" { #include "RE_pipeline.h" } @@ -33,6 +33,7 @@ DirectionalBlurOperation::DirectionalBlurOperation() : NodeOperation() this->addOutputSocket(COM_DT_COLOR); this->setComplex(true); + this->setOpenCL(true); this->m_inputProgram = NULL; } @@ -97,9 +98,35 @@ void DirectionalBlurOperation::executePixel(float *color, int x, int y, MemoryBu lsc += this->m_sc; } - mul_v4_v4fl(color, col2, 1.0f / iterations); + mul_v4_v4fl(color, col2, 1.0f / (iterations+1)); } +void DirectionalBlurOperation::executeOpenCL(OpenCLDevice* device, + MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, + MemoryBuffer **inputMemoryBuffers, list *clMemToCleanUp, + list *clKernelsToCleanUp) +{ + cl_kernel directionalBlurKernel = device->COM_clCreateKernel("directionalBlurKernel", NULL); + + cl_int iterations = pow(2.0f, this->m_data->iter); + cl_float2 ltxy = {this->m_tx, this->m_ty}; + cl_float2 centerpix = {this->m_center_x_pix, this->m_center_y_pix}; + cl_float lsc = this->m_sc; + cl_float lrot = this->m_rot; + + device->COM_clAttachMemoryBufferToKernelParameter(directionalBlurKernel, 0, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputProgram); + device->COM_clAttachOutputMemoryBufferToKernelParameter(directionalBlurKernel, 1, clOutputBuffer); + device->COM_clAttachMemoryBufferOffsetToKernelParameter(directionalBlurKernel, 2, outputMemoryBuffer); + clSetKernelArg(directionalBlurKernel, 3, sizeof(cl_int), &iterations); + clSetKernelArg(directionalBlurKernel, 4, sizeof(cl_float), &lsc); + clSetKernelArg(directionalBlurKernel, 5, sizeof(cl_float), &lrot); + clSetKernelArg(directionalBlurKernel, 6, sizeof(cl_float2), <xy); + clSetKernelArg(directionalBlurKernel, 7, sizeof(cl_float2), ¢erpix); + + device->COM_clEnqueueRange(directionalBlurKernel, outputMemoryBuffer, 8, this); +} + + void DirectionalBlurOperation::deinitExecution() { this->m_inputProgram = NULL; diff --git a/source/blender/compositor/operations/COM_DirectionalBlurOperation.h b/source/blender/compositor/operations/COM_DirectionalBlurOperation.h index 329f855871e..0ab5e9dff2d 100644 --- a/source/blender/compositor/operations/COM_DirectionalBlurOperation.h +++ b/source/blender/compositor/operations/COM_DirectionalBlurOperation.h @@ -55,5 +55,11 @@ public: bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); void setData(NodeDBlurData *data) { this->m_data = data; } + + void executeOpenCL(OpenCLDevice* device, + MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, + MemoryBuffer **inputMemoryBuffers, list *clMemToCleanUp, + list *clKernelsToCleanUp); + }; #endif diff --git a/source/blender/compositor/operations/COM_OpenCLKernels.cl b/source/blender/compositor/operations/COM_OpenCLKernels.cl index f9b6d34bfc3..41838e41fba 100644 --- a/source/blender/compositor/operations/COM_OpenCLKernels.cl +++ b/source/blender/compositor/operations/COM_OpenCLKernels.cl @@ -1,7 +1,30 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + /// This file contains all opencl kernels for node-operation implementations // Global SAMPLERS -const sampler_t SAMPLER_NEAREST = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST; +const sampler_t SAMPLER_NEAREST = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST; +const sampler_t SAMPLER_NEAREST_CLAMP = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP | CLK_FILTER_NEAREST; __constant const int2 zero = {0,0}; @@ -168,3 +191,44 @@ __kernel void erodeKernel(__read_only image2d_t inputImage, __write_only image2 float4 color = {value,0.0f,0.0f,0.0f}; write_imagef(output, coords, color); } + +// KERNEL --- DIRECTIONAL BLUR --- +__kernel void directionalBlurKernel(__read_only image2d_t inputImage, __write_only image2d_t output, + int2 offsetOutput, int iterations, float scale, float rotation, float2 translate, + float2 center, int2 offset) +{ + int2 coords = {get_global_id(0), get_global_id(1)}; + coords += offset; + const int2 realCoordinate = coords + offsetOutput; + + float4 col; + float2 ltxy = translate; + float lsc = scale; + float lrot = rotation; + + col = read_imagef(inputImage, SAMPLER_NEAREST, realCoordinate); + + /* blur the image */ + for (int i = 0; i < iterations; ++i) { + const float cs = cos(lrot), ss = sin(lrot); + const float isc = 1.0f / (1.0f + lsc); + + const float v = isc * (realCoordinate.s1 - center.s1) + ltxy.s1; + const float u = isc * (realCoordinate.s0 - center.s0) + ltxy.s0; + float2 uv = { + cs * u + ss * v + center.s0, + cs * v - ss * u + center.s1 + }; + + col += read_imagef(inputImage, SAMPLER_NEAREST_CLAMP, uv); + + /* double transformations */ + ltxy += translate; + lrot += rotation; + lsc += scale; + } + + col *= (1.0f/(iterations+1)); + + write_imagef(output, coords, col); +} diff --git a/source/blender/compositor/operations/COM_OpenCLKernels.cl.h b/source/blender/compositor/operations/COM_OpenCLKernels.cl.h index 2c9ec76501d..d57aa1366de 100644 --- a/source/blender/compositor/operations/COM_OpenCLKernels.cl.h +++ b/source/blender/compositor/operations/COM_OpenCLKernels.cl.h @@ -1,9 +1,32 @@ /* clkernelstoh output of file */ -const char * clkernelstoh_COM_OpenCLKernels_cl = "/// This file contains all opencl kernels for node-operation implementations\n" \ +const char * clkernelstoh_COM_OpenCLKernels_cl = "/*\n" \ +" * Copyright 2011, Blender Foundation.\n" \ +" *\n" \ +" * This program is free software; you can redistribute it and/or\n" \ +" * modify it under the terms of the GNU General Public License\n" \ +" * as published by the Free Software Foundation; either version 2\n" \ +" * of the License, or (at your option) any later version.\n" \ +" *\n" \ +" * This program is distributed in the hope that it will be useful,\n" \ +" * but WITHOUT ANY WARRANTY; without even the implied warranty of\n" \ +" * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" \ +" * GNU General Public License for more details.\n" \ +" *\n" \ +" * You should have received a copy of the GNU General Public License\n" \ +" * along with this program; if not, write to the Free Software Foundation,\n" \ +" * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n" \ +" *\n" \ +" * Contributor:\n" \ +" * Jeroen Bakker\n" \ +" * Monique Dewanchand\n" \ +" */\n" \ +"\n" \ +"/// This file contains all opencl kernels for node-operation implementations\n" \ "\n" \ "// Global SAMPLERS\n" \ -"const sampler_t SAMPLER_NEAREST = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;\n" \ +"const sampler_t SAMPLER_NEAREST = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;\n" \ +"const sampler_t SAMPLER_NEAREST_CLAMP = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP | CLK_FILTER_NEAREST;\n" \ "\n" \ "__constant const int2 zero = {0,0};\n" \ "\n" \ @@ -170,4 +193,45 @@ const char * clkernelstoh_COM_OpenCLKernels_cl = "/// This file contains all ope " float4 color = {value,0.0f,0.0f,0.0f};\n" \ " write_imagef(output, coords, color);\n" \ "}\n" \ +"\n" \ +"// KERNEL --- DIRECTIONAL BLUR ---\n" \ +"__kernel void directionalBlurKernel(__read_only image2d_t inputImage, __write_only image2d_t output,\n" \ +" int2 offsetOutput, int iterations, float scale, float rotation, float2 translate,\n" \ +" float2 center, int2 offset)\n" \ +"{\n" \ +" int2 coords = {get_global_id(0), get_global_id(1)};\n" \ +" coords += offset;\n" \ +" const int2 realCoordinate = coords + offsetOutput;\n" \ +"\n" \ +" float4 col;\n" \ +" float2 ltxy = translate;\n" \ +" float lsc = scale;\n" \ +" float lrot = rotation;\n" \ +"\n" \ +" col = read_imagef(inputImage, SAMPLER_NEAREST, realCoordinate);\n" \ +"\n" \ +" /* blur the image */\n" \ +" for (int i = 0; i < iterations; ++i) {\n" \ +" const float cs = cos(lrot), ss = sin(lrot);\n" \ +" const float isc = 1.0f / (1.0f + lsc);\n" \ +"\n" \ +" const float v = isc * (realCoordinate.s1 - center.s1) + ltxy.s1;\n" \ +" const float u = isc * (realCoordinate.s0 - center.s0) + ltxy.s0;\n" \ +" float2 uv = {\n" \ +" cs * u + ss * v + center.s0,\n" \ +" cs * v - ss * u + center.s1\n" \ +" };\n" \ +"\n" \ +" col += read_imagef(inputImage, SAMPLER_NEAREST_CLAMP, uv);\n" \ +"\n" \ +" /* double transformations */\n" \ +" ltxy += translate;\n" \ +" lrot += rotation;\n" \ +" lsc += scale;\n" \ +" }\n" \ +"\n" \ +" col *= (1.0f/(iterations+1));\n" \ +"\n" \ +" write_imagef(output, coords, col);\n" \ +"}\n" \ "\0"; From 83d2314edfe2c123c3151884a66c5a6ba2d849f6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 11 Jul 2012 20:18:46 +0000 Subject: [PATCH 11/27] ability to calculate mask curve and feather with predefined resolution (*_ex functions) --- source/blender/blenkernel/BKE_mask.h | 5 +++-- source/blender/blenkernel/intern/mask.c | 28 +++++++++++++++++++------ 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/source/blender/blenkernel/BKE_mask.h b/source/blender/blenkernel/BKE_mask.h index 936628bf0e7..384bc327a81 100644 --- a/source/blender/blenkernel/BKE_mask.h +++ b/source/blender/blenkernel/BKE_mask.h @@ -67,9 +67,10 @@ struct MaskSpline *BKE_mask_spline_add(struct MaskLayer *masklay); float (*BKE_mask_spline_differentiate(struct MaskSpline *spline, int *tot_diff_point))[2]; float (*BKE_mask_spline_feather_differentiated_points(struct MaskSpline *spline, int *tot_feather_point))[2]; +float (*BKE_mask_spline_differentiate_with_resolution_ex(struct MaskSpline *spline, const int resol, int *tot_diff_point))[2]; float (*BKE_mask_spline_differentiate_with_resolution(struct MaskSpline *spline, int width, int height, int *tot_diff_point))[2]; -float (*BKE_mask_spline_feather_differentiated_points_with_resolution(struct MaskSpline *spline, - int width, int height, int *tot_feather_point))[2]; +float (*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(struct MaskSpline *spline, const int resol, int *tot_feather_point))[2]; +float (*BKE_mask_spline_feather_differentiated_points_with_resolution(struct MaskSpline *spline, int width, int height, int *tot_feather_point))[2]; float (*BKE_mask_spline_feather_points(struct MaskSpline *spline, int *tot_feather_point))[2]; diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index 6f6f15955cd..ea152e4c188 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -314,14 +314,14 @@ static int BKE_mask_spline_feather_resolution(MaskSpline *spline, int width, int return resol; } -float (*BKE_mask_spline_differentiate_with_resolution(MaskSpline *spline, int width, int height, - int *tot_diff_point))[2] +float (*BKE_mask_spline_differentiate_with_resolution_ex(MaskSpline *spline, const int resol, + int *tot_diff_point))[2] { MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline); MaskSplinePoint *point, *prev; float (*diff_points)[2], (*fp)[2]; - int a, len, resol = BKE_mask_spline_resolution(spline, width, height); + int a, len; if (spline->tot_point <= 1) { /* nothing to differentiate */ @@ -378,18 +378,26 @@ float (*BKE_mask_spline_differentiate_with_resolution(MaskSpline *spline, int wi return diff_points; } +float (*BKE_mask_spline_differentiate_with_resolution(MaskSpline *spline, int width, int height, + int *tot_diff_point))[2] +{ + int resol = BKE_mask_spline_resolution(spline, width, height); + + return BKE_mask_spline_differentiate_with_resolution_ex(spline, resol, tot_diff_point); +} + float (*BKE_mask_spline_differentiate(MaskSpline *spline, int *tot_diff_point))[2] { return BKE_mask_spline_differentiate_with_resolution(spline, 0, 0, tot_diff_point); } -float (*BKE_mask_spline_feather_differentiated_points_with_resolution(MaskSpline *spline, int width, int height, - int *tot_feather_point))[2] +float (*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(MaskSpline *spline, const int resol, + int *tot_feather_point))[2] { MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline); float (*feather)[2], (*fp)[2]; - int i, j, tot, resol = BKE_mask_spline_feather_resolution(spline, width, height); + int i, j, tot; tot = resol * spline->tot_point; feather = fp = MEM_mallocN(tot * sizeof(*feather), "mask spline feather diff points"); @@ -416,6 +424,14 @@ float (*BKE_mask_spline_feather_differentiated_points_with_resolution(MaskSpline return feather; } +float (*BKE_mask_spline_feather_differentiated_points_with_resolution(MaskSpline *spline, int width, int height, + int *tot_feather_point))[2] +{ + int resol = BKE_mask_spline_feather_resolution(spline, width, height); + + return BKE_mask_spline_feather_differentiated_points_with_resolution_ex(spline, resol, tot_feather_point); +} + float (*BKE_mask_spline_feather_differentiated_points(MaskSpline *spline, int *tot_feather_point))[2] { return BKE_mask_spline_feather_differentiated_points_with_resolution(spline, 0, 0, tot_feather_point); From 4fb850c72ee15cf0a305079e8fb6d23f180fb419 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Wed, 11 Jul 2012 20:51:00 +0000 Subject: [PATCH 12/27] Compositor: re-optimized the Defocus node. * localized MemoryBuffers * removed read(x,y) calls * shuffled some lines in the execute pixel * added a readNoCheck function to the memorybuffer (only use this when you are certain you are reading a pixel inside the memorybuffer. --- .../compositor/intern/COM_MemoryBuffer.h | 7 ++ .../operations/COM_OpenCLKernels.cl | 24 +++---- .../operations/COM_OpenCLKernels.cl.h | 20 +++--- .../COM_VariableSizeBokehBlurOperation.cpp | 66 +++++++++++++------ .../COM_VariableSizeBokehBlurOperation.h | 4 ++ 5 files changed, 79 insertions(+), 42 deletions(-) diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.h b/source/blender/compositor/intern/COM_MemoryBuffer.h index 51a45efc051..eed0c796cd8 100644 --- a/source/blender/compositor/intern/COM_MemoryBuffer.h +++ b/source/blender/compositor/intern/COM_MemoryBuffer.h @@ -140,6 +140,13 @@ public: } } + inline void readNoCheck(float result[4], int x, int y) { + const int dx = x - this->m_rect.xmin; + const int dy = y - this->m_rect.ymin; + const int offset = (this->m_chunkWidth * dy + dx) * COM_NUMBER_OF_CHANNELS; + copy_v4_v4(result, &this->m_buffer[offset]); + } + void writePixel(int x, int y, const float color[4]); void addPixel(int x, int y, const float color[4]); inline void readCubic(float result[4], float x, float y) diff --git a/source/blender/compositor/operations/COM_OpenCLKernels.cl b/source/blender/compositor/operations/COM_OpenCLKernels.cl index 41838e41fba..cbbb4d0b3f2 100644 --- a/source/blender/compositor/operations/COM_OpenCLKernels.cl +++ b/source/blender/compositor/operations/COM_OpenCLKernels.cl @@ -101,16 +101,16 @@ __kernel void defocusKernel(__read_only image2d_t inputImage, __read_only image2 float size = read_imagef(inputSize, SAMPLER_NEAREST, inputCoordinate).s0; color_accum = read_imagef(inputImage, SAMPLER_NEAREST, inputCoordinate); - for (int ny = miny; ny < maxy; ny += step) { - for (int nx = minx; nx < maxx; nx += step) { - if (nx >= 0 && nx < dimension.s0 && ny >= 0 && ny < dimension.s1) { - inputCoordinate.s0 = nx - offsetInput.s0; - inputCoordinate.s1 = ny - offsetInput.s1; - tempSize = read_imagef(inputSize, SAMPLER_NEAREST, inputCoordinate).s0; - if (size > threshold && tempSize > threshold) { - float dx = nx - realCoordinate.s0; - float dy = ny - realCoordinate.s1; - if (dx != 0 || dy != 0) { + if (size > threshold) { + for (int ny = miny; ny < maxy; ny += step) { + inputCoordinate.s1 = ny - offsetInput.s1; + float dy = ny - realCoordinate.s1; + for (int nx = minx; nx < maxx; nx += step) { + float dx = nx - realCoordinate.s0; + if (dx != 0 || dy != 0) { + inputCoordinate.s0 = nx - offsetInput.s0; + tempSize = read_imagef(inputSize, SAMPLER_NEAREST, inputCoordinate).s0; + if (tempSize > threshold) { if (tempSize >= fabs(dx) && tempSize >= fabs(dy)) { float2 uv = { 256.0f + dx * 256.0f / tempSize, 256.0f + dy * 256.0f / tempSize}; bokeh = read_imagef(bokehImage, SAMPLER_NEAREST, uv); @@ -121,8 +121,8 @@ __kernel void defocusKernel(__read_only image2d_t inputImage, __read_only image2 } } } - } - } + } + } } color = color_accum * (1.0f / multiplier_accum); diff --git a/source/blender/compositor/operations/COM_OpenCLKernels.cl.h b/source/blender/compositor/operations/COM_OpenCLKernels.cl.h index d57aa1366de..cc18039c5b1 100644 --- a/source/blender/compositor/operations/COM_OpenCLKernels.cl.h +++ b/source/blender/compositor/operations/COM_OpenCLKernels.cl.h @@ -103,16 +103,16 @@ const char * clkernelstoh_COM_OpenCLKernels_cl = "/*\n" \ " float size = read_imagef(inputSize, SAMPLER_NEAREST, inputCoordinate).s0;\n" \ " color_accum = read_imagef(inputImage, SAMPLER_NEAREST, inputCoordinate);\n" \ "\n" \ -" for (int ny = miny; ny < maxy; ny += step) {\n" \ -" for (int nx = minx; nx < maxx; nx += step) {\n" \ -" if (nx >= 0 && nx < dimension.s0 && ny >= 0 && ny < dimension.s1) {\n" \ -" inputCoordinate.s0 = nx - offsetInput.s0;\n" \ -" inputCoordinate.s1 = ny - offsetInput.s1;\n" \ -" tempSize = read_imagef(inputSize, SAMPLER_NEAREST, inputCoordinate).s0;\n" \ -" if (size > threshold && tempSize > threshold) {\n" \ -" float dx = nx - realCoordinate.s0;\n" \ -" float dy = ny - realCoordinate.s1;\n" \ -" if (dx != 0 || dy != 0) {\n" \ +" if (size > threshold) {\n" \ +" for (int ny = miny; ny < maxy; ny += step) {\n" \ +" inputCoordinate.s1 = ny - offsetInput.s1;\n" \ +" float dy = ny - realCoordinate.s1;\n" \ +" for (int nx = minx; nx < maxx; nx += step) {\n" \ +" float dx = nx - realCoordinate.s0;\n" \ +" if (dx != 0 || dy != 0) {\n" \ +" inputCoordinate.s0 = nx - offsetInput.s0;\n" \ +" tempSize = read_imagef(inputSize, SAMPLER_NEAREST, inputCoordinate).s0;\n" \ +" if (tempSize > threshold) {\n" \ " if (tempSize >= fabs(dx) && tempSize >= fabs(dy)) {\n" \ " float2 uv = { 256.0f + dx * 256.0f / tempSize, 256.0f + dy * 256.0f / tempSize};\n" \ " bokeh = read_imagef(bokehImage, SAMPLER_NEAREST, uv);\n" \ diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp index 61538fde258..5d17526185b 100644 --- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp @@ -62,8 +62,29 @@ void VariableSizeBokehBlurOperation::initExecution() QualityStepHelper::initExecution(COM_QH_INCREASE); } +void *VariableSizeBokehBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) +{ + MemoryBuffer** result = new MemoryBuffer*[3]; + result[0] = (MemoryBuffer*)this->m_inputProgram->initializeTileData(rect, memoryBuffers); + result[1] = (MemoryBuffer*)this->m_inputBokehProgram->initializeTileData(rect, memoryBuffers); + result[2] = (MemoryBuffer*)this->m_inputSizeProgram->initializeTileData(rect, memoryBuffers); + return result; +} + +void VariableSizeBokehBlurOperation::deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data) +{ + MemoryBuffer** result = (MemoryBuffer**)data; + delete[] result; +} + void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) { + MemoryBuffer** buffers = (MemoryBuffer**)data; + MemoryBuffer* inputProgramBuffer = buffers[0]; + MemoryBuffer* inputBokehBuffer = buffers[1]; + MemoryBuffer* inputSizeBuffer = buffers[2]; + float* inputSizeFloatBuffer = inputSizeBuffer->getBuffer(); + float* inputProgramFloatBuffer = inputProgramBuffer->getBuffer(); float readColor[4]; float bokeh[4]; float tempSize[4]; @@ -84,32 +105,37 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, Me int maxy = MIN2(y + this->m_maxBlur, m_height); #endif { - this->m_inputSizeProgram->read(tempSize, x, y, COM_PS_NEAREST, inputBuffers); - this->m_inputProgram->read(readColor, x, y, COM_PS_NEAREST, inputBuffers); + inputSizeBuffer->readNoCheck(tempSize, x, y); + inputProgramBuffer->readNoCheck(readColor, x, y); + add_v4_v4(color_accum, readColor); add_v4_fl(multiplier_accum, 1.0f); float sizeCenter = tempSize[0]; - for (int ny = miny; ny < maxy; ny += QualityStepHelper::getStep()) { - for (int nx = minx; nx < maxx; nx += QualityStepHelper::getStep()) { - if (nx >= 0 && nx < this->getWidth() && ny >= 0 && ny < getHeight()) { - this->m_inputSizeProgram->read(tempSize, nx, ny, COM_PS_NEAREST, inputBuffers); - float size = tempSize[0]; - float fsize = fabsf(size); - if (sizeCenter > this->m_threshold && size > this->m_threshold) { - float dx = nx - x; - float dy = ny - y; - if (nx == x && ny == y) { - } - else if (fsize > fabsf(dx) && fsize > fabsf(dy)) { - float u = (256 + (dx/size) * 256); - float v = (256 + (dy/size) * 256); - this->m_inputBokehProgram->read(bokeh, u, v, COM_PS_NEAREST, inputBuffers); - this->m_inputProgram->read(readColor, nx, ny, COM_PS_NEAREST, inputBuffers); - madd_v4_v4v4(color_accum, bokeh, readColor); - add_v4_v4(multiplier_accum, bokeh); + const int addXStep = QualityStepHelper::getStep()*COM_NUMBER_OF_CHANNELS; + + if (sizeCenter > this->m_threshold) { + for (int ny = miny; ny < maxy; ny += QualityStepHelper::getStep()) { + float dy = ny - y; + int offsetNy = ny * inputSizeBuffer->getWidth() * COM_NUMBER_OF_CHANNELS; + int offsetNxNy = offsetNy + (minx*COM_NUMBER_OF_CHANNELS); + for (int nx = minx; nx < maxx; nx += QualityStepHelper::getStep()) { + if (nx != x || ny != y) + { + float size = inputSizeFloatBuffer[offsetNxNy]; + if (size > this->m_threshold) { + float fsize = fabsf(size); + float dx = nx - x; + if (fsize > fabsf(dx) && fsize > fabsf(dy)) { + float u = (256.0f + (dx/size) * 256.0f); + float v = (256.0f + (dy/size) * 256.0f); + inputBokehBuffer->readNoCheck(bokeh, u, v); + madd_v4_v4v4(color_accum, bokeh, &inputProgramFloatBuffer[offsetNxNy]); + add_v4_v4(multiplier_accum, bokeh); + } } } + offsetNxNy += addXStep; } } } diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h index 6c9196c3eab..0ecfb5a542c 100644 --- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h +++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h @@ -50,6 +50,10 @@ public: */ void initExecution(); + void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); + + void deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data); + /** * Deinitialize the execution */ From fabc2322aa9d0ad78f3a0c027c47aaf858845f31 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Wed, 11 Jul 2012 21:42:06 +0000 Subject: [PATCH 13/27] Fix for [#32078] Rendering output to Frame Server is broken. * BKE_frameserver_append() always returned 0, which caused the frameserver to crash after the first frame was requested. Patch by "alas2718" --- source/blender/blenkernel/intern/writeframeserver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/writeframeserver.c b/source/blender/blenkernel/intern/writeframeserver.c index b5965838a30..a2028ff5fa1 100644 --- a/source/blender/blenkernel/intern/writeframeserver.c +++ b/source/blender/blenkernel/intern/writeframeserver.c @@ -383,7 +383,7 @@ int BKE_frameserver_append(RenderData *UNUSED(rd), int UNUSED(start_frame), int connsock = -1; } - return 0; + return 1; } void BKE_frameserver_end(void) From 4f5d982fb1dda38c104e9800d5156e5acda7fb83 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Wed, 11 Jul 2012 21:57:11 +0000 Subject: [PATCH 14/27] Readme and Release Log Links: * Update to 2.64 --- release/scripts/startup/bl_ui/space_info.py | 2 +- release/text/readme.html | 10 +++++----- source/blender/windowmanager/intern/wm_operators.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_info.py b/release/scripts/startup/bl_ui/space_info.py index 8ddb2df352a..04ea6b818ac 100644 --- a/release/scripts/startup/bl_ui/space_info.py +++ b/release/scripts/startup/bl_ui/space_info.py @@ -372,7 +372,7 @@ class INFO_MT_help(Menu): layout = self.layout layout.operator("wm.url_open", text="Manual", icon='HELP').url = "http://wiki.blender.org/index.php/Doc:2.6/Manual" - layout.operator("wm.url_open", text="Release Log", icon='URL').url = "http://www.blender.org/development/release-logs/blender-263" + layout.operator("wm.url_open", text="Release Log", icon='URL').url = "http://www.blender.org/development/release-logs/blender-264" layout.separator() layout.operator("wm.url_open", text="Blender Website", icon='URL').url = "http://www.blender.org" diff --git a/release/text/readme.html b/release/text/readme.html index 78ee25bb3ee..512ba32bac0 100644 --- a/release/text/readme.html +++ b/release/text/readme.html @@ -12,18 +12,18 @@ -

Blender 2.63

+

Blender 2.64


About

Welcome to Blender, the free, open source 3D application for modeling, animation, rendering, compositing, video editing and game creation. Blender is available for Linux, Mac OS X, Windows and FreeBSD and has a large world-wide community.

Blender can be used freely for any purpose, including commercial use and distribution. It's free and open-source software, released under the GNU GPL licence. The entire source code is available on our website.

For more information, visit blender.org.


-

2.63

-

The Blender Foundation and online developer community is proud to present Blender 2.63. This release is the fourth official stable release of the Blender 2.6 series, in which we will refine the 2.5 series and add exciting new features. More information about this release.

+

2.64

+

The Blender Foundation and online developer community is proud to present Blender 2.64. This release is the fifth official stable release of the Blender 2.6 series, in which we will refine the 2.5 series and add exciting new features. More information about this release.


Bugs

-

Although Blender 2.63 is considered a stable release, you may encounter a bug. If you do, please help us by posting it in the bug tracker or using Help → Report a Bug from inside Blender. If it wasn’t reported yet, please log in (or register) and fill in detailed information about the error. Please post detailed instructions on how to reproduce it or post a .blend file showcasing the bug.

+

Although Blender 2.64 is considered a stable release, you may encounter a bug. If you do, please help us by posting it in the bug tracker or using Help → Report a Bug from inside Blender. If it wasn’t reported yet, please log in (or register) and fill in detailed information about the error. Please post detailed instructions on how to reproduce it or post a .blend file showcasing the bug.


Package Contents

The downloaded Blender package includes:

@@ -47,7 +47,7 @@

Links

Users:

General information www.blender.org
- Full release log www.blender.org/development/release-logs/blender-263/
+ Full release log www.blender.org/development/release-logs/blender-264/
Tutorials www.blender.org/education-help/
Manual wiki.blender.org/index.php/Doc:2.6/Manual
User Forum www.blenderartists.org
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 2aa010f012e..d905d981134 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1336,7 +1336,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar uiItemL(col, "Links", ICON_NONE); uiItemStringO(col, IFACE_("Donations"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/blenderorg/blender-foundation/donation-payment"); uiItemStringO(col, IFACE_("Credits"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/development/credits"); - uiItemStringO(col, IFACE_("Release Log"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/development/release-logs/blender-263"); + uiItemStringO(col, IFACE_("Release Log"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/development/release-logs/blender-264"); uiItemStringO(col, IFACE_("Manual"), ICON_URL, "WM_OT_url_open", "url", "http://wiki.blender.org/index.php/Doc:2.6/Manual"); uiItemStringO(col, IFACE_("Blender Website"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org"); uiItemStringO(col, IFACE_("User Community"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/community/user-community"); From 677876e4294708784eceb47bfc73698673a6e910 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Thu, 12 Jul 2012 05:55:07 +0000 Subject: [PATCH 15/27] Fix normals around root nodes of skin modifier output. The direction for these are flipped from other end caps, so add a root flag to indicate whether the cap polygon's vertex output order should be reversed. Fixes bug [#32079] Skin-modifier calculates root's normals wrong projects.blender.org/tracker/index.php?func=detail&aid=32079&group_id=9&atid=498 --- source/blender/modifiers/intern/MOD_skin.c | 29 ++++++++++++++++------ 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c index 46987f30205..f24898ccee2 100644 --- a/source/blender/modifiers/intern/MOD_skin.c +++ b/source/blender/modifiers/intern/MOD_skin.c @@ -91,6 +91,7 @@ typedef enum { CAP_START = 1, CAP_END = 2, SEAM_FRAME = 4, + ROOT = 8 } SkinNodeFlag; typedef struct Frame { @@ -502,6 +503,9 @@ static void end_node_frames(int v, SkinNode *skin_nodes, const MVert *mvert, /* End frame */ create_frame(&skin_nodes[v].frames[0], mvert[v].co, rad, mat, 0); } + + if (nodes[v].flag & MVERT_SKIN_ROOT) + skin_nodes[v].flag |= ROOT; } /* Returns 1 for seam, 0 otherwise */ @@ -1493,18 +1497,27 @@ static void skin_output_end_nodes(SkinOutput *so, SkinNode *skin_nodes, } if (sn->flag & CAP_START) { - add_poly(so, - sn->frames[0].verts[3], - sn->frames[0].verts[2], - sn->frames[0].verts[1], - sn->frames[0].verts[0]); + if (sn->flag & ROOT) { + add_poly(so, + sn->frames[0].verts[0], + sn->frames[0].verts[1], + sn->frames[0].verts[2], + sn->frames[0].verts[3]); + } + else { + add_poly(so, + sn->frames[0].verts[3], + sn->frames[0].verts[2], + sn->frames[0].verts[1], + sn->frames[0].verts[0]); + } } if (sn->flag & CAP_END) { add_poly(so, - sn->frames[1].verts[3], - sn->frames[1].verts[2], + sn->frames[1].verts[0], sn->frames[1].verts[1], - sn->frames[1].verts[0]); + sn->frames[1].verts[2], + sn->frames[1].verts[3]); } } } From 54c5edcfbb3547d88079e4c4fa6bfc8d7610db3c Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 12 Jul 2012 07:15:32 +0000 Subject: [PATCH 16/27] Fix crash on creating tooltip for sequencer's gl preview mode Issue was caused by missed value for this enum, fixed by adding check in tooltip generation. Default value for this enum should also be fixed, but that would be in separated commit. --- source/blender/editors/interface/interface.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 381560fc9ac..60f071f2ad2 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -3792,12 +3792,14 @@ void uiButGetStrInfo(bContext *C, uiBut *but, int nbr, ...) break; } } - if (type == BUT_GET_RNAENUM_IDENTIFIER) - tmp = BLI_strdup(item->identifier); - else if (type == BUT_GET_RNAENUM_LABEL) - tmp = BLI_strdup(item->name); - else if (item->description && item->description[0]) - tmp = BLI_strdup(item->description); + if (item && item->identifier) { + if (type == BUT_GET_RNAENUM_IDENTIFIER) + tmp = BLI_strdup(item->identifier); + else if (type == BUT_GET_RNAENUM_LABEL) + tmp = BLI_strdup(item->name); + else if (item->description && item->description[0]) + tmp = BLI_strdup(item->description); + } } } else if (type == BUT_GET_OP_KEYMAP) { From 92119982cb2073829560c54991179359f1c1fca1 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 12 Jul 2012 07:30:50 +0000 Subject: [PATCH 17/27] Fix #32082: face textures lost when linking scene from another file Issue was caused by missing expand for MTexPoly-s tpages. --- source/blender/blenloader/intern/readfile.c | 37 ++++++++++++++++----- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 14860509d81..4a5eabc7615 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -8519,7 +8519,6 @@ static void expand_curve(FileData *fd, Main *mainvar, Curve *cu) static void expand_mesh(FileData *fd, Main *mainvar, Mesh *me) { CustomDataLayer *layer; - MTFace *mtf; TFace *tf; int a, i; @@ -8541,14 +8540,34 @@ static void expand_mesh(FileData *fd, Main *mainvar, Mesh *me) } } - for (a = 0; a < me->fdata.totlayer; a++) { - layer = &me->fdata.layers[a]; - - if (layer->type == CD_MTFACE) { - mtf = (MTFace*)layer->data; - for (i = 0; i < me->totface; i++, mtf++) { - if (mtf->tpage) - expand_doit(fd, mainvar, mtf->tpage); + if (me->mface && !me->mpoly) { + MTFace *mtf; + + for (a = 0; a < me->fdata.totlayer; a++) { + layer = &me->fdata.layers[a]; + + if (layer->type == CD_MTFACE) { + mtf = (MTFace *) layer->data; + for (i = 0; i < me->totface; i++, mtf++) { + if (mtf->tpage) + expand_doit(fd, mainvar, mtf->tpage); + } + } + } + } + else { + MTexPoly *mtp; + + for (a = 0; a < me->pdata.totlayer; a++) { + layer = &me->pdata.layers[a]; + + if (layer->type == CD_MTEXPOLY) { + mtp = (MTexPoly *) layer->data; + + for (i = 0; i < me->totpoly; i++, mtp++) { + if (mtp->tpage) + expand_doit(fd, mainvar, mtp->tpage); + } } } } From 993dfd7d2a2eb18949a6c7680e05a950e7a1e9c8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 12 Jul 2012 08:31:23 +0000 Subject: [PATCH 18/27] add bli rect funcs BLI_rctf_init_minmax, BLI_rcti_init_minmax --- source/blender/blenkernel/intern/colortools.c | 2 +- source/blender/blenkernel/intern/scene.c | 2 +- source/blender/blenlib/BLI_rect.h | 14 +++------- source/blender/blenlib/intern/rct.c | 26 +++++++++++++++-- .../compositor/intern/COM_ExecutionGroup.cpp | 6 ++-- .../compositor/intern/COM_MemoryBuffer.cpp | 4 +-- .../compositor/intern/COM_NodeOperation.cpp | 2 +- .../operations/COM_GlareFogGlowOperation.cpp | 2 +- .../operations/COM_KeyingScreenOperation.cpp | 2 +- .../operations/COM_ReadBufferOperation.cpp | 2 +- source/blender/editors/screen/area.c | 28 +++++++++---------- .../editors/sculpt_paint/paint_utils.c | 4 +-- source/blender/editors/space_file/file_ops.c | 2 +- .../editors/space_image/image_buttons.c | 2 +- .../editors/space_view3d/view3d_select.c | 6 ++-- 15 files changed, 60 insertions(+), 44 deletions(-) diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 6879ec506f0..31ad4d0380a 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -71,7 +71,7 @@ CurveMapping *curvemapping_add(int tot, float minx, float miny, float maxx, floa clipmaxx = MAX2(minx, maxx); clipmaxy = MAX2(miny, maxy); - BLI_init_rctf(&cumap->curr, clipminx, clipmaxx, clipminy, clipmaxy); + BLI_rctf_init(&cumap->curr, clipminx, clipmaxx, clipminy, clipmaxy); cumap->clipr = cumap->curr; cumap->white[0] = cumap->white[1] = cumap->white[2] = 1.0f; diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 6f24eadd1b6..d9afd1eefb4 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -487,7 +487,7 @@ Scene *BKE_scene_add(const char *name) BLI_strncpy(sce->r.pic, U.renderdir, sizeof(sce->r.pic)); - BLI_init_rctf(&sce->r.safety, 0.1f, 0.9f, 0.1f, 0.9f); + BLI_rctf_init(&sce->r.safety, 0.1f, 0.9f, 0.1f, 0.9f); sce->r.osa = 8; /* note; in header_info.c the scene copy happens..., if you add more to renderdata it has to be checked there */ diff --git a/source/blender/blenlib/BLI_rect.h b/source/blender/blenlib/BLI_rect.h index 4d0e54e344c..49d10eb0be6 100644 --- a/source/blender/blenlib/BLI_rect.h +++ b/source/blender/blenlib/BLI_rect.h @@ -40,18 +40,12 @@ struct rcti; extern "C" { #endif -/* BLI_rct.c */ -/** - * Determine if a rect is empty. An empty - * rect is one with a zero (or negative) - * width or height. - * - * \return True if \a rect is empty. - */ int BLI_rcti_is_empty(const struct rcti *rect); int BLI_rctf_is_empty(const struct rctf *rect); -void BLI_init_rctf(struct rctf *rect, float xmin, float xmax, float ymin, float ymax); -void BLI_init_rcti(struct rcti *rect, int xmin, int xmax, int ymin, int ymax); +void BLI_rctf_init(struct rctf *rect, float xmin, float xmax, float ymin, float ymax); +void BLI_rcti_init(struct rcti *rect, int xmin, int xmax, int ymin, int ymax); +void BLI_rcti_init_minmax(struct rcti *rect); +void BLI_rctf_init_minmax(struct rctf *rect); void BLI_translate_rctf(struct rctf *rect, float x, float y); void BLI_translate_rcti(struct rcti *rect, int x, int y); void BLI_resize_rcti(struct rcti *rect, int x, int y); diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c index b4397ea4546..4ac30da2369 100644 --- a/source/blender/blenlib/intern/rct.c +++ b/source/blender/blenlib/intern/rct.c @@ -35,6 +35,9 @@ #include #include +#include +#include + #include "DNA_vec_types.h" #include "BLI_rect.h" @@ -57,6 +60,13 @@ int BLI_in_rcti(const rcti *rect, const int x, const int y) return 1; } +/** + * Determine if a rect is empty. An empty + * rect is one with a zero (or negative) + * width or height. + * + * \return True if \a rect is empty. + */ int BLI_in_rcti_v(const rcti *rect, const int xy[2]) { if (xy[0] < rect->xmin) return 0; @@ -149,7 +159,7 @@ void BLI_union_rcti(rcti *rct1, const rcti *rct2) if (rct1->ymax < rct2->ymax) rct1->ymax = rct2->ymax; } -void BLI_init_rctf(rctf *rect, float xmin, float xmax, float ymin, float ymax) +void BLI_rctf_init(rctf *rect, float xmin, float xmax, float ymin, float ymax) { if (xmin <= xmax) { rect->xmin = xmin; @@ -169,7 +179,7 @@ void BLI_init_rctf(rctf *rect, float xmin, float xmax, float ymin, float ymax) } } -void BLI_init_rcti(rcti *rect, int xmin, int xmax, int ymin, int ymax) +void BLI_rcti_init(rcti *rect, int xmin, int xmax, int ymin, int ymax) { if (xmin <= xmax) { rect->xmin = xmin; @@ -189,6 +199,18 @@ void BLI_init_rcti(rcti *rect, int xmin, int xmax, int ymin, int ymax) } } +void BLI_rcti_init_minmax(struct rcti *rect) +{ + rect->xmin = rect->ymin = INT_MAX; + rect->xmax = rect->ymax = INT_MIN; +} + +void BLI_rctf_init_minmax(struct rctf *rect) +{ + rect->xmin = rect->ymin = FLT_MAX; + rect->xmax = rect->ymax = FLT_MIN; +} + void BLI_translate_rcti(rcti *rect, int x, int y) { rect->xmin += x; diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cpp b/source/blender/compositor/intern/COM_ExecutionGroup.cpp index 1e42dba001a..46a0db7af2d 100644 --- a/source/blender/compositor/intern/COM_ExecutionGroup.cpp +++ b/source/blender/compositor/intern/COM_ExecutionGroup.cpp @@ -432,12 +432,12 @@ void ExecutionGroup::finalizeChunkExecution(int chunkNumber, MemoryBuffer **memo inline void ExecutionGroup::determineChunkRect(rcti *rect, const unsigned int xChunk, const unsigned int yChunk) const { if (this->m_singleThreaded) { - BLI_init_rcti(rect, 0, this->m_width, 0, this->m_height); + BLI_rcti_init(rect, 0, this->m_width, 0, this->m_height); } else { const unsigned int minx = xChunk * this->m_chunkSize; const unsigned int miny = yChunk * this->m_chunkSize; - BLI_init_rcti(rect, minx, min(minx + this->m_chunkSize, this->m_width), miny, min(miny + this->m_chunkSize, this->m_height)); + BLI_rcti_init(rect, minx, min(minx + this->m_chunkSize, this->m_width), miny, min(miny + this->m_chunkSize, this->m_height)); } } @@ -534,7 +534,7 @@ bool ExecutionGroup::scheduleChunkWhenPossible(ExecutionSystem *graph, int xChun for (index = 0; index < this->m_cachedReadOperations.size(); index++) { ReadBufferOperation *readOperation = (ReadBufferOperation *)this->m_cachedReadOperations[index]; - BLI_init_rcti(&area, 0, 0, 0, 0); + BLI_rcti_init(&area, 0, 0, 0, 0); MemoryProxy *memoryProxy = memoryProxies[index]; determineDependingAreaOfInterest(&rect, readOperation, &area); ExecutionGroup *group = memoryProxy->getExecutor(); diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.cpp b/source/blender/compositor/intern/COM_MemoryBuffer.cpp index 223c582d999..572308dd87f 100644 --- a/source/blender/compositor/intern/COM_MemoryBuffer.cpp +++ b/source/blender/compositor/intern/COM_MemoryBuffer.cpp @@ -40,7 +40,7 @@ int MemoryBuffer::getHeight() const MemoryBuffer::MemoryBuffer(MemoryProxy *memoryProxy, unsigned int chunkNumber, rcti *rect) { - BLI_init_rcti(&this->m_rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax); + BLI_rcti_init(&this->m_rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax); this->m_memoryProxy = memoryProxy; this->m_chunkNumber = chunkNumber; this->m_buffer = (float *)MEM_mallocN(sizeof(float) * determineBufferSize() * COM_NUMBER_OF_CHANNELS, "COM_MemoryBuffer"); @@ -51,7 +51,7 @@ MemoryBuffer::MemoryBuffer(MemoryProxy *memoryProxy, unsigned int chunkNumber, r MemoryBuffer::MemoryBuffer(MemoryProxy *memoryProxy, rcti *rect) { - BLI_init_rcti(&this->m_rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax); + BLI_rcti_init(&this->m_rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax); this->m_memoryProxy = memoryProxy; this->m_chunkNumber = -1; this->m_buffer = (float *)MEM_mallocN(sizeof(float) * determineBufferSize() * COM_NUMBER_OF_CHANNELS, "COM_MemoryBuffer"); diff --git a/source/blender/compositor/intern/COM_NodeOperation.cpp b/source/blender/compositor/intern/COM_NodeOperation.cpp index c3fa308971c..9baab584d9e 100644 --- a/source/blender/compositor/intern/COM_NodeOperation.cpp +++ b/source/blender/compositor/intern/COM_NodeOperation.cpp @@ -120,7 +120,7 @@ void NodeOperation::getConnectedInputSockets(vector *sockets) bool NodeOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { if (this->isInputNode()) { - BLI_init_rcti(output, input->xmin, input->xmax, input->ymin, input->ymax); + BLI_rcti_init(output, input->xmin, input->xmax, input->ymin, input->ymax); return false; } else { diff --git a/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp b/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp index cb4c27a4c80..5452e779968 100644 --- a/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp +++ b/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp @@ -379,7 +379,7 @@ void GlareFogGlowOperation::generateGlare(float *data, MemoryBuffer *inputTile, // temp. src image // make the convolution kernel rcti kernelRect; - BLI_init_rcti(&kernelRect, 0, sz, 0, sz); + BLI_rcti_init(&kernelRect, 0, sz, 0, sz); ckrn = new MemoryBuffer(NULL, &kernelRect); scale = 0.25f * sqrtf((float)(sz * sz)); diff --git a/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp b/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp index cf20712cfeb..134fd8bc7fe 100644 --- a/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp +++ b/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp @@ -242,7 +242,7 @@ void *KeyingScreenOperation::initializeTileData(rcti *rect, MemoryBuffer **memor if (!triangulation) return NULL; - BLI_init_rctf(&rect_float, rect->xmin, rect->xmax, rect->ymin, rect->ymax); + BLI_rctf_init(&rect_float, rect->xmin, rect->xmax, rect->ymin, rect->ymax); tile_data = (TileData *) MEM_callocN(sizeof(TileData), "keying screen tile data"); diff --git a/source/blender/compositor/operations/COM_ReadBufferOperation.cpp b/source/blender/compositor/operations/COM_ReadBufferOperation.cpp index 882d302656d..c1aa51f5017 100644 --- a/source/blender/compositor/operations/COM_ReadBufferOperation.cpp +++ b/source/blender/compositor/operations/COM_ReadBufferOperation.cpp @@ -67,7 +67,7 @@ void ReadBufferOperation::executePixel(float *color, float x, float y, float dx, bool ReadBufferOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { if (this == readOperation) { - BLI_init_rcti(output, input->xmin, input->xmax, input->ymin, input->ymax); + BLI_rcti_init(output, input->xmin, input->xmax, input->ymin, input->ymax); return true; } return false; diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index a79d38d4081..714700ec8f1 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -607,7 +607,7 @@ static void area_azone_initialize(ScrArea *sa) az->y1 = sa->totrct.ymin - 1; az->x2 = sa->totrct.xmin + (AZONESPOT - 1); az->y2 = sa->totrct.ymin + (AZONESPOT - 1); - BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); + BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2); az = (AZone *)MEM_callocN(sizeof(AZone), "actionzone"); BLI_addtail(&(sa->actionzones), az); @@ -616,7 +616,7 @@ static void area_azone_initialize(ScrArea *sa) az->y1 = sa->totrct.ymax + 1; az->x2 = sa->totrct.xmax - (AZONESPOT - 1); az->y2 = sa->totrct.ymax - (AZONESPOT - 1); - BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); + BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2); } #define AZONEPAD_EDGE 4 @@ -650,7 +650,7 @@ static void region_azone_edge(AZone *az, ARegion *ar) break; } - BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); + BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2); } static void region_azone_icon(ScrArea *sa, AZone *az, ARegion *ar) @@ -692,7 +692,7 @@ static void region_azone_icon(ScrArea *sa, AZone *az, ARegion *ar) break; } - BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); + BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2); /* if more azones on 1 spot, set offset */ for (azt = sa->actionzones.first; azt; azt = azt->next) { @@ -706,7 +706,7 @@ static void region_azone_icon(ScrArea *sa, AZone *az, ARegion *ar) az->y1 -= AZONESPOT; az->y2 -= AZONESPOT; } - BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); + BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2); } } } @@ -753,7 +753,7 @@ static void region_azone_tab_plus(ScrArea *sa, AZone *az, ARegion *ar) break; } /* rect needed for mouse pointer test */ - BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); + BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2); } @@ -798,7 +798,7 @@ static void region_azone_tab(ScrArea *sa, AZone *az, ARegion *ar) break; } /* rect needed for mouse pointer test */ - BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); + BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2); } #define AZONEPAD_TRIAW 16 @@ -843,7 +843,7 @@ static void region_azone_tria(ScrArea *sa, AZone *az, ARegion *ar) break; } /* rect needed for mouse pointer test */ - BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); + BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2); } @@ -911,7 +911,7 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int return; /* no returns in function, winrct gets set in the end again */ - BLI_init_rcti(&ar->winrct, 0, 0, 0, 0); + BLI_rcti_init(&ar->winrct, 0, 0, 0, 0); /* for test; allow split of previously defined region */ if (ar->alignment & RGN_SPLIT_PREV) @@ -947,7 +947,7 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int else if (alignment == RGN_ALIGN_NONE) { /* typically last region */ ar->winrct = *remainder; - BLI_init_rcti(remainder, 0, 0, 0, 0); + BLI_rcti_init(remainder, 0, 0, 0, 0); } else if (alignment == RGN_ALIGN_TOP || alignment == RGN_ALIGN_BOTTOM) { @@ -1007,7 +1007,7 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int remainder->xmin = ar->winrct.xmax + 1; } else { - BLI_init_rcti(remainder, 0, 0, 0, 0); + BLI_rcti_init(remainder, 0, 0, 0, 0); } } else { @@ -1016,7 +1016,7 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int remainder->ymin = ar->winrct.ymax + 1; } else { - BLI_init_rcti(remainder, 0, 0, 0, 0); + BLI_rcti_init(remainder, 0, 0, 0, 0); } } } @@ -1036,7 +1036,7 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int if (count != 4) { /* let's stop adding regions */ - BLI_init_rcti(remainder, 0, 0, 0, 0); + BLI_rcti_init(remainder, 0, 0, 0, 0); if (G.debug & G_DEBUG) printf("region quadsplit failed\n"); } @@ -1058,7 +1058,7 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int else { /* right top */ ar->winrct.xmin = 1 + (remainder->xmin + remainder->xmax) / 2; ar->winrct.ymin = 1 + (remainder->ymin + remainder->ymax) / 2; - BLI_init_rcti(remainder, 0, 0, 0, 0); + BLI_rcti_init(remainder, 0, 0, 0, 0); } quad++; diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 082e40f8e4c..26c51596a5e 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -41,6 +41,7 @@ #include "BLI_math.h" #include "BLI_utildefines.h" +#include "BLI_rect.h" #include "BKE_brush.h" #include "BKE_context.h" @@ -80,8 +81,7 @@ int paint_convert_bb_to_rect(rcti *rect, float projection_mat[4][4]; int i, j, k; - rect->xmin = rect->ymin = INT_MAX; - rect->xmax = rect->ymax = INT_MIN; + BLI_rcti_init_minmax(rect); /* return zero if the bounding box has non-positive volume */ if (bb_min[0] > bb_max[0] || bb_min[1] > bb_max[1] || bb_min[2] > bb_max[2]) diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 2d778b94216..9591e624296 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -81,7 +81,7 @@ static FileSelection find_file_mouse_rect(SpaceFile *sfile, struct ARegion *ar, UI_view2d_region_to_view(v2d, rect->xmin, rect->ymin, &fxmin, &fymin); UI_view2d_region_to_view(v2d, rect->xmax, rect->ymax, &fxmax, &fymax); - BLI_init_rcti(&rect_view, (int)(v2d->tot.xmin + fxmin), (int)(v2d->tot.xmin + fxmax), (int)(v2d->tot.ymax - fymin), (int)(v2d->tot.ymax - fymax)); + BLI_rcti_init(&rect_view, (int)(v2d->tot.xmin + fxmin), (int)(v2d->tot.xmin + fxmax), (int)(v2d->tot.ymax - fymin), (int)(v2d->tot.ymax - fymax)); sel = ED_fileselect_layout_offset_rect(sfile->layout, &rect_view); diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 116e155f501..99969405f9c 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -276,7 +276,7 @@ static void preview_cb(struct ScrArea *sa, struct uiBlock *block) /* while dragging we need to update the rects, otherwise it doesn't end with correct one */ - BLI_init_rctf(&dispf, 15.0f, (block->maxx - block->minx) - 15.0f, 15.0f, (block->maxy - block->miny) - 15.0f); + BLI_rctf_init(&dispf, 15.0f, (block->maxx - block->minx) - 15.0f, 15.0f, (block->maxy - block->miny) - 15.0f); ui_graphics_to_window_rct(sa->win, &dispf, disprect); /* correction for gla draw */ diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 43add69987b..39ec7514a88 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -1130,19 +1130,19 @@ static short mixed_bones_object_selectbuffer(ViewContext *vc, unsigned int *buff short a, hits15, hits9 = 0, hits5 = 0; short has_bones15 = 0, has_bones9 = 0, has_bones5 = 0; - BLI_init_rcti(&rect, mval[0] - 14, mval[0] + 14, mval[1] - 14, mval[1] + 14); + BLI_rcti_init(&rect, mval[0] - 14, mval[0] + 14, mval[1] - 14, mval[1] + 14); hits15 = view3d_opengl_select(vc, buffer, MAXPICKBUF, &rect); if (hits15 > 0) { for (a = 0; a < hits15; a++) if (buffer[4 * a + 3] & 0xFFFF0000) has_bones15 = 1; offs = 4 * hits15; - BLI_init_rcti(&rect, mval[0] - 9, mval[0] + 9, mval[1] - 9, mval[1] + 9); + BLI_rcti_init(&rect, mval[0] - 9, mval[0] + 9, mval[1] - 9, mval[1] + 9); hits9 = view3d_opengl_select(vc, buffer + offs, MAXPICKBUF - offs, &rect); if (hits9 > 0) { for (a = 0; a < hits9; a++) if (buffer[offs + 4 * a + 3] & 0xFFFF0000) has_bones9 = 1; offs += 4 * hits9; - BLI_init_rcti(&rect, mval[0] - 5, mval[0] + 5, mval[1] - 5, mval[1] + 5); + BLI_rcti_init(&rect, mval[0] - 5, mval[0] + 5, mval[1] - 5, mval[1] + 5); hits5 = view3d_opengl_select(vc, buffer + offs, MAXPICKBUF - offs, &rect); if (hits5 > 0) { for (a = 0; a < hits5; a++) if (buffer[offs + 4 * a + 3] & 0xFFFF0000) has_bones5 = 1; From 25607258073d3574a13f2fd5544a5e3cd90eb767 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 12 Jul 2012 08:34:59 +0000 Subject: [PATCH 19/27] - add a temp var for edge scanfill (fits in 4 bytes alignment - won't increase mem usage) - make keyindex an unsigned int, since its used to store vertex indices - use BLI_in_rcti_v for IN_2D_VERT_SCROLL and IN_2D_HORIZ_SCROLL --- source/blender/blenlib/BLI_scanfill.h | 5 ++++- source/blender/editors/include/UI_view2d.h | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/source/blender/blenlib/BLI_scanfill.h b/source/blender/blenlib/BLI_scanfill.h index cb996119fff..a6b1943cb4d 100644 --- a/source/blender/blenlib/BLI_scanfill.h +++ b/source/blender/blenlib/BLI_scanfill.h @@ -70,7 +70,7 @@ typedef struct ScanFillVert { } tmp; float co[3]; /* vertex location */ float xy[2]; /* 2D copy of vertex location (using dominant axis) */ - int keyindex; /* original index #, for restoring key information */ + unsigned int keyindex; /* original index #, for restoring key information */ short poly_nr; unsigned char f, h; } ScanFillVert; @@ -80,6 +80,9 @@ typedef struct ScanFillEdge { struct ScanFillVert *v1, *v2; short poly_nr; unsigned char f; + union { + unsigned char c; + } tmp; } ScanFillEdge; typedef struct ScanFillFace { diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h index 5039a30b61a..f0bdb2fc2ea 100644 --- a/source/blender/editors/include/UI_view2d.h +++ b/source/blender/editors/include/UI_view2d.h @@ -120,8 +120,8 @@ enum { /* Macros: */ /* test if mouse in a scrollbar (assume that scroller availability has been tested) */ -#define IN_2D_VERT_SCROLL(v2d, co) (BLI_in_rcti(&v2d->vert, co[0], co[1])) -#define IN_2D_HORIZ_SCROLL(v2d, co) (BLI_in_rcti(&v2d->hor, co[0], co[1])) +#define IN_2D_VERT_SCROLL(v2d, co) (BLI_in_rcti_v(&v2d->vert, co)) +#define IN_2D_HORIZ_SCROLL(v2d, co) (BLI_in_rcti_v(&v2d->hor, co)) /* ------------------------------------------ */ /* Type definitions: */ From c8d29b19968cafe91937ea3c26afef819372c599 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 12 Jul 2012 09:03:45 +0000 Subject: [PATCH 20/27] feather points now align with mask outline when called with same resolution. --- source/blender/blenkernel/intern/mask.c | 86 +++++++++++++++++++------ 1 file changed, 66 insertions(+), 20 deletions(-) diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index ea152e4c188..2326a8fa59c 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -314,6 +314,23 @@ static int BKE_mask_spline_feather_resolution(MaskSpline *spline, int width, int return resol; } +static int mask_spline_points_calc_tot(const MaskSpline *spline, const int resol) +{ + int len; + + /* count */ + len = (spline->tot_point - 1) * resol; + + if (spline->flag & MASK_SPLINE_CYCLIC) { + len += resol; + } + else { + len++; + } + + return len; +} + float (*BKE_mask_spline_differentiate_with_resolution_ex(MaskSpline *spline, const int resol, int *tot_diff_point))[2] { @@ -321,7 +338,8 @@ float (*BKE_mask_spline_differentiate_with_resolution_ex(MaskSpline *spline, con MaskSplinePoint *point, *prev; float (*diff_points)[2], (*fp)[2]; - int a, len; + const int tot = mask_spline_points_calc_tot(spline, resol); + int a; if (spline->tot_point <= 1) { /* nothing to differentiate */ @@ -329,17 +347,9 @@ float (*BKE_mask_spline_differentiate_with_resolution_ex(MaskSpline *spline, con return NULL; } - /* count */ - len = (spline->tot_point - 1) * resol; - - if (spline->flag & MASK_SPLINE_CYCLIC) - len += resol; - else - len++; - /* len+1 because of 'forward_diff_bezier' function */ - *tot_diff_point = len; - diff_points = fp = MEM_mallocN((len + 1) * sizeof(*diff_points), "mask spline vets"); + *tot_diff_point = tot; + diff_points = fp = MEM_mallocN((tot + 1) * sizeof(*diff_points), "mask spline vets"); a = spline->tot_point - 1; if (spline->flag & MASK_SPLINE_CYCLIC) @@ -391,19 +401,41 @@ float (*BKE_mask_spline_differentiate(MaskSpline *spline, int *tot_diff_point))[ return BKE_mask_spline_differentiate_with_resolution(spline, 0, 0, tot_diff_point); } +/** + * values align with #BKE_mask_spline_differentiate_with_resolution_ex + * when \a resol arguments match. + */ float (*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(MaskSpline *spline, const int resol, int *tot_feather_point))[2] { MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline); - + MaskSplinePoint *point, *prev; float (*feather)[2], (*fp)[2]; - int i, j, tot; - tot = resol * spline->tot_point; - feather = fp = MEM_mallocN(tot * sizeof(*feather), "mask spline feather diff points"); + const int tot = mask_spline_points_calc_tot(spline, resol); + int a; - for (i = 0; i < spline->tot_point; i++) { - MaskSplinePoint *point = &points_array[i]; + /* tot+1 because of 'forward_diff_bezier' function */ + feather = fp = MEM_mallocN((tot + 1) * sizeof(*feather), "mask spline feather diff points"); + + a = spline->tot_point - 1; + if (spline->flag & MASK_SPLINE_CYCLIC) + a++; + + prev = points_array; + point = prev + 1; + + while (a--) { + /* BezTriple *prevbezt; */ /* UNUSED */ + /* BezTriple *bezt; */ /* UNUSED */ + int j; + + if (a == 0 && (spline->flag & MASK_SPLINE_CYCLIC)) + point = points_array; + + + /* prevbezt = &prev->bezt; */ + /* bezt = &point->bezt; */ for (j = 0; j < resol; j++, fp++) { float u = (float) j / resol, weight; @@ -411,12 +443,26 @@ float (*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(MaskSpl /* TODO - these calls all calculate similar things * could be unified for some speed */ - BKE_mask_point_segment_co(spline, point, u, co); - BKE_mask_point_normal(spline, point, u, n); - weight = BKE_mask_point_weight(spline, point, u); + BKE_mask_point_segment_co(spline, prev, u, co); + BKE_mask_point_normal(spline, prev, u, n); + weight = BKE_mask_point_weight(spline, prev, u); madd_v2_v2v2fl(*fp, co, n, weight); } + + if (a == 0 && (spline->flag & MASK_SPLINE_CYCLIC) == 0) { + float u = 1.0f, weight; + float co[2], n[2]; + + BKE_mask_point_segment_co(spline, prev, u, co); + BKE_mask_point_normal(spline, prev, u, n); + weight = BKE_mask_point_weight(spline, prev, u); + + madd_v2_v2v2fl(*fp, co, n, weight); + } + + prev = point; + point++; } *tot_feather_point = tot; From 38f91db37c4789dfbca03676f2a92a2f85417d72 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 12 Jul 2012 09:24:17 +0000 Subject: [PATCH 21/27] add bli rect min/max functions. --- source/blender/blenlib/BLI_rect.h | 3 +++ source/blender/blenlib/intern/rct.c | 16 ++++++++++++++++ .../blender/editors/sculpt_paint/paint_utils.c | 11 +++++++---- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/source/blender/blenlib/BLI_rect.h b/source/blender/blenlib/BLI_rect.h index 49d10eb0be6..8a9794b77c9 100644 --- a/source/blender/blenlib/BLI_rect.h +++ b/source/blender/blenlib/BLI_rect.h @@ -46,6 +46,9 @@ void BLI_rctf_init(struct rctf *rect, float xmin, float xmax, float ymin, float void BLI_rcti_init(struct rcti *rect, int xmin, int xmax, int ymin, int ymax); void BLI_rcti_init_minmax(struct rcti *rect); void BLI_rctf_init_minmax(struct rctf *rect); +void BLI_rcti_do_minmax_v(struct rcti *rect, const int xy[2]); +void BLI_rctf_do_minmax_v(struct rctf *rect, const float xy[2]); + void BLI_translate_rctf(struct rctf *rect, float x, float y); void BLI_translate_rcti(struct rcti *rect, int x, int y); void BLI_resize_rcti(struct rcti *rect, int x, int y); diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c index 4ac30da2369..c1ef3e27291 100644 --- a/source/blender/blenlib/intern/rct.c +++ b/source/blender/blenlib/intern/rct.c @@ -211,6 +211,22 @@ void BLI_rctf_init_minmax(struct rctf *rect) rect->xmax = rect->ymax = FLT_MIN; } +void BLI_rcti_do_minmax_v(struct rcti *rect, const int xy[2]) +{ + if (xy[0] < rect->xmin) rect->xmin = xy[0]; + if (xy[0] > rect->xmax) rect->xmax = xy[0]; + if (xy[1] < rect->ymin) rect->ymin = xy[1]; + if (xy[1] > rect->ymax) rect->ymax = xy[1]; +} + +void BLI_rctf_do_minmax_v(struct rctf *rect, const float xy[2]) +{ + if (xy[0] < rect->xmin) rect->xmin = xy[0]; + if (xy[0] > rect->xmax) rect->xmax = xy[0]; + if (xy[1] < rect->ymin) rect->ymin = xy[1]; + if (xy[1] > rect->ymax) rect->ymax = xy[1]; +} + void BLI_translate_rcti(rcti *rect, int x, int y) { rect->xmin += x; diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 26c51596a5e..3c8f39a44b1 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -93,16 +93,19 @@ int paint_convert_bb_to_rect(rcti *rect, for (j = 0; j < 2; ++j) { for (k = 0; k < 2; ++k) { float vec[3], proj[2]; + int proj_i[2]; vec[0] = i ? bb_min[0] : bb_max[0]; vec[1] = j ? bb_min[1] : bb_max[1]; vec[2] = k ? bb_min[2] : bb_max[2]; /* convert corner to screen space */ ED_view3d_project_float_v2(ar, vec, proj, projection_mat); /* expand 2D rectangle */ - rect->xmin = MIN2(rect->xmin, proj[0]); - rect->xmax = MAX2(rect->xmax, proj[0]); - rect->ymin = MIN2(rect->ymin, proj[1]); - rect->ymax = MAX2(rect->ymax, proj[1]); + + /* we could project directly to int? */ + proj_i[0] = proj[0]; + proj_i[1] = proj[1]; + + BLI_rcti_do_minmax_v(rect, proj_i); } } } From c86d31cc55f98ebebdf8af0c76b89eb3b891f7a6 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 12 Jul 2012 09:56:18 +0000 Subject: [PATCH 22/27] Fix #32050: UV map and game engine property cause crash --- source/blender/editors/space_view3d/drawmesh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 38109c3048e..41d69030e1a 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -640,7 +640,7 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl) short matnr = mp->mat_nr; int mf_smooth = mp->flag & ME_SMOOTH; Material *mat = me->mat[matnr]; - int mode = mat->game.flag; + int mode = mat ? mat->game.flag : GEMAT_INVISIBLE; if (!(mode & GEMAT_INVISIBLE) && (mode & GEMAT_TEXT) && mp->totloop >= 3) { /* get the polygon as a tri/quad */ From f7f216262da9c809e2899d588f458db201f863a8 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 12 Jul 2012 10:27:22 +0000 Subject: [PATCH 23/27] Fix #32041: Empty display size is not taken into account for centering view --- source/blender/blenkernel/intern/object.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 2ba2ad7bd6e..a3145ddeedd 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2300,14 +2300,21 @@ void BKE_object_minmax(Object *ob, float min_r[3], float max_r[3]) } if (change == FALSE) { + float size[3]; + + copy_v3_v3(size, ob->size); + if (ob->type == OB_EMPTY) { + mul_v3_fl(size, ob->empty_drawsize); + } + minmax_v3v3_v3(min_r, max_r, ob->obmat[3]); copy_v3_v3(vec, ob->obmat[3]); - add_v3_v3(vec, ob->size); + add_v3_v3(vec, size); minmax_v3v3_v3(min_r, max_r, vec); copy_v3_v3(vec, ob->obmat[3]); - sub_v3_v3(vec, ob->size); + sub_v3_v3(vec, size); minmax_v3v3_v3(min_r, max_r, vec); } } From ddf7d364e953951cd576609376a35b88da467140 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 12 Jul 2012 11:22:46 +0000 Subject: [PATCH 24/27] Fix for metaballs used as dupli-object for particle It used to be a dependency cycle which lead to incorrect or missed tesselation on some circumstances. Seems to be introduced in rev41627. This commit seems to behaving properly on simple cases, probably could fail in some other cases, so need to be checked further. Discovered when was looking into: #32034: Metaball used as render object(group) for particle will display wire only. --- source/blender/blenkernel/intern/depsgraph.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 31621dffdef..4026d3f06d3 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -672,7 +672,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O * engine instancing assumes particular ordering of objects in list */ dag_add_relation(dag, node, node2, DAG_RL_OB_OB, "Particle Object Visualization"); if (part->dup_ob->type == OB_MBALL) - dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA, "Particle Object Visualization"); + dag_add_relation(dag, node, node2, DAG_RL_DATA_DATA, "Particle Object Visualization"); } if (part->ren_as == PART_DRAW_GR && part->dup_group) { From 30b3907128d2b7f6523158dcea2cac9668706cb9 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Thu, 12 Jul 2012 11:35:51 +0000 Subject: [PATCH 25/27] OSX: make the progressbar in dock a gradient, to give it a more matching 3D appearance --- intern/ghost/intern/GHOST_WindowCocoa.mm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm index f94f08b1d13..ac6cc548f32 100644 --- a/intern/ghost/intern/GHOST_WindowCocoa.mm +++ b/intern/ghost/intern/GHOST_WindowCocoa.mm @@ -1235,9 +1235,11 @@ GHOST_TSuccess GHOST_WindowCocoa::setProgressBar(float progress) // Progress fill progressBox = NSInsetRect(progressBox, 1, 1); - [[NSColor knobColor] setFill]; + progressBox.size.width = progressBox.size.width * progress; - NSRectFill(progressBox); + NSGradient *gradient = [[NSGradient alloc] initWithStartingColor:[NSColor darkGrayColor] endingColor:[NSColor lightGrayColor]]; + [gradient drawInRect:progressBox angle:90]; + [gradient release]; [dockIcon unlockFocus]; From 5a878c50ebe88eb6d41977a6f8c9201ec527b061 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 12 Jul 2012 11:52:09 +0000 Subject: [PATCH 26/27] Fixed issue with drag-n-drop into Clip Editor. --- source/blender/editors/space_clip/clip_ops.c | 6 +++--- source/blender/editors/space_clip/space_clip.c | 12 ++++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index 9d1f52568b4..948b6490331 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -239,12 +239,12 @@ static int open_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) strncpy(path, U.textudir, sizeof(path)); } + if (RNA_struct_property_is_set(op->ptr, "files")) + return open_exec(C, op); + if (!RNA_struct_property_is_set(op->ptr, "relative_path")) RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS); - if (RNA_struct_property_is_set(op->ptr, "filepath")) - return open_exec(C, op); - open_init(C, op); clip_filesel(C, op, path); diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 0a6a4af6960..13caf0b51fe 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -792,8 +792,16 @@ static int clip_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(eve static void clip_drop_copy(wmDrag *drag, wmDropBox *drop) { - /* copy drag path to properties */ - RNA_string_set(drop->ptr, "filepath", drag->path); + PointerRNA itemptr; + char dir[FILE_MAX], file[FILE_MAX]; + + BLI_split_dirfile(drag->path, dir, file, sizeof(dir), sizeof(file)); + + RNA_string_set(drop->ptr, "directory", dir); + + RNA_collection_clear(drop->ptr, "files"); + RNA_collection_add(drop->ptr, "files", &itemptr); + RNA_string_set(&itemptr, "name", file); } /* area+region dropbox definition */ From 8ef23c6743ce00176754597f60ae549093ab6339 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 12 Jul 2012 12:06:40 +0000 Subject: [PATCH 27/27] Clip editor mode selection: show menu with modes on TAB This seems to be the only straightforward way to switch fast between modes without keeping bunch of shortcuts and current mode in head. --- release/scripts/startup/bl_ui/space_clip.py | 11 ++++++++++ source/blender/editors/space_clip/clip_ops.c | 20 +++---------------- .../blender/editors/space_clip/space_clip.c | 8 +------- source/blender/makesrna/RNA_enum_types.h | 2 ++ source/blender/makesrna/intern/rna_space.c | 20 +++++++++---------- 5 files changed, 27 insertions(+), 34 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index a590a6cea94..d937837e5d1 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -1301,6 +1301,17 @@ class CLIP_MT_mask(Menu): layout.menu("CLIP_MT_mask_animation") +class CLIP_MT_select_mode(Menu): + bl_label = "Select Mode" + + def draw(self, context): + layout = self.layout + + layout.operator_context = 'INVOKE_REGION_WIN' + + layout.operator_enum("clip.mode_set", "mode") + + class CLIP_MT_mask_visibility(Menu): bl_label = "Show/Hide" diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index 948b6490331..86d74ef4c78 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -62,6 +62,7 @@ #include "RNA_access.h" #include "RNA_define.h" +#include "RNA_enum_types.h" #include "UI_view2d.h" @@ -1074,15 +1075,8 @@ static int mode_set_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); int mode = RNA_enum_get(op->ptr, "mode"); - int toggle = RNA_boolean_get(op->ptr, "toggle"); - if (sc->mode == mode) { - if (toggle) - sc->mode = SC_MODE_TRACKING; - } - else { - sc->mode = mode; - } + sc->mode = mode; WM_event_add_notifier(C, NC_SPACE | ND_SPACE_CLIP, NULL); @@ -1091,13 +1085,6 @@ static int mode_set_exec(bContext *C, wmOperator *op) void CLIP_OT_mode_set(wmOperatorType *ot) { - static EnumPropertyItem mode_items[] = { - {SC_MODE_TRACKING, "TRACKING", 0, "Tracking", "Show tracking and solving tools"}, - {SC_MODE_RECONSTRUCTION, "RECONSTRUCTION", 0, "Reconstruction", "Show tracking/reconstruction tools"}, - {SC_MODE_DISTORTION, "DISTORTION", 0, "Distortion", "Show distortion tools"}, - {0, NULL, 0, NULL, NULL}}; - - /* identifiers */ ot->name = "Set Clip Mode"; ot->description = "Set the clip interaction mode"; @@ -1109,8 +1096,7 @@ void CLIP_OT_mode_set(wmOperatorType *ot) ot->poll = ED_space_clip_poll; /* properties */ - RNA_def_enum(ot->srna, "mode", mode_items, SC_MODE_TRACKING, "Mode", ""); - RNA_def_boolean(ot->srna, "toggle", 0, "Toggle", ""); + RNA_def_enum(ot->srna, "mode", clip_editor_mode_items, SC_MODE_TRACKING, "Mode", ""); } /********************** macroses *********************/ diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 13caf0b51fe..3623cd1d58b 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -559,13 +559,7 @@ static void clip_keymap(struct wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "sequence", TRUE); /* mode */ - kmi = WM_keymap_add_item(keymap, "CLIP_OT_mode_set", TABKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "mode", SC_MODE_RECONSTRUCTION); - RNA_boolean_set(kmi->ptr, "toggle", TRUE); - - kmi = WM_keymap_add_item(keymap, "CLIP_OT_mode_set", TABKEY, KM_PRESS, KM_CTRL, 0); - RNA_enum_set(kmi->ptr, "mode", SC_MODE_DISTORTION); - RNA_boolean_set(kmi->ptr, "toggle", TRUE); + WM_keymap_add_menu(keymap, "CLIP_MT_select_mode", TABKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "CLIP_OT_solve_camera", SKEY, KM_PRESS, KM_SHIFT, 0); diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index a0614a9d82a..2fbee1e9e1a 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -127,6 +127,8 @@ extern EnumPropertyItem ramp_blend_items[]; extern EnumPropertyItem prop_dynamicpaint_type_items[]; +extern EnumPropertyItem clip_editor_mode_items[]; + struct bContext; struct PointerRNA; struct PropertyRNA; diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index d5bac7a8c26..4473a9ef0f6 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -118,6 +118,15 @@ EnumPropertyItem viewport_shade_items[] = { {0, NULL, 0, NULL, NULL} }; +EnumPropertyItem clip_editor_mode_items[] = { + {SC_MODE_TRACKING, "TRACKING", ICON_ANIM_DATA, "Tracking", "Show tracking and solving tools"}, + {SC_MODE_RECONSTRUCTION, "RECONSTRUCTION", ICON_SNAP_FACE, "Reconstruction", + "Show tracking/reconstruction tools"}, + {SC_MODE_DISTORTION, "DISTORTION", ICON_GRID, "Distortion", "Show distortion tools"}, + {SC_MODE_MASKEDIT, "MASKEDIT", ICON_MOD_MASK, "Mask editing", "Show mask editing tools"}, + {0, NULL, 0, NULL, NULL} +}; + #ifdef RNA_RUNTIME #include "DNA_anim_types.h" @@ -3011,15 +3020,6 @@ static void rna_def_space_clip(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - static EnumPropertyItem mode_items[] = { - {SC_MODE_TRACKING, "TRACKING", ICON_ANIM_DATA, "Tracking", "Show tracking and solving tools"}, - {SC_MODE_RECONSTRUCTION, "RECONSTRUCTION", ICON_SNAP_FACE, "Reconstruction", - "Show tracking/reconstruction tools"}, - {SC_MODE_DISTORTION, "DISTORTION", ICON_GRID, "Distortion", "Show distortion tools"}, - {SC_MODE_MASKEDIT, "MASKEDIT", ICON_MOD_MASK, "Mask editing", "Show mask editing tools"}, - {0, NULL, 0, NULL, NULL} - }; - static EnumPropertyItem view_items[] = { {SC_VIEW_CLIP, "CLIP", ICON_SEQUENCE, "Clip", "Show editing clip preview"}, {SC_VIEW_GRAPH, "GRAPH", ICON_IPO, "Graph", "Show graph view for active element"}, @@ -3086,7 +3086,7 @@ static void rna_def_space_clip(BlenderRNA *brna) /* mode */ prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "mode"); - RNA_def_property_enum_items(prop, mode_items); + RNA_def_property_enum_items(prop, clip_editor_mode_items); RNA_def_property_ui_text(prop, "Mode", "Editing context being displayed"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, "rna_SpaceClipEditor_clip_mode_update");