Merged changes in the trunk up to revision 52858.

Congratulations to all trunk devs on the Blender 2.65 release!
This commit is contained in:
Tamito Kajiyama 2012-12-10 23:34:41 +00:00
commit c9dc80111b
52 changed files with 518 additions and 338 deletions

@ -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") set(PYTHON_NUMPY_PATH "" CACHE PATH "Python to python site-packages or dist-packages containing 'numpy' module")
mark_as_advanced(PYTHON_NUMPY_PATH) 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 # Cycles
option(WITH_CYCLES "Enable cycles Render Engine" ON) option(WITH_CYCLES "Enable cycles Render Engine" ON)
option(WITH_CYCLES_TEST "Build cycles test application" OFF) option(WITH_CYCLES_TEST "Build cycles test application" OFF)
@ -867,8 +862,16 @@ elseif(WIN32)
if(CMAKE_COMPILER_IS_GNUCC) if(CMAKE_COMPILER_IS_GNUCC)
set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/mingw32) set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/mingw32)
INCLUDE (CheckCSourceCompiles)
# Setup 64bit and 64bit windows systems # Setup 64bit and 64bit windows systems
CHECK_C_SOURCE_COMPILES("
#ifndef __MINGW64__
#error
#endif
main(){}
"
WITH_MINGW64)
if(WITH_MINGW64) if(WITH_MINGW64)
message("Compiling for 64 bit with MinGW-w64.") message("Compiling for 64 bit with MinGW-w64.")
set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/mingw64) set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/mingw64)
@ -940,13 +943,6 @@ elseif(WIN32)
endif() endif()
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) if(MSVC)
set(PLATFORM_LINKLIBS ws2_32 vfw32 winmm kernel32 user32 gdi32 comdlg32 advapi32 shfolder shell32 ole32 oleaut32 uuid psapi) 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") set(OPENIMAGEIO_DEFINITIONS "-DUSE_TBB=0")
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(WITH_OPENCOLORIO) if(WITH_OPENCOLORIO)
set(OPENCOLORIO ${LIBDIR}/opencolorio) set(OPENCOLORIO ${LIBDIR}/opencolorio)
set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO}/include) set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO}/include)
@ -1261,6 +1263,7 @@ elseif(WIN32)
if(WITH_IMAGE_OPENEXR) if(WITH_IMAGE_OPENEXR)
set(OPENEXR ${LIBDIR}/openexr) set(OPENEXR ${LIBDIR}/openexr)
set(OPENEXR_INCLUDE_DIR ${OPENEXR}/include)
set(OPENEXR_INCLUDE_DIRS ${OPENEXR}/include/OpenEXR) set(OPENEXR_INCLUDE_DIRS ${OPENEXR}/include/OpenEXR)
set(OPENEXR_LIBRARIES Half IlmImf Imath IlmThread Iex) set(OPENEXR_LIBRARIES Half IlmImf Imath IlmThread Iex)
set(OPENEXR_LIBPATH ${OPENEXR}/lib) set(OPENEXR_LIBPATH ${OPENEXR}/lib)
@ -1328,6 +1331,34 @@ elseif(WIN32)
set(OPENIMAGEIO_DEFINITIONS) set(OPENIMAGEIO_DEFINITIONS)
endif() 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) if(WITH_OPENCOLORIO)
set(OPENCOLORIO ${LIBDIR}/opencolorio) set(OPENCOLORIO ${LIBDIR}/opencolorio)
set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO}/include) 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) 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 # 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) ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNINITIALIZED -Wuninitialized)
endif() 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) 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 # 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) ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNINITIALIZED -Wuninitialized)
endif() endif()
@ -1933,7 +1964,7 @@ if(WITH_PYTHON)
if(WITH_PYTHON_INSTALL AND WITH_PYTHON_INSTALL_NUMPY) if(WITH_PYTHON_INSTALL AND WITH_PYTHON_INSTALL_NUMPY)
# set but invalid # set but invalid
# -- disabled until we make numpy bundled with blender - campbell # -- 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") # if(NOT EXISTS "${PYTHON_NUMPY_PATH}/numpy")
# message(WARNING "PYTHON_NUMPY_PATH is invalid, numpy not found in '${PYTHON_NUMPY_PATH}' " # 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") # "WITH_PYTHON_INSTALL_NUMPY option will be ignored when installing python")

@ -46,6 +46,9 @@ CHECKER_ARGS = [
# "--enable=all", # if you want sixty hundred pedantic suggestions # "--enable=all", # if you want sixty hundred pedantic suggestions
] ]
if USE_QUIET:
CHECKER_ARGS.append("--quiet")
def main(): def main():
source_info = project_source_info.build_info(ignore_prefix_list=CHECKER_IGNORE_PREFIX) 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) project_source_info.queue_processes(process_functions)
print("Finished!")
if __name__ == "__main__": if __name__ == "__main__":
main() main()

@ -57,7 +57,7 @@ struct EuclideanResectCostFunction {
EuclideanResectCostFunction(const vector<Marker> &markers, EuclideanResectCostFunction(const vector<Marker> &markers,
const EuclideanReconstruction &reconstruction, const EuclideanReconstruction &reconstruction,
const Mat3 initial_R) const Mat3 &initial_R)
: markers(markers), : markers(markers),
reconstruction(reconstruction), reconstruction(reconstruction),
initial_R(initial_R) {} initial_R(initial_R) {}

@ -34,6 +34,7 @@ set(INC_SYS
set(SRC set(SRC
FX/AUD_AccumulatorFactory.cpp FX/AUD_AccumulatorFactory.cpp
FX/AUD_BaseIIRFilterReader.cpp FX/AUD_BaseIIRFilterReader.cpp
FX/AUD_ButterworthCalculator.cpp
FX/AUD_ButterworthFactory.cpp FX/AUD_ButterworthFactory.cpp
FX/AUD_CallbackIIRFilterReader.cpp FX/AUD_CallbackIIRFilterReader.cpp
FX/AUD_DelayFactory.cpp FX/AUD_DelayFactory.cpp
@ -47,6 +48,7 @@ set(SRC
FX/AUD_EnvelopeFactory.cpp FX/AUD_EnvelopeFactory.cpp
FX/AUD_FaderFactory.cpp FX/AUD_FaderFactory.cpp
FX/AUD_FaderReader.cpp FX/AUD_FaderReader.cpp
FX/AUD_HighpassCalculator.cpp
FX/AUD_HighpassFactory.cpp FX/AUD_HighpassFactory.cpp
FX/AUD_IIRFilterFactory.cpp FX/AUD_IIRFilterFactory.cpp
FX/AUD_IIRFilterReader.cpp FX/AUD_IIRFilterReader.cpp
@ -54,6 +56,7 @@ set(SRC
FX/AUD_LimiterReader.cpp FX/AUD_LimiterReader.cpp
FX/AUD_LoopFactory.cpp FX/AUD_LoopFactory.cpp
FX/AUD_LoopReader.cpp FX/AUD_LoopReader.cpp
FX/AUD_LowpassCalculator.cpp
FX/AUD_LowpassFactory.cpp FX/AUD_LowpassFactory.cpp
FX/AUD_PingPongFactory.cpp FX/AUD_PingPongFactory.cpp
FX/AUD_PitchFactory.cpp FX/AUD_PitchFactory.cpp
@ -145,6 +148,7 @@ set(SRC
FX/AUD_AccumulatorFactory.h FX/AUD_AccumulatorFactory.h
FX/AUD_BaseIIRFilterReader.h FX/AUD_BaseIIRFilterReader.h
FX/AUD_ButterworthCalculator.h
FX/AUD_ButterworthFactory.h FX/AUD_ButterworthFactory.h
FX/AUD_CallbackIIRFilterReader.h FX/AUD_CallbackIIRFilterReader.h
FX/AUD_DelayFactory.h FX/AUD_DelayFactory.h
@ -159,6 +163,7 @@ set(SRC
FX/AUD_EnvelopeFactory.h FX/AUD_EnvelopeFactory.h
FX/AUD_FaderFactory.h FX/AUD_FaderFactory.h
FX/AUD_FaderReader.h FX/AUD_FaderReader.h
FX/AUD_HighpassCalculator.h
FX/AUD_HighpassFactory.h FX/AUD_HighpassFactory.h
FX/AUD_IIRFilterFactory.h FX/AUD_IIRFilterFactory.h
FX/AUD_IIRFilterReader.h FX/AUD_IIRFilterReader.h
@ -166,6 +171,7 @@ set(SRC
FX/AUD_LimiterReader.h FX/AUD_LimiterReader.h
FX/AUD_LoopFactory.h FX/AUD_LoopFactory.h
FX/AUD_LoopReader.h FX/AUD_LoopReader.h
FX/AUD_LowpassCalculator.h
FX/AUD_LowpassFactory.h FX/AUD_LowpassFactory.h
FX/AUD_PingPongFactory.h FX/AUD_PingPongFactory.h
FX/AUD_PitchFactory.h FX/AUD_PitchFactory.h

@ -0,0 +1,5 @@
#include "AUD_BandpassCalculator.h"
AUD_BandpassCalculator::AUD_BandpassCalculator()
{
}

@ -0,0 +1,10 @@
#ifndef AUD_BANDPASSCALCULATOR_H
#define AUD_BANDPASSCALCULATOR_H
class AUD_BandpassCalculator
{
public:
AUD_BandpassCalculator();
};
#endif // AUD_BANDPASSCALCULATOR_H

@ -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]);
}

@ -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

@ -29,44 +29,11 @@
#include "AUD_ButterworthFactory.h" #include "AUD_ButterworthFactory.h"
#include "AUD_IIRFilterReader.h" #include "AUD_IIRFilterReader.h"
#include "AUD_ButterworthCalculator.h"
#include <cmath>
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#define BWPB41 0.76536686473
#define BWPB42 1.84775906502
AUD_ButterworthFactory::AUD_ButterworthFactory(boost::shared_ptr<AUD_IFactory> factory, AUD_ButterworthFactory::AUD_ButterworthFactory(boost::shared_ptr<AUD_IFactory> factory,
float frequency) : float frequency) :
AUD_DynamicIIRFilterFactory(factory), AUD_DynamicIIRFilterFactory(factory, boost::shared_ptr<AUD_IDynamicIIRFilterCalculator>(new AUD_ButterworthCalculator(frequency)))
m_frequency(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]);
}

@ -38,11 +38,6 @@
class AUD_ButterworthFactory : public AUD_DynamicIIRFilterFactory class AUD_ButterworthFactory : public AUD_DynamicIIRFilterFactory
{ {
private: private:
/**
* The attack value in seconds.
*/
const float m_frequency;
// hide copy constructor and operator= // hide copy constructor and operator=
AUD_ButterworthFactory(const AUD_ButterworthFactory&); AUD_ButterworthFactory(const AUD_ButterworthFactory&);
AUD_ButterworthFactory& operator=(const AUD_ButterworthFactory&); AUD_ButterworthFactory& operator=(const AUD_ButterworthFactory&);
@ -54,10 +49,6 @@ public:
* \param frequency The cutoff frequency. * \param frequency The cutoff frequency.
*/ */
AUD_ButterworthFactory(boost::shared_ptr<AUD_IFactory> factory, float 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__ #endif //__AUD_BUTTERWORTHFACTORY_H__

@ -30,8 +30,10 @@
#include "AUD_DynamicIIRFilterReader.h" #include "AUD_DynamicIIRFilterReader.h"
AUD_DynamicIIRFilterFactory::AUD_DynamicIIRFilterFactory(boost::shared_ptr<AUD_IFactory> factory) : AUD_DynamicIIRFilterFactory::AUD_DynamicIIRFilterFactory(boost::shared_ptr<AUD_IFactory> factory,
AUD_EffectFactory(factory) boost::shared_ptr<AUD_IDynamicIIRFilterCalculator> calculator) :
AUD_EffectFactory(factory),
m_calculator(calculator)
{ {
} }

@ -49,7 +49,8 @@ public:
* Creates a new Dynmic IIR filter factory. * Creates a new Dynmic IIR filter factory.
* \param factory The input 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(); virtual boost::shared_ptr<AUD_IReader> createReader();
}; };

@ -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]);
}

@ -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

@ -29,33 +29,11 @@
#include "AUD_HighpassFactory.h" #include "AUD_HighpassFactory.h"
#include "AUD_IIRFilterReader.h" #include "AUD_IIRFilterReader.h"
#include "AUD_HighpassCalculator.h"
#include <cmath>
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
AUD_HighpassFactory::AUD_HighpassFactory(boost::shared_ptr<AUD_IFactory> factory, float frequency, AUD_HighpassFactory::AUD_HighpassFactory(boost::shared_ptr<AUD_IFactory> factory, float frequency,
float Q) : float Q) :
AUD_DynamicIIRFilterFactory(factory), AUD_DynamicIIRFilterFactory(factory, boost::shared_ptr<AUD_IDynamicIIRFilterCalculator>(new AUD_HighpassCalculator(frequency, Q)))
m_frequency(frequency),
m_Q(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]);
}

@ -38,16 +38,6 @@
class AUD_HighpassFactory : public AUD_DynamicIIRFilterFactory class AUD_HighpassFactory : public AUD_DynamicIIRFilterFactory
{ {
private: private:
/**
* The cutoff frequency.
*/
const float m_frequency;
/**
* The Q factor.
*/
const float m_Q;
// hide copy constructor and operator= // hide copy constructor and operator=
AUD_HighpassFactory(const AUD_HighpassFactory&); AUD_HighpassFactory(const AUD_HighpassFactory&);
AUD_HighpassFactory& operator=(const AUD_HighpassFactory&); AUD_HighpassFactory& operator=(const AUD_HighpassFactory&);
@ -60,8 +50,6 @@ public:
* \param Q The Q factor. * \param Q The Q factor.
*/ */
AUD_HighpassFactory(boost::shared_ptr<AUD_IFactory> factory, float frequency, float Q = 1.0f); 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__ #endif //__AUD_HIGHPASSFACTORY_H__

@ -29,6 +29,8 @@
#ifndef AUD_IDYNAMICIIRFILTERCALCULATOR_H #ifndef AUD_IDYNAMICIIRFILTERCALCULATOR_H
#define AUD_IDYNAMICIIRFILTERCALCULATOR_H #define AUD_IDYNAMICIIRFILTERCALCULATOR_H
#include "AUD_Space.h"
#include <vector> #include <vector>
/** /**

@ -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]);
}

@ -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

@ -29,33 +29,10 @@
#include "AUD_LowpassFactory.h" #include "AUD_LowpassFactory.h"
#include "AUD_IIRFilterReader.h" #include "AUD_IIRFilterReader.h"
#include "AUD_LowpassCalculator.h"
#include <cmath>
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
AUD_LowpassFactory::AUD_LowpassFactory(boost::shared_ptr<AUD_IFactory> factory, float frequency, AUD_LowpassFactory::AUD_LowpassFactory(boost::shared_ptr<AUD_IFactory> factory, float frequency,
float Q) : float Q) :
AUD_DynamicIIRFilterFactory(factory), AUD_DynamicIIRFilterFactory(factory, boost::shared_ptr<AUD_IDynamicIIRFilterCalculator>(new AUD_LowpassCalculator(frequency, Q)))
m_frequency(frequency),
m_Q(Q)
{ {
} }
void AUD_LowpassFactory::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]);
}

@ -38,16 +38,6 @@
class AUD_LowpassFactory : public AUD_DynamicIIRFilterFactory class AUD_LowpassFactory : public AUD_DynamicIIRFilterFactory
{ {
private: private:
/**
* The cutoff frequency.
*/
const float m_frequency;
/**
* The Q factor.
*/
const float m_Q;
// hide copy constructor and operator= // hide copy constructor and operator=
AUD_LowpassFactory(const AUD_LowpassFactory&); AUD_LowpassFactory(const AUD_LowpassFactory&);
AUD_LowpassFactory& operator=(const AUD_LowpassFactory&); AUD_LowpassFactory& operator=(const AUD_LowpassFactory&);
@ -60,8 +50,6 @@ public:
* \param Q The Q factor. * \param Q The Q factor.
*/ */
AUD_LowpassFactory(boost::shared_ptr<AUD_IFactory> factory, float frequency, float Q = 1.0f); 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__ #endif //__AUD_LOWPASSFACTORY_H__

@ -310,6 +310,13 @@ Object *BlenderSync::sync_object(BL::Object b_parent, int persistent_id[OBJECT_P
return object; 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 */ /* Object Loop */
void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, int motion) 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; 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)) { if(!(b_dup->hide() || dup_hide || emitter_hide)) {
/* the persistent_id allows us to match dupli objects /* the persistent_id allows us to match dupli objects
* between frames and updates */ * 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 */ /* check if we should render or hide particle emitter */
BL::Object::particle_systems_iterator b_psys; 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()) if(b_psys->settings().use_render_emitter())
hide = false; 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) { if(!hide) {
/* object itself */ /* object itself */

@ -152,6 +152,7 @@ static void flatten_surface_closure_tree(ShaderData *sd, bool no_glossy,
sc.sample_weight = sample_weight; sc.sample_weight = sample_weight;
sc.type = bsdf->shaderclosure_type(); sc.type = bsdf->shaderclosure_type();
sc.N = bsdf->sc.N; /* needed for AO */
/* add */ /* add */
if(sc.sample_weight > 1e-5f && sd->num_closure < MAX_CLOSURE) { if(sc.sample_weight > 1e-5f && sd->num_closure < MAX_CLOSURE) {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 207 KiB

After

Width:  |  Height:  |  Size: 323 KiB

@ -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.dupli_extrude_cursor', 'ACTIONMOUSE', 'CLICK', ctrl=True)
kmi = km.keymap_items.new('mesh.delete', 'X', 'PRESS') kmi = km.keymap_items.new('mesh.delete', 'X', 'PRESS')
kmi = km.keymap_items.new('mesh.delete', 'DEL', '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 # 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 = km.keymap_items.new('mesh.knifetool', 'LEFTMOUSE', 'PRESS', shift=True, key_modifier='K')
#kmi.properties.type = 'MIDPOINTS' #kmi.properties.type = 'MIDPOINTS'

@ -224,7 +224,7 @@ class ProjectApply(Operator):
image_name = ProjectEdit._proj_hack[0] # TODO, deal with this nicer image_name = ProjectEdit._proj_hack[0] # TODO, deal with this nicer
try: try:
image = bpy.data.images[image_name] image = bpy.data.images[image_name, None]
except KeyError: except KeyError:
import traceback import traceback
traceback.print_exc() traceback.print_exc()

@ -25,7 +25,7 @@ class CONSOLE_HT_header(Header):
bl_space_type = 'CONSOLE' bl_space_type = 'CONSOLE'
def draw(self, context): def draw(self, context):
layout = self.layout.row(align=True) layout = self.layout.row()
layout.template_header() layout.template_header()

@ -193,7 +193,7 @@ class INFO_MT_mesh_add(Menu):
def draw(self, context): def draw(self, context):
layout = self.layout 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_plane_add", icon='MESH_PLANE', text="Plane")
layout.operator("mesh.primitive_cube_add", icon='MESH_CUBE', text="Cube") layout.operator("mesh.primitive_cube_add", icon='MESH_CUBE', text="Cube")
layout.operator("mesh.primitive_circle_add", icon='MESH_CIRCLE', text="Circle") layout.operator("mesh.primitive_circle_add", icon='MESH_CIRCLE', text="Circle")

@ -41,8 +41,8 @@ extern "C" {
/* these lines are grep'd, watch out for our not-so-awesome regex /* these lines are grep'd, watch out for our not-so-awesome regex
* and keep comment above the defines. * and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */ * Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 264 #define BLENDER_VERSION 265
#define BLENDER_SUBVERSION 9 #define BLENDER_SUBVERSION 0
/* 262 was the last editmesh release but it has compatibility code for bmesh data */ /* 262 was the last editmesh release but it has compatibility code for bmesh data */
#define BLENDER_MINVERSION 262 #define BLENDER_MINVERSION 262
@ -50,9 +50,9 @@ extern "C" {
/* used by packaging tools */ /* used by packaging tools */
/* can be left blank, otherwise a,b,c... etc with no quotes */ /* 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 */ /* alpha/beta/rc/release, docs use this */
#define BLENDER_VERSION_CYCLE alpha #define BLENDER_VERSION_CYCLE release
extern char versionstr[]; /* from blender.c */ extern char versionstr[]; /* from blender.c */

@ -1257,6 +1257,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
float (*obmat)[4], (*oldobmat)[4]; float (*obmat)[4], (*oldobmat)[4];
int a, b, hair = 0; int a, b, hair = 0;
int totpart, totchild, totgroup = 0 /*, pa_num */; int totpart, totchild, totgroup = 0 /*, pa_num */;
int dupli_type_hack = !BKE_scene_use_new_shading_nodes(scene);
int no_draw_flag = PARS_UNEXIST; int no_draw_flag = PARS_UNEXIST;
@ -1474,6 +1475,13 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
} }
} }
else { 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 */ /* to give ipos in object correct offset */
BKE_object_where_is_calc_time(scene, ob, ctime - pa_time); 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) if (part->draw & PART_DRAW_GLOBAL_OB)
add_v3_v3v3(mat[3], mat[3], vec); 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; dob->particle_system = psys;
copy_m4_m4(dob->omat, oldobmat); copy_m4_m4(dob->omat, oldobmat);
if (flag & DUPLILIST_FOR_RENDER) if (flag & DUPLILIST_FOR_RENDER)

@ -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 line_point_factor_v2(const float p[2], const float l1[2], const float l2[2])
{ {
float h[2], u[2]; float h[2], u[2];
float dot;
sub_v2_v2v2(u, l2, l1); sub_v2_v2v2(u, l2, l1);
sub_v2_v2v2(h, p, l1); sub_v2_v2v2(h, p, l1);
#if 0
return (dot_v2v2(u, h) / dot_v2v2(u, u)); 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' /* ensure the distance between these points is no greater then 'dist'

@ -38,7 +38,7 @@
typedef enum strCursorDelimType { typedef enum strCursorDelimType {
STRCUR_DELIM_NONE, STRCUR_DELIM_NONE,
STRCUR_DELIM_ALPHA, STRCUR_DELIM_ALPHANUMERIC,
STRCUR_DELIM_PUNCT, STRCUR_DELIM_PUNCT,
STRCUR_DELIM_BRACE, STRCUR_DELIM_BRACE,
STRCUR_DELIM_OPERATOR, STRCUR_DELIM_OPERATOR,
@ -47,21 +47,12 @@ typedef enum strCursorDelimType {
STRCUR_DELIM_OTHER STRCUR_DELIM_OTHER
} strCursorDelimType; } strCursorDelimType;
/* return 1 if char ch is special character, otherwise return 0 */ static strCursorDelimType cursor_delim_type(const char *ch_utf8)
static strCursorDelimType test_special_char(const char *ch_utf8)
{ {
/* for full unicode support we really need to have large lookup tables to figure /* 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. */ * out whats what in every possible char set - and python, glib both have these. */
unsigned int uch = BLI_str_utf8_as_unicode(ch_utf8); 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) { switch (uch) {
case ',': case ',':
case '.': case '.':
@ -86,10 +77,11 @@ static strCursorDelimType test_special_char(const char *ch_utf8)
case '^': case '^':
case '*': case '*':
case '&': case '&':
case '|':
return STRCUR_DELIM_OPERATOR; return STRCUR_DELIM_OPERATOR;
case '\'': case '\'':
case '\"': // " - an extra closing one for Aligorith's text editor case '\"':
return STRCUR_DELIM_QUOTE; return STRCUR_DELIM_QUOTE;
case ' ': case ' ':
@ -97,20 +89,22 @@ static strCursorDelimType test_special_char(const char *ch_utf8)
return STRCUR_DELIM_WHITESPACE; return STRCUR_DELIM_WHITESPACE;
case '\\': case '\\':
case '!':
case '@': case '@':
case '#': case '#':
case '$': case '$':
case ':': case ':':
case ';': case ';':
case '?': case '?':
case '!':
case 0xA3: /* pound */
case 0x80: /* euro */
/* case '_': *//* special case, for python */ /* case '_': *//* special case, for python */
return STRCUR_DELIM_OTHER; return STRCUR_DELIM_OTHER;
default: default:
break; 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) int BLI_str_cursor_step_next_utf8(const char *str, size_t maxlen, int *pos)
@ -153,13 +147,13 @@ void BLI_str_cursor_step_utf8(const char *str, size_t maxlen,
BLI_str_cursor_step_next_utf8(str, maxlen, pos); BLI_str_cursor_step_next_utf8(str, maxlen, pos);
if (jump != STRCUR_JUMP_NONE) { 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.), /* 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 -> */ * list of special character, ctr -> */
while ((*pos) < maxlen) { while ((*pos) < maxlen) {
if (BLI_str_cursor_step_next_utf8(str, maxlen, pos)) { if (BLI_str_cursor_step_next_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; break;
} }
else { else {
@ -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); BLI_str_cursor_step_prev_utf8(str, maxlen, pos);
if (jump != STRCUR_JUMP_NONE) { 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.), /* 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 -> */ * list of special character, ctr -> */
while ((*pos) > 0) { while ((*pos) > 0) {
if (BLI_str_cursor_step_prev_utf8(str, maxlen, pos)) { 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; break;
} }
else { else {

@ -8560,7 +8560,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
} }
} }
{ if (main->versionfile < 265) {
Object *ob; Object *ob;
for (ob = main->object.first; ob; ob = ob->id.next) { for (ob = main->object.first; ob; ob = ob->id.next) {
if (ob->step_height == 0.0f) { if (ob->step_height == 0.0f) {

@ -1225,7 +1225,7 @@ static void bmo_flag_layer_free(BMesh *bm)
/* de-increment the totflags first.. */ /* de-increment the totflags first.. */
bm->totflags--; bm->totflags--;
/* allocate new flag poo */ /* 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 */ /* now go through and memcpy all the flag */
BM_ITER_MESH_INDEX (ele, &iter, bm, BM_VERTS_OF_MESH, i) { BM_ITER_MESH_INDEX (ele, &iter, bm, BM_VERTS_OF_MESH, i) {

@ -1409,6 +1409,11 @@ static int ed_marker_make_links_scene_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED; 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) static void MARKER_OT_make_links_scene(wmOperatorType *ot)
{ {
PropertyRNA *prop; PropertyRNA *prop;
@ -1420,7 +1425,7 @@ static void MARKER_OT_make_links_scene(wmOperatorType *ot)
/* api callbacks */ /* api callbacks */
ot->exec = ed_marker_make_links_scene_exec; 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; ot->poll = ed_markers_poll_selected_markers;
/* flags */ /* flags */

@ -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_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_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_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_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); 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 #define VIEW3D_MARGIN 1.4f
float ED_view3d_offset_distance(float mat[4][4], float ofs[3]); 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); float ED_view3d_grid_scale(struct Scene *scene, struct View3D *v3d, const char **grid_unit);
/* view matrix properties utilities */ /* view matrix properties utilities */

@ -651,8 +651,8 @@ static void widget_verts_to_quad_strip_open(uiWidgetBase *wtb, const int totvert
for (a = 0; a < totvert; a++) { for (a = 0; a < totvert; a++) {
quad_strip[a * 2][0] = wtb->outer_v[a][0]; 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] = wtb->outer_v[a][1];
quad_strip[a * 2 + 1][0] = wtb->outer_v[a][0]; quad_strip[a * 2 + 1][0] = wtb->inner_v[a][0];
quad_strip[a * 2 + 1][1] = wtb->outer_v[a][1] - 1.0f; quad_strip[a * 2 + 1][1] = wtb->inner_v[a][1];
} }
} }

@ -204,7 +204,7 @@ static int add_primitive_circle_exec(bContext *C, wmOperator *op)
if (!EDBM_op_call_and_selectf(em, op, "verts.out", if (!EDBM_op_call_and_selectf(em, op, "verts.out",
"create_circle segments=%i diameter=%f cap_ends=%b cap_tris=%b matrix=%m4", "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)) cap_end, cap_tri, mat))
{ {
return OPERATOR_CANCELLED; return OPERATOR_CANCELLED;
@ -225,6 +225,7 @@ void MESH_OT_primitive_circle_add(wmOperatorType *ot)
ot->idname = "MESH_OT_primitive_circle_add"; ot->idname = "MESH_OT_primitive_circle_add";
/* api callbacks */ /* api callbacks */
ot->invoke = WM_operator_view3d_distance_invoke;
ot->exec = add_primitive_circle_exec; ot->exec = add_primitive_circle_exec;
ot->poll = ED_operator_scene_editable; ot->poll = ED_operator_scene_editable;
@ -260,10 +261,10 @@ static int add_primitive_cylinder_exec(bContext *C, wmOperator *op)
em, op, "verts.out", em, op, "verts.out",
"create_cone segments=%i diameter1=%f diameter2=%f cap_ends=%b cap_tris=%b depth=%f matrix=%m4", "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_int_get(op->ptr, "vertices"),
RNA_float_get(op->ptr, "radius") * dia, RNA_float_get(op->ptr, "radius"),
RNA_float_get(op->ptr, "radius") * dia, RNA_float_get(op->ptr, "radius"),
cap_end, cap_tri, cap_end, cap_tri,
RNA_float_get(op->ptr, "depth") * dia, mat)) RNA_float_get(op->ptr, "depth"), mat))
{ {
return OPERATOR_CANCELLED; return OPERATOR_CANCELLED;
} }
@ -283,6 +284,7 @@ void MESH_OT_primitive_cylinder_add(wmOperatorType *ot)
ot->idname = "MESH_OT_primitive_cylinder_add"; ot->idname = "MESH_OT_primitive_cylinder_add";
/* api callbacks */ /* api callbacks */
ot->invoke = WM_operator_view3d_distance_invoke;
ot->exec = add_primitive_cylinder_exec; ot->exec = add_primitive_cylinder_exec;
ot->poll = ED_operator_scene_editable; 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( if (!EDBM_op_call_and_selectf(
em, op, "verts.out", em, op, "verts.out",
"create_cone segments=%i diameter1=%f diameter2=%f cap_ends=%b cap_tris=%b depth=%f matrix=%m4", "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_int_get(op->ptr, "vertices"), RNA_float_get(op->ptr, "radius1"),
RNA_float_get(op->ptr, "radius2") * dia, cap_end, cap_tri, RNA_float_get(op->ptr, "depth") * dia, mat)) RNA_float_get(op->ptr, "radius2"), cap_end, cap_tri, RNA_float_get(op->ptr, "depth"), mat))
{ {
return OPERATOR_CANCELLED; return OPERATOR_CANCELLED;
} }
@ -340,6 +342,7 @@ void MESH_OT_primitive_cone_add(wmOperatorType *ot)
ot->idname = "MESH_OT_primitive_cone_add"; ot->idname = "MESH_OT_primitive_cone_add";
/* api callbacks */ /* api callbacks */
ot->invoke = WM_operator_view3d_distance_invoke;
ot->exec = add_primitive_cone_exec; ot->exec = add_primitive_cone_exec;
ot->poll = ED_operator_scene_editable; 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", "create_grid x_segments=%i y_segments=%i size=%f matrix=%m4",
RNA_int_get(op->ptr, "x_subdivisions"), RNA_int_get(op->ptr, "x_subdivisions"),
RNA_int_get(op->ptr, "y_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; return OPERATOR_CANCELLED;
} }
@ -396,6 +399,7 @@ void MESH_OT_primitive_grid_add(wmOperatorType *ot)
ot->idname = "MESH_OT_primitive_grid_add"; ot->idname = "MESH_OT_primitive_grid_add";
/* api callbacks */ /* api callbacks */
ot->invoke = WM_operator_view3d_distance_invoke;
ot->exec = add_primitive_grid_exec; ot->exec = add_primitive_grid_exec;
ot->poll = ED_operator_scene_editable; 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", if (!EDBM_op_call_and_selectf(em, op, "verts.out",
"create_uvsphere u_segments=%i v_segments=%i diameter=%f matrix=%m4", "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_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; return OPERATOR_CANCELLED;
} }
@ -493,6 +497,7 @@ void MESH_OT_primitive_uv_sphere_add(wmOperatorType *ot)
ot->idname = "MESH_OT_primitive_uv_sphere_add"; ot->idname = "MESH_OT_primitive_uv_sphere_add";
/* api callbacks */ /* api callbacks */
ot->invoke = WM_operator_view3d_distance_invoke;
ot->exec = add_primitive_uvsphere_exec; ot->exec = add_primitive_uvsphere_exec;
ot->poll = ED_operator_scene_editable; ot->poll = ED_operator_scene_editable;
@ -525,7 +530,7 @@ static int add_primitive_icosphere_exec(bContext *C, wmOperator *op)
em, op, "verts.out", em, op, "verts.out",
"create_icosphere subdivisions=%i diameter=%f matrix=%m4", "create_icosphere subdivisions=%i diameter=%f matrix=%m4",
RNA_int_get(op->ptr, "subdivisions"), RNA_int_get(op->ptr, "subdivisions"),
RNA_float_get(op->ptr, "size") * dia, mat)) RNA_float_get(op->ptr, "size"), mat))
{ {
return OPERATOR_CANCELLED; return OPERATOR_CANCELLED;
} }
@ -545,6 +550,7 @@ void MESH_OT_primitive_ico_sphere_add(wmOperatorType *ot)
ot->idname = "MESH_OT_primitive_ico_sphere_add"; ot->idname = "MESH_OT_primitive_ico_sphere_add";
/* api callbacks */ /* api callbacks */
ot->invoke = WM_operator_view3d_distance_invoke;
ot->exec = add_primitive_icosphere_exec; ot->exec = add_primitive_icosphere_exec;
ot->poll = ED_operator_scene_editable; ot->poll = ED_operator_scene_editable;

@ -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, const float mval_f[2] = {ar->winx / 2.0f,
ar->winy / 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); invert_m4_m4(invmat, obedit->obmat);
mul_m4_v3(invmat, origin); mul_m4_v3(invmat, origin);

@ -1181,7 +1181,6 @@ static BMEdgeHit *knife_edge_tri_isect(KnifeTool_OpData *kcd, BMBVHTree *bmtree,
result = results = BLI_bvhtree_overlap(tree, tree2, &tot); result = results = BLI_bvhtree_overlap(tree, tree2, &tot);
for (i = 0; i < tot; i++, result++) { for (i = 0; i < tot; i++, result++) {
float p[3];
BMLoop *l1; BMLoop *l1;
BMFace *hitf; BMFace *hitf;
ListBase *lst; 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)) { 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); 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; continue;
} }
if ((kcd->vc.rv3d->rflag & RV3D_CLIPPING) &&
ED_view3d_clipping_test(kcd->vc.rv3d, p, TRUE))
{
continue;
}
knife_project_v3(kcd, p, sp); knife_project_v3(kcd, p, sp);
ED_view3d_unproject(mats, view, sp[0], sp[1], 0.0f); 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); dis = len_v2v2(kfv->sco, sco);
if (dis < radius) { if (dis < radius) {
if (kcd->vc.rv3d->rflag & RV3D_CLIPPING) { if (kcd->vc.rv3d->rflag & RV3D_CLIPPING) {
float vec[3]; if (ED_view3d_clipping_test(kcd->vc.rv3d, kfv->cageco, TRUE) == 0) {
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) {
c++; 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); dis = dist_to_line_segment_v2(sco, kfe->v1->sco, kfe->v2->sco);
if (dis < curdis && dis < maxdist) { if (dis < curdis && dis < maxdist) {
if (kcd->vc.rv3d->rflag & RV3D_CLIPPING) { 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]; float vec[3];
vec[0] = kfe->v1->cageco[0] + labda * (kfe->v2->cageco[0] - kfe->v1->cageco[0]); interp_v3_v3v3(vec, kfe->v1->cageco, kfe->v2->cageco, labda);
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);
if (ED_view3d_clipping_test(kcd->vc.rv3d, vec, TRUE) == 0) { if (ED_view3d_clipping_test(kcd->vc.rv3d, vec, TRUE) == 0) {
cure = kfe; 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); dis = len_v2v2(kfv->sco, sco);
if (dis < curdis && dis < maxdist) { if (dis < curdis && dis < maxdist) {
if (kcd->vc.rv3d->rflag & RV3D_CLIPPING) { if (kcd->vc.rv3d->rflag & RV3D_CLIPPING) {
float vec[3]; if (ED_view3d_clipping_test(kcd->vc.rv3d, kfv->cageco, TRUE) == 0) {
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) {
curv = kfv; curv = kfv;
curdis = dis; curdis = dis;
} }
@ -3114,6 +3105,7 @@ static int knifetool_modal(bContext *C, wmOperator *op, wmEvent *event)
{ {
Object *obedit = CTX_data_edit_object(C); Object *obedit = CTX_data_edit_object(C);
KnifeTool_OpData *kcd = op->customdata; KnifeTool_OpData *kcd = op->customdata;
int do_refresh = FALSE;
if (!obedit || obedit->type != OB_MESH || BMEdit_FromObject(obedit) != kcd->em) { if (!obedit || obedit->type != OB_MESH || BMEdit_FromObject(obedit) != kcd->em) {
knifetool_exit(C, op); knifetool_exit(C, op);
@ -3122,6 +3114,7 @@ static int knifetool_modal(bContext *C, wmOperator *op, wmEvent *event)
} }
view3d_operator_needs_opengl(C); view3d_operator_needs_opengl(C);
ED_view3d_init_mats_rv3d(obedit, kcd->vc.rv3d); /* needed to initialize clipping */
if (kcd->mode == MODE_PANNING) if (kcd->mode == MODE_PANNING)
kcd->mode = kcd->prevmode; kcd->mode = kcd->prevmode;
@ -3153,6 +3146,7 @@ static int knifetool_modal(bContext *C, wmOperator *op, wmEvent *event)
knife_update_active(kcd); knife_update_active(kcd);
knife_update_header(C, kcd); knife_update_header(C, kcd);
ED_region_tag_redraw(kcd->ar); ED_region_tag_redraw(kcd->ar);
do_refresh = TRUE;
break; break;
case KNF_MODAL_MIDPOINT_OFF: case KNF_MODAL_MIDPOINT_OFF:
kcd->snap_midpoints = 0; kcd->snap_midpoints = 0;
@ -3161,25 +3155,29 @@ static int knifetool_modal(bContext *C, wmOperator *op, wmEvent *event)
knife_update_active(kcd); knife_update_active(kcd);
knife_update_header(C, kcd); knife_update_header(C, kcd);
ED_region_tag_redraw(kcd->ar); ED_region_tag_redraw(kcd->ar);
do_refresh = TRUE;
break; break;
case KNF_MODEL_IGNORE_SNAP_ON: case KNF_MODEL_IGNORE_SNAP_ON:
ED_region_tag_redraw(kcd->ar); ED_region_tag_redraw(kcd->ar);
kcd->ignore_vert_snapping = kcd->ignore_edge_snapping = 1; kcd->ignore_vert_snapping = kcd->ignore_edge_snapping = 1;
knife_update_header(C, kcd); knife_update_header(C, kcd);
do_refresh = TRUE;
break; break;
case KNF_MODEL_IGNORE_SNAP_OFF: case KNF_MODEL_IGNORE_SNAP_OFF:
ED_region_tag_redraw(kcd->ar); ED_region_tag_redraw(kcd->ar);
kcd->ignore_vert_snapping = kcd->ignore_edge_snapping = 0; kcd->ignore_vert_snapping = kcd->ignore_edge_snapping = 0;
knife_update_header(C, kcd); knife_update_header(C, kcd);
do_refresh = TRUE;
break; break;
case KNF_MODAL_ANGLE_SNAP_TOGGLE: case KNF_MODAL_ANGLE_SNAP_TOGGLE:
kcd->angle_snapping = !kcd->angle_snapping; kcd->angle_snapping = !kcd->angle_snapping;
knife_update_header(C, kcd); knife_update_header(C, kcd);
do_refresh = TRUE;
break; break;
case KNF_MODAL_CUT_THROUGH_TOGGLE: case KNF_MODAL_CUT_THROUGH_TOGGLE:
kcd->cut_through = !kcd->cut_through; kcd->cut_through = !kcd->cut_through;
knifetool_update_mval(kcd, event->mval); /* refresh knife path */
knife_update_header(C, kcd); knife_update_header(C, kcd);
do_refresh = TRUE;
break; break;
case KNF_MODAL_NEW_CUT: case KNF_MODAL_NEW_CUT:
ED_region_tag_redraw(kcd->ar); 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 */ /* keep going until the user confirms */
return OPERATOR_RUNNING_MODAL; return OPERATOR_RUNNING_MODAL;
} }

@ -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 */ /* 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)) 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 (distance < data->dist) {
if (data->vc.rv3d->rflag & RV3D_CLIPPING) { 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]; float vec[3];
vec[0] = eed->v1->co[0] + labda * (eed->v2->co[0] - eed->v1->co[0]); vec[0] = eed->v1->co[0] + labda * (eed->v2->co[0] - eed->v1->co[0]);

@ -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_flag_disable_all(struct BMEditMesh *em, const char hflag);
void EDBM_stats_update(struct BMEditMesh *em); 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 */ /* ******************** editface.c */
void MESH_OT_separate(struct wmOperatorType *ot); void MESH_OT_separate(struct wmOperatorType *ot);

@ -210,8 +210,8 @@ float ED_object_new_primitive_matrix(bContext *C, Object *obedit,
invert_m3_m3(imat, mat); invert_m3_m3(imat, mat);
mul_m3_v3(imat, primmat[3]); 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) { if (apply_diameter) {
primmat[0][0] *= dia; primmat[0][0] *= dia;

@ -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[0] = mouse[0] - vc.ar->winrct.xmin;
mval[1] = mouse[1] - vc.ar->winrct.ymin; 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); ED_view3d_win_to_segment_clip(vc.ar, vc.v3d, mval, ray_start, ray_end);
invert_m4_m4(obimat, ob->obmat); invert_m4_m4(obimat, ob->obmat);

@ -451,10 +451,9 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char **
} }
#undef GRID_MIN_PX #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 */ /* apply units */
if (scene->unit.system) { if (scene->unit.system) {
void *usys; void *usys;
@ -466,11 +465,16 @@ float ED_view3d_grid_scale(Scene *scene, View3D *v3d, const char **grid_unit)
int i = bUnit_GetBaseUnit(usys); int i = bUnit_GetBaseUnit(usys);
if (grid_unit) if (grid_unit)
*grid_unit = bUnit_GetNameDisplay(usys, i); *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) static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit)

@ -296,7 +296,7 @@ void ED_view3d_win_to_ray(ARegion *ar, View3D *v3d, const float mval[2], float r
{ {
float ray_end[3]; 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); sub_v3_v3v3(ray_normal, ray_end, ray_start);
normalize_v3(ray_normal); 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); normalize_v3(out);
} }
/** void ED_view3d_win_to_segment(ARegion *ar, View3D *v3d, const float mval[2], float ray_start[3], float ray_end[3])
* 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])
{ {
RegionView3D *rv3d = ar->regiondata; 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_start, vec, rv3d->viewinv[2], 1000.0f);
madd_v3_v3v3fl(ray_end, 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 */ /* clipping */
if (rv3d->rflag & RV3D_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; int a;
for (a = 0; a < 4; 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;
} }

@ -1614,4 +1614,4 @@ typedef enum SculptFlags {
} }
#endif #endif
#endif #endif /* __DNA_SCENE_TYPES_H__ */

@ -94,6 +94,15 @@ static EnumPropertyItem parent_type_items[] = {
{0, NULL, 0, NULL, NULL} {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[] = { static EnumPropertyItem collision_bounds_items[] = {
{OB_BOUND_BOX, "BOX", 0, "Box", ""}, {OB_BOUND_BOX, "BOX", 0, "Box", ""},
{OB_BOUND_SPHERE, "SPHERE", 0, "Sphere", ""}, {OB_BOUND_SPHERE, "SPHERE", 0, "Sphere", ""},
@ -2019,14 +2028,6 @@ static void rna_def_object(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL} {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, /* XXX: this RNA enum define is currently duplicated for objects,
* since there is some text here which is not applicable */ * since there is some text here which is not applicable */
@ -2681,6 +2682,11 @@ static void rna_def_dupli_object(BlenderRNA *brna)
RNA_def_property_array(prop, 2); RNA_def_property_array(prop, 2);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
RNA_def_property_ui_text(prop, "UV Coordinates", "UV coordinates in parent object space"); 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) static void rna_def_object_base(BlenderRNA *brna)

@ -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 */ /* clumsy checking... should do dynamic outputs once */
static void force_hidden_passes(bNode *node, int passflag) 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) for (sock= node->outputs.first; sock; sock= sock->next)
sock->flag &= ~SOCK_UNAVAIL; sock->flag &= ~SOCK_UNAVAIL;
if (!(passflag & SCE_PASS_COMBINED)) { set_output_visible(node, passflag, RRES_OUT_IMAGE, SCE_PASS_COMBINED);
sock= BLI_findlink(&node->outputs, RRES_OUT_IMAGE); set_output_visible(node, passflag, RRES_OUT_ALPHA, SCE_PASS_COMBINED);
sock->flag |= SOCK_UNAVAIL;
sock= BLI_findlink(&node->outputs, RRES_OUT_ALPHA);
sock->flag |= SOCK_UNAVAIL;
}
sock= BLI_findlink(&node->outputs, RRES_OUT_Z); set_output_visible(node, passflag, RRES_OUT_Z, SCE_PASS_Z);
if (!(passflag & SCE_PASS_Z)) sock->flag |= SOCK_UNAVAIL; set_output_visible(node, passflag, RRES_OUT_NORMAL, SCE_PASS_NORMAL);
sock= BLI_findlink(&node->outputs, RRES_OUT_NORMAL); set_output_visible(node, passflag, RRES_OUT_VEC, SCE_PASS_VECTOR);
if (!(passflag & SCE_PASS_NORMAL)) sock->flag |= SOCK_UNAVAIL; set_output_visible(node, passflag, RRES_OUT_UV, SCE_PASS_UV);
sock= BLI_findlink(&node->outputs, RRES_OUT_VEC); set_output_visible(node, passflag, RRES_OUT_RGBA, SCE_PASS_RGBA);
if (!(passflag & SCE_PASS_VECTOR)) sock->flag |= SOCK_UNAVAIL; set_output_visible(node, passflag, RRES_OUT_DIFF, SCE_PASS_DIFFUSE);
sock= BLI_findlink(&node->outputs, RRES_OUT_UV); set_output_visible(node, passflag, RRES_OUT_SPEC, SCE_PASS_SPEC);
if (!(passflag & SCE_PASS_UV)) sock->flag |= SOCK_UNAVAIL; set_output_visible(node, passflag, RRES_OUT_SHADOW, SCE_PASS_SHADOW);
sock= BLI_findlink(&node->outputs, RRES_OUT_RGBA); set_output_visible(node, passflag, RRES_OUT_AO, SCE_PASS_AO);
if (!(passflag & SCE_PASS_RGBA)) sock->flag |= SOCK_UNAVAIL; set_output_visible(node, passflag, RRES_OUT_REFLECT, SCE_PASS_REFLECT);
sock= BLI_findlink(&node->outputs, RRES_OUT_DIFF); set_output_visible(node, passflag, RRES_OUT_REFRACT, SCE_PASS_REFRACT);
if (!(passflag & SCE_PASS_DIFFUSE)) sock->flag |= SOCK_UNAVAIL; set_output_visible(node, passflag, RRES_OUT_INDIRECT, SCE_PASS_INDIRECT);
sock= BLI_findlink(&node->outputs, RRES_OUT_SPEC); set_output_visible(node, passflag, RRES_OUT_INDEXOB, SCE_PASS_INDEXOB);
if (!(passflag & SCE_PASS_SPEC)) sock->flag |= SOCK_UNAVAIL; set_output_visible(node, passflag, RRES_OUT_INDEXMA, SCE_PASS_INDEXMA);
sock= BLI_findlink(&node->outputs, RRES_OUT_SHADOW); set_output_visible(node, passflag, RRES_OUT_MIST, SCE_PASS_MIST);
if (!(passflag & SCE_PASS_SHADOW)) sock->flag |= SOCK_UNAVAIL; set_output_visible(node, passflag, RRES_OUT_EMIT, SCE_PASS_EMIT);
sock= BLI_findlink(&node->outputs, RRES_OUT_AO); set_output_visible(node, passflag, RRES_OUT_ENV, SCE_PASS_ENVIRONMENT);
if (!(passflag & SCE_PASS_AO)) sock->flag |= SOCK_UNAVAIL; set_output_visible(node, passflag, RRES_OUT_DIFF_DIRECT, SCE_PASS_DIFFUSE_DIRECT);
sock= BLI_findlink(&node->outputs, RRES_OUT_REFLECT); set_output_visible(node, passflag, RRES_OUT_DIFF_INDIRECT, SCE_PASS_DIFFUSE_INDIRECT);
if (!(passflag & SCE_PASS_REFLECT)) sock->flag |= SOCK_UNAVAIL; set_output_visible(node, passflag, RRES_OUT_DIFF_COLOR, SCE_PASS_DIFFUSE_COLOR);
sock= BLI_findlink(&node->outputs, RRES_OUT_REFRACT); set_output_visible(node, passflag, RRES_OUT_GLOSSY_DIRECT, SCE_PASS_GLOSSY_DIRECT);
if (!(passflag & SCE_PASS_REFRACT)) sock->flag |= SOCK_UNAVAIL; set_output_visible(node, passflag, RRES_OUT_GLOSSY_INDIRECT, SCE_PASS_GLOSSY_INDIRECT);
sock= BLI_findlink(&node->outputs, RRES_OUT_INDIRECT); set_output_visible(node, passflag, RRES_OUT_GLOSSY_COLOR, SCE_PASS_GLOSSY_COLOR);
if (!(passflag & SCE_PASS_INDIRECT)) sock->flag |= SOCK_UNAVAIL; set_output_visible(node, passflag, RRES_OUT_TRANSM_DIRECT, SCE_PASS_TRANSM_DIRECT);
sock= BLI_findlink(&node->outputs, RRES_OUT_INDEXOB); set_output_visible(node, passflag, RRES_OUT_TRANSM_INDIRECT, SCE_PASS_TRANSM_INDIRECT);
if (!(passflag & SCE_PASS_INDEXOB)) sock->flag |= SOCK_UNAVAIL; set_output_visible(node, passflag, RRES_OUT_TRANSM_COLOR, SCE_PASS_TRANSM_COLOR);
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;
} }
/* based on rules, force sockets hidden always */ /* based on rules, force sockets hidden always */

@ -34,12 +34,12 @@
/* **************** NORMAL ******************** */ /* **************** NORMAL ******************** */
static bNodeSocketTemplate sh_node_normal_in[] = { 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, "" } { -1, 0, "" }
}; };
static bNodeSocketTemplate sh_node_normal_out[] = { 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")}, { SOCK_FLOAT, 0, N_("Dot")},
{ -1, 0, "" } { -1, 0, "" }
}; };

@ -171,6 +171,7 @@ void WM_event_timer_sleep(struct wmWindowManager *wm, struct wmWindow *win, str
/* operator api, default callbacks */ /* operator api, default callbacks */
/* invoke callback, uses enum property named "type" */ /* 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_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); int WM_enum_search_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
/* invoke callback, confirm menu + exec */ /* invoke callback, confirm menu + exec */

@ -87,6 +87,7 @@
#include "ED_screen.h" #include "ED_screen.h"
#include "ED_util.h" #include "ED_util.h"
#include "ED_object.h" #include "ED_object.h"
#include "ED_view3d.h"
#include "RNA_access.h" #include "RNA_access.h"
#include "RNA_define.h" #include "RNA_define.h"
@ -689,6 +690,35 @@ void WM_operator_properties_free(PointerRNA *ptr)
/* ************ default op callbacks, exported *********** */ /* ************ 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" */ /* invoke callback, uses enum property named "type" */
int WM_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) int WM_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
{ {