diff options
52 files changed, 519 insertions, 339 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 23e9eba0cf0..3e1c8fec02a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -241,11 +241,6 @@ option(WITH_PYTHON_INSTALL_NUMPY "Copy system numpy into the blender install fol set(PYTHON_NUMPY_PATH "" CACHE PATH "Python to python site-packages or dist-packages containing 'numpy' module") mark_as_advanced(PYTHON_NUMPY_PATH) -if(MINGW) - option(WITH_MINGW64 "Use the 64-bit version of MinGW" OFF) - mark_as_advanced(WITH_MINGW64) -endif() - # Cycles option(WITH_CYCLES "Enable cycles Render Engine" ON) option(WITH_CYCLES_TEST "Build cycles test application" OFF) @@ -867,8 +862,16 @@ elseif(WIN32) if(CMAKE_COMPILER_IS_GNUCC) set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/mingw32) - + INCLUDE (CheckCSourceCompiles) # Setup 64bit and 64bit windows systems + CHECK_C_SOURCE_COMPILES(" + #ifndef __MINGW64__ + #error + #endif + main(){} + " + WITH_MINGW64) + if(WITH_MINGW64) message("Compiling for 64 bit with MinGW-w64.") set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/mingw64) @@ -940,13 +943,6 @@ elseif(WIN32) endif() endif() - if(WITH_LLVM) - set(LLVM_DIRECTORY ${LIBDIR}/llvm CACHE PATH "Path to the LLVM installation") - file(GLOB LLVM_LIBRARY ${LLVM_DIRECTORY}/lib/*.lib) - set(LLVM_STATIC YES) - endif() - - if(MSVC) set(PLATFORM_LINKLIBS ws2_32 vfw32 winmm kernel32 user32 gdi32 comdlg32 advapi32 shfolder shell32 ole32 oleaut32 uuid psapi) @@ -1149,6 +1145,12 @@ elseif(WIN32) set(OPENIMAGEIO_DEFINITIONS "-DUSE_TBB=0") endif() + if(WITH_LLVM) + set(LLVM_DIRECTORY ${LIBDIR}/llvm CACHE PATH "Path to the LLVM installation") + file(GLOB LLVM_LIBRARY ${LLVM_DIRECTORY}/lib/*.lib) + set(LLVM_STATIC YES) + endif() + if(WITH_OPENCOLORIO) set(OPENCOLORIO ${LIBDIR}/opencolorio) set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO}/include) @@ -1261,6 +1263,7 @@ elseif(WIN32) if(WITH_IMAGE_OPENEXR) set(OPENEXR ${LIBDIR}/openexr) + set(OPENEXR_INCLUDE_DIR ${OPENEXR}/include) set(OPENEXR_INCLUDE_DIRS ${OPENEXR}/include/OpenEXR) set(OPENEXR_LIBRARIES Half IlmImf Imath IlmThread Iex) set(OPENEXR_LIBPATH ${OPENEXR}/lib) @@ -1328,6 +1331,34 @@ elseif(WIN32) set(OPENIMAGEIO_DEFINITIONS) endif() + if(WITH_LLVM) + set(LLVM_DIRECTORY ${LIBDIR}/llvm CACHE PATH "Path to the LLVM installation") + set(LLVM_LIB_DIR ${LLVM_DIRECTORY}/lib) + #Explicitly set llvm lib order. + #---- WARNING ON GCC ORDER OF LIBS IS IMPORTANT, DO NOT CHANGE! --------- + set(LLVM_LIBRARY LLVMSelectionDAG LLVMCodeGen LLVMScalarOpts LLVMAnalysis LLVMArchive + LLVMAsmParser LLVMAsmPrinter + LLVMBitReader LLVMBitWriter + LLVMDebugInfo LLVMExecutionEngine + LLVMInstCombine LLVMInstrumentation + LLVMInterpreter LLVMJIT + LLVMLinker LLVMMC + LLVMMCDisassembler LLVMMCJIT + LLVMMCParser LLVMObject + LLVMRuntimeDyld + LLVMSupport + LLVMTableGen LLVMTarget + LLVMTransformUtils LLVMVectorize + LLVMX86AsmParser LLVMX86AsmPrinter + LLVMX86CodeGen LLVMX86Desc + LLVMX86Disassembler LLVMX86Info + LLVMX86Utils LLVMipa + LLVMipo LLVMCore) + #imagehelp is needed by LLVM 3.1 on MinGW, check lib\Support\Windows\Signals.inc + set(PLATFORM_LINKLIBS "${PLATFORM_LINKLIBS} -limagehlp") + set(LLVM_STATIC YES) + endif() + if(WITH_OPENCOLORIO) set(OPENCOLORIO ${LIBDIR}/opencolorio) set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO}/include) @@ -1839,7 +1870,7 @@ if(CMAKE_COMPILER_IS_GNUCC) ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_DIV_BY_ZERO -Wno-div-by-zero) # gcc 4.2 gives annoying warnings on every file with this - if ("${CMAKE_C_COMPILER_VERSION}" VERSION_GREATER "4.2") + if (NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.3") ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNINITIALIZED -Wuninitialized) endif() @@ -1859,7 +1890,7 @@ if(CMAKE_COMPILER_IS_GNUCC) ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_DIV_BY_ZERO -Wno-div-by-zero) # gcc 4.2 gives annoying warnings on every file with this - if ("${CMAKE_C_COMPILER_VERSION}" VERSION_GREATER "4.2") + if (NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.3") ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNINITIALIZED -Wuninitialized) endif() @@ -1933,7 +1964,7 @@ if(WITH_PYTHON) if(WITH_PYTHON_INSTALL AND WITH_PYTHON_INSTALL_NUMPY) # set but invalid # -- disabled until we make numpy bundled with blender - campbell - if(NOT ${PYTHON_NUMPY_PATH} STREQUAL "") + if((NOT ${PYTHON_NUMPY_PATH} STREQUAL "") AND (NOT ${PYTHON_NUMPY_PATH} MATCHES NOTFOUND)) # if(NOT EXISTS "${PYTHON_NUMPY_PATH}/numpy") # message(WARNING "PYTHON_NUMPY_PATH is invalid, numpy not found in '${PYTHON_NUMPY_PATH}' " # "WITH_PYTHON_INSTALL_NUMPY option will be ignored when installing python") diff --git a/build_files/cmake/cmake_static_check_cppcheck.py b/build_files/cmake/cmake_static_check_cppcheck.py index 12369a5e8cd..d79145f8586 100644 --- a/build_files/cmake/cmake_static_check_cppcheck.py +++ b/build_files/cmake/cmake_static_check_cppcheck.py @@ -46,6 +46,9 @@ CHECKER_ARGS = [ # "--enable=all", # if you want sixty hundred pedantic suggestions ] +if USE_QUIET: + CHECKER_ARGS.append("--quiet") + def main(): source_info = project_source_info.build_info(ignore_prefix_list=CHECKER_IGNORE_PREFIX) @@ -78,6 +81,8 @@ def main(): project_source_info.queue_processes(process_functions) + print("Finished!") + if __name__ == "__main__": main() diff --git a/extern/libmv/libmv/simple_pipeline/resect.cc b/extern/libmv/libmv/simple_pipeline/resect.cc index 4c9ca6d8677..3929271e66f 100644 --- a/extern/libmv/libmv/simple_pipeline/resect.cc +++ b/extern/libmv/libmv/simple_pipeline/resect.cc @@ -57,7 +57,7 @@ struct EuclideanResectCostFunction { EuclideanResectCostFunction(const vector<Marker> &markers, const EuclideanReconstruction &reconstruction, - const Mat3 initial_R) + const Mat3 &initial_R) : markers(markers), reconstruction(reconstruction), initial_R(initial_R) {} diff --git a/intern/audaspace/CMakeLists.txt b/intern/audaspace/CMakeLists.txt index 1617e520ac7..91b0549f742 100644 --- a/intern/audaspace/CMakeLists.txt +++ b/intern/audaspace/CMakeLists.txt @@ -34,6 +34,7 @@ set(INC_SYS set(SRC FX/AUD_AccumulatorFactory.cpp FX/AUD_BaseIIRFilterReader.cpp + FX/AUD_ButterworthCalculator.cpp FX/AUD_ButterworthFactory.cpp FX/AUD_CallbackIIRFilterReader.cpp FX/AUD_DelayFactory.cpp @@ -47,6 +48,7 @@ set(SRC FX/AUD_EnvelopeFactory.cpp FX/AUD_FaderFactory.cpp FX/AUD_FaderReader.cpp + FX/AUD_HighpassCalculator.cpp FX/AUD_HighpassFactory.cpp FX/AUD_IIRFilterFactory.cpp FX/AUD_IIRFilterReader.cpp @@ -54,6 +56,7 @@ set(SRC FX/AUD_LimiterReader.cpp FX/AUD_LoopFactory.cpp FX/AUD_LoopReader.cpp + FX/AUD_LowpassCalculator.cpp FX/AUD_LowpassFactory.cpp FX/AUD_PingPongFactory.cpp FX/AUD_PitchFactory.cpp @@ -145,6 +148,7 @@ set(SRC FX/AUD_AccumulatorFactory.h FX/AUD_BaseIIRFilterReader.h + FX/AUD_ButterworthCalculator.h FX/AUD_ButterworthFactory.h FX/AUD_CallbackIIRFilterReader.h FX/AUD_DelayFactory.h @@ -159,6 +163,7 @@ set(SRC FX/AUD_EnvelopeFactory.h FX/AUD_FaderFactory.h FX/AUD_FaderReader.h + FX/AUD_HighpassCalculator.h FX/AUD_HighpassFactory.h FX/AUD_IIRFilterFactory.h FX/AUD_IIRFilterReader.h @@ -166,6 +171,7 @@ set(SRC FX/AUD_LimiterReader.h FX/AUD_LoopFactory.h FX/AUD_LoopReader.h + FX/AUD_LowpassCalculator.h FX/AUD_LowpassFactory.h FX/AUD_PingPongFactory.h FX/AUD_PitchFactory.h diff --git a/intern/audaspace/FX/AUD_BandpassCalculator.cpp b/intern/audaspace/FX/AUD_BandpassCalculator.cpp new file mode 100644 index 00000000000..f5bbd63f81c --- /dev/null +++ b/intern/audaspace/FX/AUD_BandpassCalculator.cpp @@ -0,0 +1,5 @@ +#include "AUD_BandpassCalculator.h" + +AUD_BandpassCalculator::AUD_BandpassCalculator() +{ +} diff --git a/intern/audaspace/FX/AUD_BandpassCalculator.h b/intern/audaspace/FX/AUD_BandpassCalculator.h new file mode 100644 index 00000000000..b5b3cad17ca --- /dev/null +++ b/intern/audaspace/FX/AUD_BandpassCalculator.h @@ -0,0 +1,10 @@ +#ifndef AUD_BANDPASSCALCULATOR_H +#define AUD_BANDPASSCALCULATOR_H + +class AUD_BandpassCalculator +{ +public: + AUD_BandpassCalculator(); +}; + +#endif // AUD_BANDPASSCALCULATOR_H diff --git a/intern/audaspace/FX/AUD_ButterworthCalculator.cpp b/intern/audaspace/FX/AUD_ButterworthCalculator.cpp new file mode 100644 index 00000000000..7a3c6f71e15 --- /dev/null +++ b/intern/audaspace/FX/AUD_ButterworthCalculator.cpp @@ -0,0 +1,38 @@ +#include "AUD_ButterworthCalculator.h" + +#include <cmath> + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +#define BWPB41 0.76536686473 +#define BWPB42 1.84775906502 + +AUD_ButterworthCalculator::AUD_ButterworthCalculator(float frequency) : + m_frequency(frequency) +{ +} + +void AUD_ButterworthCalculator::recalculateCoefficients(AUD_SampleRate rate, std::vector<float> &b, std::vector<float> &a) +{ + float omega = 2 * tan(m_frequency * M_PI / rate); + float o2 = omega * omega; + float o4 = o2 * o2; + float x1 = o2 + 2.0f * (float)BWPB41 * omega + 4.0f; + float x2 = o2 + 2.0f * (float)BWPB42 * omega + 4.0f; + float y1 = o2 - 2.0f * (float)BWPB41 * omega + 4.0f; + float y2 = o2 - 2.0f * (float)BWPB42 * omega + 4.0f; + float o228 = 2.0f * o2 - 8.0f; + float norm = x1 * x2; + a.push_back(1); + a.push_back((x1 + x2) * o228 / norm); + a.push_back((x1 * y2 + x2 * y1 + o228 * o228) / norm); + a.push_back((y1 + y2) * o228 / norm); + a.push_back(y1 * y2 / norm); + b.push_back(o4 / norm); + b.push_back(4 * o4 / norm); + b.push_back(6 * o4 / norm); + b.push_back(b[1]); + b.push_back(b[0]); +} diff --git a/intern/audaspace/FX/AUD_ButterworthCalculator.h b/intern/audaspace/FX/AUD_ButterworthCalculator.h new file mode 100644 index 00000000000..a7ae196afda --- /dev/null +++ b/intern/audaspace/FX/AUD_ButterworthCalculator.h @@ -0,0 +1,20 @@ +#ifndef AUD_BUTTERWORTHCALCULATOR_H +#define AUD_BUTTERWORTHCALCULATOR_H + +#include "AUD_IDynamicIIRFilterCalculator.h" + +class AUD_ButterworthCalculator : public AUD_IDynamicIIRFilterCalculator +{ +private: + /** + * The attack value in seconds. + */ + const float m_frequency; + +public: + AUD_ButterworthCalculator(float frequency); + + virtual void recalculateCoefficients(AUD_SampleRate rate, std::vector<float> &b, std::vector<float> &a); +}; + +#endif // AUD_BUTTERWORTHCALCULATOR_H diff --git a/intern/audaspace/FX/AUD_ButterworthFactory.cpp b/intern/audaspace/FX/AUD_ButterworthFactory.cpp index 97d85c8122f..12c4306c2f7 100644 --- a/intern/audaspace/FX/AUD_ButterworthFactory.cpp +++ b/intern/audaspace/FX/AUD_ButterworthFactory.cpp @@ -29,44 +29,11 @@ #include "AUD_ButterworthFactory.h" #include "AUD_IIRFilterReader.h" - -#include <cmath> - -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - -#define BWPB41 0.76536686473 -#define BWPB42 1.84775906502 +#include "AUD_ButterworthCalculator.h" AUD_ButterworthFactory::AUD_ButterworthFactory(boost::shared_ptr<AUD_IFactory> factory, float frequency) : - AUD_DynamicIIRFilterFactory(factory), - m_frequency(frequency) + AUD_DynamicIIRFilterFactory(factory, boost::shared_ptr<AUD_IDynamicIIRFilterCalculator>(new AUD_ButterworthCalculator(frequency))) { } -void AUD_ButterworthFactory::recalculateCoefficients(AUD_SampleRate rate, - std::vector<float> &b, - std::vector<float> &a) -{ - float omega = 2 * tan(m_frequency * M_PI / rate); - float o2 = omega * omega; - float o4 = o2 * o2; - float x1 = o2 + 2.0f * (float)BWPB41 * omega + 4.0f; - float x2 = o2 + 2.0f * (float)BWPB42 * omega + 4.0f; - float y1 = o2 - 2.0f * (float)BWPB41 * omega + 4.0f; - float y2 = o2 - 2.0f * (float)BWPB42 * omega + 4.0f; - float o228 = 2.0f * o2 - 8.0f; - float norm = x1 * x2; - a.push_back(1); - a.push_back((x1 + x2) * o228 / norm); - a.push_back((x1 * y2 + x2 * y1 + o228 * o228) / norm); - a.push_back((y1 + y2) * o228 / norm); - a.push_back(y1 * y2 / norm); - b.push_back(o4 / norm); - b.push_back(4 * o4 / norm); - b.push_back(6 * o4 / norm); - b.push_back(b[1]); - b.push_back(b[0]); -} diff --git a/intern/audaspace/FX/AUD_ButterworthFactory.h b/intern/audaspace/FX/AUD_ButterworthFactory.h index e796f76aa29..3a86b14a7a6 100644 --- a/intern/audaspace/FX/AUD_ButterworthFactory.h +++ b/intern/audaspace/FX/AUD_ButterworthFactory.h @@ -38,11 +38,6 @@ class AUD_ButterworthFactory : public AUD_DynamicIIRFilterFactory { private: - /** - * The attack value in seconds. - */ - const float m_frequency; - // hide copy constructor and operator= AUD_ButterworthFactory(const AUD_ButterworthFactory&); AUD_ButterworthFactory& operator=(const AUD_ButterworthFactory&); @@ -54,10 +49,6 @@ public: * \param frequency The cutoff frequency. */ AUD_ButterworthFactory(boost::shared_ptr<AUD_IFactory> factory, float frequency); - - virtual void recalculateCoefficients(AUD_SampleRate rate, - std::vector<float>& b, - std::vector<float>& a); }; #endif //__AUD_BUTTERWORTHFACTORY_H__ diff --git a/intern/audaspace/FX/AUD_DynamicIIRFilterFactory.cpp b/intern/audaspace/FX/AUD_DynamicIIRFilterFactory.cpp index e8ea4323b2e..319a78cfedd 100644 --- a/intern/audaspace/FX/AUD_DynamicIIRFilterFactory.cpp +++ b/intern/audaspace/FX/AUD_DynamicIIRFilterFactory.cpp @@ -30,8 +30,10 @@ #include "AUD_DynamicIIRFilterReader.h" -AUD_DynamicIIRFilterFactory::AUD_DynamicIIRFilterFactory(boost::shared_ptr<AUD_IFactory> factory) : - AUD_EffectFactory(factory) +AUD_DynamicIIRFilterFactory::AUD_DynamicIIRFilterFactory(boost::shared_ptr<AUD_IFactory> factory, + boost::shared_ptr<AUD_IDynamicIIRFilterCalculator> calculator) : + AUD_EffectFactory(factory), + m_calculator(calculator) { } diff --git a/intern/audaspace/FX/AUD_DynamicIIRFilterFactory.h b/intern/audaspace/FX/AUD_DynamicIIRFilterFactory.h index f36a37f44b4..aece7a8c2ef 100644 --- a/intern/audaspace/FX/AUD_DynamicIIRFilterFactory.h +++ b/intern/audaspace/FX/AUD_DynamicIIRFilterFactory.h @@ -49,7 +49,8 @@ public: * Creates a new Dynmic IIR filter factory. * \param factory The input factory. */ - AUD_DynamicIIRFilterFactory(boost::shared_ptr<AUD_IFactory> factory); + AUD_DynamicIIRFilterFactory(boost::shared_ptr<AUD_IFactory> factory, + boost::shared_ptr<AUD_IDynamicIIRFilterCalculator> calculator); virtual boost::shared_ptr<AUD_IReader> createReader(); }; diff --git a/intern/audaspace/FX/AUD_HighpassCalculator.cpp b/intern/audaspace/FX/AUD_HighpassCalculator.cpp new file mode 100644 index 00000000000..573bba1c62b --- /dev/null +++ b/intern/audaspace/FX/AUD_HighpassCalculator.cpp @@ -0,0 +1,27 @@ +#include "AUD_HighpassCalculator.h" + +#include <cmath> + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +AUD_HighpassCalculator::AUD_HighpassCalculator(float frequency, float Q) : + m_frequency(frequency), + m_Q(Q) +{ +} + +void AUD_HighpassCalculator::recalculateCoefficients(AUD_SampleRate rate, std::vector<float> &b, std::vector<float> &a) +{ + float w0 = 2.0 * M_PI * (AUD_SampleRate)m_frequency / rate; + float alpha = (float)(sin(w0) / (2.0 * (double)m_Q)); + float norm = 1 + alpha; + float c = cos(w0); + a.push_back(1); + a.push_back(-2 * c / norm); + a.push_back((1 - alpha) / norm); + b.push_back((1 + c) / (2 * norm)); + b.push_back((-1 - c) / norm); + b.push_back(b[0]); +} diff --git a/intern/audaspace/FX/AUD_HighpassCalculator.h b/intern/audaspace/FX/AUD_HighpassCalculator.h new file mode 100644 index 00000000000..bad1c08f7c7 --- /dev/null +++ b/intern/audaspace/FX/AUD_HighpassCalculator.h @@ -0,0 +1,25 @@ +#ifndef AUD_HIGHPASSCALCULATOR_H +#define AUD_HIGHPASSCALCULATOR_H + +#include "AUD_IDynamicIIRFilterCalculator.h" + +class AUD_HighpassCalculator : public AUD_IDynamicIIRFilterCalculator +{ +private: + /** + * The cutoff frequency. + */ + const float m_frequency; + + /** + * The Q factor. + */ + const float m_Q; + +public: + AUD_HighpassCalculator(float frequency, float Q); + + virtual void recalculateCoefficients(AUD_SampleRate rate, std::vector<float> &b, std::vector<float> &a); +}; + +#endif // AUD_HIGHPASSCALCULATOR_H diff --git a/intern/audaspace/FX/AUD_HighpassFactory.cpp b/intern/audaspace/FX/AUD_HighpassFactory.cpp index ba5297d21ed..2456085a8a1 100644 --- a/intern/audaspace/FX/AUD_HighpassFactory.cpp +++ b/intern/audaspace/FX/AUD_HighpassFactory.cpp @@ -29,33 +29,11 @@ #include "AUD_HighpassFactory.h" #include "AUD_IIRFilterReader.h" - -#include <cmath> - -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif +#include "AUD_HighpassCalculator.h" AUD_HighpassFactory::AUD_HighpassFactory(boost::shared_ptr<AUD_IFactory> factory, float frequency, float Q) : - AUD_DynamicIIRFilterFactory(factory), - m_frequency(frequency), - m_Q(Q) + AUD_DynamicIIRFilterFactory(factory, boost::shared_ptr<AUD_IDynamicIIRFilterCalculator>(new AUD_HighpassCalculator(frequency, Q))) { } -void AUD_HighpassFactory::recalculateCoefficients(AUD_SampleRate rate, - std::vector<float> &b, - std::vector<float> &a) -{ - float w0 = 2.0 * M_PI * (AUD_SampleRate)m_frequency / rate; - float alpha = (float)(sin(w0) / (2.0 * (double)m_Q)); - float norm = 1 + alpha; - float c = cos(w0); - a.push_back(1); - a.push_back(-2 * c / norm); - a.push_back((1 - alpha) / norm); - b.push_back((1 + c) / (2 * norm)); - b.push_back((-1 - c) / norm); - b.push_back(b[0]); -} diff --git a/intern/audaspace/FX/AUD_HighpassFactory.h b/intern/audaspace/FX/AUD_HighpassFactory.h index ed7e9db44a4..56ced91c53c 100644 --- a/intern/audaspace/FX/AUD_HighpassFactory.h +++ b/intern/audaspace/FX/AUD_HighpassFactory.h @@ -38,16 +38,6 @@ class AUD_HighpassFactory : public AUD_DynamicIIRFilterFactory { private: - /** - * The cutoff frequency. - */ - const float m_frequency; - - /** - * The Q factor. - */ - const float m_Q; - // hide copy constructor and operator= AUD_HighpassFactory(const AUD_HighpassFactory&); AUD_HighpassFactory& operator=(const AUD_HighpassFactory&); @@ -60,8 +50,6 @@ public: * \param Q The Q factor. */ AUD_HighpassFactory(boost::shared_ptr<AUD_IFactory> factory, float frequency, float Q = 1.0f); - - virtual void recalculateCoefficients(AUD_SampleRate rate, std::vector<float> &b, std::vector<float> &a); }; #endif //__AUD_HIGHPASSFACTORY_H__ diff --git a/intern/audaspace/FX/AUD_IDynamicIIRFilterCalculator.h b/intern/audaspace/FX/AUD_IDynamicIIRFilterCalculator.h index 77d83360255..29b87e57ad0 100644 --- a/intern/audaspace/FX/AUD_IDynamicIIRFilterCalculator.h +++ b/intern/audaspace/FX/AUD_IDynamicIIRFilterCalculator.h @@ -29,6 +29,8 @@ #ifndef AUD_IDYNAMICIIRFILTERCALCULATOR_H #define AUD_IDYNAMICIIRFILTERCALCULATOR_H +#include "AUD_Space.h" + #include <vector> /** diff --git a/intern/audaspace/FX/AUD_LowpassCalculator.cpp b/intern/audaspace/FX/AUD_LowpassCalculator.cpp new file mode 100644 index 00000000000..57452f09038 --- /dev/null +++ b/intern/audaspace/FX/AUD_LowpassCalculator.cpp @@ -0,0 +1,27 @@ +#include "AUD_LowpassCalculator.h" + +#include <cmath> + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +AUD_LowpassCalculator::AUD_LowpassCalculator(float frequency, float Q) : + m_frequency(frequency), + m_Q(Q) +{ +} + +void AUD_LowpassCalculator::recalculateCoefficients(AUD_SampleRate rate, std::vector<float> &b, std::vector<float> &a) +{ + float w0 = 2 * M_PI * m_frequency / rate; + float alpha = sin(w0) / (2 * m_Q); + float norm = 1 + alpha; + float c = cos(w0); + a.push_back(1); + a.push_back(-2 * c / norm); + a.push_back((1 - alpha) / norm); + b.push_back((1 - c) / (2 * norm)); + b.push_back((1 - c) / norm); + b.push_back(b[0]); +} diff --git a/intern/audaspace/FX/AUD_LowpassCalculator.h b/intern/audaspace/FX/AUD_LowpassCalculator.h new file mode 100644 index 00000000000..18bb11feda7 --- /dev/null +++ b/intern/audaspace/FX/AUD_LowpassCalculator.h @@ -0,0 +1,25 @@ +#ifndef AUD_LOWPASSCALCULATOR_H +#define AUD_LOWPASSCALCULATOR_H + +#include "AUD_IDynamicIIRFilterCalculator.h" + +class AUD_LowpassCalculator : public AUD_IDynamicIIRFilterCalculator +{ +private: + /** + * The cutoff frequency. + */ + const float m_frequency; + + /** + * The Q factor. + */ + const float m_Q; + +public: + AUD_LowpassCalculator(float frequency, float Q); + + virtual void recalculateCoefficients(AUD_SampleRate rate, std::vector<float> &b, std::vector<float> &a); +}; + +#endif // AUD_LOWPASSCALCULATOR_H diff --git a/intern/audaspace/FX/AUD_LowpassFactory.cpp b/intern/audaspace/FX/AUD_LowpassFactory.cpp index e2faa241ac9..bd225998392 100644 --- a/intern/audaspace/FX/AUD_LowpassFactory.cpp +++ b/intern/audaspace/FX/AUD_LowpassFactory.cpp @@ -29,33 +29,10 @@ #include "AUD_LowpassFactory.h" #include "AUD_IIRFilterReader.h" - -#include <cmath> - -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif +#include "AUD_LowpassCalculator.h" AUD_LowpassFactory::AUD_LowpassFactory(boost::shared_ptr<AUD_IFactory> factory, float frequency, float Q) : - AUD_DynamicIIRFilterFactory(factory), - m_frequency(frequency), - m_Q(Q) -{ -} - -void AUD_LowpassFactory::recalculateCoefficients(AUD_SampleRate rate, - std::vector<float> &b, - std::vector<float> &a) + AUD_DynamicIIRFilterFactory(factory, boost::shared_ptr<AUD_IDynamicIIRFilterCalculator>(new AUD_LowpassCalculator(frequency, Q))) { - float w0 = 2 * M_PI * m_frequency / rate; - float alpha = sin(w0) / (2 * m_Q); - float norm = 1 + alpha; - float c = cos(w0); - a.push_back(1); - a.push_back(-2 * c / norm); - a.push_back((1 - alpha) / norm); - b.push_back((1 - c) / (2 * norm)); - b.push_back((1 - c) / norm); - b.push_back(b[0]); } diff --git a/intern/audaspace/FX/AUD_LowpassFactory.h b/intern/audaspace/FX/AUD_LowpassFactory.h index fdbc6e5d91d..dfd8ab35521 100644 --- a/intern/audaspace/FX/AUD_LowpassFactory.h +++ b/intern/audaspace/FX/AUD_LowpassFactory.h @@ -38,16 +38,6 @@ class AUD_LowpassFactory : public AUD_DynamicIIRFilterFactory { private: - /** - * The cutoff frequency. - */ - const float m_frequency; - - /** - * The Q factor. - */ - const float m_Q; - // hide copy constructor and operator= AUD_LowpassFactory(const AUD_LowpassFactory&); AUD_LowpassFactory& operator=(const AUD_LowpassFactory&); @@ -60,8 +50,6 @@ public: * \param Q The Q factor. */ AUD_LowpassFactory(boost::shared_ptr<AUD_IFactory> factory, float frequency, float Q = 1.0f); - - virtual void recalculateCoefficients(AUD_SampleRate rate, std::vector<float> &b, std::vector<float> &a); }; #endif //__AUD_LOWPASSFACTORY_H__ diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp index 95263ebe463..38f27bcf2af 100644 --- a/intern/cycles/blender/blender_object.cpp +++ b/intern/cycles/blender/blender_object.cpp @@ -310,6 +310,13 @@ Object *BlenderSync::sync_object(BL::Object b_parent, int persistent_id[OBJECT_P return object; } +static bool object_dupli_hide_original(BL::Object::dupli_type_enum dupli_type) +{ + return (dupli_type == BL::Object::dupli_type_VERTS || + dupli_type == BL::Object::dupli_type_FACES || + dupli_type == BL::Object::dupli_type_FRAMES); +} + /* Object Loop */ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, int motion) @@ -371,6 +378,12 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, int motion) emitter_hide = false; } + /* hide original object for duplis */ + BL::Object parent = b_dup_ob.parent(); + if(parent && object_dupli_hide_original(parent.dupli_type())) + if(b_dup->type() == BL::DupliObject::type_GROUP) + dup_hide = true; + if(!(b_dup->hide() || dup_hide || emitter_hide)) { /* the persistent_id allows us to match dupli objects * between frames and updates */ @@ -399,10 +412,14 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, int motion) /* check if we should render or hide particle emitter */ BL::Object::particle_systems_iterator b_psys; - for(b_ob->particle_systems.begin(b_psys); b_psys != b_ob->particle_systems.end(); ++b_psys) { + for(b_ob->particle_systems.begin(b_psys); b_psys != b_ob->particle_systems.end(); ++b_psys) if(b_psys->settings().use_render_emitter()) hide = false; - } + + /* hide original object for duplis */ + BL::Object parent = b_ob->parent(); + if(parent && object_dupli_hide_original(parent.dupli_type())) + hide = true; if(!hide) { /* object itself */ diff --git a/intern/cycles/kernel/osl/osl_shader.cpp b/intern/cycles/kernel/osl/osl_shader.cpp index f72e4dd1384..32712b25e92 100644 --- a/intern/cycles/kernel/osl/osl_shader.cpp +++ b/intern/cycles/kernel/osl/osl_shader.cpp @@ -152,6 +152,7 @@ static void flatten_surface_closure_tree(ShaderData *sd, bool no_glossy, sc.sample_weight = sample_weight; sc.type = bsdf->shaderclosure_type(); + sc.N = bsdf->sc.N; /* needed for AO */ /* add */ if(sc.sample_weight > 1e-5f && sd->num_closure < MAX_CLOSURE) { diff --git a/release/datafiles/splash.png b/release/datafiles/splash.png Binary files differindex 7f40ead3911..41284eff9c1 100644 --- a/release/datafiles/splash.png +++ b/release/datafiles/splash.png diff --git a/release/scripts/presets/keyconfig/maya.py b/release/scripts/presets/keyconfig/maya.py index b5df519cf59..ec8efc8d371 100644 --- a/release/scripts/presets/keyconfig/maya.py +++ b/release/scripts/presets/keyconfig/maya.py @@ -366,7 +366,7 @@ kmi = km.keymap_items.new('mesh.split', 'Y', 'PRESS') kmi = km.keymap_items.new('mesh.dupli_extrude_cursor', 'ACTIONMOUSE', 'CLICK', ctrl=True) kmi = km.keymap_items.new('mesh.delete', 'X', 'PRESS') kmi = km.keymap_items.new('mesh.delete', 'DEL', 'PRESS') -kmi = km.keymap_items.new('mesh.knifetool', 'LEFTMOUSE', 'PRESS', key_modifier='K') +kmi = km.keymap_items.new('mesh.knife_tool', 'LEFTMOUSE', 'PRESS', key_modifier='K') # BMESH_TODO: midpoints for knife were moved to modal keymap #kmi = km.keymap_items.new('mesh.knifetool', 'LEFTMOUSE', 'PRESS', shift=True, key_modifier='K') #kmi.properties.type = 'MIDPOINTS' diff --git a/release/scripts/startup/bl_operators/image.py b/release/scripts/startup/bl_operators/image.py index 074069255bc..ce328b86eac 100644 --- a/release/scripts/startup/bl_operators/image.py +++ b/release/scripts/startup/bl_operators/image.py @@ -224,7 +224,7 @@ class ProjectApply(Operator): image_name = ProjectEdit._proj_hack[0] # TODO, deal with this nicer try: - image = bpy.data.images[image_name] + image = bpy.data.images[image_name, None] except KeyError: import traceback traceback.print_exc() diff --git a/release/scripts/startup/bl_ui/space_console.py b/release/scripts/startup/bl_ui/space_console.py index 5ff179902a3..23d16c14f2d 100644 --- a/release/scripts/startup/bl_ui/space_console.py +++ b/release/scripts/startup/bl_ui/space_console.py @@ -25,7 +25,7 @@ class CONSOLE_HT_header(Header): bl_space_type = 'CONSOLE' def draw(self, context): - layout = self.layout.row(align=True) + layout = self.layout.row() layout.template_header() diff --git a/release/scripts/startup/bl_ui/space_info.py b/release/scripts/startup/bl_ui/space_info.py index 662d5526a37..8df117e27a0 100644 --- a/release/scripts/startup/bl_ui/space_info.py +++ b/release/scripts/startup/bl_ui/space_info.py @@ -193,7 +193,7 @@ class INFO_MT_mesh_add(Menu): def draw(self, context): layout = self.layout - layout.operator_context = 'EXEC_REGION_WIN' + layout.operator_context = 'INVOKE_REGION_WIN' layout.operator("mesh.primitive_plane_add", icon='MESH_PLANE', text="Plane") layout.operator("mesh.primitive_cube_add", icon='MESH_CUBE', text="Cube") layout.operator("mesh.primitive_circle_add", icon='MESH_CIRCLE', text="Circle") diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 3c210877de7..b624d0f9c3a 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -41,8 +41,8 @@ extern "C" { /* these lines are grep'd, watch out for our not-so-awesome regex * and keep comment above the defines. * Use STRINGIFY() rather than defining with quotes */ -#define BLENDER_VERSION 264 -#define BLENDER_SUBVERSION 9 +#define BLENDER_VERSION 265 +#define BLENDER_SUBVERSION 0 /* 262 was the last editmesh release but it has compatibility code for bmesh data */ #define BLENDER_MINVERSION 262 @@ -50,9 +50,9 @@ extern "C" { /* used by packaging tools */ /* can be left blank, otherwise a,b,c... etc with no quotes */ -#define BLENDER_VERSION_CHAR a +#define BLENDER_VERSION_CHAR /* alpha/beta/rc/release, docs use this */ -#define BLENDER_VERSION_CYCLE alpha +#define BLENDER_VERSION_CYCLE release extern char versionstr[]; /* from blender.c */ diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index f5c0660371b..9a2462e9724 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -1257,6 +1257,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p float (*obmat)[4], (*oldobmat)[4]; int a, b, hair = 0; int totpart, totchild, totgroup = 0 /*, pa_num */; + int dupli_type_hack = !BKE_scene_use_new_shading_nodes(scene); int no_draw_flag = PARS_UNEXIST; @@ -1474,6 +1475,13 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p } } else { + int dupli_type = OB_DUPLIPARTS; + + /* blender internal needs this to be set to dupligroup to render + * groups correctly, but we don't want this hack for cycles */ + if(dupli_type_hack && GS(id->name) == ID_GR) + dupli_type = OB_DUPLIGROUP; + /* to give ipos in object correct offset */ BKE_object_where_is_calc_time(scene, ob, ctime - pa_time); @@ -1527,7 +1535,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p if (part->draw & PART_DRAW_GLOBAL_OB) add_v3_v3v3(mat[3], mat[3], vec); - dob = new_dupli_object(lb, ob, mat, ob->lay, persistent_id, level, a, GS(id->name) == ID_GR ? OB_DUPLIGROUP : OB_DUPLIPARTS, (flag & DUPLILIST_ANIMATED)); + dob = new_dupli_object(lb, ob, mat, ob->lay, persistent_id, level, a, dupli_type, (flag & DUPLILIST_ANIMATED)); dob->particle_system = psys; copy_m4_m4(dob->omat, oldobmat); if (flag & DUPLILIST_FOR_RENDER) diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index cd726179f56..74abd7e8c7e 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -1453,9 +1453,16 @@ float line_point_factor_v3(const float p[3], const float l1[3], const float l2[3 float line_point_factor_v2(const float p[2], const float l1[2], const float l2[2]) { float h[2], u[2]; + float dot; sub_v2_v2v2(u, l2, l1); sub_v2_v2v2(h, p, l1); +#if 0 return (dot_v2v2(u, h) / dot_v2v2(u, u)); +#else + /* better check for zero */ + dot = dot_v2v2(u, u); + return (dot != 0.0f) ? (dot_v2v2(u, h) / dot) : 0.0f; +#endif } /* ensure the distance between these points is no greater then 'dist' diff --git a/source/blender/blenlib/intern/string_cursor_utf8.c b/source/blender/blenlib/intern/string_cursor_utf8.c index bab144266a4..65763f21b0f 100644 --- a/source/blender/blenlib/intern/string_cursor_utf8.c +++ b/source/blender/blenlib/intern/string_cursor_utf8.c @@ -38,7 +38,7 @@ typedef enum strCursorDelimType { STRCUR_DELIM_NONE, - STRCUR_DELIM_ALPHA, + STRCUR_DELIM_ALPHANUMERIC, STRCUR_DELIM_PUNCT, STRCUR_DELIM_BRACE, STRCUR_DELIM_OPERATOR, @@ -47,21 +47,12 @@ typedef enum strCursorDelimType { STRCUR_DELIM_OTHER } strCursorDelimType; -/* return 1 if char ch is special character, otherwise return 0 */ -static strCursorDelimType test_special_char(const char *ch_utf8) +static strCursorDelimType cursor_delim_type(const char *ch_utf8) { /* for full unicode support we really need to have large lookup tables to figure * out whats what in every possible char set - and python, glib both have these. */ unsigned int uch = BLI_str_utf8_as_unicode(ch_utf8); - if ((uch >= 'a' && uch <= 'z') || - (uch >= 'A' && uch <= 'Z') || - (uch == '_') /* not quite correct but allow for python, could become configurable */ - ) - { - return STRCUR_DELIM_ALPHA; - } - switch (uch) { case ',': case '.': @@ -86,10 +77,11 @@ static strCursorDelimType test_special_char(const char *ch_utf8) case '^': case '*': case '&': + case '|': return STRCUR_DELIM_OPERATOR; case '\'': - case '\"': // " - an extra closing one for Aligorith's text editor + case '\"': return STRCUR_DELIM_QUOTE; case ' ': @@ -97,20 +89,22 @@ static strCursorDelimType test_special_char(const char *ch_utf8) return STRCUR_DELIM_WHITESPACE; case '\\': - case '!': case '@': case '#': case '$': case ':': case ';': case '?': + case '!': + case 0xA3: /* pound */ + case 0x80: /* euro */ /* case '_': *//* special case, for python */ return STRCUR_DELIM_OTHER; default: break; } - return STRCUR_DELIM_NONE; + return STRCUR_DELIM_ALPHANUMERIC; /* Not quite true, but ok for now */ } int BLI_str_cursor_step_next_utf8(const char *str, size_t maxlen, int *pos) @@ -153,14 +147,14 @@ void BLI_str_cursor_step_utf8(const char *str, size_t maxlen, BLI_str_cursor_step_next_utf8(str, maxlen, pos); if (jump != STRCUR_JUMP_NONE) { - const strCursorDelimType is_special = (*pos) < maxlen ? test_special_char(&str[*pos]) : STRCUR_DELIM_NONE; + const strCursorDelimType delim_type = (*pos) < maxlen ? cursor_delim_type(&str[*pos]) : STRCUR_DELIM_NONE; /* jump between special characters (/,\,_,-, etc.), - * look at function test_special_char() for complete + * look at function cursor_delim_type() for complete * list of special character, ctr -> */ while ((*pos) < maxlen) { if (BLI_str_cursor_step_next_utf8(str, maxlen, pos)) { - if ((jump != STRCUR_JUMP_ALL) && (is_special != test_special_char(&str[*pos]))) - break; + if ((jump != STRCUR_JUMP_ALL) && (delim_type != cursor_delim_type(&str[*pos]))) + break; } else { break; /* unlikely but just in case */ @@ -172,13 +166,13 @@ void BLI_str_cursor_step_utf8(const char *str, size_t maxlen, BLI_str_cursor_step_prev_utf8(str, maxlen, pos); if (jump != STRCUR_JUMP_NONE) { - const strCursorDelimType is_special = (*pos) > 1 ? test_special_char(&str[(*pos) - 1]) : STRCUR_DELIM_NONE; + const strCursorDelimType delim_type = (*pos) > 1 ? cursor_delim_type(&str[(*pos) - 1]) : STRCUR_DELIM_NONE; /* jump between special characters (/,\,_,-, etc.), - * look at function test_special_char() for complete + * look at function cursor_delim_type() for complete * list of special character, ctr -> */ while ((*pos) > 0) { if (BLI_str_cursor_step_prev_utf8(str, maxlen, pos)) { - if ((jump != STRCUR_JUMP_ALL) && (is_special != test_special_char(&str[*pos]))) + if ((jump != STRCUR_JUMP_ALL) && (delim_type != cursor_delim_type(&str[*pos]))) break; } else { diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index bad884b9025..79a246e20f0 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -8560,7 +8560,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } - { + if (main->versionfile < 265) { Object *ob; for (ob = main->object.first; ob; ob = ob->id.next) { if (ob->step_height == 0.0f) { diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index baec0b7745d..5e51f5a5ada 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -1225,7 +1225,7 @@ static void bmo_flag_layer_free(BMesh *bm) /* de-increment the totflags first.. */ bm->totflags--; /* allocate new flag poo */ - bm->toolflagpool = newpool = BLI_mempool_create(new_totflags_size, 512, 512, BLI_MEMPOOL_SYSMALLOC); + bm->toolflagpool = newpool = BLI_mempool_create(new_totflags_size, 512, 512, 0); /* now go through and memcpy all the flag */ BM_ITER_MESH_INDEX (ele, &iter, bm, BM_VERTS_OF_MESH, i) { diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 62ffdc7fd3a..1b980790fdc 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -1409,6 +1409,11 @@ static int ed_marker_make_links_scene_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } +static int ed_marker_make_links_scene_invoke_wrapper(bContext *C, wmOperator *op, wmEvent *evt) +{ + return ed_markers_opwrap_invoke_custom(C, op, evt, WM_menu_invoke); +} + static void MARKER_OT_make_links_scene(wmOperatorType *ot) { PropertyRNA *prop; @@ -1420,7 +1425,7 @@ static void MARKER_OT_make_links_scene(wmOperatorType *ot) /* api callbacks */ ot->exec = ed_marker_make_links_scene_exec; - ot->invoke = ed_markers_opwrap_invoke; + ot->invoke = ed_marker_make_links_scene_invoke_wrapper; ot->poll = ed_markers_poll_selected_markers; /* flags */ diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index d5c9b9ef01a..f15f2418707 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -193,7 +193,8 @@ void ED_view3d_global_to_vector(struct RegionView3D *rv3d, const float coord[3], void ED_view3d_win_to_3d(struct ARegion *ar, const float depth_pt[3], const float mval[2], float out[3]); void ED_view3d_win_to_delta(struct ARegion *ar, const float mval[2], float out[3]); void ED_view3d_win_to_vector(struct ARegion *ar, const float mval[2], float out[3]); -void ED_view3d_win_to_segment_clip(struct ARegion *ar, struct View3D *v3d, const float mval[2], float ray_start[3], float ray_end[3]); +void ED_view3d_win_to_segment(struct ARegion *ar, struct View3D *v3d, const float mval[2], float ray_start[3], float ray_end[3]); +int ED_view3d_win_to_segment_clip(struct ARegion *ar, struct View3D *v3d, const float mval[2], float ray_start[3], float ray_end[3]); void ED_view3d_ob_project_mat_get(struct RegionView3D *v3d, struct Object *ob, float pmat[4][4]); void ED_view3d_unproject(struct bglMats *mats, float out[3], const float x, const float y, const float z); @@ -295,6 +296,8 @@ void ED_view3D_background_image_clear(struct View3D *v3d); #define VIEW3D_MARGIN 1.4f float ED_view3d_offset_distance(float mat[4][4], float ofs[3]); + +float ED_scene_grid_scale(struct Scene *scene, const char **grid_unit); float ED_view3d_grid_scale(struct Scene *scene, struct View3D *v3d, const char **grid_unit); /* view matrix properties utilities */ diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 527f383c837..c4b80f0a42f 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -651,8 +651,8 @@ static void widget_verts_to_quad_strip_open(uiWidgetBase *wtb, const int totvert for (a = 0; a < totvert; a++) { quad_strip[a * 2][0] = wtb->outer_v[a][0]; quad_strip[a * 2][1] = wtb->outer_v[a][1]; - quad_strip[a * 2 + 1][0] = wtb->outer_v[a][0]; - quad_strip[a * 2 + 1][1] = wtb->outer_v[a][1] - 1.0f; + quad_strip[a * 2 + 1][0] = wtb->inner_v[a][0]; + quad_strip[a * 2 + 1][1] = wtb->inner_v[a][1]; } } diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c index eed72935b3c..4a425c83d86 100644 --- a/source/blender/editors/mesh/editmesh_add.c +++ b/source/blender/editors/mesh/editmesh_add.c @@ -204,7 +204,7 @@ static int add_primitive_circle_exec(bContext *C, wmOperator *op) if (!EDBM_op_call_and_selectf(em, op, "verts.out", "create_circle segments=%i diameter=%f cap_ends=%b cap_tris=%b matrix=%m4", - RNA_int_get(op->ptr, "vertices"), RNA_float_get(op->ptr, "radius") * dia, + RNA_int_get(op->ptr, "vertices"), RNA_float_get(op->ptr, "radius"), cap_end, cap_tri, mat)) { return OPERATOR_CANCELLED; @@ -225,6 +225,7 @@ void MESH_OT_primitive_circle_add(wmOperatorType *ot) ot->idname = "MESH_OT_primitive_circle_add"; /* api callbacks */ + ot->invoke = WM_operator_view3d_distance_invoke; ot->exec = add_primitive_circle_exec; ot->poll = ED_operator_scene_editable; @@ -260,10 +261,10 @@ static int add_primitive_cylinder_exec(bContext *C, wmOperator *op) em, op, "verts.out", "create_cone segments=%i diameter1=%f diameter2=%f cap_ends=%b cap_tris=%b depth=%f matrix=%m4", RNA_int_get(op->ptr, "vertices"), - RNA_float_get(op->ptr, "radius") * dia, - RNA_float_get(op->ptr, "radius") * dia, + RNA_float_get(op->ptr, "radius"), + RNA_float_get(op->ptr, "radius"), cap_end, cap_tri, - RNA_float_get(op->ptr, "depth") * dia, mat)) + RNA_float_get(op->ptr, "depth"), mat)) { return OPERATOR_CANCELLED; } @@ -283,6 +284,7 @@ void MESH_OT_primitive_cylinder_add(wmOperatorType *ot) ot->idname = "MESH_OT_primitive_cylinder_add"; /* api callbacks */ + ot->invoke = WM_operator_view3d_distance_invoke; ot->exec = add_primitive_cylinder_exec; ot->poll = ED_operator_scene_editable; @@ -319,8 +321,8 @@ static int add_primitive_cone_exec(bContext *C, wmOperator *op) if (!EDBM_op_call_and_selectf( em, op, "verts.out", "create_cone segments=%i diameter1=%f diameter2=%f cap_ends=%b cap_tris=%b depth=%f matrix=%m4", - RNA_int_get(op->ptr, "vertices"), RNA_float_get(op->ptr, "radius1") * dia, - RNA_float_get(op->ptr, "radius2") * dia, cap_end, cap_tri, RNA_float_get(op->ptr, "depth") * dia, mat)) + RNA_int_get(op->ptr, "vertices"), RNA_float_get(op->ptr, "radius1"), + RNA_float_get(op->ptr, "radius2"), cap_end, cap_tri, RNA_float_get(op->ptr, "depth"), mat)) { return OPERATOR_CANCELLED; } @@ -340,6 +342,7 @@ void MESH_OT_primitive_cone_add(wmOperatorType *ot) ot->idname = "MESH_OT_primitive_cone_add"; /* api callbacks */ + ot->invoke = WM_operator_view3d_distance_invoke; ot->exec = add_primitive_cone_exec; ot->poll = ED_operator_scene_editable; @@ -376,7 +379,7 @@ static int add_primitive_grid_exec(bContext *C, wmOperator *op) "create_grid x_segments=%i y_segments=%i size=%f matrix=%m4", RNA_int_get(op->ptr, "x_subdivisions"), RNA_int_get(op->ptr, "y_subdivisions"), - RNA_float_get(op->ptr, "size") * dia, mat)) + RNA_float_get(op->ptr, "size"), mat)) { return OPERATOR_CANCELLED; } @@ -396,6 +399,7 @@ void MESH_OT_primitive_grid_add(wmOperatorType *ot) ot->idname = "MESH_OT_primitive_grid_add"; /* api callbacks */ + ot->invoke = WM_operator_view3d_distance_invoke; ot->exec = add_primitive_grid_exec; ot->poll = ED_operator_scene_editable; @@ -473,7 +477,7 @@ static int add_primitive_uvsphere_exec(bContext *C, wmOperator *op) if (!EDBM_op_call_and_selectf(em, op, "verts.out", "create_uvsphere u_segments=%i v_segments=%i diameter=%f matrix=%m4", RNA_int_get(op->ptr, "segments"), RNA_int_get(op->ptr, "ring_count"), - RNA_float_get(op->ptr, "size") * dia, mat)) + RNA_float_get(op->ptr, "size"), mat)) { return OPERATOR_CANCELLED; } @@ -493,6 +497,7 @@ void MESH_OT_primitive_uv_sphere_add(wmOperatorType *ot) ot->idname = "MESH_OT_primitive_uv_sphere_add"; /* api callbacks */ + ot->invoke = WM_operator_view3d_distance_invoke; ot->exec = add_primitive_uvsphere_exec; ot->poll = ED_operator_scene_editable; @@ -525,7 +530,7 @@ static int add_primitive_icosphere_exec(bContext *C, wmOperator *op) em, op, "verts.out", "create_icosphere subdivisions=%i diameter=%f matrix=%m4", RNA_int_get(op->ptr, "subdivisions"), - RNA_float_get(op->ptr, "size") * dia, mat)) + RNA_float_get(op->ptr, "size"), mat)) { return OPERATOR_CANCELLED; } @@ -545,6 +550,7 @@ void MESH_OT_primitive_ico_sphere_add(wmOperatorType *ot) ot->idname = "MESH_OT_primitive_ico_sphere_add"; /* api callbacks */ + ot->invoke = WM_operator_view3d_distance_invoke; ot->exec = add_primitive_icosphere_exec; ot->poll = ED_operator_scene_editable; diff --git a/source/blender/editors/mesh/editmesh_bvh.c b/source/blender/editors/mesh/editmesh_bvh.c index 4324e50f914..8e397797dd9 100644 --- a/source/blender/editors/mesh/editmesh_bvh.c +++ b/source/blender/editors/mesh/editmesh_bvh.c @@ -399,7 +399,7 @@ int BMBVH_EdgeVisible(BMBVHTree *tree, BMEdge *e, ARegion *ar, View3D *v3d, Obje const float mval_f[2] = {ar->winx / 2.0f, ar->winy / 2.0f}; - ED_view3d_win_to_segment_clip(ar, v3d, mval_f, origin, end); + ED_view3d_win_to_segment(ar, v3d, mval_f, origin, end); invert_m4_m4(invmat, obedit->obmat); mul_m4_v3(invmat, origin); diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index d5cf174b1a1..a59c491fe13 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -1181,7 +1181,6 @@ static BMEdgeHit *knife_edge_tri_isect(KnifeTool_OpData *kcd, BMBVHTree *bmtree, result = results = BLI_bvhtree_overlap(tree, tree2, &tot); for (i = 0; i < tot; i++, result++) { - float p[3]; BMLoop *l1; BMFace *hitf; ListBase *lst; @@ -1200,7 +1199,7 @@ static BMEdgeHit *knife_edge_tri_isect(KnifeTool_OpData *kcd, BMBVHTree *bmtree, } if (isect_line_tri_v3(kfe->v1->cageco, kfe->v2->cageco, v1, v2, v3, &lambda, NULL)) { - float no[3], view[3], sp[3]; + float p[3], no[3], view[3], sp[3]; interp_v3_v3v3(p, kfe->v1->cageco, kfe->v2->cageco, lambda); @@ -1215,6 +1214,11 @@ static BMEdgeHit *knife_edge_tri_isect(KnifeTool_OpData *kcd, BMBVHTree *bmtree, { continue; } + if ((kcd->vc.rv3d->rflag & RV3D_CLIPPING) && + ED_view3d_clipping_test(kcd->vc.rv3d, p, TRUE)) + { + continue; + } knife_project_v3(kcd, p, sp); ED_view3d_unproject(mats, view, sp[0], sp[1], 0.0f); @@ -1523,12 +1527,7 @@ static int knife_sample_screen_density(KnifeTool_OpData *kcd, float radius) dis = len_v2v2(kfv->sco, sco); if (dis < radius) { if (kcd->vc.rv3d->rflag & RV3D_CLIPPING) { - float vec[3]; - - copy_v3_v3(vec, kfv->cageco); - mul_m4_v3(kcd->vc.obedit->obmat, vec); - - if (ED_view3d_clipping_test(kcd->vc.rv3d, vec, TRUE) == 0) { + if (ED_view3d_clipping_test(kcd->vc.rv3d, kfv->cageco, TRUE) == 0) { c++; } } @@ -1595,13 +1594,10 @@ static KnifeEdge *knife_find_closest_edge(KnifeTool_OpData *kcd, float p[3], flo dis = dist_to_line_segment_v2(sco, kfe->v1->sco, kfe->v2->sco); if (dis < curdis && dis < maxdist) { if (kcd->vc.rv3d->rflag & RV3D_CLIPPING) { - float labda = labda_PdistVL2Dfl(sco, kfe->v1->sco, kfe->v2->sco); + float labda = line_point_factor_v2(sco, kfe->v1->sco, kfe->v2->sco); float vec[3]; - vec[0] = kfe->v1->cageco[0] + labda * (kfe->v2->cageco[0] - kfe->v1->cageco[0]); - vec[1] = kfe->v1->cageco[1] + labda * (kfe->v2->cageco[1] - kfe->v1->cageco[1]); - vec[2] = kfe->v1->cageco[2] + labda * (kfe->v2->cageco[2] - kfe->v1->cageco[2]); - mul_m4_v3(kcd->vc.obedit->obmat, vec); + interp_v3_v3v3(vec, kfe->v1->cageco, kfe->v2->cageco, labda); if (ED_view3d_clipping_test(kcd->vc.rv3d, vec, TRUE) == 0) { cure = kfe; @@ -1693,12 +1689,7 @@ static KnifeVert *knife_find_closest_vert(KnifeTool_OpData *kcd, float p[3], flo dis = len_v2v2(kfv->sco, sco); if (dis < curdis && dis < maxdist) { if (kcd->vc.rv3d->rflag & RV3D_CLIPPING) { - float vec[3]; - - copy_v3_v3(vec, kfv->cageco); - mul_m4_v3(kcd->vc.obedit->obmat, vec); - - if (ED_view3d_clipping_test(kcd->vc.rv3d, vec, TRUE) == 0) { + if (ED_view3d_clipping_test(kcd->vc.rv3d, kfv->cageco, TRUE) == 0) { curv = kfv; curdis = dis; } @@ -3114,6 +3105,7 @@ static int knifetool_modal(bContext *C, wmOperator *op, wmEvent *event) { Object *obedit = CTX_data_edit_object(C); KnifeTool_OpData *kcd = op->customdata; + int do_refresh = FALSE; if (!obedit || obedit->type != OB_MESH || BMEdit_FromObject(obedit) != kcd->em) { knifetool_exit(C, op); @@ -3122,6 +3114,7 @@ static int knifetool_modal(bContext *C, wmOperator *op, wmEvent *event) } view3d_operator_needs_opengl(C); + ED_view3d_init_mats_rv3d(obedit, kcd->vc.rv3d); /* needed to initialize clipping */ if (kcd->mode == MODE_PANNING) kcd->mode = kcd->prevmode; @@ -3153,6 +3146,7 @@ static int knifetool_modal(bContext *C, wmOperator *op, wmEvent *event) knife_update_active(kcd); knife_update_header(C, kcd); ED_region_tag_redraw(kcd->ar); + do_refresh = TRUE; break; case KNF_MODAL_MIDPOINT_OFF: kcd->snap_midpoints = 0; @@ -3161,25 +3155,29 @@ static int knifetool_modal(bContext *C, wmOperator *op, wmEvent *event) knife_update_active(kcd); knife_update_header(C, kcd); ED_region_tag_redraw(kcd->ar); + do_refresh = TRUE; break; case KNF_MODEL_IGNORE_SNAP_ON: ED_region_tag_redraw(kcd->ar); kcd->ignore_vert_snapping = kcd->ignore_edge_snapping = 1; knife_update_header(C, kcd); + do_refresh = TRUE; break; case KNF_MODEL_IGNORE_SNAP_OFF: ED_region_tag_redraw(kcd->ar); kcd->ignore_vert_snapping = kcd->ignore_edge_snapping = 0; knife_update_header(C, kcd); + do_refresh = TRUE; break; case KNF_MODAL_ANGLE_SNAP_TOGGLE: kcd->angle_snapping = !kcd->angle_snapping; knife_update_header(C, kcd); + do_refresh = TRUE; break; case KNF_MODAL_CUT_THROUGH_TOGGLE: kcd->cut_through = !kcd->cut_through; - knifetool_update_mval(kcd, event->mval); /* refresh knife path */ knife_update_header(C, kcd); + do_refresh = TRUE; break; case KNF_MODAL_NEW_CUT: ED_region_tag_redraw(kcd->ar); @@ -3232,6 +3230,12 @@ static int knifetool_modal(bContext *C, wmOperator *op, wmEvent *event) } } + if (do_refresh) { + /* we don't really need to update mval, + * but this happens to be the best way to refresh at the moment */ + knifetool_update_mval(kcd, event->mval); + } + /* keep going until the user confirms */ return OPERATOR_RUNNING_MODAL; } diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index cb1b4ebba72..68dfbf66ec3 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -450,20 +450,6 @@ BMVert *EDBM_vert_find_nearest(ViewContext *vc, float *r_dist, const short sel, } } -/* returns labda for closest distance v1 to line-piece v2 - v3 */ -float labda_PdistVL2Dfl(const float v1[2], const float v2[2], const float v3[2]) -{ - float rc[2], len; - - rc[0] = v3[0] - v2[0]; - rc[1] = v3[1] - v2[1]; - len = rc[0] * rc[0] + rc[1] * rc[1]; - if (len == 0.0f) - return 0.0f; - - return (rc[0] * (v1[0] - v2[0]) + rc[1] * (v1[1] - v2[1])) / len; -} - /* note; uses v3d, so needs active 3d window */ static void findnearestedge__doClosest(void *userData, BMEdge *eed, const float screen_co_a[2], const float screen_co_b[2], int UNUSED(index)) { @@ -478,7 +464,7 @@ static void findnearestedge__doClosest(void *userData, BMEdge *eed, const float if (distance < data->dist) { if (data->vc.rv3d->rflag & RV3D_CLIPPING) { - float labda = labda_PdistVL2Dfl(data->mval_fl, screen_co_a, screen_co_b); + float labda = line_point_factor_v2(data->mval_fl, screen_co_a, screen_co_b); float vec[3]; vec[0] = eed->v1->co[0] + labda * (eed->v2->co[0] - eed->v1->co[0]); diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h index 58f05df83f1..043679b9d8a 100644 --- a/source/blender/editors/mesh/mesh_intern.h +++ b/source/blender/editors/mesh/mesh_intern.h @@ -80,9 +80,6 @@ int EDBM_op_finish(struct BMEditMesh *em, struct BMOperator *bmop, void EDBM_flag_disable_all(struct BMEditMesh *em, const char hflag); void EDBM_stats_update(struct BMEditMesh *em); -/* TODO, move to math_geometry.c */ -float labda_PdistVL2Dfl(const float v1[3], const float v2[3], const float v3[3]); - /* ******************** editface.c */ void MESH_OT_separate(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index ad1e2816c10..7c4a547debc 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -210,8 +210,8 @@ float ED_object_new_primitive_matrix(bContext *C, Object *obedit, invert_m3_m3(imat, mat); mul_m3_v3(imat, primmat[3]); - if (v3d) { - float dia = ED_view3d_grid_scale(scene, v3d, NULL); + { + const float dia = v3d ? ED_view3d_grid_scale(scene, v3d, NULL) : ED_scene_grid_scale(scene, NULL); if (apply_diameter) { primmat[0][0] *= dia; diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 25ea08a4bb1..e2ed7776b7e 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -3764,6 +3764,7 @@ int sculpt_stroke_get_location(bContext *C, float out[3], const float mouse[2]) mval[0] = mouse[0] - vc.ar->winrct.xmin; mval[1] = mouse[1] - vc.ar->winrct.ymin; + /* TODO: what if the segment is totally clipped? (return == 0) */ ED_view3d_win_to_segment_clip(vc.ar, vc.v3d, mval, ray_start, ray_end); invert_m4_m4(obimat, ob->obmat); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 6c23635da90..51261f4c341 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -451,10 +451,9 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** } #undef GRID_MIN_PX -float ED_view3d_grid_scale(Scene *scene, View3D *v3d, const char **grid_unit) +/** could move this elsewhere, but tied into #ED_view3d_grid_scale */ +float ED_scene_grid_scale(Scene *scene, const char **grid_unit) { - float grid_scale = v3d->grid; - /* apply units */ if (scene->unit.system) { void *usys; @@ -466,11 +465,16 @@ float ED_view3d_grid_scale(Scene *scene, View3D *v3d, const char **grid_unit) int i = bUnit_GetBaseUnit(usys); if (grid_unit) *grid_unit = bUnit_GetNameDisplay(usys, i); - grid_scale = (grid_scale * (float)bUnit_GetScaler(usys, i)) / scene->unit.scale_length; + return (float)bUnit_GetScaler(usys, i) / scene->unit.scale_length; } } - return grid_scale; + return 1.0f; +} + +float ED_view3d_grid_scale(Scene *scene, View3D *v3d, const char **grid_unit) +{ + return v3d->grid * ED_scene_grid_scale(scene, grid_unit); } static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit) diff --git a/source/blender/editors/space_view3d/view3d_project.c b/source/blender/editors/space_view3d/view3d_project.c index 6ba05abae9a..34b983f83df 100644 --- a/source/blender/editors/space_view3d/view3d_project.c +++ b/source/blender/editors/space_view3d/view3d_project.c @@ -296,7 +296,7 @@ void ED_view3d_win_to_ray(ARegion *ar, View3D *v3d, const float mval[2], float r { float ray_end[3]; - ED_view3d_win_to_segment_clip(ar, v3d, mval, ray_start, ray_end); + ED_view3d_win_to_segment(ar, v3d, mval, ray_start, ray_end); sub_v3_v3v3(ray_normal, ray_end, ray_start); normalize_v3(ray_normal); } @@ -419,19 +419,7 @@ void ED_view3d_win_to_vector(ARegion *ar, const float mval[2], float out[3]) normalize_v3(out); } -/** - * Calculate a 3d segment from 2d window coordinates. - * This ray_start is located at the viewpoint, ray_end is a far point. - * ray_start and ray_end are clipped by the view near and far limits - * so points along this line are always in view. - * In orthographic view all resulting segments will be parallel. - * \param ar The region (used for the window width and height). - * \param v3d The 3d viewport (used for near and far clipping range). - * \param mval The area relative 2d location (such as event->mval, converted into float[2]). - * \param ray_start The world-space starting point of the segment. - * \param ray_end The world-space end point of the segment. - */ -void ED_view3d_win_to_segment_clip(ARegion *ar, View3D *v3d, const float mval[2], float ray_start[3], float ray_end[3]) +void ED_view3d_win_to_segment(ARegion *ar, View3D *v3d, const float mval[2], float ray_start[3], float ray_end[3]) { RegionView3D *rv3d = ar->regiondata; @@ -455,14 +443,46 @@ void ED_view3d_win_to_segment_clip(ARegion *ar, View3D *v3d, const float mval[2] madd_v3_v3v3fl(ray_start, vec, rv3d->viewinv[2], 1000.0f); madd_v3_v3v3fl(ray_end, vec, rv3d->viewinv[2], -1000.0f); } +} + +/** + * Calculate a 3d segment from 2d window coordinates. + * This ray_start is located at the viewpoint, ray_end is a far point. + * ray_start and ray_end are clipped by the view near and far limits + * so points along this line are always in view. + * In orthographic view all resulting segments will be parallel. + * \param ar The region (used for the window width and height). + * \param v3d The 3d viewport (used for near and far clipping range). + * \param mval The area relative 2d location (such as event->mval, converted into float[2]). + * \param ray_start The world-space starting point of the segment. + * \param ray_end The world-space end point of the segment. + * \return success, FALSE if the segment is totally clipped. + */ +int ED_view3d_win_to_segment_clip(ARegion *ar, View3D *v3d, const float mval[2], float ray_start[3], float ray_end[3]) +{ + RegionView3D *rv3d = ar->regiondata; + ED_view3d_win_to_segment(ar, v3d, mval, ray_start, ray_end); /* clipping */ if (rv3d->rflag & RV3D_CLIPPING) { + /* if the ray is totally clipped, + * restore the original values but return FALSE + * caller can choose what to do */ + float tray_start[3] = {UNPACK3(ray_start)}; + float tray_end[3] = {UNPACK3(ray_end)}; int a; for (a = 0; a < 4; a++) { - clip_line_plane(ray_start, ray_end, rv3d->clip[a]); + if (clip_line_plane(tray_start, tray_end, rv3d->clip[a]) == FALSE) { + return FALSE; + } } + + /* copy in clipped values */ + copy_v3_v3(ray_start, tray_start); + copy_v3_v3(ray_end, tray_end); } + + return TRUE; } diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 8af971b9b65..44db8d25b77 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -1342,46 +1342,46 @@ typedef struct Scene { #define TESTBASE(v3d, base) ( \ ((base)->flag & SELECT) && \ ((base)->lay & v3d->lay) && \ - (((base)->object->restrictflag & OB_RESTRICT_VIEW)==0) ) + (((base)->object->restrictflag & OB_RESTRICT_VIEW) == 0)) #define TESTBASELIB(v3d, base) ( \ ((base)->flag & SELECT) && \ ((base)->lay & v3d->lay) && \ - ((base)->object->id.lib==NULL) && \ - (((base)->object->restrictflag & OB_RESTRICT_VIEW)==0) ) + ((base)->object->id.lib == NULL) && \ + (((base)->object->restrictflag & OB_RESTRICT_VIEW) == 0)) #define TESTBASELIB_BGMODE(v3d, scene, base) ( \ ((base)->flag & SELECT) && \ ((base)->lay & (v3d ? v3d->lay : scene->lay)) && \ - ((base)->object->id.lib==NULL) && \ - (((base)->object->restrictflag & OB_RESTRICT_VIEW)==0) ) + ((base)->object->id.lib == NULL) && \ + (((base)->object->restrictflag & OB_RESTRICT_VIEW) == 0)) #define BASE_EDITABLE_BGMODE(v3d, scene, base) ( \ ((base)->lay & (v3d ? v3d->lay : scene->lay)) && \ - ((base)->object->id.lib==NULL) && \ - (((base)->object->restrictflag & OB_RESTRICT_VIEW)==0)) + ((base)->object->id.lib == NULL) && \ + (((base)->object->restrictflag & OB_RESTRICT_VIEW) == 0)) #define BASE_SELECTABLE(v3d, base) ( \ (base->lay & v3d->lay) && \ - (base->object->restrictflag & (OB_RESTRICT_SELECT|OB_RESTRICT_VIEW))==0 ) + (base->object->restrictflag & (OB_RESTRICT_SELECT | OB_RESTRICT_VIEW)) == 0) #define BASE_VISIBLE(v3d, base) ( \ (base->lay & v3d->lay) && \ - (base->object->restrictflag & OB_RESTRICT_VIEW)==0 ) + (base->object->restrictflag & OB_RESTRICT_VIEW) == 0) #define FIRSTBASE scene->base.first #define LASTBASE scene->base.last #define BASACT (scene->basact) -#define OBACT (BASACT? BASACT->object: NULL) +#define OBACT (BASACT ? BASACT->object: NULL) #define V3D_CAMERA_LOCAL(v3d) ((!(v3d)->scenelock && (v3d)->camera) ? (v3d)->camera : NULL) #define V3D_CAMERA_SCENE(scene, v3d) ((!(v3d)->scenelock && (v3d)->camera) ? (v3d)->camera : (scene)->camera) -#define CFRA (scene->r.cfra) -#define SUBFRA (scene->r.subframe) -#define SFRA (scene->r.sfra) -#define EFRA (scene->r.efra) -#define PRVRANGEON (scene->r.flag & SCER_PRV_RANGE) -#define PSFRA ((PRVRANGEON) ? (scene->r.psfra) : (scene->r.sfra)) -#define PEFRA ((PRVRANGEON) ? (scene->r.pefra) : (scene->r.efra)) -#define FRA2TIME(a) ((((double) scene->r.frs_sec_base) * (double)(a)) / (double)scene->r.frs_sec) -#define TIME2FRA(a) ((((double) scene->r.frs_sec) * (double)(a)) / (double)scene->r.frs_sec_base) -#define FPS (((double) scene->r.frs_sec) / (double)scene->r.frs_sec_base) +#define CFRA (scene->r.cfra) +#define SUBFRA (scene->r.subframe) +#define SFRA (scene->r.sfra) +#define EFRA (scene->r.efra) +#define PRVRANGEON (scene->r.flag & SCER_PRV_RANGE) +#define PSFRA ((PRVRANGEON) ? (scene->r.psfra) : (scene->r.sfra)) +#define PEFRA ((PRVRANGEON) ? (scene->r.pefra) : (scene->r.efra)) +#define FRA2TIME(a) ((((double) scene->r.frs_sec_base) * (double)(a)) / (double)scene->r.frs_sec) +#define TIME2FRA(a) ((((double) scene->r.frs_sec) * (double)(a)) / (double)scene->r.frs_sec_base) +#define FPS (((double) scene->r.frs_sec) / (double)scene->r.frs_sec_base) /* base->flag is in DNA_object_types.h */ @@ -1614,4 +1614,4 @@ typedef enum SculptFlags { } #endif -#endif +#endif /* __DNA_SCENE_TYPES_H__ */ diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index bd51af77b34..1d08ea97b79 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -94,6 +94,15 @@ static EnumPropertyItem parent_type_items[] = { {0, NULL, 0, NULL, NULL} }; +static EnumPropertyItem dupli_items[] = { + {0, "NONE", 0, "None", ""}, + {OB_DUPLIFRAMES, "FRAMES", 0, "Frames", "Make copy of object for every frame"}, + {OB_DUPLIVERTS, "VERTS", 0, "Verts", "Duplicate child objects on all vertices"}, + {OB_DUPLIFACES, "FACES", 0, "Faces", "Duplicate child objects on all faces"}, + {OB_DUPLIGROUP, "GROUP", 0, "Group", "Enable group instancing"}, + {0, NULL, 0, NULL, NULL} +}; + static EnumPropertyItem collision_bounds_items[] = { {OB_BOUND_BOX, "BOX", 0, "Box", ""}, {OB_BOUND_SPHERE, "SPHERE", 0, "Sphere", ""}, @@ -2019,15 +2028,7 @@ static void rna_def_object(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; - static EnumPropertyItem dupli_items[] = { - {0, "NONE", 0, "None", ""}, - {OB_DUPLIFRAMES, "FRAMES", 0, "Frames", "Make copy of object for every frame"}, - {OB_DUPLIVERTS, "VERTS", 0, "Verts", "Duplicate child objects on all vertices"}, - {OB_DUPLIFACES, "FACES", 0, "Faces", "Duplicate child objects on all faces"}, - {OB_DUPLIGROUP, "GROUP", 0, "Group", "Enable group instancing"}, - {0, NULL, 0, NULL, NULL} - }; - + /* XXX: this RNA enum define is currently duplicated for objects, * since there is some text here which is not applicable */ static EnumPropertyItem prop_rotmode_items[] = { @@ -2681,6 +2682,11 @@ static void rna_def_dupli_object(BlenderRNA *brna) RNA_def_property_array(prop, 2); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); RNA_def_property_ui_text(prop, "UV Coordinates", "UV coordinates in parent object space"); + + prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, dupli_items); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Dupli Type", "Duplicator type that generated this dupli object"); } static void rna_def_object_base(BlenderRNA *brna) diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c index 9a7e587ff56..03462738d58 100644 --- a/source/blender/nodes/composite/node_composite_tree.c +++ b/source/blender/nodes/composite/node_composite_tree.c @@ -719,6 +719,16 @@ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int rendering, int /* *********************************************** */ +static void set_output_visible(bNode *node, int passflag, int index, int pass) +{ + bNodeSocket *sock = BLI_findlink(&node->outputs, index); + /* clear the SOCK_HIDDEN flag as well, in case a socket was hidden before */ + if (passflag & pass) + sock->flag &= ~(SOCK_HIDDEN | SOCK_UNAVAIL); + else + sock->flag |= SOCK_UNAVAIL; +} + /* clumsy checking... should do dynamic outputs once */ static void force_hidden_passes(bNode *node, int passflag) { @@ -727,68 +737,35 @@ static void force_hidden_passes(bNode *node, int passflag) for (sock= node->outputs.first; sock; sock= sock->next) sock->flag &= ~SOCK_UNAVAIL; - if (!(passflag & SCE_PASS_COMBINED)) { - sock= BLI_findlink(&node->outputs, RRES_OUT_IMAGE); - sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_ALPHA); - sock->flag |= SOCK_UNAVAIL; - } - - sock= BLI_findlink(&node->outputs, RRES_OUT_Z); - if (!(passflag & SCE_PASS_Z)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_NORMAL); - if (!(passflag & SCE_PASS_NORMAL)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_VEC); - if (!(passflag & SCE_PASS_VECTOR)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_UV); - if (!(passflag & SCE_PASS_UV)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_RGBA); - if (!(passflag & SCE_PASS_RGBA)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_DIFF); - if (!(passflag & SCE_PASS_DIFFUSE)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_SPEC); - if (!(passflag & SCE_PASS_SPEC)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_SHADOW); - if (!(passflag & SCE_PASS_SHADOW)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_AO); - if (!(passflag & SCE_PASS_AO)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_REFLECT); - if (!(passflag & SCE_PASS_REFLECT)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_REFRACT); - if (!(passflag & SCE_PASS_REFRACT)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_INDIRECT); - if (!(passflag & SCE_PASS_INDIRECT)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_INDEXOB); - if (!(passflag & SCE_PASS_INDEXOB)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_INDEXMA); - if (!(passflag & SCE_PASS_INDEXMA)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_MIST); - if (!(passflag & SCE_PASS_MIST)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_EMIT); - if (!(passflag & SCE_PASS_EMIT)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_ENV); - if (!(passflag & SCE_PASS_ENVIRONMENT)) sock->flag |= SOCK_UNAVAIL; - - sock= BLI_findlink(&node->outputs, RRES_OUT_DIFF_DIRECT); - if (!(passflag & SCE_PASS_DIFFUSE_DIRECT)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_DIFF_INDIRECT); - if (!(passflag & SCE_PASS_DIFFUSE_INDIRECT)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_DIFF_COLOR); - if (!(passflag & SCE_PASS_DIFFUSE_COLOR)) sock->flag |= SOCK_UNAVAIL; - - sock= BLI_findlink(&node->outputs, RRES_OUT_GLOSSY_DIRECT); - if (!(passflag & SCE_PASS_GLOSSY_DIRECT)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_GLOSSY_INDIRECT); - if (!(passflag & SCE_PASS_GLOSSY_INDIRECT)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_GLOSSY_COLOR); - if (!(passflag & SCE_PASS_GLOSSY_COLOR)) sock->flag |= SOCK_UNAVAIL; - - sock= BLI_findlink(&node->outputs, RRES_OUT_TRANSM_DIRECT); - if (!(passflag & SCE_PASS_TRANSM_DIRECT)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_TRANSM_INDIRECT); - if (!(passflag & SCE_PASS_TRANSM_INDIRECT)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_TRANSM_COLOR); - if (!(passflag & SCE_PASS_TRANSM_COLOR)) sock->flag |= SOCK_UNAVAIL; + set_output_visible(node, passflag, RRES_OUT_IMAGE, SCE_PASS_COMBINED); + set_output_visible(node, passflag, RRES_OUT_ALPHA, SCE_PASS_COMBINED); + + set_output_visible(node, passflag, RRES_OUT_Z, SCE_PASS_Z); + set_output_visible(node, passflag, RRES_OUT_NORMAL, SCE_PASS_NORMAL); + set_output_visible(node, passflag, RRES_OUT_VEC, SCE_PASS_VECTOR); + set_output_visible(node, passflag, RRES_OUT_UV, SCE_PASS_UV); + set_output_visible(node, passflag, RRES_OUT_RGBA, SCE_PASS_RGBA); + set_output_visible(node, passflag, RRES_OUT_DIFF, SCE_PASS_DIFFUSE); + set_output_visible(node, passflag, RRES_OUT_SPEC, SCE_PASS_SPEC); + set_output_visible(node, passflag, RRES_OUT_SHADOW, SCE_PASS_SHADOW); + set_output_visible(node, passflag, RRES_OUT_AO, SCE_PASS_AO); + set_output_visible(node, passflag, RRES_OUT_REFLECT, SCE_PASS_REFLECT); + set_output_visible(node, passflag, RRES_OUT_REFRACT, SCE_PASS_REFRACT); + set_output_visible(node, passflag, RRES_OUT_INDIRECT, SCE_PASS_INDIRECT); + set_output_visible(node, passflag, RRES_OUT_INDEXOB, SCE_PASS_INDEXOB); + set_output_visible(node, passflag, RRES_OUT_INDEXMA, SCE_PASS_INDEXMA); + set_output_visible(node, passflag, RRES_OUT_MIST, SCE_PASS_MIST); + set_output_visible(node, passflag, RRES_OUT_EMIT, SCE_PASS_EMIT); + set_output_visible(node, passflag, RRES_OUT_ENV, SCE_PASS_ENVIRONMENT); + set_output_visible(node, passflag, RRES_OUT_DIFF_DIRECT, SCE_PASS_DIFFUSE_DIRECT); + set_output_visible(node, passflag, RRES_OUT_DIFF_INDIRECT, SCE_PASS_DIFFUSE_INDIRECT); + set_output_visible(node, passflag, RRES_OUT_DIFF_COLOR, SCE_PASS_DIFFUSE_COLOR); + set_output_visible(node, passflag, RRES_OUT_GLOSSY_DIRECT, SCE_PASS_GLOSSY_DIRECT); + set_output_visible(node, passflag, RRES_OUT_GLOSSY_INDIRECT, SCE_PASS_GLOSSY_INDIRECT); + set_output_visible(node, passflag, RRES_OUT_GLOSSY_COLOR, SCE_PASS_GLOSSY_COLOR); + set_output_visible(node, passflag, RRES_OUT_TRANSM_DIRECT, SCE_PASS_TRANSM_DIRECT); + set_output_visible(node, passflag, RRES_OUT_TRANSM_INDIRECT, SCE_PASS_TRANSM_INDIRECT); + set_output_visible(node, passflag, RRES_OUT_TRANSM_COLOR, SCE_PASS_TRANSM_COLOR); } /* based on rules, force sockets hidden always */ diff --git a/source/blender/nodes/shader/nodes/node_shader_normal.c b/source/blender/nodes/shader/nodes/node_shader_normal.c index 98a56c85279..0ad58d6af76 100644 --- a/source/blender/nodes/shader/nodes/node_shader_normal.c +++ b/source/blender/nodes/shader/nodes/node_shader_normal.c @@ -34,12 +34,12 @@ /* **************** NORMAL ******************** */ static bNodeSocketTemplate sh_node_normal_in[] = { - { SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE}, + { SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_DIRECTION}, { -1, 0, "" } }; static bNodeSocketTemplate sh_node_normal_out[] = { - { SOCK_VECTOR, 0, N_("Normal")}, + { SOCK_VECTOR, 0, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_DIRECTION}, { SOCK_FLOAT, 0, N_("Dot")}, { -1, 0, "" } }; diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 1037542759f..8d885bf6d6f 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -171,6 +171,7 @@ void WM_event_timer_sleep(struct wmWindowManager *wm, struct wmWindow *win, str /* operator api, default callbacks */ /* invoke callback, uses enum property named "type" */ +int WM_operator_view3d_distance_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *event); int WM_menu_invoke (struct bContext *C, struct wmOperator *op, struct wmEvent *event); int WM_enum_search_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *event); /* invoke callback, confirm menu + exec */ diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index c555f771a48..8a0701b1063 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -87,6 +87,7 @@ #include "ED_screen.h" #include "ED_util.h" #include "ED_object.h" +#include "ED_view3d.h" #include "RNA_access.h" #include "RNA_define.h" @@ -689,6 +690,35 @@ void WM_operator_properties_free(PointerRNA *ptr) /* ************ default op callbacks, exported *********** */ +int WM_operator_view3d_distance_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *UNUSED(event)) +{ + Scene *scene = CTX_data_scene(C); + View3D *v3d = CTX_wm_view3d(C); + + const float dia = v3d ? ED_view3d_grid_scale(scene, v3d, NULL) : ED_scene_grid_scale(scene, NULL); + + /* always run, so the values are initialized, + * otherwise we may get differ behavior when (dia != 1.0) */ + RNA_STRUCT_BEGIN(op->ptr, prop) + { + if (RNA_property_type(prop) == PROP_FLOAT) { + PropertySubType pstype = RNA_property_subtype(prop); + if (pstype == PROP_DISTANCE) { + /* we don't support arrays yet */ + BLI_assert(RNA_property_array_check(prop) == FALSE); + /* initialize */ + if (!RNA_property_is_set_ex(op->ptr, prop, FALSE)) { + const float value = RNA_property_float_get_default(op->ptr, prop) * dia; + RNA_property_float_set(op->ptr, prop, value); + } + } + } + } + RNA_STRUCT_END; + + return op->type->exec(C, op); +} + /* invoke callback, uses enum property named "type" */ int WM_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { |