Merging r45936 through r46042 from trunk into soc-2011-tomato

y
This commit is contained in:
Sergey Sharybin 2012-04-28 18:27:32 +00:00
commit 38b80df618
426 changed files with 20710 additions and 22371 deletions

@ -802,33 +802,35 @@ elseif(WIN32)
endif()
if(MSVC)
if(CMAKE_CL_64)
set(PLATFORM_LINKLIBS ws2_32 vfw32 winmm kernel32 user32 gdi32 comdlg32 advapi32 shfolder shell32 ole32 oleaut32 uuid)
else()
set(PLATFORM_LINKLIBS ws2_32 vfw32 winmm kernel32 user32 gdi32 comdlg32 advapi32 shfolder shell32 ole32 oleaut32 uuid)
endif()
set(PLATFORM_LINKLIBS ws2_32 vfw32 winmm kernel32 user32 gdi32 comdlg32 advapi32 shfolder shell32 ole32 oleaut32 uuid)
add_definitions(/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_CONSOLE /D_LIB)
set(CMAKE_CXX_FLAGS "/nologo /J /W1 /Gd /wd4018 /wd4244 /wd4305 /wd4800 /wd4065 /wd4267 /we4013" CACHE STRING "MSVC MT C++ flags " FORCE)
set(CMAKE_C_FLAGS "/nologo /J /W1 /Gd /wd4018 /wd4244 /wd4305 /wd4800 /wd4065 /wd4267 /we4013 /EHsc" CACHE STRING "MSVC MT C++ flags " FORCE)
set(CMAKE_CXX_FLAGS "/nologo /J /Gd /EHsc" CACHE STRING "MSVC MT C++ flags " FORCE)
set(CMAKE_C_FLAGS "/nologo /J /Gd" CACHE STRING "MSVC MT C++ flags " FORCE)
if(CMAKE_CL_64)
set(CMAKE_CXX_FLAGS_DEBUG "/Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
set(CMAKE_CXX_FLAGS_DEBUG "/Od /Gm /RTC1 /MTd /Zi" CACHE STRING "MSVC MT flags " FORCE)
else()
set(CMAKE_CXX_FLAGS_DEBUG "/Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
set(CMAKE_CXX_FLAGS_DEBUG "/Od /Gm /RTC1 /MTd /ZI" CACHE STRING "MSVC MT flags " FORCE)
endif()
set(CMAKE_CXX_FLAGS_RELEASE "/O2 /Ob2 /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
set(CMAKE_CXX_FLAGS_MINSIZEREL "/O1 /Ob1 /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
set(CMAKE_CXX_FLAGS_RELEASE "/O2 /Ob2 /MT" CACHE STRING "MSVC MT flags " FORCE)
set(CMAKE_CXX_FLAGS_MINSIZEREL "/O1 /Ob1 /MT" CACHE STRING "MSVC MT flags " FORCE)
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /MT /Zi" CACHE STRING "MSVC MT flags " FORCE)
if(CMAKE_CL_64)
set(CMAKE_C_FLAGS_DEBUG "/Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
set(CMAKE_C_FLAGS_DEBUG "/Od /Gm /RTC1 /MTd /Zi" CACHE STRING "MSVC MT flags " FORCE)
else()
set(CMAKE_C_FLAGS_DEBUG "/Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
set(CMAKE_C_FLAGS_DEBUG "/Od /Gm /RTC1 /MTd /ZI" CACHE STRING "MSVC MT flags " FORCE)
endif()
set(CMAKE_C_FLAGS_RELEASE "/O2 /Ob2 /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
set(CMAKE_C_FLAGS_MINSIZEREL "/O1 /Ob1 /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
set(CMAKE_C_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
set(CMAKE_C_FLAGS_RELEASE "/O2 /Ob2 /MT" CACHE STRING "MSVC MT flags " FORCE)
set(CMAKE_C_FLAGS_MINSIZEREL "/O1 /Ob1 /MT" CACHE STRING "MSVC MT flags " FORCE)
set(CMAKE_C_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /MT /Zi" CACHE STRING "MSVC MT flags " FORCE)
# most msvc warnings are C & C++
set(_WARNINGS "/W3 /wd4018 /wd4244 /wd4305 /wd4800 /wd4181 /wd4065 /wd4267 /we4013")
set(C_WARNINGS "${_WARNINGS}")
set(CXX_WARNINGS "${_WARNINGS}")
unset(_WARNINGS)
if(WITH_INTERNATIONAL)
set(GETTEXT ${LIBDIR}/gettext)
@ -1001,6 +1003,9 @@ elseif(WIN32)
set(PLATFORM_LINKFLAGS_DEBUG "/NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libc.lib")
# used in many places so include globally, like OpenGL
blender_include_dirs("${PTHREADS_INCLUDE_DIRS}")
elseif(CMAKE_COMPILER_IS_GNUCC)
# keep GCC specific stuff here
set(PLATFORM_LINKLIBS "-lshell32 -lshfolder -lgdi32 -lmsvcrt -lwinmm -lmingw32 -lm -lws2_32 -lz -lstdc++ -lole32 -luuid -lwsock32 -lpsapi")
@ -1008,7 +1013,7 @@ elseif(WIN32)
if(WITH_MINGW64)
#Yes, the point for MinGW64 is moar optimization by default :)
set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -mmmx -msse -msse2 -O3")
set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -mmmx -msse -msse2 -ftree-vectorize")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive")
set(PLATFORM_LINKLIBS "${PLATFORM_LINKLIBS} -lpthread")
@ -1154,9 +1159,6 @@ elseif(WIN32)
endif()
# used in many places so include globally, like OpenGL
blender_include_dirs("${PTHREADS_INCLUDE_DIRS}")
elseif(APPLE)
if(${CMAKE_OSX_DEPLOYMENT_TARGET} STREQUAL "10.5" OR ${CMAKE_OSX_DEPLOYMENT_TARGET} STRGREATER "10.5")

@ -774,7 +774,7 @@ if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-vc', 'linuxcross'):
dllsources.append('${LCGDIR}/thumbhandler/lib/BlendThumb.dll')
dllsources.append('${LCGDIR}/thumbhandler/lib/BlendThumb64.dll')
if env['WITH_BF_OIIO']:
if env['WITH_BF_OIIO'] and env['OURPLATFORM'] != 'win32-mingw':
dllsources.append('${LCGDIR}/openimageio/bin/OpenImageIO.dll')
dllsources.append('#source/icons/blender.exe.manifest')

@ -117,6 +117,8 @@ add_builder(c, 'salad_linux_x86_64_scons', '', generic_builder, 'soc-2011-salad'
add_builder(c, 'win32_scons', 'windows', generic_builder)
add_builder(c, 'salad_win32_scons', 'windows', generic_builder, 'soc-2011-salad')
add_builder(c, 'win64_scons', 'win64', generic_builder)
add_builder(c, 'mingw_win64_scons', 'mingw64', generic_builder)
add_builder(c, 'mingw_win32_scons', 'mingw32', generic_builder)
#add_builder(c, 'freebsd_i386_cmake', '', generic_builder)
#add_builder(c, 'freebsd_x86_64_cmake', '', generic_builder)

@ -48,7 +48,8 @@ def get_platform(filename):
tokens = filename.split("-")
platforms = ('osx', 'mac', 'bsd',
'win', 'linux', 'source',
'solaris')
'solaris',
'mingw')
platform_tokens = []
found = False

@ -117,6 +117,8 @@ else:
scons_options.append('BF_BITNESS=' + bitness)
scons_options.append('WITH_BF_CYCLES_CUDA_BINARIES=True')
scons_options.append('BF_CYCLES_CUDA_NVCC=nvcc.exe')
if builder.find('mingw') != -1:
scons_options.append('BF_TOOLSET=mingw')
retcode = subprocess.call(['python', 'scons/scons.py'] + scons_options)
sys.exit(retcode)

@ -81,6 +81,8 @@ if builder.find('scons') != -1:
scons_options.append('BF_BITNESS=' + bitness)
scons_options.append('WITH_BF_CYCLES_CUDA_BINARIES=True')
scons_options.append('BF_CYCLES_CUDA_NVCC=nvcc.exe')
if builder.find('mingw') != -1:
scons_options.append('BF_TOOLSET=mingw')
retcode = subprocess.call(['python', 'scons/scons.py'] + scons_options)
sys.exit(retcode)

@ -179,9 +179,9 @@ CCFLAGS = [ '-pipe', '-funsigned-char', '-fno-strict-aliasing' ]
CXXFLAGS = [ '-fpermissive' ]
CPPFLAGS = ['-DWIN32', '-DMS_WIN64', '-DFREE_WINDOWS', '-DFREE_WINDOWS64', '-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64', '-D_LARGEFILE64_SOURCE', '-DBOOST_ALL_NO_LIB', '-DBOOST_THREAD_USE_LIB', '-DGLEW_STATIC', '-D_SSIZE_T_']
REL_CFLAGS = ['-O3', '-mmmx', '-msse', '-msse2']
REL_CXXFLAGS = ['-O3', '-mmmx', '-msse', '-msse2']
REL_CCFLAGS = ['-DNDEBUG', '-O3', '-mmmx', '-msse', '-msse2']
REL_CFLAGS = []
REL_CXXFLAGS = []
REL_CCFLAGS = ['-DNDEBUG', '-O2', '-ftree-vectorize', '-mmmx', '-msse', '-msse2']
C_WARN = ['-Wno-char-subscripts', '-Wdeclaration-after-statement', '-Wstrict-prototypes']

@ -622,7 +622,13 @@ def buildslave(target=None, source=None, env=None):
else:
extension = '.tar.bz2'
platform = env['OURPLATFORM'].split('-')[0]
if env['OURPLATFORM'] == 'win32-mingw':
platform = 'mingw32'
elif env['OURPLATFORM'] == 'win64-mingw':
platform = 'mingw64'
else:
platform = env['OURPLATFORM'].split('-')[0]
if platform == 'linux':
import platform
@ -665,12 +671,10 @@ def NSIS_Installer(target=None, source=None, env=None):
if env['OURPLATFORM'] not in ('win32-vc', 'win32-mingw', 'win64-vc', 'win64-mingw'):
print "NSIS installer is only available on Windows."
Exit()
if env['OURPLATFORM'] == 'win32-vc':
if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw'):
bitness = '32'
elif env['OURPLATFORM'] == 'win64-vc':
elif env['OURPLATFORM'] in ('win64-vc', 'win64-mingw'):
bitness = '64'
else:
bitness = '-mingw'
start_dir = os.getcwd()
rel_dir = os.path.join(start_dir,'release','windows','installer')
@ -762,7 +766,7 @@ def NSIS_Installer(target=None, source=None, env=None):
cmdline = "makensis " + "\""+tmpnsi+"\""
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
#startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
proc = subprocess.Popen(cmdline, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, startupinfo=startupinfo, shell = True)
data, err = proc.communicate()

@ -1,4 +1,13 @@
.TH "BLENDER" "1" "April 05, 2012" "Blender Blender 2\&.62 (sub 3)"
.TH "BLENDER" "1" "April 26, 2012" "Blender Blender 2\&.63 (sub 0)
build date: 2012-04-26
build time: 19:38:31
build revision: 45987
build platform: Linux
build type: Debug
build c flags: -fopenmp -msse2 -msse -pipe -fPIC -funsigned-char -fno-strict-aliasing -Wall -Wcast-align -Werror=declaration-after-statement -Werror=implicit-function-declaration -Werror=return-type -Wstrict-prototypes -Wno-char-subscripts -Wno-unknown-pragmas -Wpointer-arith -Wunused-parameter -Wwrite-strings
build c++ flags: -D__STDC_CONSTANT_MACROS -fopenmp -msse2 -msse -pipe -fPIC -funsigned-char -fno-strict-aliasing -Wall -Wno-invalid-offsetof -Wno-sign-compare
build link flags: -pthread
build system: CMake"
.SH NAME
blender \- a 3D modelling and rendering package
@ -15,7 +24,7 @@ Use Blender to create TV commercials, to make technical visualizations, business
http://www.blender.org
.SH OPTIONS
Blender 2.62 (sub 3)
Blender 2.63 (sub 0)
Usage: blender [args ...] [file] [args ...]
.br
.SS "Render Options:"
@ -220,6 +229,12 @@ Enable floating point exceptions
Enable debug messages from FFmpeg library
.br
.TP
.B \-\-debug\-libmv
.br
Enable debug messages from libmv library
.br
.IP
.TP
@ -406,6 +421,7 @@ Arguments are executed in the order they are given. eg
\fIBLENDER_SYSTEM_DATAFILES\fR Directory for system wide data files.
\fIBLENDER_SYSTEM_PYTHON\fR Directory for system python libraries.
\fITMP\fR or \fITMPDIR\fR Store temporary files here.
\fISDL_AUDIODRIVER\fR LibSDL audio driver \- alsa, esd, dma.
\fIPYTHONHOME\fR Path to the python directory, eg. /usr/lib/python.
.br
.br

@ -41,6 +41,7 @@
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <sstream>
#include "AUD_NULLDevice.h"
#include "AUD_I3DDevice.h"
@ -1236,6 +1237,47 @@ const char* AUD_mixdown(AUD_Sound* sound, unsigned int start, unsigned int lengt
}
}
const char* AUD_mixdown_per_channel(AUD_Sound* sound, unsigned int start, unsigned int length, unsigned int buffersize, const char* filename, AUD_DeviceSpecs specs, AUD_Container format, AUD_Codec codec, unsigned int bitrate)
{
try
{
AUD_SequencerFactory* f = dynamic_cast<AUD_SequencerFactory*>(sound->get());
f->setSpecs(specs.specs);
std::vector<AUD_Reference<AUD_IWriter> > writers;
int channels = specs.channels;
specs.channels = AUD_CHANNELS_MONO;
for(int i = 0; i < channels; i++)
{
std::stringstream stream;
std::string fn = filename;
size_t index = fn.find_last_of('.');
size_t index_slash = fn.find_last_of('/');
size_t index_backslash = fn.find_last_of('\\');
if((index == std::string::npos) ||
((index < index_slash) && (index_slash != std::string::npos)) ||
((index < index_backslash) && (index_backslash != std::string::npos)))
stream << filename << "_" << (i + 1);
else
stream << fn.substr(0, index) << "_" << (i + 1) << fn.substr(index);
writers.push_back(AUD_FileWriter::createWriter(stream.str(), specs, format, codec, bitrate));
}
AUD_Reference<AUD_IReader> reader = f->createQualityReader();
reader->seek(start);
AUD_FileWriter::writeReader(reader, writers, length, buffersize);
return NULL;
}
catch(AUD_Exception& e)
{
return e.str;
}
}
AUD_Device* AUD_openMixdownDevice(AUD_DeviceSpecs specs, AUD_Sound* sequencer, float volume, float start)
{
try

@ -709,6 +709,21 @@ extern void* AUD_getSet(void* set);
*/
extern const char* AUD_mixdown(AUD_Sound* sound, unsigned int start, unsigned int length, unsigned int buffersize, const char* filename, AUD_DeviceSpecs specs, AUD_Container format, AUD_Codec codec, unsigned int bitrate);
/**
* Mixes a sound down into multiple files.
* \param sound The sound scene to mix down.
* \param start The start frame.
* \param length The count of frames to write.
* \param buffersize How many samples should be written at once.
* \param filename The file to write to, the channel number and an underscore are added at the beginning.
* \param specs The file's audio specification.
* \param format The file's container format.
* \param codec The codec used for encoding the audio data.
* \param bitrate The bitrate for encoding.
* \return An error message or NULL in case of success.
*/
extern const char* AUD_mixdown_per_channel(AUD_Sound* sound, unsigned int start, unsigned int length, unsigned int buffersize, const char* filename, AUD_DeviceSpecs specs, AUD_Container format, AUD_Codec codec, unsigned int bitrate);
/**
* Opens a read device and prepares it for mixdown of the sound scene.
* \param specs Output audio specifications.

@ -93,3 +93,39 @@ void AUD_FileWriter::writeReader(AUD_Reference<AUD_IReader> reader, AUD_Referenc
writer->write(len, buf);
}
}
void AUD_FileWriter::writeReader(AUD_Reference<AUD_IReader> reader, std::vector<AUD_Reference<AUD_IWriter> >& writers, unsigned int length, unsigned int buffersize)
{
AUD_Buffer buffer(buffersize * AUD_SAMPLE_SIZE(reader->getSpecs()));
AUD_Buffer buffer2(buffersize * sizeof(sample_t));
sample_t* buf = buffer.getBuffer();
sample_t* buf2 = buffer2.getBuffer();
int len;
bool eos = false;
int channels = reader->getSpecs().channels;
for(unsigned int pos = 0; ((pos < length) || (length <= 0)) && !eos; pos += len)
{
len = buffersize;
if((len > length - pos) && (length > 0))
len = length - pos;
reader->read(len, eos, buf);
for(int channel = 0; channel < channels; channel++)
{
for(int i = 0; i < len; i++)
{
// clamping!
if(buf[i * channels + channel] > 1)
buf2[i] = 1;
else if(buf[i * channels + channel] < -1)
buf2[i] = -1;
else
buf2[i] = buf[i * channels + channel];
}
writers[channel]->write(len, buf2);
}
}
}

@ -31,6 +31,7 @@
#define __AUD_FILEWRITER_H__
#include <string>
#include <vector>
#include "AUD_Reference.h"
@ -68,6 +69,15 @@ public:
* \param buffersize How many samples should be transfered at once.
*/
static void writeReader(AUD_Reference<AUD_IReader> reader, AUD_Reference<AUD_IWriter> writer, unsigned int length, unsigned int buffersize);
/**
* Writes a reader to several writers.
* \param reader The reader to read from.
* \param writers The writers to write to.
* \param length How many samples should be transfered.
* \param buffersize How many samples should be transfered at once.
*/
static void writeReader(AUD_Reference<AUD_IReader> reader, std::vector<AUD_Reference<AUD_IWriter> >& writers, unsigned int length, unsigned int buffersize);
};
#endif //__AUD_FILEWRITER_H__

@ -31,6 +31,7 @@
#include <map>
#include <cstddef>
#include <pthread.h>
// #define MEM_DEBUG
@ -49,8 +50,13 @@ private:
* Saves the reference counts.
*/
static std::map<void*, unsigned int> m_references;
static pthread_mutex_t m_mutex;
static bool m_mutex_initialised;
public:
static pthread_mutex_t* getMutex();
/**
* Reference increment.
* \param reference The reference.
@ -108,6 +114,7 @@ public:
template <class U>
AUD_Reference(U* reference)
{
pthread_mutex_lock(AUD_ReferenceHandler::getMutex());
m_original = reference;
m_reference = dynamic_cast<T*>(reference);
AUD_ReferenceHandler::incref(m_original);
@ -115,6 +122,7 @@ public:
if(m_reference != NULL)
std::cerr << "+" << typeid(*m_reference).name() << std::endl;
#endif
pthread_mutex_unlock(AUD_ReferenceHandler::getMutex());
}
AUD_Reference()
@ -129,6 +137,7 @@ public:
*/
AUD_Reference(const AUD_Reference& ref)
{
pthread_mutex_lock(AUD_ReferenceHandler::getMutex());
m_original = ref.m_original;
m_reference = ref.m_reference;
AUD_ReferenceHandler::incref(m_original);
@ -136,11 +145,13 @@ public:
if(m_reference != NULL)
std::cerr << "+" << typeid(*m_reference).name() << std::endl;
#endif
pthread_mutex_unlock(AUD_ReferenceHandler::getMutex());
}
template <class U>
explicit AUD_Reference(const AUD_Reference<U>& ref)
{
pthread_mutex_lock(AUD_ReferenceHandler::getMutex());
m_original = ref.get();
m_reference = dynamic_cast<T*>(ref.get());
AUD_ReferenceHandler::incref(m_original);
@ -148,6 +159,7 @@ public:
if(m_reference != NULL)
std::cerr << "+" << typeid(*m_reference).name() << std::endl;
#endif
pthread_mutex_unlock(AUD_ReferenceHandler::getMutex());
}
/**
@ -156,12 +168,14 @@ public:
*/
~AUD_Reference()
{
pthread_mutex_lock(AUD_ReferenceHandler::getMutex());
#ifdef MEM_DEBUG
if(m_reference != NULL)
std::cerr << "-" << typeid(*m_reference).name() << std::endl;
#endif
if(AUD_ReferenceHandler::decref(m_original))
delete m_reference;
pthread_mutex_unlock(AUD_ReferenceHandler::getMutex());
}
/**
@ -173,6 +187,8 @@ public:
if(&ref == this)
return *this;
pthread_mutex_lock(AUD_ReferenceHandler::getMutex());
#ifdef MEM_DEBUG
if(m_reference != NULL)
std::cerr << "-" << typeid(*m_reference).name() << std::endl;
@ -188,6 +204,8 @@ public:
std::cerr << "+" << typeid(*m_reference).name() << std::endl;
#endif
pthread_mutex_unlock(AUD_ReferenceHandler::getMutex());
return *this;
}

@ -29,3 +29,24 @@
#include "AUD_Reference.h"
std::map<void*, unsigned int> AUD_ReferenceHandler::m_references;
pthread_mutex_t AUD_ReferenceHandler::m_mutex;
bool AUD_ReferenceHandler::m_mutex_initialised = false;
pthread_mutex_t *AUD_ReferenceHandler::getMutex()
{
if(!m_mutex_initialised)
{
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
pthread_mutex_init(&m_mutex, &attr);
pthread_mutexattr_destroy(&attr);
m_mutex_initialised = true;
}
return &m_mutex;
}

@ -63,7 +63,7 @@ public:
for (int i = 0; i < m_num_buckets; ++i) {
m_buckets[i] = 0;
for(Entry *entry = map.m_buckets[i]; entry; entry=entry->m_next)
for (Entry *entry = map.m_buckets[i]; entry; entry=entry->m_next)
insert(entry->m_key, entry->m_value);
}
}

@ -86,7 +86,7 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
default=False,
)
cls.blur_glossy = FloatProperty(
name="Blur Glossy",
name="Filter Glossy",
description="Adaptively blur glossy shaders after blurry bounces, to reduce noise at the cost of accuracy",
min=0.0, max=10.0,
default=0.0,

@ -790,6 +790,31 @@ class CyclesTexture_PT_colors(CyclesButtonsPanel, Panel):
layout.template_color_ramp(mapping, "color_ramp", expand=True)
class CyclesScene_PT_simplify(CyclesButtonsPanel, Panel):
bl_label = "Simplify"
bl_context = "scene"
COMPAT_ENGINES = {'CYCLES'}
def draw_header(self, context):
rd = context.scene.render
self.layout.prop(rd, "use_simplify", text="")
def draw(self, context):
layout = self.layout
rd = context.scene.render
layout.active = rd.use_simplify
split = layout.split()
col = split.column()
col.prop(rd, "simplify_subdivision", text="Subdivision")
col = split.column()
col.prop(rd, "simplify_child_particles", text="Child Particles")
def draw_device(self, context):
scene = context.scene
layout = self.layout

@ -153,7 +153,7 @@ void BlenderSync::sync_integrator()
integrator->transparent_shadows = get_boolean(cscene, "use_transparent_shadows");
integrator->no_caustics = get_boolean(cscene, "no_caustics");
integrator->blur_glossy = get_float(cscene, "blur_glossy");
integrator->filter_glossy = get_float(cscene, "blur_glossy");
integrator->seed = get_int(cscene, "seed");

@ -266,8 +266,8 @@ __device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample, R
/* blurring of bsdf after bounces, for rays that have a small likelihood
of following this particular path (diffuse, rough glossy) */
if(kernel_data.integrator.blur_glossy != FLT_MAX) {
float blur_pdf = kernel_data.integrator.blur_glossy*min_ray_pdf;
if(kernel_data.integrator.filter_glossy != FLT_MAX) {
float blur_pdf = kernel_data.integrator.filter_glossy*min_ray_pdf;
if(blur_pdf < 1.0f) {
float blur_roughness = sqrtf(1.0f - blur_pdf)*0.5f;

@ -516,7 +516,7 @@ typedef struct KernelIntegrator {
/* caustics */
int no_caustics;
float blur_glossy;
float filter_glossy;
/* seed */
int seed;

@ -41,7 +41,7 @@ Integrator::Integrator()
transparent_shadows = false;
no_caustics = false;
blur_glossy = 0.0f;
filter_glossy = 0.0f;
seed = 0;
layer_flag = ~0;
sample_clamp = 0.0f;
@ -82,7 +82,7 @@ void Integrator::device_update(Device *device, DeviceScene *dscene)
kintegrator->transparent_shadows = transparent_shadows;
kintegrator->no_caustics = no_caustics;
kintegrator->blur_glossy = (blur_glossy == 0.0f)? FLT_MAX: 1.0f/blur_glossy;
kintegrator->filter_glossy = (filter_glossy == 0.0f)? FLT_MAX: 1.0f/filter_glossy;
kintegrator->seed = hash_int(seed);
kintegrator->layer_flag = layer_flag << PATH_RAY_LAYER_SHIFT;
@ -122,7 +122,7 @@ bool Integrator::modified(const Integrator& integrator)
transparent_probalistic == integrator.transparent_probalistic &&
transparent_shadows == integrator.transparent_shadows &&
no_caustics == integrator.no_caustics &&
blur_glossy == integrator.blur_glossy &&
filter_glossy == integrator.filter_glossy &&
layer_flag == integrator.layer_flag &&
seed == integrator.seed &&
sample_clamp == integrator.sample_clamp);

@ -41,7 +41,7 @@ public:
bool transparent_shadows;
bool no_caustics;
float blur_glossy;
float filter_glossy;
int seed;
int layer_flag;

@ -182,93 +182,74 @@ __device_inline float average(const float2 a)
__device_inline float2 operator-(const float2 a)
{
float2 r = {-a.x, -a.y};
return r;
return make_float2(-a.x, -a.y);
}
__device_inline float2 operator*(const float2 a, const float2 b)
{
float2 r = {a.x*b.x, a.y*b.y};
return r;
return make_float2(a.x*b.x, a.y*b.y);
}
__device_inline float2 operator*(const float2 a, float f)
{
float2 r = {a.x*f, a.y*f};
return r;
return make_float2(a.x*f, a.y*f);
}
__device_inline float2 operator*(float f, const float2 a)
{
float2 r = {a.x*f, a.y*f};
return r;
return make_float2(a.x*f, a.y*f);
}
__device_inline float2 operator/(float f, const float2 a)
{
float2 r = {f/a.x, f/a.y};
return r;
return make_float2(f/a.x, f/a.y);
}
__device_inline float2 operator/(const float2 a, float f)
{
float invf = 1.0f/f;
float2 r = {a.x*invf, a.y*invf};
return r;
return make_float2(a.x*invf, a.y*invf);
}
__device_inline float2 operator/(const float2 a, const float2 b)
{
float2 r = {a.x/b.x, a.y/b.y};
return r;
return make_float2(a.x/b.x, a.y/b.y);
}
__device_inline float2 operator+(const float2 a, const float2 b)
{
float2 r = {a.x+b.x, a.y+b.y};
return r;
return make_float2(a.x+b.x, a.y+b.y);
}
__device_inline float2 operator-(const float2 a, const float2 b)
{
float2 r = {a.x-b.x, a.y-b.y};
return r;
return make_float2(a.x-b.x, a.y-b.y);
}
__device_inline float2 operator+=(float2& a, const float2 b)
{
a.x += b.x;
a.y += b.y;
return a;
return a = a + b;
}
__device_inline float2 operator*=(float2& a, const float2 b)
{
a.x *= b.x;
a.y *= b.y;
return a;
return a = a * b;
}
__device_inline float2 operator*=(float2& a, float f)
{
a.x *= f;
a.y *= f;
return a;
return a = a * f;
}
__device_inline float2 operator/=(float2& a, const float2 b)
{
a.x /= b.x;
a.y /= b.y;
return a;
return a = a / b;
}
__device_inline float2 operator/=(float2& a, float f)
{
float invf = 1.0f/f;
a.x *= invf;
a.y *= invf;
return a;
return a = a * invf;
}
@ -314,14 +295,12 @@ __device_inline bool operator!=(const float2 a, const float2 b)
__device_inline float2 min(float2 a, float2 b)
{
float2 r = {min(a.x, b.x), min(a.y, b.y)};
return r;
return make_float2(min(a.x, b.x), min(a.y, b.y));
}
__device_inline float2 max(float2 a, float2 b)
{
float2 r = {max(a.x, b.x), max(a.y, b.y)};
return r;
return make_float2(max(a.x, b.x), max(a.y, b.y));
}
__device_inline float2 clamp(float2 a, float2 mn, float2 mx)
@ -361,112 +340,78 @@ __device_inline float2 interp(float2 a, float2 b, float t)
/* Float3 Vector */
__device_inline bool is_zero(const float3 a)
{
return (a.x == 0.0f && a.y == 0.0f && a.z == 0.0f);
}
__device_inline float average(const float3 a)
{
return (a.x + a.y + a.z)*(1.0f/3.0f);
}
#ifndef __KERNEL_OPENCL__
__device_inline float3 operator-(const float3 a)
{
float3 r = make_float3(-a.x, -a.y, -a.z);
return r;
return make_float3(-a.x, -a.y, -a.z);
}
__device_inline float3 operator*(const float3 a, const float3 b)
{
float3 r = make_float3(a.x*b.x, a.y*b.y, a.z*b.z);
return r;
return make_float3(a.x*b.x, a.y*b.y, a.z*b.z);
}
__device_inline float3 operator*(const float3 a, float f)
{
float3 r = make_float3(a.x*f, a.y*f, a.z*f);
return r;
return make_float3(a.x*f, a.y*f, a.z*f);
}
__device_inline float3 operator*(float f, const float3 a)
{
float3 r = make_float3(a.x*f, a.y*f, a.z*f);
return r;
return make_float3(a.x*f, a.y*f, a.z*f);
}
__device_inline float3 operator/(float f, const float3 a)
{
float3 r = make_float3(f/a.x, f/a.y, f/a.z);
return r;
return make_float3(f/a.x, f/a.y, f/a.z);
}
__device_inline float3 operator/(const float3 a, float f)
{
float invf = 1.0f/f;
float3 r = make_float3(a.x*invf, a.y*invf, a.z*invf);
return r;
return make_float3(a.x*invf, a.y*invf, a.z*invf);
}
__device_inline float3 operator/(const float3 a, const float3 b)
{
float3 r = make_float3(a.x/b.x, a.y/b.y, a.z/b.z);
return r;
return make_float3(a.x/b.x, a.y/b.y, a.z/b.z);
}
__device_inline float3 operator+(const float3 a, const float3 b)
{
float3 r = make_float3(a.x+b.x, a.y+b.y, a.z+b.z);
return r;
return make_float3(a.x+b.x, a.y+b.y, a.z+b.z);
}
__device_inline float3 operator-(const float3 a, const float3 b)
{
float3 r = make_float3(a.x-b.x, a.y-b.y, a.z-b.z);
return r;
return make_float3(a.x-b.x, a.y-b.y, a.z-b.z);
}
__device_inline float3 operator+=(float3& a, const float3 b)
{
a.x += b.x;
a.y += b.y;
a.z += b.z;
return a;
return a = a + b;
}
__device_inline float3 operator*=(float3& a, const float3 b)
{
a.x *= b.x;
a.y *= b.y;
a.z *= b.z;
return a;
return a = a * b;
}
__device_inline float3 operator*=(float3& a, float f)
{
a.x *= f;
a.y *= f;
a.z *= f;
return a;
return a = a * f;
}
__device_inline float3 operator/=(float3& a, const float3 b)
{
a.x /= b.x;
a.y /= b.y;
a.z /= b.z;
return a;
return a = a / b;
}
__device_inline float3 operator/=(float3& a, float f)
{
float invf = 1.0f/f;
a.x *= invf;
a.y *= invf;
a.z *= invf;
return a;
return a = a * invf;
}
__device_inline float dot(const float3 a, const float3 b)
@ -506,7 +451,11 @@ __device_inline float3 normalize_len(const float3 a, float *t)
__device_inline bool operator==(const float3 a, const float3 b)
{
#ifdef __KERNEL_SSE__
return (_mm_movemask_ps(_mm_cmpeq_ps(a.m128, b.m128)) & 7) == 7;
#else
return (a.x == b.x && a.y == b.y && a.z == b.z);
#endif
}
__device_inline bool operator!=(const float3 a, const float3 b)
@ -516,14 +465,20 @@ __device_inline bool operator!=(const float3 a, const float3 b)
__device_inline float3 min(float3 a, float3 b)
{
float3 r = make_float3(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z));
return r;
#ifdef __KERNEL_SSE__
return _mm_min_ps(a.m128, b.m128);
#else
return make_float3(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z));
#endif
}
__device_inline float3 max(float3 a, float3 b)
{
float3 r = make_float3(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z));
return r;
#ifdef __KERNEL_SSE__
return _mm_max_ps(a.m128, b.m128);
#else
return make_float3(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z));
#endif
}
__device_inline float3 clamp(float3 a, float3 mn, float3 mx)
@ -533,7 +488,12 @@ __device_inline float3 clamp(float3 a, float3 mn, float3 mx)
__device_inline float3 fabs(float3 a)
{
#ifdef __KERNEL_SSE__
__m128 mask = _mm_castsi128_ps(_mm_set1_epi32(0x7fffffff));
return _mm_and_ps(a.m128, mask);
#else
return make_float3(fabsf(a.x), fabsf(a.y), fabsf(a.z));
#endif
}
#endif
@ -555,6 +515,16 @@ __device_inline void print_float3(const char *label, const float3& a)
printf("%s: %.8f %.8f %.8f\n", label, a.x, a.y, a.z);
}
__device_inline float3 rcp(const float3& a)
{
#ifdef __KERNEL_SSE__
float4 r = _mm_rcp_ps(a.m128);
return _mm_sub_ps(_mm_add_ps(r, r), _mm_mul_ps(_mm_mul_ps(r, r), a));
#else
return make_float3(1.0f/a.x, 1.0f/a.y, 1.0f/a.z);
#endif
}
#endif
__device_inline float3 interp(float3 a, float3 b, float t)
@ -562,122 +532,209 @@ __device_inline float3 interp(float3 a, float3 b, float t)
return a + t*(b - a);
}
__device_inline bool is_zero(const float3 a)
{
#ifdef __KERNEL_SSE__
return a == make_float3(0.0f);
#else
return (a.x == 0.0f && a.y == 0.0f && a.z == 0.0f);
#endif
}
__device_inline float reduce_add(const float3& a)
{
#ifdef __KERNEL_SSE__
return (a.x + a.y + a.z);
#else
return (a.x + a.y + a.z);
#endif
}
__device_inline float average(const float3 a)
{
return reduce_add(a)*(1.0f/3.0f);
}
/* Float4 Vector */
#ifdef __KERNEL_SSE__
template<size_t index_0, size_t index_1, size_t index_2, size_t index_3> __forceinline const float4 shuffle(const float4& b)
{
return _mm_castsi128_ps(_mm_shuffle_epi32(_mm_castps_si128(b), _MM_SHUFFLE(index_3, index_2, index_1, index_0)));
}
template<> __forceinline const float4 shuffle<0, 0, 2, 2>(const float4& b)
{
return _mm_moveldup_ps(b);
}
template<> __forceinline const float4 shuffle<1, 1, 3, 3>(const float4& b)
{
return _mm_movehdup_ps(b);
}
template<> __forceinline const float4 shuffle<0, 1, 0, 1>(const float4& b)
{
return _mm_castpd_ps(_mm_movedup_pd(_mm_castps_pd(b)));
}
#endif
#ifndef __KERNEL_OPENCL__
__device_inline bool is_zero(const float4& a)
{
return (a.x == 0.0f && a.y == 0.0f && a.z == 0.0f && a.w == 0.0f);
}
__device_inline float average(const float4& a)
{
return (a.x + a.y + a.z + a.w)*(1.0f/4.0f);
}
__device_inline float4 operator-(const float4& a)
{
#ifdef __KERNEL_SSE__
__m128 mask = _mm_castsi128_ps(_mm_set1_epi32(0x80000000));
return _mm_xor_ps(a.m128, mask);
#else
return make_float4(-a.x, -a.y, -a.z, -a.w);
#endif
}
__device_inline float4 operator*(const float4& a, const float4& b)
{
#ifdef __KERNEL_SSE__
return _mm_mul_ps(a.m128, b.m128);
#else
return make_float4(a.x*b.x, a.y*b.y, a.z*b.z, a.w*b.w);
#endif
}
__device_inline float4 operator*(const float4& a, float f)
{
#ifdef __KERNEL_SSE__
return a * make_float4(f);
#else
return make_float4(a.x*f, a.y*f, a.z*f, a.w*f);
#endif
}
__device_inline float4 operator*(float f, const float4& a)
{
return make_float4(a.x*f, a.y*f, a.z*f, a.w*f);
return a * f;
}
__device_inline float4 rcp(const float4& a)
{
#ifdef __KERNEL_SSE__
float4 r = _mm_rcp_ps(a.m128);
return _mm_sub_ps(_mm_add_ps(r, r), _mm_mul_ps(_mm_mul_ps(r, r), a));
#else
return make_float4(1.0f/a.x, 1.0f/a.y, 1.0f/a.z, 1.0f/a.w);
#endif
}
__device_inline float4 operator/(const float4& a, float f)
{
float invf = 1.0f/f;
return make_float4(a.x*invf, a.y*invf, a.z*invf, a.w*invf);
return a * (1.0f/f);
}
__device_inline float4 operator/(const float4& a, const float4& b)
{
#ifdef __KERNEL_SSE__
return a * rcp(b);
#else
return make_float4(a.x/b.x, a.y/b.y, a.z/b.z, a.w/b.w);
#endif
}
__device_inline float4 operator+(const float4& a, const float4& b)
{
#ifdef __KERNEL_SSE__
return _mm_add_ps(a.m128, b.m128);
#else
return make_float4(a.x+b.x, a.y+b.y, a.z+b.z, a.w+b.w);
#endif
}
__device_inline float4 operator-(const float4& a, const float4& b)
{
#ifdef __KERNEL_SSE__
return _mm_sub_ps(a.m128, b.m128);
#else
return make_float4(a.x-b.x, a.y-b.y, a.z-b.z, a.w-b.w);
#endif
}
__device_inline float4 operator+=(float4& a, const float4& b)
{
a.x += b.x;
a.y += b.y;
a.z += b.z;
a.w += b.w;
return a;
return a = a + b;
}
__device_inline float4 operator*=(float4& a, const float4& b)
{
a.x *= b.x;
a.y *= b.y;
a.z *= b.z;
a.w *= b.w;
return a;
return a = a * b;
}
__device_inline float4 operator/=(float4& a, float f)
{
float invf = 1.0f/f;
a.x *= invf;
a.y *= invf;
a.z *= invf;
a.w *= invf;
return a;
return a = a / f;
}
__device_inline int4 operator<(const float4& a, const float4& b)
{
#ifdef __KERNEL_SSE__
return _mm_cvtps_epi32(_mm_cmplt_ps(a.m128, b.m128)); /* todo: avoid cvt */
#else
return make_int4(a.x < b.x, a.y < b.y, a.z < b.z, a.w < b.w);
#endif
}
__device_inline int4 operator>=(float4 a, float4 b)
{
#ifdef __KERNEL_SSE__
return _mm_cvtps_epi32(_mm_cmpge_ps(a.m128, b.m128)); /* todo: avoid cvt */
#else
return make_int4(a.x >= b.x, a.y >= b.y, a.z >= b.z, a.w >= b.w);
#endif
}
__device_inline int4 operator<=(const float4& a, const float4& b)
{
#ifdef __KERNEL_SSE__
return _mm_cvtps_epi32(_mm_cmple_ps(a.m128, b.m128)); /* todo: avoid cvt */
#else
return make_int4(a.x <= b.x, a.y <= b.y, a.z <= b.z, a.w <= b.w);
#endif
}
__device_inline bool operator==(const float4 a, const float4 b)
{
#ifdef __KERNEL_SSE__
return (_mm_movemask_ps(_mm_cmpeq_ps(a.m128, b.m128)) & 15) == 15;
#else
return (a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w);
}
__device_inline float dot(const float4& a, const float4& b)
{
return a.x*b.x + a.y*b.y + a.z*b.z + a.w*b.w;
#endif
}
__device_inline float4 cross(const float4& a, const float4& b)
{
#ifdef __KERNEL_SSE__
return (shuffle<1,2,0,0>(a)*shuffle<2,0,1,0>(b)) - (shuffle<2,0,1,0>(a)*shuffle<1,2,0,0>(b));
#else
return make_float4(a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y*b.x, 0.0f);
#endif
}
__device_inline float4 min(float4 a, float4 b)
{
#ifdef __KERNEL_SSE__
return _mm_min_ps(a.m128, b.m128);
#else
return make_float4(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z), min(a.w, b.w));
#endif
}
__device_inline float4 max(float4 a, float4 b)
{
#ifdef __KERNEL_SSE__
return _mm_max_ps(a.m128, b.m128);
#else
return make_float4(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z), max(a.w, b.w));
#endif
}
#endif
@ -686,28 +743,45 @@ __device_inline float4 max(float4 a, float4 b)
__device_inline float4 select(const int4& mask, const float4& a, const float4& b)
{
#ifdef __KERNEL_SSE__
/* blendv is sse4, and apparently broken on vs2008 */
return _mm_or_ps(_mm_and_ps(_mm_cvtepi32_ps(mask), a), _mm_andnot_ps(_mm_cvtepi32_ps(mask), b)); /* todo: avoid cvt */
#else
return make_float4((mask.x)? a.x: b.x, (mask.y)? a.y: b.y, (mask.z)? a.z: b.z, (mask.w)? a.w: b.w);
#endif
}
__device_inline float4 reduce_min(const float4& a)
{
#ifdef __KERNEL_SSE__
float4 h = min(shuffle<1,0,3,2>(a), a);
return min(shuffle<2,3,0,1>(h), h);
#else
return make_float4(min(min(a.x, a.y), min(a.z, a.w)));
#endif
}
__device_inline float4 reduce_max(const float4& a)
{
#ifdef __KERNEL_SSE__
float4 h = max(shuffle<1,0,3,2>(a), a);
return max(shuffle<2,3,0,1>(h), h);
#else
return make_float4(max(max(a.x, a.y), max(a.z, a.w)));
#endif
}
#if 0
__device_inline float4 reduce_add(const float4& a)
{
#ifdef __KERNEL_SSE__
float4 h = shuffle<1,0,3,2>(a) + a;
return shuffle<2,3,0,1>(h) + h;
#else
return make_float4((a.x + a.y) + (a.z + a.w));
#endif
}
__device_inline float3 rcp(const float3& a)
{
return make_float3(1.0f/a.x, 1.0f/a.y, 1.0f/a.z);
}
#endif
__device_inline void print_float4(const char *label, const float4& a)
{
@ -716,23 +790,77 @@ __device_inline void print_float4(const char *label, const float4& a)
#endif
#ifndef __KERNEL_OPENCL__
__device_inline bool is_zero(const float4& a)
{
#ifdef __KERNEL_SSE__
return a == make_float4(0.0f);
#else
return (a.x == 0.0f && a.y == 0.0f && a.z == 0.0f && a.w == 0.0f);
#endif
}
__device_inline float reduce_add(const float4& a)
{
#ifdef __KERNEL_SSE__
float4 h = shuffle<1,0,3,2>(a) + a;
return _mm_cvtss_f32(shuffle<2,3,0,1>(h) + h); /* todo: efficiency? */
#else
return ((a.x + a.y) + (a.z + a.w));
#endif
}
__device_inline float average(const float4& a)
{
return reduce_add(a) * 0.25f;
}
__device_inline float dot(const float4& a, const float4& b)
{
return reduce_add(a * b);
}
#endif
/* Int3 */
#ifndef __KERNEL_OPENCL__
__device_inline int3 min(int3 a, int3 b)
{
#ifdef __KERNEL_SSE__
return _mm_min_epi32(a.m128, b.m128);
#else
return make_int3(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z));
#endif
}
__device_inline int3 max(int3 a, int3 b)
{
#ifdef __KERNEL_SSE__
return _mm_max_epi32(a.m128, b.m128);
#else
return make_int3(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z));
#endif
}
__device_inline int3 clamp(const int3& a, int mn, int mx)
{
#ifdef __KERNEL_SSE__
return min(max(a, make_int3(mn)), make_int3(mx));
#else
return make_int3(clamp(a.x, mn, mx), clamp(a.y, mn, mx), clamp(a.z, mn, mx));
#endif
}
__device_inline int3 clamp(const int3& a, int3& mn, int mx)
{
#ifdef __KERNEL_SSE__
return min(max(a, mn), make_int3(mx));
#else
return make_int3(clamp(a.x, mn.x, mx), clamp(a.y, mn.y, mx), clamp(a.z, mn.z, mx));
#endif
}
#endif
@ -748,44 +876,62 @@ __device_inline void print_int3(const char *label, const int3& a)
/* Int4 */
#ifndef __KERNEL_OPENCL__
__device_inline int4 operator>=(float4 a, float4 b)
{
return make_int4(a.x >= b.x, a.y >= b.y, a.z >= b.z, a.w >= b.w);
}
#endif
#ifndef __KERNEL_GPU__
__device_inline int4 operator+(const int4& a, const int4& b)
{
#ifdef __KERNEL_SSE__
return _mm_add_epi32(a.m128, b.m128);
#else
return make_int4(a.x+b.x, a.y+b.y, a.z+b.z, a.w+b.w);
#endif
}
__device_inline int4 operator+=(int4& a, const int4& b)
{
a.x += b.x;
a.y += b.y;
a.z += b.z;
a.w += b.w;
return a;
return a = a + b;
}
__device_inline int4 operator>>(const int4& a, int i)
{
#ifdef __KERNEL_SSE__
return _mm_srai_epi32(a.m128, i);
#else
return make_int4(a.x >> i, a.y >> i, a.z >> i, a.w >> i);
#endif
}
__device_inline int4 min(int4 a, int4 b)
{
#ifdef __KERNEL_SSE__
return _mm_min_epi32(a.m128, b.m128);
#else
return make_int4(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z), min(a.w, b.w));
#endif
}
__device_inline int4 max(int4 a, int4 b)
{
#ifdef __KERNEL_SSE__
return _mm_max_epi32(a.m128, b.m128);
#else
return make_int4(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z), max(a.w, b.w));
#endif
}
__device_inline int4 clamp(const int4& a, const int4& mn, const int4& mx)
{
return make_int4(clamp(a.x, mn.x, mx.x), clamp(a.y, mn.y, mx.y), clamp(a.z, mn.z, mx.z), clamp(a.w, mn.w, mx.w));
return min(max(a, mn), mx);
}
__device_inline int4 select(const int4& mask, const int4& a, const int4& b)
{
#ifdef __KERNEL_SSE__
__m128 m = _mm_cvtepi32_ps(mask);
return _mm_castps_si128(_mm_or_ps(_mm_and_ps(m, _mm_castsi128_ps(a)), _mm_andnot_ps(m, _mm_castsi128_ps(b)))); /* todo: avoid cvt */
#else
return make_int4((mask.x)? a.x: b.x, (mask.y)? a.y: b.y, (mask.z)? a.z: b.z, (mask.w)? a.w: b.w);
#endif
}
__device_inline void print_int4(const char *label, const int4& a)

@ -129,23 +129,26 @@ static bool transform_matrix4_gj_inverse(float R[][4], float M[][4])
Transform transform_inverse(const Transform& tfm)
{
union { Transform T; float M[4][4]; } R, M;
R.T = transform_identity();
M.T = tfm;
Transform tfmR = transform_identity();
float M[4][4], R[4][4];
if(!transform_matrix4_gj_inverse(R.M, M.M)) {
memcpy(R, &tfmR, sizeof(R));
memcpy(M, &tfm, sizeof(M));
if(!transform_matrix4_gj_inverse(R, M)) {
/* matrix is degenerate (e.g. 0 scale on some axis), ideally we should
never be in this situation, but try to invert it anyway with tweak */
M.M[0][0] += 1e-8f;
M.M[1][1] += 1e-8f;
M.M[2][2] += 1e-8f;
M[0][0] += 1e-8f;
M[1][1] += 1e-8f;
M[2][2] += 1e-8f;
if(!transform_matrix4_gj_inverse(R.M, M.M))
if(!transform_matrix4_gj_inverse(R, M))
return transform_identity();
}
return R.T;
memcpy(&tfmR, R, sizeof(R));
return tfmR;
}
CCL_NAMESPACE_END

@ -55,15 +55,17 @@
/* SIMD Types */
/* not enabled yet, just testing */
#if 0
#define __KERNEL_SSE__
/* not enabled, globally applying it just gives slowdown,
* but useful for testing. */
//#define __KERNEL_SSE__
#ifdef __KERNEL_SSE__
#include <emmintrin.h>
#include <xmmintrin.h>
#include <xmmintrin.h> /* SSE 1 */
#include <emmintrin.h> /* SSE 2 */
#include <pmmintrin.h> /* SSE 3 */
#include <tmmintrin.h> /* SSE 3 */
#include <smmintrin.h> /* SSE 4 */
#endif
#endif
#ifndef _WIN32
@ -126,29 +128,29 @@ typedef uint64_t device_ptr;
struct uchar2 {
uchar x, y;
uchar operator[](int i) const { return *(&x + i); }
uchar& operator[](int i) { return *(&x + i); }
__forceinline uchar operator[](int i) const { return *(&x + i); }
__forceinline uchar& operator[](int i) { return *(&x + i); }
};
struct uchar3 {
uchar x, y, z;
uchar operator[](int i) const { return *(&x + i); }
uchar& operator[](int i) { return *(&x + i); }
__forceinline uchar operator[](int i) const { return *(&x + i); }
__forceinline uchar& operator[](int i) { return *(&x + i); }
};
struct uchar4 {
uchar x, y, z, w;
uchar operator[](int i) const { return *(&x + i); }
uchar& operator[](int i) { return *(&x + i); }
__forceinline uchar operator[](int i) const { return *(&x + i); }
__forceinline uchar& operator[](int i) { return *(&x + i); }
};
struct int2 {
int x, y;
int operator[](int i) const { return *(&x + i); }
int& operator[](int i) { return *(&x + i); }
__forceinline int operator[](int i) const { return *(&x + i); }
__forceinline int& operator[](int i) { return *(&x + i); }
};
#ifdef __KERNEL_SSE__
@ -157,13 +159,18 @@ struct __align(16) int3 {
__m128i m128;
struct { int x, y, z, w; };
};
__forceinline int3() {}
__forceinline int3(const __m128i a) : m128(a) {}
__forceinline operator const __m128i&(void) const { return m128; }
__forceinline operator __m128i&(void) { return m128; }
#else
struct int3 {
int x, y, z, w;
#endif
int operator[](int i) const { return *(&x + i); }
int& operator[](int i) { return *(&x + i); }
__forceinline int operator[](int i) const { return *(&x + i); }
__forceinline int& operator[](int i) { return *(&x + i); }
};
#ifdef __KERNEL_SSE__
@ -172,41 +179,46 @@ struct __align(16) int4 {
__m128i m128;
struct { int x, y, z, w; };
};
__forceinline int4() {}
__forceinline int4(const __m128i a) : m128(a) {}
__forceinline operator const __m128i&(void) const { return m128; }
__forceinline operator __m128i&(void) { return m128; }
#else
struct int4 {
int x, y, z, w;
#endif
int operator[](int i) const { return *(&x + i); }
int& operator[](int i) { return *(&x + i); }
__forceinline int operator[](int i) const { return *(&x + i); }
__forceinline int& operator[](int i) { return *(&x + i); }
};
struct uint2 {
uint x, y;
uint operator[](int i) const { return *(&x + i); }
uint& operator[](int i) { return *(&x + i); }
__forceinline uint operator[](uint i) const { return *(&x + i); }
__forceinline uint& operator[](uint i) { return *(&x + i); }
};
struct uint3 {
uint x, y, z;
uint operator[](int i) const { return *(&x + i); }
uint& operator[](int i) { return *(&x + i); }
__forceinline uint operator[](uint i) const { return *(&x + i); }
__forceinline uint& operator[](uint i) { return *(&x + i); }
};
struct uint4 {
uint x, y, z, w;
uint operator[](int i) const { return *(&x + i); }
uint& operator[](int i) { return *(&x + i); }
__forceinline uint operator[](uint i) const { return *(&x + i); }
__forceinline uint& operator[](uint i) { return *(&x + i); }
};
struct float2 {
float x, y;
float operator[](int i) const { return *(&x + i); }
float& operator[](int i) { return *(&x + i); }
__forceinline float operator[](int i) const { return *(&x + i); }
__forceinline float& operator[](int i) { return *(&x + i); }
};
#ifdef __KERNEL_SSE__
@ -215,13 +227,18 @@ struct __align(16) float3 {
__m128 m128;
struct { float x, y, z, w; };
};
__forceinline float3() {}
__forceinline float3(const __m128 a) : m128(a) {}
__forceinline operator const __m128&(void) const { return m128; }
__forceinline operator __m128&(void) { return m128; }
#else
struct float3 {
float x, y, z, w;
#endif
float operator[](int i) const { return *(&x + i); }
float& operator[](int i) { return *(&x + i); }
__forceinline float operator[](int i) const { return *(&x + i); }
__forceinline float& operator[](int i) { return *(&x + i); }
};
#ifdef __KERNEL_SSE__
@ -230,13 +247,18 @@ struct __align(16) float4 {
__m128 m128;
struct { float x, y, z, w; };
};
__forceinline float4() {}
__forceinline float4(const __m128 a) : m128(a) {}
__forceinline operator const __m128&(void) const { return m128; }
__forceinline operator __m128&(void) { return m128; }
#else
struct float4 {
float x, y, z, w;
#endif
float operator[](int i) const { return *(&x + i); }
float& operator[](int i) { return *(&x + i); }
__forceinline float operator[](int i) const { return *(&x + i); }
__forceinline float& operator[](int i) { return *(&x + i); }
};
#endif
@ -348,6 +370,18 @@ __device_inline int align_up(int offset, int alignment)
return (offset + alignment - 1) & ~(alignment - 1);
}
__device_inline int3 make_int3(int i)
{
#ifdef __KERNEL_SSE__
int3 a;
a.m128 = _mm_set1_epi32(i);
#else
int3 a = {i, i, i, i};
#endif
return a;
}
__device_inline int4 make_int4(int i)
{
#ifdef __KERNEL_SSE__

@ -241,8 +241,10 @@ inline void GHOST_Rect::wrapPoint(GHOST_TInt32 &x, GHOST_TInt32 &y, GHOST_TInt32
GHOST_TInt32 h= getHeight();
/* highly unlikely but avoid eternal loop */
if(w-ofs*2 <= 0 || h-ofs*2 <= 0)
if (w-ofs*2 <= 0 || h-ofs*2 <= 0) {
return;
}
while(x-ofs < m_l) x+= w-(ofs*2);
while(y-ofs < m_t) y+= h-(ofs*2);
while(x+ofs > m_r) x-= w-(ofs*2);

@ -75,28 +75,32 @@ bool GHOST_NDOFManagerX11::available()
bool GHOST_NDOFManagerX11::processEvents()
{
GHOST_TUns64 now = m_system.getMilliSeconds();
bool anyProcessed = false;
spnav_event e;
while (spnav_poll_event(&e)) {
switch (e.type) {
case SPNAV_EVENT_MOTION:
{
/* convert to blender view coords */
short t[3] = {e.motion.x, e.motion.y, -e.motion.z};
short r[3] = {-e.motion.rx, -e.motion.ry, e.motion.rz};
updateTranslation(t, now);
updateRotation(r, now);
break;
if (m_available) {
GHOST_TUns64 now = m_system.getMilliSeconds();
spnav_event e;
while (spnav_poll_event(&e)) {
switch (e.type) {
case SPNAV_EVENT_MOTION:
{
/* convert to blender view coords */
short t[3] = {e.motion.x, e.motion.y, -e.motion.z};
short r[3] = {-e.motion.rx, -e.motion.ry, e.motion.rz};
updateTranslation(t, now);
updateRotation(r, now);
break;
}
case SPNAV_EVENT_BUTTON:
updateButton(e.button.bnum, e.button.press, now);
break;
}
case SPNAV_EVENT_BUTTON:
updateButton(e.button.bnum, e.button.press, now);
break;
anyProcessed = true;
}
anyProcessed = true;
}
return anyProcessed;
}

@ -243,7 +243,7 @@ void *MEM_dupallocN(void *vmemh)
MemHead *memh= vmemh;
memh--;
if(memh->mmap)
if (memh->mmap)
newp= MEM_mapallocN(memh->len, "dupli_mapalloc");
else
newp= MEM_mallocN(memh->len, "dupli_alloc");
@ -265,8 +265,8 @@ void *MEM_reallocN(void *vmemh, size_t len)
memh--;
newp= MEM_mallocN(len, memh->name);
if(newp) {
if(len < memh->len)
if (newp) {
if (len < memh->len)
memcpy(newp, vmemh, len);
else
memcpy(newp, vmemh, memh->len);
@ -311,14 +311,14 @@ void *MEM_mallocN(size_t len, const char *str)
memh= (MemHead *)malloc(len+sizeof(MemHead)+sizeof(MemTail));
if(memh) {
if (memh) {
make_memhead_header(memh, len, str);
mem_unlock_thread();
if(malloc_debug_memset && len)
if (malloc_debug_memset && len)
memset(memh+1, 255, len);
#ifdef DEBUG_MEMCOUNTER
if(_mallocn_count==DEBUG_MEMCOUNTER_ERROR_VAL)
if (_mallocn_count==DEBUG_MEMCOUNTER_ERROR_VAL)
memcount_raise(__func__);
memh->_count= _mallocn_count++;
#endif
@ -339,11 +339,11 @@ void *MEM_callocN(size_t len, const char *str)
memh= (MemHead *)calloc(len+sizeof(MemHead)+sizeof(MemTail),1);
if(memh) {
if (memh) {
make_memhead_header(memh, len, str);
mem_unlock_thread();
#ifdef DEBUG_MEMCOUNTER
if(_mallocn_count==DEBUG_MEMCOUNTER_ERROR_VAL)
if (_mallocn_count==DEBUG_MEMCOUNTER_ERROR_VAL)
memcount_raise(__func__);
memh->_count= _mallocn_count++;
#endif
@ -366,14 +366,14 @@ void *MEM_mapallocN(size_t len, const char *str)
memh= mmap(NULL, len+sizeof(MemHead)+sizeof(MemTail),
PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANON, -1, 0);
if(memh!=(MemHead *)-1) {
if (memh!=(MemHead *)-1) {
make_memhead_header(memh, len, str);
memh->mmap= 1;
mmap_in_use += len;
peak_mem = mmap_in_use > peak_mem ? mmap_in_use : peak_mem;
mem_unlock_thread();
#ifdef DEBUG_MEMCOUNTER
if(_mallocn_count==DEBUG_MEMCOUNTER_ERROR_VAL)
if (_mallocn_count==DEBUG_MEMCOUNTER_ERROR_VAL)
memcount_raise(__func__);
memh->_count= _mallocn_count++;
#endif
@ -406,9 +406,9 @@ static int compare_len(const void *p1, const void *p2)
const MemPrintBlock *pb1= (const MemPrintBlock*)p1;
const MemPrintBlock *pb2= (const MemPrintBlock*)p2;
if(pb1->len < pb2->len)
if (pb1->len < pb2->len)
return 1;
else if(pb1->len == pb2->len)
else if (pb1->len == pb2->len)
return 0;
else
return -1;
@ -431,7 +431,7 @@ void MEM_printmemlist_stats(void)
membl = membase->first;
if (membl) membl = MEMNEXT(membl);
while(membl) {
while (membl) {
pb->name= membl->name;
pb->len= membl->len;
pb->items= 1;
@ -439,18 +439,18 @@ void MEM_printmemlist_stats(void)
totpb++;
pb++;
if(membl->next)
if (membl->next)
membl= MEMNEXT(membl->next);
else break;
}
/* sort by name and add together blocks with the same name */
qsort(printblock, totpb, sizeof(MemPrintBlock), compare_name);
for(a=0, b=0; a<totpb; a++) {
if(a == b) {
for (a = 0, b=0; a<totpb; a++) {
if (a == b) {
continue;
}
else if(strcmp(printblock[a].name, printblock[b].name) == 0) {
else if (strcmp(printblock[a].name, printblock[b].name) == 0) {
printblock[b].len += printblock[a].len;
printblock[b].items++;
}
@ -465,7 +465,7 @@ void MEM_printmemlist_stats(void)
qsort(printblock, totpb, sizeof(MemPrintBlock), compare_len);
printf("\ntotal memory len: %.3f MB\n", (double)mem_in_use/(double)(1024*1024));
printf(" ITEMS TOTAL-MiB AVERAGE-KiB TYPE\n");
for(a=0, pb=printblock; a<totpb; a++, pb++)
for (a = 0, pb=printblock; a<totpb; a++, pb++)
printf("%6d (%8.3f %8.3f) %s\n", pb->items, (double)pb->len/(double)(1024*1024), (double)pb->len/1024.0/(double)pb->items, pb->name);
free(printblock);
@ -491,7 +491,7 @@ static void MEM_printmemlist_internal( int pydict )
print_error("# membase_debug.py\n");
print_error("membase = [\\\n");
}
while(membl) {
while (membl) {
if (pydict) {
fprintf(stderr, "{'len':" SIZET_FORMAT ", 'name':'''%s''', 'pointer':'%p'},\\\n", SIZET_ARG(membl->len), membl->name, (void *)(membl+1));
} else {
@ -501,7 +501,7 @@ static void MEM_printmemlist_internal( int pydict )
print_error("%s len: " SIZET_FORMAT " %p\n", membl->name, SIZET_ARG(membl->len), membl+1);
#endif
}
if(membl->next)
if (membl->next)
membl= MEMNEXT(membl->next);
else break;
}
@ -536,9 +536,9 @@ void MEM_callbackmemlist(void (*func)(void*)) {
membl = membase->first;
if (membl) membl = MEMNEXT(membl);
while(membl) {
while (membl) {
func(membl+1);
if(membl->next)
if (membl->next)
membl= MEMNEXT(membl->next);
else break;
}
@ -554,13 +554,13 @@ short MEM_testN(void *vmemh) {
membl = membase->first;
if (membl) membl = MEMNEXT(membl);
while(membl) {
while (membl) {
if (vmemh == membl+1) {
mem_unlock_thread();
return 1;
}
if(membl->next)
if (membl->next)
membl= MEMNEXT(membl->next);
else break;
}
@ -585,13 +585,13 @@ short MEM_freeN(void *vmemh) /* anders compileertie niet meer */
MemHead *memh= vmemh;
const char *name;
if (memh == NULL){
if (memh == NULL) {
MemorY_ErroR("free","attempt to free NULL pointer");
/* print_error(err_stream, "%d\n", (memh+4000)->tag1); */
return(-1);
}
if(sizeof(intptr_t)==8) {
if (sizeof(intptr_t)==8) {
if (((intptr_t) memh) & 0x7) {
MemorY_ErroR("free","attempt to free illegal pointer");
return(-1);
@ -605,7 +605,7 @@ short MEM_freeN(void *vmemh) /* anders compileertie niet meer */
}
memh--;
if(memh->tag1 == MEMFREE && memh->tag2 == MEMFREE) {
if (memh->tag1 == MEMFREE && memh->tag2 == MEMFREE) {
MemorY_ErroR(memh->name,"double free");
return(-1);
}
@ -613,7 +613,7 @@ short MEM_freeN(void *vmemh) /* anders compileertie niet meer */
mem_lock_thread();
if ((memh->tag1 == MEMTAG1) && (memh->tag2 == MEMTAG2) && ((memh->len & 0x3) == 0)) {
memt = (MemTail *)(((char *) memh) + sizeof(MemHead) + memh->len);
if (memt->tag3 == MEMTAG3){
if (memt->tag3 == MEMTAG3) {
memh->tag1 = MEMFREE;
memh->tag2 = MEMFREE;
@ -628,7 +628,7 @@ short MEM_freeN(void *vmemh) /* anders compileertie niet meer */
error = 2;
MemorY_ErroR(memh->name,"end corrupt");
name = check_memlist(memh);
if (name != NULL){
if (name != NULL) {
if (name != memh->name) MemorY_ErroR(name,"is also corrupt");
}
} else{
@ -694,13 +694,13 @@ static void rem_memblock(MemHead *memh)
totblock--;
mem_in_use -= memh->len;
if(memh->mmap) {
if (memh->mmap) {
mmap_in_use -= memh->len;
if (munmap(memh, memh->len + sizeof(MemHead) + sizeof(MemTail)))
printf("Couldn't unmap memory %s\n", memh->name);
}
else {
if(malloc_debug_memset && memh->len)
if (malloc_debug_memset && memh->len)
memset(memh+1, 255, memh->len);
free(memh);
}
@ -723,7 +723,7 @@ static const char *check_memlist(MemHead *memh)
forw = membase->first;
if (forw) forw = MEMNEXT(forw);
forwok = NULL;
while(forw){
while (forw) {
if (forw->tag1 != MEMTAG1 || forw->tag2 != MEMTAG2) break;
forwok = forw;
if (forw->next) forw = MEMNEXT(forw->next);
@ -733,7 +733,7 @@ static const char *check_memlist(MemHead *memh)
back = (MemHead *) membase->last;
if (back) back = MEMNEXT(back);
backok = NULL;
while(back){
while (back) {
if (back->tag1 != MEMTAG1 || back->tag2 != MEMTAG2) break;
backok = back;
if (back->prev) back = MEMNEXT(back->prev);
@ -742,13 +742,13 @@ static const char *check_memlist(MemHead *memh)
if (forw != back) return ("MORE THAN 1 MEMORYBLOCK CORRUPT");
if (forw == NULL && back == NULL){
if (forw == NULL && back == NULL) {
/* geen foute headers gevonden dan maar op zoek naar memblock*/
forw = membase->first;
if (forw) forw = MEMNEXT(forw);
forwok = NULL;
while(forw){
while (forw) {
if (forw == memh) break;
if (forw->tag1 != MEMTAG1 || forw->tag2 != MEMTAG2) break;
forwok = forw;
@ -760,7 +760,7 @@ static const char *check_memlist(MemHead *memh)
back = (MemHead *) membase->last;
if (back) back = MEMNEXT(back);
backok = NULL;
while(back){
while (back) {
if (back == memh) break;
if (back->tag1 != MEMTAG1 || back->tag2 != MEMTAG2) break;
backok = back;
@ -772,10 +772,10 @@ static const char *check_memlist(MemHead *memh)
if (forwok) name = forwok->nextname;
else name = "No name found";
if (forw == memh){
if (forw == memh) {
/* voor alle zekerheid wordt dit block maar uit de lijst gehaald */
if (forwok){
if (backok){
if (forwok) {
if (backok) {
forwok->next = (MemHead *)&backok->next;
backok->prev = (MemHead *)&forwok->next;
forwok->nextname = backok->name;
@ -785,7 +785,7 @@ static const char *check_memlist(MemHead *memh)
/* membase->last = (struct Link *) &forwok->next; */
}
} else{
if (backok){
if (backok) {
backok->prev = NULL;
membase->first = &backok->next;
} else{

File diff suppressed because it is too large Load Diff

@ -39,7 +39,7 @@ FILE * ufopen(const char * filename, const char * mode)
UTF16_ENCODE(filename);
UTF16_ENCODE (mode);
if(filename_16 && mode_16) {
if (filename_16 && mode_16) {
f = _wfopen(filename_16, mode_16);
}
@ -81,7 +81,7 @@ int urename(const char *oldname, const char *newname )
UTF16_ENCODE(oldname);
UTF16_ENCODE (newname);
if(oldname_16 && newname_16) r = _wrename(oldname_16, newname_16);
if (oldname_16 && newname_16) r = _wrename(oldname_16, newname_16);
UTF16_UN_ENCODE(newname);
UTF16_UN_ENCODE(oldname);
@ -94,7 +94,7 @@ int umkdir(const char *pathname)
BOOL r = 0;
UTF16_ENCODE(pathname);
if(pathname_16) r = CreateDirectoryW(pathname_16, NULL);
if (pathname_16) r = CreateDirectoryW(pathname_16, NULL);
UTF16_UN_ENCODE(pathname);
@ -123,10 +123,10 @@ int uput_getenv(const char *varname, char * value, size_t buffsize)
{
int r = 0;
wchar_t * str;
if(!buffsize) return r;
if (!buffsize) return r;
UTF16_ENCODE(varname);
if(varname_16) {
if (varname_16) {
str = _wgetenv(varname_16);
conv_utf_16_to_8(str, value, buffsize);
r = 1;
@ -143,7 +143,7 @@ int uputenv(const char *name, const char *value)
int r = -1;
UTF16_ENCODE(name);
UTF16_ENCODE(value);
if(name_16 && value_16) {
if (name_16 && value_16) {
r = (SetEnvironmentVariableW(name_16,value_16)!= 0) ? 0 : -1;
}
UTF16_UN_ENCODE(value);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 108 KiB

After

Width:  |  Height:  |  Size: 107 KiB

@ -106,20 +106,20 @@ void blurbuf(struct ImBuf *ibuf, int nr, Cast *cast)
x4= ibuf->x/4;
/* This doesn't seem to work... paprmh */
if(cast->gamma != 1.0) gamwarp(tbuf, cast->gamma);
if (cast->gamma != 1.0) gamwarp(tbuf, cast->gamma);
/* reduce */
for(i=0; i<nr; i++) {
for (i=0; i<nr; i++) {
ttbuf = onehalf(tbuf);
if (ttbuf) {
freeImBuf(tbuf);
tbuf = ttbuf;
}
if(tbuf->x<4 || tbuf->y<4) break;
if (tbuf->x<4 || tbuf->y<4) break;
}
/* enlarge */
for(i=0; i<nr; i++) {
for (i=0; i<nr; i++) {
ttbuf = double_x(tbuf);
if (ttbuf) {
freeImBuf(tbuf);
@ -130,18 +130,18 @@ void blurbuf(struct ImBuf *ibuf, int nr, Cast *cast)
freeImBuf(tbuf);
tbuf = ttbuf;
}
if(tbuf->x > x4) {
if (tbuf->x > x4) {
scaleImBuf(tbuf, ibuf->x, ibuf->y);
break;
}
}
/* this doesn't seem to work...paprmh*/
if(cast->gamma != 1.0) gamwarp(tbuf, 1.0 / cast->gamma);
if (cast->gamma != 1.0) gamwarp(tbuf, 1.0 / cast->gamma);
if(ibuf->rect)memcpy(ibuf->rect, tbuf->rect, 4*ibuf->x*ibuf->y);
if (ibuf->rect)memcpy(ibuf->rect, tbuf->rect, 4*ibuf->x*ibuf->y);
if(ibuf->rect_float)
if (ibuf->rect_float)
memcpy(ibuf->rect_float, tbuf->rect_float, 4*ibuf->x*ibuf->y*sizeof(float));
freeImBuf(tbuf);
@ -161,13 +161,13 @@ void doblur(struct ImBuf *mbuf, float fac, Cast *cast)
/* which buffers ? */
if(fac>7.0) fac= 7.0;
if(fac<=1.0) return;
if (fac>7.0) fac= 7.0;
if (fac<=1.0) return;
pfac= 2.0;
pbuf= dupImBuf(mbuf);
n= 1;
while(pfac < fac) {
while (pfac < fac) {
blurbuf(pbuf, n, cast);
blurbuf(pbuf, n, cast);
@ -185,10 +185,10 @@ void doblur(struct ImBuf *mbuf, float fac, Cast *cast)
fac= (fac-pfac)/(ifac-pfac);
n= mbuf->x*mbuf->y;
if(cast->show) fac=cast->show-1;
if (cast->show) fac=cast->show-1;
if(mbuf->rect_float){
if(fac>=1) {
if (mbuf->rect_float){
if (fac>=1) {
memcpy(mbuf->rect_float, ibuf->rect_float, 4*n*sizeof(float));
}
else if(fac<=0) {
@ -200,7 +200,7 @@ void doblur(struct ImBuf *mbuf, float fac, Cast *cast)
irectf= (float *)ibuf->rect_float;
prectf= (float *)pbuf->rect_float;
mrectf= (float *)mbuf->rect_float;
while(n--) {
while (n--) {
mrectf[0]= irectf[0]*fac+ prectf[0]*infac;
mrectf[1]= irectf[1]*fac+ prectf[1]*infac;
mrectf[2]= irectf[2]*fac+ prectf[2]*infac;
@ -213,10 +213,10 @@ void doblur(struct ImBuf *mbuf, float fac, Cast *cast)
}
else if(mbuf->rect){
b1= (int)fac*255.0;
if(b1>255) b1= 255;
if (b1>255) b1= 255;
b2= 255-b1;
if(b1==255) {
if (b1==255) {
memcpy(mbuf->rect, ibuf->rect, 4*n);
}
else if(b1==0) {
@ -226,7 +226,7 @@ void doblur(struct ImBuf *mbuf, float fac, Cast *cast)
irect= (char *)ibuf->rect;
prect= (char *)pbuf->rect;
mrect= (char *)mbuf->rect;
while(n--) {
while (n--) {
mrect[0]= (irect[0]*b1+ prect[0]*b2)>>8;
mrect[1]= (irect[1]*b1+ prect[1]*b2)>>8;
mrect[2]= (irect[2]*b1+ prect[2]*b2)>>8;
@ -247,7 +247,7 @@ void plugin_seq_doit(Cast *cast, float facf0, float facf1, int x, int y, ImBuf *
{
float bfacf0, bfacf1;
if(cast->use_ipo==0) {
if (cast->use_ipo==0) {
bfacf0= bfacf1= cast->blur+1.0;
}
else {
@ -255,8 +255,8 @@ void plugin_seq_doit(Cast *cast, float facf0, float facf1, int x, int y, ImBuf *
bfacf1 = (facf1 * 6.0) + 1.0;
}
if(out->rect) memcpy(out->rect, ibuf1->rect, 4*out->x*out->y);
if(out->rect_float) memcpy(out->rect_float, ibuf1->rect_float, 4*out->x*out->y*sizeof(float));
if (out->rect) memcpy(out->rect, ibuf1->rect, 4*out->x*out->y);
if (out->rect_float) memcpy(out->rect_float, ibuf1->rect_float, 4*out->x*out->y*sizeof(float));
/****************I can't get this field code to work... works ok without...paprmh****************/
@ -269,13 +269,13 @@ void plugin_seq_doit(Cast *cast, float facf0, float facf1, int x, int y, ImBuf *
doblur(out, bfacf0, cast); /*fieldA*/
/* if(out->rect)out->rect += out->x * out->y;
if(out->rect_float)out->rect_float += out->x * out->y;
/* if (out->rect)out->rect += out->x * out->y;
if (out->rect_float)out->rect_float += out->x * out->y;
doblur(out, bfacf1, cast);*/ /*fieldB*/
/* if(out->rect)out->rect -= out->x * out->y;
if(out->rect_float)out->rect_float -= out->x * out->y;
/* if (out->rect)out->rect -= out->x * out->y;
if (out->rect_float)out->rect_float -= out->x * out->y;
out->flags |= IB_fields;
interlace(out);*/

@ -150,7 +150,7 @@ int plugin_tex_doit(int stype, Cast *cast, float *texvec, float *dxt, float *dyt
/* always return this value */
result[0] = CLAMP (val+cast->offset, 0.0, 1.0) * pow (fabs(sqrt(tv[0]*tv[0]+tv[1]*tv[1]+tv[2]*tv[2])), cast->falloff);
if(stype==1) {
if (stype==1) {
/*
* this is r, g, b, a:
*/
@ -161,7 +161,7 @@ int plugin_tex_doit(int stype, Cast *cast, float *texvec, float *dxt, float *dyt
res |= TEX_RGB;
}
if(stype==2) {
if (stype==2) {
/*
* This value is the displacement of the actual normal in
* the Material calculation.

@ -124,7 +124,7 @@ float sample_wave(float freq, float coord, float pixsize)
float fac, frac, retval;
int part1, part2;
if(pixsize > freq) return 0.5;
if (pixsize > freq) return 0.5;
pixsize/= freq;
@ -132,19 +132,19 @@ float sample_wave(float freq, float coord, float pixsize)
part1= ffloor(fac);
frac= fac - part1;
if(part1 & 1) retval= 0.0;
else retval= 1.0;
if (part1 & 1) retval= 0.0;
else retval = 1.0;
if(pixsize != 0.0) {
if (pixsize != 0.0) {
/* is coord+pixsize another value? */
part2= ffloor(fac + pixsize);
if(part1==part2) return retval;
if (part1==part2) return retval;
/* antialias */
if(retval==1.0) retval= (1.0-frac)/pixsize;
else retval= 1.0-(1.0-frac)/pixsize;
if (retval == 1.0) retval= (1.0 - frac) / pixsize;
else retval= 1.0 - (1.0 - frac) / pixsize;
}
return retval;
}
@ -153,23 +153,23 @@ int plugin_tex_doit(int stype, Cast *cast, float *texvec, float *dxt, float *dyt
{
float xwave, ywave;
if(stype==1) {
if (stype==1) {
texvec[0]+= hnoise(cast->noise, texvec[0], texvec[1], texvec[2]);
texvec[1]+= hnoise(cast->noise, texvec[1], texvec[2], texvec[0]);
}
if(dxt && dyt) {
if (dxt && dyt) {
xwave= sample_wave(cast->size, texvec[0], fabs(dxt[0]) + fabs(dyt[0]) );
ywave= sample_wave(cast->size, texvec[1], fabs(dxt[1]) + fabs(dyt[1]) );
if(xwave > ywave) result[0]= xwave-ywave;
if (xwave > ywave) result[0]= xwave-ywave;
else result[0]= ywave-xwave;
}
else {
xwave= sample_wave(cast->size, texvec[0], 0.0 );
ywave= sample_wave(cast->size, texvec[1], 0.0 );
if(xwave > ywave) result[0]= xwave-ywave;
if (xwave > ywave) result[0]= xwave-ywave;
else result[0]= ywave-xwave;
}

@ -75,7 +75,7 @@ def read_blend_rend_chunk(path):
# Now we want the scene name, start and end frame. this is 32bites long
start_frame, end_frame = struct.unpack('>2i' if is_big_endian else '<2i', blendfile.read(8))
scene_name = blendfile.read(24)
scene_name = blendfile.read(64)
scene_name = scene_name[:scene_name.index(b'\0')]

@ -440,11 +440,15 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
layout.separator()
flow = layout.column_flow()
flow.prop(md, "time")
flow.prop(md, "resolution")
flow.prop(md, "spatial_size")
flow.prop(md, "depth")
split = layout.split()
col = split.column()
col.prop(md, "time")
col.prop(md, "resolution")
col = split.column()
col.prop(md, "spatial_size")
col.prop(md, "depth")
layout.label("Waves:")

@ -220,7 +220,6 @@ class SEQUENCER_MT_add_effect(Menu):
layout.operator("sequencer.effect_strip_add", text="Gamma Cross").type = 'GAMMA_CROSS'
layout.operator("sequencer.effect_strip_add", text="Multiply").type = 'MULTIPLY'
layout.operator("sequencer.effect_strip_add", text="Over Drop").type = 'OVER_DROP'
layout.operator("sequencer.effect_strip_add", text="Plugin").type = 'PLUGIN'
layout.operator("sequencer.effect_strip_add", text="Wipe").type = 'WIPE'
layout.operator("sequencer.effect_strip_add", text="Glow").type = 'GLOW'
layout.operator("sequencer.effect_strip_add", text="Transform").type = 'TRANSFORM'
@ -488,7 +487,7 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel, Panel):
col = layout.column(align=True)
if strip.type == 'SPEED':
col.prop(strip, "multiply_speed")
elif strip.type in {'CROSS', 'GAMMA_CROSS', 'PLUGIN', 'WIPE'}:
elif strip.type in {'CROSS', 'GAMMA_CROSS', 'WIPE'}:
col.prop(strip, "use_default_fade", "Default fade")
if not strip.use_default_fade:
col.prop(strip, "effect_fader", text="Effect fader")
@ -553,7 +552,6 @@ class SEQUENCER_PT_input(SequencerButtonsPanel, Panel):
return strip.type in {'MOVIE', 'IMAGE', 'SCENE', 'MOVIECLIP', 'META',
'ADD', 'SUBTRACT', 'ALPHA_OVER', 'ALPHA_UNDER',
'CROSS', 'GAMMA_CROSS', 'MULTIPLY', 'OVER_DROP',
'PLUGIN',
'WIPE', 'GLOW', 'TRANSFORM',
'MULTICAM', 'SPEED', 'ADJUSTMENT'}
@ -716,7 +714,6 @@ class SEQUENCER_PT_filter(SequencerButtonsPanel, Panel):
return strip.type in {'MOVIE', 'IMAGE', 'SCENE', 'MOVIECLIP', 'META',
'ADD', 'SUBTRACT', 'ALPHA_OVER', 'ALPHA_UNDER',
'CROSS', 'GAMMA_CROSS', 'MULTIPLY', 'OVER_DROP',
'PLUGIN',
'WIPE', 'GLOW', 'TRANSFORM', 'COLOR',
'MULTICAM', 'SPEED', 'ADJUSTMENT'}

@ -785,8 +785,6 @@ class USERPREF_PT_file(Panel):
sub = col1.column()
sub.label(text="Fonts:")
sub.label(text="Textures:")
sub.label(text="Texture Plugins:")
sub.label(text="Sequence Plugins:")
sub.label(text="Render Output:")
sub.label(text="Scripts:")
sub.label(text="Sounds:")
@ -797,8 +795,6 @@ class USERPREF_PT_file(Panel):
sub = col1.column()
sub.prop(paths, "font_directory", text="")
sub.prop(paths, "texture_directory", text="")
sub.prop(paths, "texture_plugin_directory", text="")
sub.prop(paths, "sequence_plugin_directory", text="")
sub.prop(paths, "render_output_directory", text="")
sub.prop(paths, "script_directory", text="")
sub.prop(paths, "sound_directory", text="")

@ -131,7 +131,7 @@ class ShowHideMenu():
layout = self.layout
layout.operator("%s.reveal" % self._operator_name, text="Show Hidden")
layout.operator("%s.hide" % self._operator_name, text="Hide Selected")
layout.operator("%s.hide" % self._operator_name, text="Hide Selected").unselected = False
layout.operator("%s.hide" % self._operator_name, text="Hide Unselected").unselected = True
@ -1602,7 +1602,7 @@ class VIEW3D_MT_edit_mesh_specials(Menu):
layout.operator("mesh.subdivide", text="Subdivide Smooth").smoothness = 1.0
layout.operator("mesh.merge", text="Merge...")
layout.operator("mesh.remove_doubles")
layout.operator("mesh.hide", text="Hide")
layout.operator("mesh.hide", text="Hide").unselected = False
layout.operator("mesh.reveal", text="Reveal")
layout.operator("mesh.select_all", text="Select Inverse").action = 'INVERT'
layout.operator("mesh.flip_normals")
@ -2036,7 +2036,7 @@ class VIEW3D_MT_edit_meta_showhide(Menu):
layout = self.layout
layout.operator("mball.reveal_metaelems", text="Show Hidden")
layout.operator("mball.hide_metaelems", text="Hide Selected")
layout.operator("mball.hide_metaelems", text="Hide Selected").unselected = False
layout.operator("mball.hide_metaelems", text="Hide Unselected").unselected = True

@ -45,7 +45,7 @@ ANIM_KS_ROTATION_ID = "Rotation"
ANIM_KS_SCALING_ID = "Scaling"
ANIM_KS_LOC_ROT_SCALE_ID = "LocRotScale"
ANIM_KS_AVAILABLE_ID = "Available"
ANIM_KS_WHOLE_CHARACTER_ID = "Whole Character"
ANIM_KS_WHOLE_CHARACTER_ID = "WholeCharacter"
# Location

@ -14,7 +14,7 @@ class ModalTimerOperator(bpy.types.Operator):
if event.type == 'TIMER':
# change theme color, silly!
color = context.user_preferences.themes[0].view_3d.back
color = context.user_preferences.themes[0].view_3d.space.back
color.s = 1.0
color.h += 0.01

@ -90,7 +90,6 @@ Function .onInit
${If} ${RunningX64}
${If} "[BITNESS]" == "32"
${OrIf} "[BITNESS]" == "-mingw"
StrCpy $INSTDIR "$PROGRAMFILES32\Blender Foundation\Blender" ; Can't use InstallDir inside Section
${ElseIf} "[BITNESS]" == "64"
StrCpy $INSTDIR "$PROGRAMFILES64\Blender Foundation\Blender"

@ -442,7 +442,9 @@ AviError AVI_open_movie (const char *name, AviMovie *movie)
if (GET_FCC (movie->fp) != FCC("RIFF") ||
!(movie->size = GET_FCC (movie->fp)))
{
return AVI_ERROR_FORMAT;
}
movie->header = (AviMainHeader *) MEM_mallocN (sizeof (AviMainHeader), "movieheader");
@ -1002,7 +1004,7 @@ AviError AVI_write_frame (AviMovie *movie, int frame_num, ...)
movie->entries[frame_num * (movie->header->Streams+1) + stream + 1].ChunkId = chunk.fcc;
movie->entries[frame_num * (movie->header->Streams+1) + stream + 1].Flags = AVIIF_KEYFRAME;
movie->entries[frame_num * (movie->header->Streams+1) + stream + 1].Offset = ftell(movie->fp)-12L-movie->movi_offset;
movie->entries[frame_num * (movie->header->Streams+1) + stream + 1].Offset = (int)(ftell(movie->fp) - 12L - movie->movi_offset);
movie->entries[frame_num * (movie->header->Streams+1) + stream + 1].Size = chunk.size;
/* Write the chunk */
@ -1024,8 +1026,8 @@ AviError AVI_write_frame (AviMovie *movie, int frame_num, ...)
movie->entries[frame_num * (movie->header->Streams+1)].ChunkId = FCC("rec ");
movie->entries[frame_num * (movie->header->Streams+1)].Flags = AVIIF_LIST;
movie->entries[frame_num * (movie->header->Streams+1)].Offset = rec_off-8L-movie->movi_offset;
movie->entries[frame_num * (movie->header->Streams+1)].Size = ftell(movie->fp)-(rec_off+4L);
movie->entries[frame_num * (movie->header->Streams+1)].Offset = (int)(rec_off - 8L - movie->movi_offset);
movie->entries[frame_num * (movie->header->Streams+1)].Size = (int)(ftell(movie->fp) - (rec_off + 4L));
/* Update the record size */
fseek (movie->fp, rec_off, SEEK_SET);
@ -1044,7 +1046,7 @@ AviError AVI_close_compress (AviMovie *movie)
int temp, movi_size, i;
fseek (movie->fp, 0L, SEEK_END);
movi_size = ftell (movie->fp);
movi_size = (int)ftell(movie->fp);
PUT_FCC ("idx1", movie->fp);
PUT_FCCN ((movie->index_entries*(movie->header->Streams+1)*16), movie->fp);
@ -1052,7 +1054,7 @@ AviError AVI_close_compress (AviMovie *movie)
for (temp=0; temp < movie->index_entries*(movie->header->Streams+1); temp++)
awrite (movie, &movie->entries[temp], 1, sizeof(AviIndexEntry), movie->fp, AVI_INDEXE);
temp = ftell (movie->fp);
temp = (int)ftell(movie->fp);
fseek (movie->fp, AVI_RIFF_SOFF, SEEK_SET);

@ -46,10 +46,12 @@ void *avi_format_convert (AviMovie *movie, int stream, void *buffer, AviFormat f
return buffer;
if (from != AVI_FORMAT_RGB24 &&
to != AVI_FORMAT_RGB24)
to != AVI_FORMAT_RGB24)
{
return avi_format_convert(movie, stream,
avi_format_convert (movie, stream, buffer, from, AVI_FORMAT_RGB24, size),
AVI_FORMAT_RGB24, to, size);
avi_format_convert(movie, stream, buffer, from, AVI_FORMAT_RGB24, size),
AVI_FORMAT_RGB24, to, size);
}
switch (to) {
case AVI_FORMAT_RGB24:

@ -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 262
#define BLENDER_SUBVERSION 4
#define BLENDER_VERSION 263
#define BLENDER_SUBVERSION 0
#define BLENDER_MINVERSION 250
#define BLENDER_MINSUBVERSION 0
@ -51,7 +51,7 @@ extern "C" {
/* can be left blank, otherwise a,b,c... etc with no quotes */
#define BLENDER_VERSION_CHAR
/* alpha/beta/rc/release, docs use this */
#define BLENDER_VERSION_CYCLE rc
#define BLENDER_VERSION_CYCLE alpha
extern char versionstr[]; /* from blender.c */

@ -53,72 +53,83 @@ struct Scene;
#define CU_DO_TILT(cu, nu) (((nu->flag & CU_2D) && (cu->flag & CU_3D)==0) ? 0 : 1)
#define CU_DO_RADIUS(cu, nu) ((CU_DO_TILT(cu, nu) || ((cu)->flag & CU_PATH_RADIUS) || (cu)->bevobj || (cu)->ext1!=0.0f || (cu)->ext2!=0.0f) ? 1:0)
/* ** Curve ** */
void BKE_curve_unlink(struct Curve *cu);
void BKE_curve_free(struct Curve *cu);
void BKE_curve_editfont_free(struct Curve *cu);
struct Curve *BKE_curve_add(const char *name, int type);
struct Curve *BKE_curve_copy(struct Curve *cu);
void BKE_curve_make_local(struct Curve *cu);
short BKE_curve_type_get(struct Curve *cu);
void BKE_curve_type_test(struct Object *ob);
void BKE_curve_curve_dimension_update(struct Curve *cu);
void BKE_curve_tex_space_calc(struct Curve *cu);
void unlink_curve(struct Curve *cu);
void free_curve_editNurb_keyIndex(struct EditNurb *editnurb);
void free_curve_editNurb(struct Curve *cu);
void free_curve(struct Curve *cu);
void BKE_free_editfont(struct Curve *cu);
struct Curve *add_curve(const char *name, int type);
struct Curve *copy_curve(struct Curve *cu);
void make_local_curve(struct Curve *cu);
struct ListBase *curve_editnurbs(struct Curve *cu);
short curve_type(struct Curve *cu);
void test_curve_type(struct Object *ob);
void update_curve_dimension(struct Curve *cu );
void tex_space_curve(struct Curve *cu);
int count_curveverts(struct ListBase *nurb);
int count_curveverts_without_handles(struct ListBase *nurb);
void freeNurb(struct Nurb *nu);
void freeNurblist(struct ListBase *lb);
struct Nurb *duplicateNurb(struct Nurb *nu);
void duplicateNurblist(struct ListBase *lb1, struct ListBase *lb2);
void test2DNurb(struct Nurb *nu);
void minmaxNurb(struct Nurb *nu, float *min, float *max);
int BKE_curve_minmax(struct Curve *cu, float min[3], float max[3]);
int BKE_curve_center_median(struct Curve *cu, float cent[3]);
int BKE_curve_center_bounds(struct Curve *cu, float cent[3]);
void BKE_curve_translate(struct Curve *cu, float offset[3], int do_keys);
void BKE_curve_delete_material_index(struct Curve *cu, int index);
void nurbs_knot_calc_u(struct Nurb *nu);
void nurbs_knot_calc_v(struct Nurb *nu);
ListBase *BKE_curve_nurbs_get(struct Curve *cu);
void makeNurbfaces(struct Nurb *nu, float *coord_array, int rowstride, int resolu, int resolv);
void makeNurbcurve(struct Nurb *nu, float *coord_array, float *tilt_array, float *radius_array, float *weight_array, int resolu, int stride);
void forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride);
float *make_orco_curve(struct Scene *scene, struct Object *ob);
float *make_orco_surf(struct Object *ob);
void makebevelcurve(struct Scene *scene, struct Object *ob, struct ListBase *disp, int forRender);
float (*BKE_curve_vertexCos_get(struct Curve *cu, struct ListBase *lb, int *numVerts_r))[3];
void BK_curve_vertexCos_apply(struct Curve *cu, struct ListBase *lb, float (*vertexCos)[3]);
void makeBevelList(struct Object *ob);
float (*BKE_curve_keyVertexCos_get(struct Curve *cu, struct ListBase *lb, float *key))[3];
void BKE_curve_keyVertexTilts_apply(struct Curve *cu, struct ListBase *lb, float *key);
void calchandleNurb(struct BezTriple *bezt, struct BezTriple *prev, struct BezTriple *next, int mode);
void calchandlesNurb(struct Nurb *nu);
void testhandlesNurb(struct Nurb *nu);
void autocalchandlesNurb(struct Nurb *nu, int flag);
void autocalchandlesNurb_all(ListBase *editnurb, int flag);
void sethandlesNurb(ListBase *editnurb, short code);
void BKE_curve_editNurb_keyIndex_free(struct EditNurb *editnurb);
void BKE_curve_editNurb_free(struct Curve *cu);
struct ListBase *BKE_curve_editNurbs_get(struct Curve *cu);
void switchdirectionNurb(struct Nurb *nu);
float *BKE_curve_make_orco(struct Scene *scene, struct Object *ob);
float *BKE_curve_surf_make_orco(struct Object *ob);
void addNurbPoints(struct Nurb *nu, int number);
void addNurbPointsBezier(struct Nurb *nu, int number);
void BKE_curve_bevelList_make(struct Object *ob);
void BKE_curve_bevel_make(struct Scene *scene, struct Object *ob, struct ListBase *disp, int forRender);
float (*curve_getVertexCos(struct Curve *cu, struct ListBase *lb, int *numVerts_r))[3];
void curve_applyVertexCos(struct Curve *cu, struct ListBase *lb, float (*vertexCos)[3]);
void BKE_curve_forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride);
float (*curve_getKeyVertexCos(struct Curve *cu, struct ListBase *lb, float *key))[3];
void curve_applyKeyVertexTilts(struct Curve *cu, struct ListBase *lb, float *key);
/* ** Nurbs ** */
int BKE_nurbList_verts_count(struct ListBase *nurb);
int BKE_nurbList_verts_count_without_handles(struct ListBase *nurb);
void BKE_nurbList_free(struct ListBase *lb);
void BKE_nurbList_duplicate(struct ListBase *lb1, struct ListBase *lb2);
void BKE_nurbList_handles_set(struct ListBase *editnurb, short code);
void BKE_nurbList_handles_autocalc(ListBase *editnurb, int flag);
void BKE_nurb_free(struct Nurb *nu);
struct Nurb *BKE_nurb_duplicate(struct Nurb *nu);
void BKE_nurb_test2D(struct Nurb *nu);
void BKE_nurb_minmax(struct Nurb *nu, float *min, float *max);
void BKE_nurb_makeFaces(struct Nurb *nu, float *coord_array, int rowstride, int resolu, int resolv);
void BKE_nurb_makeCurve(struct Nurb *nu, float *coord_array, float *tilt_array, float *radius_array, float *weight_array, int resolu, int stride);
void BKE_nurb_knot_calc_u(struct Nurb *nu);
void BKE_nurb_knot_calc_v(struct Nurb *nu);
/* nurb checks if they can be drawn, also clamp order func */
int check_valid_nurb_u(struct Nurb *nu);
int check_valid_nurb_v(struct Nurb *nu);
int BKE_nurb_check_valid_u(struct Nurb *nu);
int BKE_nurb_check_valid_v(struct Nurb *nu);
int clamp_nurb_order_u(struct Nurb *nu);
int clamp_nurb_order_v(struct Nurb *nu);
int BKE_nurb_order_clamp_u(struct Nurb *nu);
int BKE_nurb_order_clamp_v(struct Nurb *nu);
ListBase *BKE_curve_nurbs(struct Curve *cu);
void BKE_nurb_direction_switch(struct Nurb *nu);
void BKE_nurb_points_add(struct Nurb *nu, int number);
void BKE_nurb_bezierPoints_add(struct Nurb *nu, int number);
void BKE_nurb_handle_calc(struct BezTriple *bezt, struct BezTriple *prev, struct BezTriple *next, int mode);
void BKE_nurb_handles_calc(struct Nurb *nu);
void BKE_nurb_handles_autocalc(struct Nurb *nu, int flag);
void BKE_nurb_handles_test(struct Nurb *nu);
int minmax_curve(struct Curve *cu, float min[3], float max[3]);
int curve_center_median(struct Curve *cu, float cent[3]);
int curve_center_bounds(struct Curve *cu, float cent[3]);
void curve_translate(struct Curve *cu, float offset[3], int do_keys);
void curve_delete_material_index(struct Curve *cu, int index);
#endif

@ -49,7 +49,7 @@ void make_local_lattice(struct Lattice *lt);
void calc_lat_fudu(int flag, int res, float *fu, float *du);
void init_latt_deform(struct Object *oblatt, struct Object *ob);
void calc_latt_deform(struct Object *, float *co, float weight);
void calc_latt_deform(struct Object *, float co[3], float weight);
void end_latt_deform(struct Object *);
int object_deform_mball(struct Object *ob, struct ListBase *dispbase);

@ -37,147 +37,30 @@ struct Object;
struct Scene;
struct MetaElem;
typedef struct point { /* a three-dimensional point */
float x, y, z; /* its coordinates */
} MB_POINT;
void BKE_metaball_unlink(struct MetaBall *mb);
void BKE_metaball_free(struct MetaBall *mb);
struct MetaBall *BKE_metaball_add(const char *name);
struct MetaBall *BKE_metaball_copy(struct MetaBall *mb);
typedef struct vertex { /* surface vertex */
MB_POINT position, normal; /* position and surface normal */
} VERTEX;
void BKE_metaball_make_local(struct MetaBall *mb);
typedef struct vertices { /* list of vertices in polygonization */
int count, max; /* # vertices, max # allowed */
VERTEX *ptr; /* dynamically allocated */
} VERTICES;
void BKE_metaball_cubeTable_free(void);
typedef struct corner { /* corner of a cube */
int i, j, k; /* (i, j, k) is index within lattice */
float x, y, z, value; /* location and function value */
struct corner *next;
} CORNER;
void BKE_metaball_polygonize(struct Scene *scene, struct Object *ob, struct ListBase *dispbase);
int BKE_metaball_is_basis_for(struct Object *ob1, struct Object *ob2);
int BKE_metaball_is_basis(struct Object *ob);
struct Object *BKE_metaball_basis_find(struct Scene *scene, struct Object *ob);
typedef struct cube { /* partitioning cell (cube) */
int i, j, k; /* lattice location of cube */
CORNER *corners[8]; /* eight corners */
} CUBE;
void BKE_metaball_tex_space_calc(struct Object *ob);
float *BKE_metaball_make_orco(struct Object *ob, struct ListBase *dispbase);
typedef struct cubes { /* linked list of cubes acting as stack */
CUBE cube; /* a single cube */
struct cubes *next; /* remaining elements */
} CUBES;
typedef struct centerlist { /* list of cube locations */
int i, j, k; /* cube location */
struct centerlist *next; /* remaining elements */
} CENTERLIST;
typedef struct edgelist { /* list of edges */
int i1, j1, k1, i2, j2, k2; /* edge corner ids */
int vid; /* vertex id */
struct edgelist *next; /* remaining elements */
} EDGELIST;
typedef struct intlist { /* list of integers */
int i; /* an integer */
struct intlist *next; /* remaining elements */
} INTLIST;
typedef struct intlists { /* list of list of integers */
INTLIST *list; /* a list of integers */
struct intlists *next; /* remaining elements */
} INTLISTS;
typedef struct process { /* parameters, function, storage */
/* what happens here? floats, I think. */
/* float (*function)(void); */ /* implicit surface function */
float (*function)(float, float, float);
float size, delta; /* cube size, normal delta */
int bounds; /* cube range within lattice */
CUBES *cubes; /* active cubes */
VERTICES vertices; /* surface vertices */
CENTERLIST **centers; /* cube center hash table */
CORNER **corners; /* corner value hash table */
EDGELIST **edges; /* edge and vertex id hash table */
} PROCESS;
/* dividing scene using octal tree makes polygonisation faster */
typedef struct ml_pointer {
struct ml_pointer *next, *prev;
struct MetaElem *ml;
} ml_pointer;
typedef struct octal_node {
struct octal_node *nodes[8]; /* children of current node */
struct octal_node *parent; /* parent of current node */
struct ListBase elems; /* ListBase of MetaElem pointers (ml_pointer) */
float x_min, y_min, z_min; /* 1st border point */
float x_max, y_max, z_max; /* 7th border point */
float x,y,z; /* center of node */
int pos, neg; /* number of positive and negative MetaElements in the node */
int count; /* number of MetaElems, which belongs to the node */
} octal_node;
typedef struct octal_tree {
struct octal_node *first; /* first node */
int pos, neg; /* number of positive and negative MetaElements in the scene */
short depth; /* number of scene subdivision */
} octal_tree;
struct pgn_elements {
struct pgn_elements *next, *prev;
char *data;
};
octal_node* find_metaball_octal_node(octal_node *node, float x, float y, float z, short depth);
void freepolygonize(PROCESS *p);
void docube(CUBE *cube, PROCESS *p, struct MetaBall *mb);
void testface(int i, int j, int k, CUBE* old, int bit, int c1, int c2, int c3, int c4, PROCESS *p);
CORNER *setcorner (PROCESS* p, int i, int j, int k);
int vertid (CORNER *c1, CORNER *c2, PROCESS *p, struct MetaBall *mb);
int setcenter(CENTERLIST *table[], int i, int j, int k);
int otherface (int edge, int face);
void makecubetable (void);
void setedge (EDGELIST *table[], int i1, int j1, int k1, int i2, int j2, int k2, int vid);
int getedge (EDGELIST *table[], int i1, int j1, int k1, int i2, int j2, int k2);
void addtovertices (VERTICES *vertices, VERTEX v);
void vnormal (MB_POINT *point, PROCESS *p, MB_POINT *v);
void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2, float (*function)(float, float, float), MB_POINT *p, struct MetaBall *mb, int f);
void add_cube(PROCESS *mbproc, int i, int j, int k, int count);
void find_first_points(PROCESS *mbproc, struct MetaBall *mb, int a);
void fill_metaball_octal_node(octal_node *node, struct MetaElem *ml, short i);
void subdivide_metaball_octal_node(octal_node *node, float size_x, float size_y, float size_z, short depth);
void free_metaball_octal_node(octal_node *node);
void init_metaball_octal_tree(int depth);
void polygonize(PROCESS *mbproc, struct MetaBall *mb);
float init_meta(struct Scene *scene, struct Object *ob);
void unlink_mball(struct MetaBall *mb);
void free_mball(struct MetaBall *mb);
struct MetaBall *add_mball(const char *name);
struct MetaBall *copy_mball(struct MetaBall *mb);
void make_local_mball(struct MetaBall *mb);
struct MetaElem *add_metaball_element(struct MetaBall *mb, const int type);
void tex_space_mball(struct Object *ob);
float *make_orco_mball(struct Object *ob, struct ListBase *dispbase);
void copy_mball_properties(struct Scene *scene, struct Object *active_object);
struct Object *find_basis_mball(struct Scene *scene, struct Object *ob);
int is_basis_mball(struct Object *ob);
int is_mball_basis_for(struct Object *ob1, struct Object *ob2);
void metaball_polygonize(struct Scene *scene, struct Object *ob, struct ListBase *dispbase);
void calc_mballco(struct MetaElem *ml, float vec[3]);
float densfunc(struct MetaElem *ball, float x, float y, float z);
float metaball(float x, float y, float z);
void accum_mballfaces(int i1, int i2, int i3, int i4);
void *new_pgn_element(int size);
int nextcwedge (int edge, int face);
void BKE_freecubetable(void);
void BKE_metaball_properties_copy(struct Scene *scene, struct Object *active_object);
int BKE_metaball_minmax(struct MetaBall *mb, float min[3], float max[3]);
int BKE_metaball_center_median(struct MetaBall *mb, float cent[3]);
int BKE_metaball_center_bounds(struct MetaBall *mb, float cent[3]);
void BKE_metaball_translate(struct MetaBall *mb, float offset[3]);
#endif
struct MetaElem *BKE_metaball_element_add(struct MetaBall *mb, const int type);
#endif

@ -40,10 +40,10 @@ struct MovieClipUser;
struct MovieTrackingTrack;
struct MovieDistortion;
void free_movieclip(struct MovieClip *clip);
void unlink_movieclip(struct Main *bmain, struct MovieClip *clip);
void BKE_movieclip_free(struct MovieClip *clip);
void BKE_movieclip_unlink(struct Main *bmain, struct MovieClip *clip);
struct MovieClip *BKE_add_movieclip_file(const char *name);
struct MovieClip *BKE_movieclip_file_add(const char *name);
void BKE_movieclip_reload(struct MovieClip *clip);
struct ImBuf *BKE_movieclip_get_ibuf(struct MovieClip *clip, struct MovieClipUser *user);

@ -54,7 +54,11 @@ __attribute__ ((format (printf, 3, 4)))
;
void BKE_reports_prepend(ReportList *reports, const char *prepend);
void BKE_reports_prependf(ReportList *reports, const char *prepend, ...);
void BKE_reports_prependf(ReportList *reports, const char *prepend, ...)
#ifdef __GNUC__
__attribute__ ((format (printf, 2, 3)))
#endif
;
ReportType BKE_report_print_level(ReportList *reports);
void BKE_report_print_level_set(ReportList *reports, ReportType level);

@ -23,6 +23,7 @@
#ifndef __BKE_TESSMESH_H__
#define __BKE_TESSMESH_H__
#include "BKE_customdata.h"
#include "bmesh.h"
struct BMesh;
@ -58,7 +59,7 @@ typedef struct BMEditMesh {
/*derivedmesh stuff*/
struct DerivedMesh *derivedFinal, *derivedCage;
int lastDataMask;
CustomDataMask lastDataMask;
/* index tables, to map indices to elements via
* EDBM_index_arrays_init and associated functions. don't

@ -1272,7 +1272,9 @@ CCGError ccgSubSurf_syncFace(CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGV
if (f->numVerts != numVerts ||
memcmp(FACE_getVerts(f), ss->tempVerts, sizeof(*ss->tempVerts) * numVerts) ||
memcmp(FACE_getEdges(f), ss->tempEdges, sizeof(*ss->tempEdges) * numVerts))
{
topologyChanged = 1;
}
}
if (!f || topologyChanged) {

@ -1223,7 +1223,7 @@ void DM_update_weight_mcol(Object *ob, DerivedMesh *dm, int const draw_flag,
for (i=0; i<dm->numPolyData; i++, mp++) {
ml = mloop + mp->loopstart;
BLI_array_growitems(wtcol_l, mp->totloop);
BLI_array_grow_items(wtcol_l, mp->totloop);
for (j = 0; j < mp->totloop; j++, ml++, totloop++) {
copy_v4_v4_char((char *)&wtcol_l[totloop],
(char *)&wtcol_v[4 * ml->v]);
@ -2279,8 +2279,10 @@ DerivedMesh *editbmesh_get_derived_cage_and_final(Scene *scene, Object *obedit,
* the data we need, rebuild the derived mesh
*/
if (!em->derivedCage ||
(em->lastDataMask & dataMask) != dataMask)
(em->lastDataMask & dataMask) != dataMask)
{
editbmesh_build_data(scene, obedit, em, dataMask);
}
*final_r = em->derivedFinal;
return em->derivedCage;
@ -2292,8 +2294,10 @@ DerivedMesh *editbmesh_get_derived_cage(Scene *scene, Object *obedit, BMEditMesh
* the data we need, rebuild the derived mesh
*/
if (!em->derivedCage ||
(em->lastDataMask & dataMask) != dataMask)
(em->lastDataMask & dataMask) != dataMask)
{
editbmesh_build_data(scene, obedit, em, dataMask);
}
return em->derivedCage;
}
@ -2701,8 +2705,7 @@ void DM_calc_auto_bump_scale(DerivedMesh *dm)
if (nr_tris_to_pile==1 || nr_tris_to_pile==2) {
const int indices[] = {offs+0, offs+1, offs+2, offs+0, offs+2, (offs+3)&0x3 };
int t;
for ( t=0; t<nr_tris_to_pile; t++ )
{
for ( t=0; t<nr_tris_to_pile; t++ ) {
float f2x_area_uv;
float * p0 = verts[indices[t*3+0]];
float * p1 = verts[indices[t*3+1]];

@ -482,7 +482,7 @@ void calc_curvepath(Object *ob)
if (ob==NULL || ob->type != OB_CURVE) return;
cu= ob->data;
nurbs= BKE_curve_nurbs(cu);
nurbs= BKE_curve_nurbs_get(cu);
nu= nurbs->first;
if (cu->path) free_path(cu->path);
@ -1350,9 +1350,11 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
/* some hair paths might be non-existent so they can't be used for duplication */
if (hair &&
((a < totpart && psys->pathcache[a]->steps < 0) ||
(a >= totpart && psys->childcache[a-totpart]->steps < 0)))
((a < totpart && psys->pathcache[a]->steps < 0) ||
(a >= totpart && psys->childcache[a-totpart]->steps < 0)))
{
continue;
}
if (part->ren_as==PART_DRAW_GR) {
/* prevent divide by zero below [#28336] */

@ -1250,8 +1250,7 @@ static void animsys_evaluate_fcurves (PointerRNA *ptr, ListBase *list, AnimMappe
FCurve *fcu;
/* calculate then execute each curve */
for (fcu= list->first; fcu; fcu= fcu->next)
{
for (fcu= list->first; fcu; fcu= fcu->next) {
/* check if this F-Curve doesn't belong to a muted group */
if ((fcu->grp == NULL) || (fcu->grp->flag & AGRP_MUTED)==0) {
/* check if this curve should be skipped */
@ -1274,8 +1273,7 @@ static void animsys_evaluate_drivers (PointerRNA *ptr, AnimData *adt, float ctim
/* drivers are stored as F-Curves, but we cannot use the standard code, as we need to check if
* the depsgraph requested that this driver be evaluated...
*/
for (fcu= adt->drivers.first; fcu; fcu= fcu->next)
{
for (fcu= adt->drivers.first; fcu; fcu= fcu->next) {
ChannelDriver *driver= fcu->driver;
short ok= 0;
@ -1351,8 +1349,7 @@ void animsys_evaluate_action_group (PointerRNA *ptr, bAction *act, bActionGroup
return;
/* calculate then execute each curve */
for (fcu= agrp->channels.first; (fcu) && (fcu->grp == agrp); fcu= fcu->next)
{
for (fcu= agrp->channels.first; (fcu) && (fcu->grp == agrp); fcu= fcu->next) {
/* check if this curve should be skipped */
if ((fcu->flag & (FCURVE_MUTED|FCURVE_DISABLED)) == 0) {
calculate_fcurve(fcu, ctime);
@ -1968,8 +1965,7 @@ void nladata_flush_channels (ListBase *channels)
float value= nec->value;
/* write values - see animsys_write_rna_setting() to sync the code */
switch (RNA_property_type(prop))
{
switch (RNA_property_type(prop)) {
case PROP_BOOLEAN:
if (RNA_property_array_length(ptr, prop))
RNA_property_boolean_set_index(ptr, prop, array_index, ANIMSYS_FLOAT_AS_BOOL(value));
@ -2171,7 +2167,7 @@ static void animsys_evaluate_overrides (PointerRNA *ptr, AnimData *adt)
*
* Current Status:
* - Currently (as of September 2009), overrides we haven't needed to (fully) implement overrides.
* However, the code fo this is relatively harmless, so is left in the code for now.
* However, the code for this is relatively harmless, so is left in the code for now.
*/
/* Evaluation loop for evaluation animation data
@ -2217,7 +2213,9 @@ void BKE_animsys_evaluate_animdata (Scene *scene, ID *id, AnimData *adt, float c
* or be layered on top of existing animation data.
* - Drivers should be in the appropriate order to be evaluated without problems...
*/
if ((recalc & ADT_RECALC_DRIVERS) /*&& (adt->recalc & ADT_RECALC_DRIVERS)*/) // XXX for now, don't check yet, as depsgraph hasn't been updated
if ((recalc & ADT_RECALC_DRIVERS)
/* XXX for now, don't check yet, as depsgraph hasn't been updated */
/* && (adt->recalc & ADT_RECALC_DRIVERS)*/)
{
animsys_evaluate_drivers(&id_ptr, adt, ctime);
}

@ -566,13 +566,13 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest)
if (bone->segments > MAX_BBONE_SUBDIV)
bone->segments = MAX_BBONE_SUBDIV;
forward_diff_bezier(0.0, h1[0], h2[0], 0.0, data[0],
BKE_curve_forward_diff_bezier(0.0, h1[0], h2[0], 0.0, data[0],
MAX_BBONE_SUBDIV, 4*sizeof(float));
forward_diff_bezier(0.0, h1[1], length + h2[1], length, data[0]+1,
BKE_curve_forward_diff_bezier(0.0, h1[1], length + h2[1], length, data[0]+1,
MAX_BBONE_SUBDIV, 4*sizeof(float));
forward_diff_bezier(0.0, h1[2], h2[2], 0.0, data[0]+2,
BKE_curve_forward_diff_bezier(0.0, h1[2], h2[2], 0.0, data[0]+2,
MAX_BBONE_SUBDIV, 4*sizeof(float));
forward_diff_bezier(roll1, roll1 + 0.390464f*(roll2-roll1), roll2 - 0.390464f*(roll2-roll1), roll2, data[0]+3,
BKE_curve_forward_diff_bezier(roll1, roll1 + 0.390464f*(roll2-roll1), roll2 - 0.390464f*(roll2-roll1), roll2, data[0]+3,
MAX_BBONE_SUBDIV, 4*sizeof(float));
equalize_bezier(data[0], bone->segments); /* note: does stride 4! */
@ -1372,7 +1372,7 @@ void armature_mat_pose_to_bone_ex(Object *ob, bPoseChannel *pchan, float inmat[]
/* same as object_mat3_to_rot() */
void pchan_mat3_to_rot(bPoseChannel *pchan, float mat[][3], short use_compat)
{
switch(pchan->rotmode) {
switch (pchan->rotmode) {
case ROT_MODE_QUAT:
mat3_to_quat(pchan->quat, mat);
break;

@ -962,7 +962,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
set_boid_values(&val, bbd->part->boids, pa);
/* go through rules */
switch(state->ruleset_type) {
switch (state->ruleset_type) {
case eBoidRulesetType_Fuzzy:
{
for (rule = state->rules.first; rule; rule = rule->next) {
@ -1258,7 +1258,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
bpa->ground = boid_find_ground(bbd, pa, ground_co, ground_nor);
/* change modes, constrain movement & keep track of down vector */
switch(bpa->data.mode) {
switch (bpa->data.mode) {
case eBoidMode_InAir:
{
float grav[3];
@ -1437,7 +1437,7 @@ BoidRule *boid_new_rule(int type)
if (type <= 0)
return NULL;
switch(type) {
switch (type) {
case eBoidRuleType_Goal:
case eBoidRuleType_Avoid:
rule = MEM_callocN(sizeof(BoidRuleGoalAvoid), "BoidRuleGoalAvoid");

@ -337,7 +337,7 @@ void brush_reset_sculpt(Brush *br)
brush_set_defaults(br);
brush_curve_preset(br, CURVE_PRESET_SMOOTH);
switch(br->sculpt_tool) {
switch (br->sculpt_tool) {
case SCULPT_TOOL_CLAY:
br->flag |= BRUSH_FRONTFACE;
break;

@ -649,8 +649,7 @@ BVHTree* bvhtree_from_mesh_edges(BVHTreeFromMesh *data, DerivedMesh *mesh, float
BVHTree *tree = bvhcache_find(&mesh->bvhCache, BVHTREE_FROM_EDGES);
//Not in cache
if (tree == NULL)
{
if (tree == NULL) {
int i;
int numEdges= mesh->getNumEdges(mesh);
MVert *vert = mesh->getVertDataArray(mesh, CD_MVERT);
@ -675,8 +674,7 @@ BVHTree* bvhtree_from_mesh_edges(BVHTreeFromMesh *data, DerivedMesh *mesh, float
}
}
}
else
{
else {
// printf("BVHTree is already build, using cached tree\n");
}

@ -230,7 +230,7 @@ static int can_pbvh_draw(Object *ob, DerivedMesh *dm)
int deformed= 0;
/* active modifiers means extra deformation, which can't be handled correct
* on bith of PBVH and sculpt "layer" levels, so use PBVH only for internal brush
* on birth of PBVH and sculpt "layer" levels, so use PBVH only for internal brush
* stuff and show final DerivedMesh so user would see actual object shape */
deformed|= ob->sculpt->modifiers_active;

@ -191,8 +191,7 @@ static BVHTree *bvhselftree_build_from_cloth (ClothModifierData *clmd, float eps
bvhtree = BLI_bvhtree_new(cloth->numverts, epsilon, 4, 6);
// fill tree
for (i = 0; i < cloth->numverts; i++, verts++)
{
for (i = 0; i < cloth->numverts; i++, verts++) {
copy_v3_v3(&co[0*3], verts->xold);
BLI_bvhtree_insert(bvhtree, i, co, 1);
@ -232,8 +231,7 @@ static BVHTree *bvhtree_build_from_cloth (ClothModifierData *clmd, float epsilon
bvhtree = BLI_bvhtree_new(cloth->numfaces, epsilon, 4, 26);
// fill tree
for (i = 0; i < cloth->numfaces; i++, mfaces++)
{
for (i = 0; i < cloth->numfaces; i++, mfaces++) {
copy_v3_v3(&co[0*3], verts[mfaces->v1].xold);
copy_v3_v3(&co[1*3], verts[mfaces->v2].xold);
copy_v3_v3(&co[2*3], verts[mfaces->v3].xold);
@ -266,10 +264,8 @@ void bvhtree_update_from_cloth(ClothModifierData *clmd, int moving)
mfaces = cloth->mfaces;
// update vertex position in bvh tree
if (verts && mfaces)
{
for (i = 0; i < cloth->numfaces; i++, mfaces++)
{
if (verts && mfaces) {
for (i = 0; i < cloth->numfaces; i++, mfaces++) {
copy_v3_v3(&co[0*3], verts[mfaces->v1].txold);
copy_v3_v3(&co[1*3], verts[mfaces->v2].txold);
copy_v3_v3(&co[2*3], verts[mfaces->v3].txold);
@ -278,8 +274,7 @@ void bvhtree_update_from_cloth(ClothModifierData *clmd, int moving)
copy_v3_v3(&co[3*3], verts[mfaces->v4].txold);
// copy new locations into array
if (moving)
{
if (moving) {
// update moving positions
copy_v3_v3(&co_moving[0*3], verts[mfaces->v1].tx);
copy_v3_v3(&co_moving[1*3], verts[mfaces->v2].tx);
@ -319,15 +314,12 @@ void bvhselftree_update_from_cloth(ClothModifierData *clmd, int moving)
mfaces = cloth->mfaces;
// update vertex position in bvh tree
if (verts && mfaces)
{
for (i = 0; i < cloth->numverts; i++, verts++)
{
if (verts && mfaces) {
for (i = 0; i < cloth->numverts; i++, verts++) {
copy_v3_v3(&co[0*3], verts->txold);
// copy new locations into array
if (moving)
{
if (moving) {
// update moving positions
copy_v3_v3(&co_moving[0*3], verts->tx);
@ -558,11 +550,9 @@ void cloth_free_modifier(ClothModifierData *clmd )
cloth = clmd->clothObject;
if ( cloth )
{
if ( cloth ) {
// If our solver provides a free function, call it
if ( solvers [clmd->sim_parms->solver_type].free )
{
if ( solvers [clmd->sim_parms->solver_type].free ) {
solvers [clmd->sim_parms->solver_type].free ( clmd );
}
@ -574,11 +564,9 @@ void cloth_free_modifier(ClothModifierData *clmd )
cloth->numverts = 0;
// Free the springs.
if ( cloth->springs != NULL )
{
if ( cloth->springs != NULL ) {
LinkNode *search = cloth->springs;
while (search)
{
while (search) {
ClothSpring *spring = search->link;
MEM_freeN ( spring );
@ -628,14 +616,12 @@ void cloth_free_modifier_extern ( ClothModifierData *clmd )
cloth = clmd->clothObject;
if ( cloth )
{
if ( cloth ) {
if (G.rt > 0)
printf("cloth_free_modifier_extern in\n");
// If our solver provides a free function, call it
if ( solvers [clmd->sim_parms->solver_type].free )
{
if ( solvers [clmd->sim_parms->solver_type].free ) {
solvers [clmd->sim_parms->solver_type].free ( clmd );
}
@ -647,11 +633,9 @@ void cloth_free_modifier_extern ( ClothModifierData *clmd )
cloth->numverts = 0;
// Free the springs.
if ( cloth->springs != NULL )
{
if ( cloth->springs != NULL ) {
LinkNode *search = cloth->springs;
while (search)
{
while (search) {
ClothSpring *spring = search->link;
MEM_freeN ( spring );
@ -708,8 +692,7 @@ static void cloth_to_object (Object *ob, ClothModifierData *clmd, float (*verte
/* inverse matrix is not uptodate... */
invert_m4_m4(ob->imat, ob->obmat);
for (i = 0; i < cloth->numverts; i++)
{
for (i = 0; i < cloth->numverts; i++) {
copy_v3_v3 (vertexCos[i], cloth->verts[i].x);
mul_m4_v3(ob->imat, vertexCos[i]); /* cloth is in global coords */
}
@ -749,17 +732,12 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm )
verts = clothObj->verts;
if (cloth_uses_vgroup(clmd))
{
for ( i = 0; i < numverts; i++, verts++ )
{
if (cloth_uses_vgroup(clmd)) {
for ( i = 0; i < numverts; i++, verts++ ) {
dvert = dm->getVertData ( dm, i, CD_MDEFORMVERT );
if ( dvert )
{
for ( j = 0; j < dvert->totweight; j++ )
{
if (( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_mass-1)) && (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL ))
{
if ( dvert ) {
for ( j = 0; j < dvert->totweight; j++ ) {
if (( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_mass-1)) && (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL )) {
verts->goal = dvert->dw [j].weight;
/* goalfac= 1.0f; */ /* UNUSED */
@ -769,22 +747,18 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm )
*/
verts->goal = ( float ) pow ( verts->goal , 4.0f );
if ( verts->goal >=SOFTGOALSNAP )
{
if ( verts->goal >=SOFTGOALSNAP ) {
verts->flags |= CLOTH_VERT_FLAG_PINNED;
}
}
if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SCALING )
{
if ( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_struct-1))
{
if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SCALING ) {
if ( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_struct-1)) {
verts->struct_stiff = dvert->dw [j].weight;
verts->shear_stiff = dvert->dw [j].weight;
}
if ( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_bend-1))
{
if ( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_bend-1)) {
verts->bend_stiff = dvert->dw [j].weight;
}
}
@ -812,8 +786,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d
float maxdist = 0;
// If we have a clothObject, free it.
if ( clmd->clothObject != NULL )
{
if ( clmd->clothObject != NULL ) {
cloth_free_modifier ( clmd );
if (G.rt > 0)
printf("cloth_free_modifier cloth_from_object\n");
@ -821,8 +794,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d
// Allocate a new cloth object.
clmd->clothObject = MEM_callocN ( sizeof ( Cloth ), "cloth" );
if ( clmd->clothObject )
{
if ( clmd->clothObject ) {
clmd->clothObject->old_solver_type = 255;
// clmd->clothObject->old_collision_type = 255;
cloth = clmd->clothObject;
@ -851,10 +823,8 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d
verts = clmd->clothObject->verts;
// set initial values
for ( i = 0; i < dm->getNumVerts(dm); i++, verts++ )
{
if (first)
{
for ( i = 0; i < dm->getNumVerts(dm); i++, verts++ ) {
if (first) {
copy_v3_v3( verts->x, mvert[i].co );
mul_m4_v3( ob->obmat, verts->x );
@ -891,18 +861,15 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d
// has to be happen before springs are build!
cloth_apply_vgroup (clmd, dm);
if ( !cloth_build_springs ( clmd, dm ) )
{
if ( !cloth_build_springs ( clmd, dm ) ) {
cloth_free_modifier ( clmd );
modifier_setError(&(clmd->modifier), "%s", TIP_("Can't build springs."));
printf("cloth_free_modifier cloth_build_springs\n");
return 0;
}
for ( i = 0; i < dm->getNumVerts(dm); i++)
{
if ((!(cloth->verts[i].flags & CLOTH_VERT_FLAG_PINNED)) && (cloth->verts[i].goal > ALMOST_ZERO))
{
for ( i = 0; i < dm->getNumVerts(dm); i++) {
if ((!(cloth->verts[i].flags & CLOTH_VERT_FLAG_PINNED)) && (cloth->verts[i].goal > ALMOST_ZERO)) {
cloth_add_spring (clmd, i, i, 0.0, CLOTH_SPRING_TYPE_GOAL);
}
}
@ -917,8 +884,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d
clmd->clothObject->bvhtree = bvhtree_build_from_cloth ( clmd, MAX2(clmd->coll_parms->epsilon, clmd->coll_parms->distance_repel) );
for (i = 0; i < dm->getNumVerts(dm); i++)
{
for (i = 0; i < dm->getNumVerts(dm); i++) {
maxdist = MAX2(maxdist, clmd->coll_parms->selfepsilon* ( cloth->verts[i].avg_spring_len*2.0f));
}
@ -937,8 +903,7 @@ static void cloth_from_mesh ( ClothModifierData *clmd, DerivedMesh *dm )
/* Allocate our vertices. */
clmd->clothObject->numverts = numverts;
clmd->clothObject->verts = MEM_callocN ( sizeof ( ClothVertex ) * clmd->clothObject->numverts, "clothVertex" );
if ( clmd->clothObject->verts == NULL )
{
if ( clmd->clothObject->verts == NULL ) {
cloth_free_modifier ( clmd );
modifier_setError(&(clmd->modifier), "%s", TIP_("Out of memory on allocating clmd->clothObject->verts."));
printf("cloth_free_modifier clmd->clothObject->verts\n");
@ -948,8 +913,7 @@ static void cloth_from_mesh ( ClothModifierData *clmd, DerivedMesh *dm )
// save face information
clmd->clothObject->numfaces = numfaces;
clmd->clothObject->mfaces = MEM_callocN ( sizeof ( MFace ) * clmd->clothObject->numfaces, "clothMFaces" );
if ( clmd->clothObject->mfaces == NULL )
{
if ( clmd->clothObject->mfaces == NULL ) {
cloth_free_modifier ( clmd );
modifier_setError(&(clmd->modifier), "%s", TIP_("Out of memory on allocating clmd->clothObject->mfaces."));
printf("cloth_free_modifier clmd->clothObject->mfaces\n");
@ -977,8 +941,7 @@ int cloth_add_spring ( ClothModifierData *clmd, unsigned int indexA, unsigned in
Cloth *cloth = clmd->clothObject;
ClothSpring *spring = NULL;
if (cloth)
{
if (cloth) {
// TODO: look if this spring is already there
spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" );
@ -1006,11 +969,9 @@ static void cloth_free_errorsprings(Cloth *cloth, EdgeHash *UNUSED(edgehash), Li
{
unsigned int i = 0;
if ( cloth->springs != NULL )
{
if ( cloth->springs != NULL ) {
LinkNode *search = cloth->springs;
while (search)
{
while (search) {
ClothSpring *spring = search->link;
MEM_freeN ( spring );
@ -1021,10 +982,8 @@ static void cloth_free_errorsprings(Cloth *cloth, EdgeHash *UNUSED(edgehash), Li
cloth->springs = NULL;
}
if (edgelist)
{
for ( i = 0; i < cloth->numverts; i++ )
{
if (edgelist) {
for ( i = 0; i < cloth->numverts; i++ ) {
BLI_linklist_free ( edgelist[i],NULL );
}
@ -1062,8 +1021,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
if (!edgelist)
return 0;
for ( i = 0; i < numverts; i++ )
{
for ( i = 0; i < numverts; i++ ) {
edgelist[i] = NULL;
}
@ -1074,12 +1032,10 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
edgehash = BLI_edgehash_new();
// structural springs
for ( i = 0; i < numedges; i++ )
{
for ( i = 0; i < numedges; i++ ) {
spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" );
if ( spring )
{
if ( spring ) {
spring->ij = MIN2(medge[i].v1, medge[i].v2);
spring->kl = MAX2(medge[i].v2, medge[i].v1);
spring->restlen = len_v3v3(cloth->verts[spring->kl].xrest, cloth->verts[spring->ij].xrest);
@ -1104,22 +1060,19 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
if (struct_springs > 0)
clmd->sim_parms->avg_spring_len /= struct_springs;
for (i = 0; i < numverts; i++)
{
for (i = 0; i < numverts; i++) {
cloth->verts[i].avg_spring_len = cloth->verts[i].avg_spring_len * 0.49f / ((float)cloth->verts[i].spring_count);
}
// shear springs
for ( i = 0; i < numfaces; i++ )
{
for ( i = 0; i < numfaces; i++ ) {
// triangle faces already have shear springs due to structural geometry
if ( !mface[i].v4 )
continue;
spring = ( ClothSpring *) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" );
if (!spring)
{
if (!spring) {
cloth_free_errorsprings(cloth, edgehash, edgelist);
return 0;
}
@ -1140,8 +1093,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
// if ( mface[i].v4 ) --> Quad face
spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" );
if (!spring)
{
if (!spring) {
cloth_free_errorsprings(cloth, edgehash, edgelist);
return 0;
}
@ -1162,15 +1114,13 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
if (numfaces) {
// bending springs
search2 = cloth->springs;
for ( i = struct_springs; i < struct_springs+shear_springs; i++ )
{
for ( i = struct_springs; i < struct_springs+shear_springs; i++ ) {
if ( !search2 )
break;
tspring2 = search2->link;
search = edgelist[tspring2->kl];
while ( search )
{
while ( search ) {
tspring = search->link;
index2 = ( ( tspring->ij==tspring2->kl ) ? ( tspring->kl ) : ( tspring->ij ) );
@ -1181,8 +1131,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
{
spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" );
if (!spring)
{
if (!spring) {
cloth_free_errorsprings(cloth, edgehash, edgelist);
return 0;
}
@ -1212,16 +1161,14 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
/* of the strands. -jahka */
search = cloth->springs;
search2 = search->next;
while (search && search2)
{
while (search && search2) {
tspring = search->link;
tspring2 = search2->link;
if (tspring->ij == tspring2->kl) {
spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" );
if (!spring)
{
if (!spring) {
cloth_free_errorsprings(cloth, edgehash, edgelist);
return 0;
}
@ -1242,13 +1189,12 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
}
/* insert other near springs in edgehash AFTER bending springs are calculated (for selfcolls) */
for ( i = 0; i < numedges; i++ ) // struct springs
for (i = 0; i < numedges; i++) { /* struct springs */
BLI_edgehash_insert ( edgehash, MIN2(medge[i].v1, medge[i].v2), MAX2(medge[i].v2, medge[i].v1), NULL );
for ( i = 0; i < numfaces; i++ ) // edge springs
{
if (mface[i].v4)
{
}
for (i = 0; i < numfaces; i++) { /* edge springs */
if (mface[i].v4) {
BLI_edgehash_insert ( edgehash, MIN2(mface[i].v1, mface[i].v3), MAX2(mface[i].v3, mface[i].v1), NULL );
BLI_edgehash_insert ( edgehash, MIN2(mface[i].v2, mface[i].v4), MAX2(mface[i].v2, mface[i].v4), NULL );
@ -1258,10 +1204,8 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
cloth->numsprings = struct_springs + shear_springs + bend_springs;
if ( edgelist )
{
for ( i = 0; i < numverts; i++ )
{
if ( edgelist ) {
for ( i = 0; i < numverts; i++ ) {
BLI_linklist_free ( edgelist[i],NULL );
}

@ -80,8 +80,7 @@ void collision_move_object(CollisionModifierData *collmd, float step, float prev
float tv[3] = {0, 0, 0};
unsigned int i = 0;
for ( i = 0; i < collmd->numverts; i++ )
{
for ( i = 0; i < collmd->numverts; i++ ) {
sub_v3_v3v3 ( tv, collmd->xnew[i].co, collmd->x[i].co );
VECADDS ( collmd->current_x[i].co, collmd->x[i].co, tv, prevstep );
VECADDS ( collmd->current_xnew[i].co, collmd->x[i].co, tv, step );
@ -101,8 +100,7 @@ BVHTree *bvhtree_build_from_mvert ( MFace *mfaces, unsigned int numfaces, MVert
tree = BLI_bvhtree_new ( numfaces*2, epsilon, 4, 26 );
// fill tree
for ( i = 0; i < numfaces; i++, tface++ )
{
for ( i = 0; i < numfaces; i++, tface++ ) {
copy_v3_v3 ( &co[0*3], x[tface->v1].co );
copy_v3_v3 ( &co[1*3], x[tface->v2].co );
copy_v3_v3 ( &co[2*3], x[tface->v3].co );
@ -128,10 +126,8 @@ void bvhtree_update_from_mvert ( BVHTree * bvhtree, MFace *faces, int numfaces,
if ( !bvhtree )
return;
if ( x )
{
for ( i = 0; i < numfaces; i++, mfaces++ )
{
if ( x ) {
for ( i = 0; i < numfaces; i++, mfaces++ ) {
copy_v3_v3 ( &co[0*3], x[mfaces->v1].co );
copy_v3_v3 ( &co[1*3], x[mfaces->v2].co );
copy_v3_v3 ( &co[2*3], x[mfaces->v3].co );
@ -139,8 +135,7 @@ void bvhtree_update_from_mvert ( BVHTree * bvhtree, MFace *faces, int numfaces,
copy_v3_v3 ( &co[3*3], x[mfaces->v4].co );
// copy new locations into array
if ( moving && xnew )
{
if ( moving && xnew ) {
// update moving positions
copy_v3_v3 ( &co_moving[0*3], xnew[mfaces->v1].co );
copy_v3_v3 ( &co_moving[1*3], xnew[mfaces->v2].co );
@ -150,8 +145,7 @@ void bvhtree_update_from_mvert ( BVHTree * bvhtree, MFace *faces, int numfaces,
ret = BLI_bvhtree_update_node ( bvhtree, i, co, co_moving, ( mfaces->v4 ? 4 : 3 ) );
}
else
{
else {
ret = BLI_bvhtree_update_node ( bvhtree, i, co, NULL, ( mfaces->v4 ? 4 : 3 ) );
}
@ -465,8 +459,7 @@ static void collision_compute_barycentric ( float pv[3], float p1[3], float p2[3
d = ( a * c - b * b );
if ( ABS ( d ) < (double)ALMOST_ZERO )
{
if ( ABS ( d ) < (double)ALMOST_ZERO ) {
*w1 = *w2 = *w3 = 1.0 / 3.0;
return;
}
@ -504,8 +497,7 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM
cloth1 = clmd->clothObject;
for ( ; collpair != collision_end; collpair++ )
{
for ( ; collpair != collision_end; collpair++ ) {
// only handle static collisions here
if ( collpair->flag & COLLISION_IN_FUTURE )
continue;
@ -540,8 +532,7 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM
// TODO
// If v_n_mag < 0 the edges are approaching each other.
if ( magrelVel > ALMOST_ZERO )
{
if ( magrelVel > ALMOST_ZERO ) {
// Calculate Impulse magnitude to stop all motion in normal direction.
float magtangent = 0, repulse = 0, d = 0;
double impulse = 0.0;
@ -558,8 +549,7 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM
magtangent = MIN2 ( clmd->coll_parms->friction * 0.01f * magrelVel, sqrtf( dot_v3v3( vrel_t_pre,vrel_t_pre ) ) );
// Apply friction impulse.
if ( magtangent > ALMOST_ZERO )
{
if ( magtangent > ALMOST_ZERO ) {
normalize_v3( vrel_t_pre );
impulse = magtangent / ( 1.0f + w1*w1 + w2*w2 + w3*w3 ); // 2.0 *
@ -587,8 +577,7 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM
spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale;
d = clmd->coll_parms->epsilon*8.0f/9.0f + epsilon2*8.0f/9.0f - collpair->distance;
if ( ( magrelVel < 0.1f*d*spf ) && ( d > ALMOST_ZERO ) )
{
if ( ( magrelVel < 0.1f*d*spf ) && ( d > ALMOST_ZERO ) ) {
repulse = MIN2 ( d*1.0f/spf, 0.1f*d*spf - magrelVel );
// stay on the safe side and clamp repulse
@ -666,8 +655,8 @@ static CollPair* cloth_edge_collision ( ModifierData *md1, ModifierData *md2,
BVHTreeOverlap *overlap, CollPair *collpair,
GHash *visithash, MemArena *arena)
{
ClothModifierData *clmd = ( ClothModifierData * ) md1;
CollisionModifierData *collmd = ( CollisionModifierData * ) md2;
ClothModifierData *clmd = (ClothModifierData *)md1;
CollisionModifierData *collmd = (CollisionModifierData *) md2;
MFace *face1=NULL, *face2 = NULL;
ClothVertex *verts1 = clmd->clothObject->verts;
double distance = 0;
@ -685,10 +674,8 @@ static CollPair* cloth_edge_collision ( ModifierData *md1, ModifierData *md2,
face2 = & ( collmd->mfaces[overlap->indexB] );
// check all 4 possible collisions
for ( i = 0; i < 4; i++ )
{
if ( i == 0 )
{
for ( i = 0; i < 4; i++ ) {
if ( i == 0 ) {
// fill faceA
ap1 = face1->v1;
ap2 = face1->v2;
@ -699,10 +686,8 @@ static CollPair* cloth_edge_collision ( ModifierData *md1, ModifierData *md2,
bp2 = face2->v2;
bp3 = face2->v3;
}
else if ( i == 1 )
{
if ( face1->v4 )
{
else if ( i == 1 ) {
if ( face1->v4 ) {
// fill faceA
ap1 = face1->v1;
ap2 = face1->v3;
@ -717,10 +702,8 @@ static CollPair* cloth_edge_collision ( ModifierData *md1, ModifierData *md2,
continue;
}
}
if ( i == 2 )
{
if ( face2->v4 )
{
if ( i == 2 ) {
if ( face2->v4 ) {
// fill faceA
ap1 = face1->v1;
ap2 = face1->v2;
@ -735,10 +718,8 @@ static CollPair* cloth_edge_collision ( ModifierData *md1, ModifierData *md2,
continue;
}
}
else if ( i == 3 )
{
if ( face1->v4 && face2->v4 )
{
else if ( i == 3 ) {
if ( face1->v4 && face2->v4 ) {
// fill faceA
ap1 = face1->v1;
ap2 = face1->v3;
@ -847,8 +828,7 @@ static int cloth_edge_collision_response_moving ( ClothModifierData *clmd, Colli
cloth1 = clmd->clothObject;
for ( ; collpair != collision_end; collpair++ )
{
for ( ; collpair != collision_end; collpair++ ) {
if (!(collpair->flag & COLLISION_IS_EDGES))
continue;
@ -865,8 +845,7 @@ static int cloth_edge_collision_response_moving ( ClothModifierData *clmd, Colli
magrelVel = dot_v3v3 ( relativeVelocity, collpair->normal );
// If v_n_mag < 0 the edges are approaching each other.
if ( magrelVel > ALMOST_ZERO )
{
if ( magrelVel > ALMOST_ZERO ) {
// Calculate Impulse magnitude to stop all motion in normal direction.
float magtangent = 0, repulse = 0, d = 0;
double impulse = 0.0;
@ -885,8 +864,7 @@ static int cloth_edge_collision_response_moving ( ClothModifierData *clmd, Colli
magtangent = MIN2 ( clmd->coll_parms->friction * 0.01 * magrelVel,sqrt ( dot_v3v3 ( vrel_t_pre,vrel_t_pre ) ) );
// Apply friction impulse.
if ( magtangent > ALMOST_ZERO )
{
if ( magtangent > ALMOST_ZERO ) {
normalize_v3( vrel_t_pre );
impulse = magtangent;
@ -906,8 +884,7 @@ static int cloth_edge_collision_response_moving ( ClothModifierData *clmd, Colli
spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale;
d = collpair->distance;
if ( ( magrelVel < 0.1*d*spf && ( d > ALMOST_ZERO ) ) )
{
if ( ( magrelVel < 0.1*d*spf && ( d > ALMOST_ZERO ) ) ) {
repulse = MIN2 ( d*1.0/spf, 0.1*d*spf - magrelVel );
// stay on the safe side and clamp repulse
@ -949,8 +926,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM
cloth1 = clmd->clothObject;
for ( ; collpair != collision_end; collpair++ )
{
for ( ; collpair != collision_end; collpair++ ) {
if (collpair->flag & COLLISION_IS_EDGES)
continue;
@ -967,8 +943,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM
magrelVel = dot_v3v3 ( relativeVelocity, collpair->normal );
// If v_n_mag < 0 the edges are approaching each other.
if ( magrelVel > ALMOST_ZERO )
{
if ( magrelVel > ALMOST_ZERO ) {
// Calculate Impulse magnitude to stop all motion in normal direction.
float magtangent = 0, repulse = 0, d = 0;
double impulse = 0.0;
@ -985,8 +960,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM
magtangent = MIN2 ( clmd->coll_parms->friction * 0.01 * magrelVel,sqrt ( dot_v3v3 ( vrel_t_pre,vrel_t_pre ) ) );
// Apply friction impulse.
if ( magtangent > ALMOST_ZERO )
{
if ( magtangent > ALMOST_ZERO ) {
normalize_v3( vrel_t_pre );
impulse = magtangent; // 2.0 *
@ -1006,8 +980,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM
spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale;
d = -collpair->distance;
if ( ( magrelVel < 0.1*d*spf ) && ( d > ALMOST_ZERO ) )
{
if ( ( magrelVel < 0.1*d*spf ) && ( d > ALMOST_ZERO ) ) {
repulse = MIN2 ( d*1.0/spf, 0.1*d*spf - magrelVel );
// stay on the safe side and clamp repulse
@ -1034,8 +1007,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM
magrelVel = dot_v3v3 ( relativeVelocity, collpair->normal );
// If v_n_mag < 0 the edges are approaching each other.
if ( magrelVel > ALMOST_ZERO )
{
if ( magrelVel > ALMOST_ZERO ) {
// Calculate Impulse magnitude to stop all motion in normal direction.
float magtangent = 0, repulse = 0, d = 0;
double impulse = 0.0;
@ -1052,8 +1024,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM
magtangent = MIN2 ( clmd->coll_parms->friction * 0.01 * magrelVel,sqrt ( dot_v3v3 ( vrel_t_pre,vrel_t_pre ) ) );
// Apply friction impulse.
if ( magtangent > ALMOST_ZERO )
{
if ( magtangent > ALMOST_ZERO ) {
normalize_v3( vrel_t_pre );
impulse = magtangent; // 2.0 *
@ -1072,8 +1043,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM
spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale;
d = -collpair->distance;
if ( ( magrelVel < 0.1*d*spf ) && ( d > ALMOST_ZERO ) )
{
if ( ( magrelVel < 0.1*d*spf ) && ( d > ALMOST_ZERO ) ) {
repulse = MIN2 ( d*1.0/spf, 0.1*d*spf - magrelVel );
// stay on the safe side and clamp repulse
@ -1185,8 +1155,8 @@ int cloth_point_tri_moving_v3v3_f(float v1[2][3], int i1, float v2[2][3], int i2
static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTreeOverlap *overlap,
CollPair *collpair, double dt, GHash *gh, MemArena *arena)
{
ClothModifierData *clmd = ( ClothModifierData * ) md1;
CollisionModifierData *collmd = ( CollisionModifierData * ) md2;
ClothModifierData *clmd = (ClothModifierData *)md1;
CollisionModifierData *collmd = (CollisionModifierData *) md2;
MFace *face1=NULL, *face2 = NULL;
ClothVertex *verts1 = clmd->clothObject->verts;
double distance = 0;
@ -1202,10 +1172,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTree
face2 = & ( collmd->mfaces[overlap->indexB] );
// check all 4 possible collisions
for ( i = 0; i < 4; i++ )
{
if ( i == 0 )
{
for ( i = 0; i < 4; i++ ) {
if ( i == 0 ) {
// fill faceA
ap1 = face1->v1;
ap2 = face1->v2;
@ -1216,10 +1184,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTree
bp2 = face2->v2;
bp3 = face2->v3;
}
else if ( i == 1 )
{
if ( face1->v4 )
{
else if ( i == 1 ) {
if ( face1->v4 ) {
// fill faceA
ap1 = face1->v1;
ap2 = face1->v3;
@ -1234,10 +1200,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTree
continue;
}
}
if ( i == 2 )
{
if ( face2->v4 )
{
if ( i == 2 ) {
if ( face2->v4 ) {
// fill faceA
ap1 = face1->v1;
ap2 = face1->v2;
@ -1252,10 +1216,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTree
continue;
}
}
else if ( i == 3 )
{
if ( face1->v4 && face2->v4 )
{
else if ( i == 3 ) {
if ( face1->v4 && face2->v4 ) {
// fill faceA
ap1 = face1->v1;
ap2 = face1->v3;
@ -1400,8 +1362,8 @@ static void machine_epsilon_offset(Cloth *cloth)
static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2,
BVHTreeOverlap *overlap, CollPair *collpair, float dt )
{
ClothModifierData *clmd = ( ClothModifierData * ) md1;
CollisionModifierData *collmd = ( CollisionModifierData * ) md2;
ClothModifierData *clmd = (ClothModifierData *)md1;
CollisionModifierData *collmd = (CollisionModifierData *) md2;
Cloth *cloth = clmd->clothObject;
MFace *face1=NULL, *face2 = NULL;
#ifdef USE_BULLET
@ -1417,10 +1379,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2,
face2 = & ( collmd->mfaces[overlap->indexB] );
// check all 4 possible collisions
for ( i = 0; i < 4; i++ )
{
if ( i == 0 )
{
for ( i = 0; i < 4; i++ ) {
if ( i == 0 ) {
// fill faceA
collpair->ap1 = face1->v1;
collpair->ap2 = face1->v2;
@ -1431,10 +1391,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2,
collpair->bp2 = face2->v2;
collpair->bp3 = face2->v3;
}
else if ( i == 1 )
{
if ( face1->v4 )
{
else if ( i == 1 ) {
if ( face1->v4 ) {
// fill faceA
collpair->ap1 = face1->v1;
collpair->ap2 = face1->v4;
@ -1448,10 +1406,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2,
else
i++;
}
if ( i == 2 )
{
if ( face2->v4 )
{
if ( i == 2 ) {
if ( face2->v4 ) {
// fill faceA
collpair->ap1 = face1->v1;
collpair->ap2 = face1->v2;
@ -1465,10 +1421,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2,
else
break;
}
else if ( i == 3 )
{
if ( face1->v4 && face2->v4 )
{
else if ( i == 3 ) {
if ( face1->v4 && face2->v4 ) {
// fill faceA
collpair->ap1 = face1->v1;
collpair->ap2 = face1->v4;
@ -1513,8 +1467,7 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2,
distance = 2.0 * (double)( epsilon1 + epsilon2 + ALMOST_ZERO );
#endif
if ( distance <= ( epsilon1 + epsilon2 + ALMOST_ZERO ) )
{
if ( distance <= ( epsilon1 + epsilon2 + ALMOST_ZERO ) ) {
normalize_v3_v3( collpair->normal, collpair->vector );
collpair->distance = distance;
@ -2283,24 +2236,21 @@ static void cloth_bvh_objcollisions_nearcheck ( ClothModifierData * clmd, Collis
#ifdef WITH_ELTOPO
machine_epsilon_offset(clmd->clothObject);
for ( i = 0; i < numresult; i++ )
{
*collisions_index = cloth_collision ( ( ModifierData * ) clmd, ( ModifierData * ) collmd,
for ( i = 0; i < numresult; i++ ) {
*collisions_index = cloth_collision ( (ModifierData *)clmd, (ModifierData *)collmd,
overlap+i, *collisions_index, dt, tri_visithash, arena );
}
for ( i = 0; i < numresult; i++ )
{
*collisions_index = cloth_edge_collision ( ( ModifierData * ) clmd, ( ModifierData * ) collmd,
for ( i = 0; i < numresult; i++ ) {
*collisions_index = cloth_edge_collision ( (ModifierData *)clmd, (ModifierData *)collmd,
overlap+i, *collisions_index, visithash, arena );
}
BLI_ghash_free(visithash, NULL, NULL);
BLI_ghash_free(tri_visithash, NULL, NULL);
BLI_memarena_free(arena);
#else /* WITH_ELTOPO */
for ( i = 0; i < numresult; i++ )
{
*collisions_index = cloth_collision ( ( ModifierData * ) clmd, ( ModifierData * ) collmd,
for ( i = 0; i < numresult; i++ ) {
*collisions_index = cloth_collision ( (ModifierData *)clmd, (ModifierData *)collmd,
overlap+i, *collisions_index, dt );
}
#endif /* WITH_ELTOPO */
@ -2323,12 +2273,10 @@ static int cloth_bvh_objcollisions_resolve ( ClothModifierData * clmd, Collision
// process all collisions (calculate impulses, TODO: also repulses if distance too short)
result = 1;
for ( j = 0; j < 5; j++ ) // 5 is just a value that ensures convergence
{
for ( j = 0; j < 5; j++ ) { /* 5 is just a value that ensures convergence */
result = 0;
if ( collmd->bvhtree )
{
if ( collmd->bvhtree ) {
#ifdef WITH_ELTOPO
result += cloth_collision_response_moving(clmd, collmd, collisions, collisions_index);
result += cloth_edge_collision_response_moving(clmd, collmd, collisions, collisions_index);
@ -2339,14 +2287,11 @@ static int cloth_bvh_objcollisions_resolve ( ClothModifierData * clmd, Collision
{
#else
// apply impulses in parallel
if ( result )
{
if (result) {
#endif
for ( i = 0; i < numverts; i++ )
{
for (i = 0; i < numverts; i++) {
// calculate "velocities" (just xnew = xold + v; no dt in v)
if ( verts[i].impulse_count )
{
if (verts[i].impulse_count) {
VECADDMUL ( verts[i].tv, verts[i].impulse, 1.0f / verts[i].impulse_count );
copy_v3_v3 ( verts[i].impulse, tnull );
verts[i].impulse_count = 0;
@ -2402,8 +2347,7 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl
collisions_index = MEM_callocN(sizeof(CollPair *) *numcollobj , "CollPair");
// check all collision objects
for (i = 0; i < numcollobj; i++)
{
for (i = 0; i < numcollobj; i++) {
Object *collob= collobjs[i];
CollisionModifierData *collmd = (CollisionModifierData*)modifiers_findByType(collob, eModifierType_Collision);
BVHTreeOverlap *overlap = NULL;
@ -2435,8 +2379,7 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl
}
rounds++;
for (i = 0; i < numcollobj; i++)
{
for (i = 0; i < numcollobj; i++) {
if ( collisions[i] ) MEM_freeN ( collisions[i] );
}
@ -2449,12 +2392,9 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl
////////////////////////////////////////////////////////////
// verts come from clmd
for ( i = 0; i < numverts; i++ )
{
if ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL )
{
if ( verts [i].flags & CLOTH_VERT_FLAG_PINNED )
{
for ( i = 0; i < numverts; i++ ) {
if ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL ) {
if ( verts [i].flags & CLOTH_VERT_FLAG_PINNED ) {
continue;
}
}
@ -2467,10 +2407,8 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl
////////////////////////////////////////////////////////////
// Test on *simple* selfcollisions
////////////////////////////////////////////////////////////
if ( clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_SELF )
{
for (l = 0; l < (unsigned int)clmd->coll_parms->self_loop_count; l++)
{
if ( clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_SELF ) {
for (l = 0; l < (unsigned int)clmd->coll_parms->self_loop_count; l++) {
// TODO: add coll quality rounds again
BVHTreeOverlap *overlap = NULL;
unsigned int result = 0;
@ -2483,14 +2421,12 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl
verts = cloth->verts;
if ( cloth->bvhselftree )
{
// search for overlapping collision pairs
if ( cloth->bvhselftree ) {
// search for overlapping collision pairs
overlap = BLI_bvhtree_overlap ( cloth->bvhselftree, cloth->bvhselftree, &result );
// #pragma omp parallel for private(k, i, j) schedule(static)
for ( k = 0; k < result; k++ )
{
for ( k = 0; k < result; k++ ) {
float temp[3];
float length = 0;
float mindistance;
@ -2500,8 +2436,7 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl
mindistance = clmd->coll_parms->selfepsilon* ( cloth->verts[i].avg_spring_len + cloth->verts[j].avg_spring_len );
if ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL )
{
if ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL ) {
if ( ( cloth->verts [i].flags & CLOTH_VERT_FLAG_PINNED ) &&
( cloth->verts [j].flags & CLOTH_VERT_FLAG_PINNED ) )
{
@ -2514,29 +2449,24 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl
if ( ( ABS ( temp[0] ) > mindistance ) || ( ABS ( temp[1] ) > mindistance ) || ( ABS ( temp[2] ) > mindistance ) ) continue;
// check for adjacent points (i must be smaller j)
if ( BLI_edgehash_haskey ( cloth->edgehash, MIN2(i, j), MAX2(i, j) ) )
{
if ( BLI_edgehash_haskey ( cloth->edgehash, MIN2(i, j), MAX2(i, j) ) ) {
continue;
}
length = normalize_v3( temp );
if ( length < mindistance )
{
if ( length < mindistance ) {
float correction = mindistance - length;
if ( cloth->verts [i].flags & CLOTH_VERT_FLAG_PINNED )
{
if ( cloth->verts [i].flags & CLOTH_VERT_FLAG_PINNED ) {
mul_v3_fl( temp, -correction );
VECADD ( verts[j].tx, verts[j].tx, temp );
}
else if ( cloth->verts [j].flags & CLOTH_VERT_FLAG_PINNED )
{
else if ( cloth->verts [j].flags & CLOTH_VERT_FLAG_PINNED ) {
mul_v3_fl( temp, correction );
VECADD ( verts[i].tx, verts[i].tx, temp );
}
else
{
else {
mul_v3_fl( temp, correction * -0.5 );
VECADD ( verts[j].tx, verts[j].tx, temp );
@ -2560,12 +2490,9 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl
////////////////////////////////////////////////////////////
// SELFCOLLISIONS: update velocities
////////////////////////////////////////////////////////////
if ( ret2 )
{
for ( i = 0; i < cloth->numverts; i++ )
{
if ( ! ( verts [i].flags & CLOTH_VERT_FLAG_PINNED ) )
{
if ( ret2 ) {
for ( i = 0; i < cloth->numverts; i++ ) {
if ( ! ( verts [i].flags & CLOTH_VERT_FLAG_PINNED ) ) {
sub_v3_v3v3 ( verts[i].tv, verts[i].tx, verts[i].txold );
}
}

@ -202,7 +202,7 @@ void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset, int slope)
if (cuma->curve)
MEM_freeN(cuma->curve);
switch(preset) {
switch (preset) {
case CURVE_PRESET_LINE: cuma->totpoint= 2; break;
case CURVE_PRESET_SHARP: cuma->totpoint= 4; break;
case CURVE_PRESET_SMOOTH: cuma->totpoint= 4; break;
@ -214,7 +214,7 @@ void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset, int slope)
cuma->curve= MEM_callocN(cuma->totpoint*sizeof(CurveMapPoint), "curve points");
switch(preset) {
switch (preset) {
case CURVE_PRESET_LINE:
cuma->curve[0].x= clipr->xmin;
cuma->curve[0].y= clipr->ymax;
@ -252,10 +252,9 @@ void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset, int slope)
case CURVE_PRESET_MID9:
{
int i;
for (i=0; i < cuma->totpoint; i++)
{
cuma->curve[i].x= i / ((float)cuma->totpoint-1);
cuma->curve[i].y= 0.5;
for (i = 0; i < cuma->totpoint; i++) {
cuma->curve[i].x = i / ((float)cuma->totpoint - 1);
cuma->curve[i].y = 0.5;
}
}
break;
@ -500,8 +499,8 @@ static void curvemap_make_table(CurveMap *cuma, rctf *clipr)
for (a=0; a<cuma->totpoint-1; a++, fp += 2*CM_RESOL) {
correct_bezpart(bezt[a].vec[1], bezt[a].vec[2], bezt[a+1].vec[0], bezt[a+1].vec[1]);
forward_diff_bezier(bezt[a].vec[1][0], bezt[a].vec[2][0], bezt[a+1].vec[0][0], bezt[a+1].vec[1][0], fp, CM_RESOL-1, 2*sizeof(float));
forward_diff_bezier(bezt[a].vec[1][1], bezt[a].vec[2][1], bezt[a+1].vec[0][1], bezt[a+1].vec[1][1], fp+1, CM_RESOL-1, 2*sizeof(float));
BKE_curve_forward_diff_bezier(bezt[a].vec[1][0], bezt[a].vec[2][0], bezt[a+1].vec[0][0], bezt[a+1].vec[1][0], fp, CM_RESOL-1, 2*sizeof(float));
BKE_curve_forward_diff_bezier(bezt[a].vec[1][1], bezt[a].vec[2][1], bezt[a+1].vec[0][1], bezt[a+1].vec[1][1], fp+1, CM_RESOL-1, 2*sizeof(float));
}
/* store first and last handle for extrapolation, unit length */

@ -3439,8 +3439,7 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
{
bShrinkwrapConstraint *scon = (bShrinkwrapConstraint *) con->data;
if ( VALID_CONS_TARGET(ct) && (ct->tar->type == OB_MESH) )
{
if ( VALID_CONS_TARGET(ct) && (ct->tar->type == OB_MESH) ) {
int fail = FALSE;
float co[3] = {0.0f, 0.0f, 0.0f};
float no[3] = {0.0f, 0.0f, 0.0f};
@ -3461,12 +3460,10 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
unit_m4(ct->matrix);
if (target != NULL)
{
if (target != NULL) {
space_transform_from_matrixs(&transform, cob->matrix, ct->tar->obmat);
switch(scon->shrinkType)
{
switch (scon->shrinkType) {
case MOD_SHRINKWRAP_NEAREST_SURFACE:
case MOD_SHRINKWRAP_NEAREST_VERTEX:
@ -3475,8 +3472,7 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
else
bvhtree_from_mesh_faces(&treeData, target, 0.0, 2, 6);
if (treeData.tree == NULL)
{
if (treeData.tree == NULL) {
fail = TRUE;
break;
}
@ -3506,14 +3502,12 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
bvhtree_from_mesh_faces(&treeData, target, scon->dist, 4, 6);
if (treeData.tree == NULL)
{
if (treeData.tree == NULL) {
fail = TRUE;
break;
}
if (normal_projection_project_vertex(0, co, no, &transform, treeData.tree, &hit, treeData.raycast_callback, &treeData) == FALSE)
{
if (normal_projection_project_vertex(0, co, no, &transform, treeData.tree, &hit, treeData.raycast_callback, &treeData) == FALSE) {
fail = TRUE;
break;
}
@ -3542,8 +3536,7 @@ static void shrinkwrap_evaluate (bConstraint *UNUSED(con), bConstraintOb *cob, L
bConstraintTarget *ct= targets->first;
/* only evaluate if there is a target */
if (VALID_CONS_TARGET(ct))
{
if (VALID_CONS_TARGET(ct)) {
copy_v3_v3(cob->matrix[3], ct->matrix[3]);
}
}

@ -777,7 +777,7 @@ int CTX_data_mode_enum(const bContext *C)
Object *obedit= CTX_data_edit_object(C);
if (obedit) {
switch(obedit->type) {
switch (obedit->type) {
case OB_MESH:
return CTX_MODE_EDIT_MESH;
case OB_CURVE:

@ -70,7 +70,7 @@ static int cu_isectLL(const float v1[3], const float v2[3], const float v3[3], c
short cox, short coy,
float *labda, float *mu, float vec[3]);
void unlink_curve(Curve *cu)
void BKE_curve_unlink(Curve *cu)
{
int a;
@ -95,7 +95,7 @@ void unlink_curve(Curve *cu)
}
/* frees editcurve entirely */
void BKE_free_editfont(Curve *cu)
void BKE_curve_editfont_free(Curve *cu)
{
if (cu->editfont) {
EditFont *ef= cu->editfont;
@ -112,7 +112,7 @@ void BKE_free_editfont(Curve *cu)
}
}
void free_curve_editNurb_keyIndex(EditNurb *editnurb)
void BKE_curve_editNurb_keyIndex_free(EditNurb *editnurb)
{
if (!editnurb->keyindex) {
return;
@ -121,26 +121,26 @@ void free_curve_editNurb_keyIndex(EditNurb *editnurb)
editnurb->keyindex= NULL;
}
void free_curve_editNurb (Curve *cu)
void BKE_curve_editNurb_free (Curve *cu)
{
if (cu->editnurb) {
freeNurblist(&cu->editnurb->nurbs);
free_curve_editNurb_keyIndex(cu->editnurb);
BKE_nurbList_free(&cu->editnurb->nurbs);
BKE_curve_editNurb_keyIndex_free(cu->editnurb);
MEM_freeN(cu->editnurb);
cu->editnurb= NULL;
}
}
/* don't free curve itself */
void free_curve(Curve *cu)
void BKE_curve_free(Curve *cu)
{
freeNurblist(&cu->nurb);
BKE_nurbList_free(&cu->nurb);
BLI_freelistN(&cu->bev);
freedisplist(&cu->disp);
BKE_free_editfont(cu);
BKE_curve_editfont_free(cu);
free_curve_editNurb(cu);
unlink_curve(cu);
BKE_curve_editNurb_free(cu);
BKE_curve_unlink(cu);
BKE_free_animdata((ID *)cu);
if (cu->mat) MEM_freeN(cu->mat);
@ -151,7 +151,7 @@ void free_curve(Curve *cu)
if (cu->tb) MEM_freeN(cu->tb);
}
Curve *add_curve(const char *name, int type)
Curve *BKE_curve_add(const char *name, int type)
{
Curve *cu;
@ -187,14 +187,14 @@ Curve *add_curve(const char *name, int type)
return cu;
}
Curve *copy_curve(Curve *cu)
Curve *BKE_curve_copy(Curve *cu)
{
Curve *cun;
int a;
cun= copy_libblock(&cu->id);
cun->nurb.first= cun->nurb.last= NULL;
duplicateNurblist( &(cun->nurb), &(cu->nurb));
BKE_nurbList_duplicate( &(cun->nurb), &(cu->nurb));
cun->mat= MEM_dupallocN(cu->mat);
for (a=0; a<cun->totcol; a++) {
@ -242,7 +242,7 @@ static void extern_local_curve(Curve *cu)
}
}
void make_local_curve(Curve *cu)
void BKE_curve_make_local(Curve *cu)
{
Main *bmain= G.main;
Object *ob;
@ -273,7 +273,7 @@ void make_local_curve(Curve *cu)
extern_local_curve(cu);
}
else if (is_local && is_lib) {
Curve *cu_new= copy_curve(cu);
Curve *cu_new= BKE_curve_copy(cu);
cu_new->id.us= 0;
BKE_id_lib_local_paths(bmain, cu->id.lib, &cu_new->id);
@ -291,7 +291,7 @@ void make_local_curve(Curve *cu)
}
/* Get list of nurbs from editnurbs structure */
ListBase *curve_editnurbs(Curve *cu)
ListBase *BKE_curve_editNurbs_get(Curve *cu)
{
if (cu->editnurb) {
return &cu->editnurb->nurbs;
@ -300,7 +300,7 @@ ListBase *curve_editnurbs(Curve *cu)
return NULL;
}
short curve_type(Curve *cu)
short BKE_curve_type_get(Curve *cu)
{
Nurb *nu;
int type= cu->type;
@ -322,9 +322,9 @@ short curve_type(Curve *cu)
return type;
}
void update_curve_dimension(Curve *cu)
void BKE_curve_curve_dimension_update(Curve *cu)
{
ListBase *nurbs= BKE_curve_nurbs(cu);
ListBase *nurbs= BKE_curve_nurbs_get(cu);
Nurb *nu= nurbs->first;
if (cu->flag&CU_3D) {
@ -335,24 +335,24 @@ void update_curve_dimension(Curve *cu)
else {
for ( ; nu; nu= nu->next) {
nu->flag |= CU_2D;
test2DNurb(nu);
BKE_nurb_test2D(nu);
/* since the handles are moved they need to be auto-located again */
if (nu->type == CU_BEZIER)
calchandlesNurb(nu);
BKE_nurb_handles_calc(nu);
}
}
}
void test_curve_type(Object *ob)
void BKE_curve_type_test(Object *ob)
{
ob->type= curve_type(ob->data);
ob->type= BKE_curve_type_get(ob->data);
if (ob->type==OB_CURVE)
update_curve_dimension((Curve *)ob->data);
BKE_curve_curve_dimension_update((Curve *)ob->data);
}
void tex_space_curve(Curve *cu)
void BKE_curve_tex_space_calc(Curve *cu)
{
DispList *dl;
BoundBox *bb;
@ -408,7 +408,7 @@ void tex_space_curve(Curve *cu)
}
}
int count_curveverts(ListBase *nurb)
int BKE_nurbList_verts_count(ListBase *nurb)
{
Nurb *nu;
int tot=0;
@ -423,7 +423,7 @@ int count_curveverts(ListBase *nurb)
return tot;
}
int count_curveverts_without_handles(ListBase *nurb)
int BKE_nurbList_verts_count_without_handles(ListBase *nurb)
{
Nurb *nu;
int tot=0;
@ -440,7 +440,7 @@ int count_curveverts_without_handles(ListBase *nurb)
/* **************** NURBS ROUTINES ******************** */
void freeNurb(Nurb *nu)
void BKE_nurb_free(Nurb *nu)
{
if (nu==NULL) return;
@ -460,7 +460,7 @@ void freeNurb(Nurb *nu)
}
void freeNurblist(ListBase *lb)
void BKE_nurbList_free(ListBase *lb)
{
Nurb *nu, *next;
@ -469,13 +469,13 @@ void freeNurblist(ListBase *lb)
nu= lb->first;
while (nu) {
next= nu->next;
freeNurb(nu);
BKE_nurb_free(nu);
nu= next;
}
lb->first= lb->last= NULL;
}
Nurb *duplicateNurb(Nurb *nu)
Nurb *BKE_nurb_duplicate(Nurb *nu)
{
Nurb *newnu;
int len;
@ -515,22 +515,22 @@ Nurb *duplicateNurb(Nurb *nu)
return newnu;
}
void duplicateNurblist(ListBase *lb1, ListBase *lb2)
void BKE_nurbList_duplicate(ListBase *lb1, ListBase *lb2)
{
Nurb *nu, *nun;
freeNurblist(lb1);
BKE_nurbList_free(lb1);
nu= lb2->first;
while (nu) {
nun= duplicateNurb(nu);
nun= BKE_nurb_duplicate(nu);
BLI_addtail(lb1, nun);
nu= nu->next;
}
}
void test2DNurb(Nurb *nu)
void BKE_nurb_test2D(Nurb *nu)
{
BezTriple *bezt;
BPoint *bp;
@ -559,7 +559,7 @@ void test2DNurb(Nurb *nu)
}
}
void minmaxNurb(Nurb *nu, float *min, float *max)
void BKE_nurb_minmax(Nurb *nu, float *min, float *max)
{
BezTriple *bezt;
BPoint *bp;
@ -586,7 +586,7 @@ void minmaxNurb(Nurb *nu, float *min, float *max)
}
/* be sure to call makeknots after this */
void addNurbPoints(Nurb *nu, int number)
void BKE_nurb_points_add(Nurb *nu, int number)
{
BPoint *tmp= nu->bp;
int i;
@ -606,7 +606,7 @@ void addNurbPoints(Nurb *nu, int number)
nu->pntsu += number;
}
void addNurbPointsBezier(Nurb *nu, int number)
void BKE_nurb_bezierPoints_add(Nurb *nu, int number)
{
BezTriple *tmp= nu->bezt;
int i;
@ -636,7 +636,7 @@ static void calcknots(float *knots, const short pnts, const short order, const s
float k;
int a;
switch(flag & (CU_NURB_ENDPOINT|CU_NURB_BEZIER)) {
switch (flag & (CU_NURB_ENDPOINT|CU_NURB_BEZIER)) {
case CU_NURB_ENDPOINT:
k= 0.0;
for (a=1; a <= pnts_order; a++) {
@ -706,7 +706,7 @@ static void makeknots(Nurb *nu, short uv)
if (nu->type == CU_NURBS) {
if (uv == 1) {
if (nu->knotsu) MEM_freeN(nu->knotsu);
if (check_valid_nurb_u(nu)) {
if (BKE_nurb_check_valid_u(nu)) {
nu->knotsu= MEM_callocN(4+sizeof(float)*KNOTSU(nu), "makeknots");
if (nu->flagu & CU_NURB_CYCLIC) {
calcknots(nu->knotsu, nu->pntsu, nu->orderu, 0); /* cyclic should be uniform */
@ -721,7 +721,7 @@ static void makeknots(Nurb *nu, short uv)
}
else if (uv == 2) {
if (nu->knotsv) MEM_freeN(nu->knotsv);
if (check_valid_nurb_v(nu)) {
if (BKE_nurb_check_valid_v(nu)) {
nu->knotsv= MEM_callocN(4+sizeof(float)*KNOTSV(nu), "makeknots");
if (nu->flagv & CU_NURB_CYCLIC) {
calcknots(nu->knotsv, nu->pntsv, nu->orderv, 0); /* cyclic should be uniform */
@ -736,12 +736,12 @@ static void makeknots(Nurb *nu, short uv)
}
}
void nurbs_knot_calc_u(Nurb *nu)
void BKE_nurb_knot_calc_u(Nurb *nu)
{
makeknots(nu, 1);
}
void nurbs_knot_calc_v(Nurb *nu)
void BKE_nurb_knot_calc_v(Nurb *nu)
{
makeknots(nu, 2);
}
@ -809,7 +809,7 @@ static void basisNurb(float t, short order, short pnts, float *knots, float *bas
}
void makeNurbfaces(Nurb *nu, float *coord_array, int rowstride, int resolu, int resolv)
void BKE_nurb_makeFaces(Nurb *nu, float *coord_array, int rowstride, int resolu, int resolv)
/* coord_array has to be 3*4*resolu*resolv in size, and zero-ed */
{
BPoint *bp;
@ -972,7 +972,7 @@ void makeNurbfaces(Nurb *nu, float *coord_array, int rowstride, int resolu, int
MEM_freeN(jend);
}
void makeNurbcurve(Nurb *nu, float *coord_array, float *tilt_array, float *radius_array, float *weight_array, int resolu, int stride)
void BKE_nurb_makeCurve(Nurb *nu, float *coord_array, float *tilt_array, float *radius_array, float *weight_array, int resolu, int stride)
/* coord_array has to be 3*4*pntsu*resolu in size and zero-ed
* tilt_array and radius_array will be written to if valid */
{
@ -1074,7 +1074,7 @@ void makeNurbcurve(Nurb *nu, float *coord_array, float *tilt_array, float *radiu
}
/* forward differencing method for bezier curve */
void forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride)
void BKE_curve_forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride)
{
float rt0,rt1,rt2,rt3,f;
int a;
@ -1122,7 +1122,7 @@ static void forward_diff_bezier_cotangent(float *p0, float *p1, float *p2, float
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
float *make_orco_surf(Object *ob)
float *BKE_curve_surf_make_orco(Object *ob)
{
/* Note: this function is used in convertblender only atm, so
* suppose nonzero curve's render resolution should always be used */
@ -1190,7 +1190,7 @@ float *make_orco_surf(Object *ob)
float *_tdata= MEM_callocN((nu->pntsu*resolu) * (nu->pntsv*resolv) *3*sizeof(float), "temp data");
float *tdata= _tdata;
makeNurbfaces(nu, tdata, 0, resolu, resolv);
BKE_nurb_makeFaces(nu, tdata, 0, resolu, resolv);
for (b=0; b<sizeu; b++) {
int use_b= b;
@ -1224,7 +1224,7 @@ float *make_orco_surf(Object *ob)
/* NOTE: This routine is tied to the order of vertex
* built by displist and as passed to the renderer.
*/
float *make_orco_curve(Scene *scene, Object *ob)
float *BKE_curve_make_orco(Scene *scene, Object *ob)
{
Curve *cu = ob->data;
DispList *dl;
@ -1312,7 +1312,7 @@ float *make_orco_curve(Scene *scene, Object *ob)
/* ***************** BEVEL ****************** */
void makebevelcurve(Scene *scene, Object *ob, ListBase *disp, int forRender)
void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp, int forRender)
{
DispList *dl, *dlnew;
Curve *bevcu, *cu;
@ -2038,7 +2038,7 @@ static void make_bevel_list_3D_tangent(BevList *bl)
static void make_bevel_list_3D(BevList *bl, int smooth_iter, int twist_mode)
{
switch(twist_mode) {
switch (twist_mode) {
case CU_TWIST_TANGENT:
make_bevel_list_3D_tangent(bl);
break;
@ -2083,7 +2083,7 @@ static void make_bevel_list_segment_3D(BevList *bl)
void makeBevelList(Object *ob)
void BKE_curve_bevelList_make(Object *ob)
{
/*
* - convert all curves to polys, with indication of resol and flags for double-vertices
@ -2112,7 +2112,7 @@ void makeBevelList(Object *ob)
BLI_freelistN(&(cu->bev));
if (cu->editnurb && ob->type!=OB_FONT) {
ListBase *nurbs= curve_editnurbs(cu);
ListBase *nurbs= BKE_curve_editNurbs_get(cu);
nu = nurbs->first;
}
else {
@ -2128,7 +2128,7 @@ void makeBevelList(Object *ob)
/* check we are a single point? also check we are not a surface and that the orderu is sane,
* enforced in the UI but can go wrong possibly */
if (!check_valid_nurb_u(nu)) {
if (!BKE_nurb_check_valid_u(nu)) {
bl= MEM_callocN(sizeof(BevList)+1*sizeof(BevPoint), "makeBevelList1");
BLI_addtail(&(cu->bev), bl);
bl->nr= 0;
@ -2201,7 +2201,7 @@ void makeBevelList(Object *ob)
/* BevPoint must stay aligned to 4 so sizeof(BevPoint)/sizeof(float) works */
for (j=0; j<3; j++) {
forward_diff_bezier( prevbezt->vec[1][j], prevbezt->vec[2][j],
BKE_curve_forward_diff_bezier( prevbezt->vec[1][j], prevbezt->vec[2][j],
bezt->vec[0][j], bezt->vec[1][j],
&(bevp->vec[j]), resolu, sizeof(BevPoint));
}
@ -2256,7 +2256,7 @@ void makeBevelList(Object *ob)
else bl->poly= -1;
bevp= (BevPoint *)(bl+1);
makeNurbcurve( nu, &bevp->vec[0],
BKE_nurb_makeCurve( nu, &bevp->vec[0],
do_tilt ? &bevp->alfa : NULL,
do_radius ? &bevp->radius : NULL,
do_weight ? &bevp->weight : NULL,
@ -2719,18 +2719,18 @@ static void calchandlesNurb_intern(Nurb *nu, int skip_align)
}
}
void calchandleNurb(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode)
void BKE_nurb_handle_calc(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode)
{
calchandleNurb_intern(bezt, prev, next, mode, FALSE);
}
void calchandlesNurb(Nurb *nu) /* first, if needed, set handle flags */
void BKE_nurb_handles_calc(Nurb *nu) /* first, if needed, set handle flags */
{
calchandlesNurb_intern(nu, FALSE);
}
void testhandlesNurb(Nurb *nu)
void BKE_nurb_handles_test(Nurb *nu)
{
/* use when something has changed with handles.
* it treats all BezTriples with the following rules:
@ -2770,10 +2770,10 @@ void testhandlesNurb(Nurb *nu)
bezt++;
}
calchandlesNurb(nu);
BKE_nurb_handles_calc(nu);
}
void autocalchandlesNurb(Nurb *nu, int flag)
void BKE_nurb_handles_autocalc(Nurb *nu, int flag)
{
/* checks handle coordinates and calculates type */
@ -2841,21 +2841,21 @@ void autocalchandlesNurb(Nurb *nu, int flag)
bezt2++;
}
calchandlesNurb(nu);
BKE_nurb_handles_calc(nu);
}
void autocalchandlesNurb_all(ListBase *editnurb, int flag)
void BKE_nurbList_handles_autocalc(ListBase *editnurb, int flag)
{
Nurb *nu;
nu= editnurb->first;
while (nu) {
autocalchandlesNurb(nu, flag);
BKE_nurb_handles_autocalc(nu, flag);
nu= nu->next;
}
}
void sethandlesNurb(ListBase *editnurb, short code)
void BKE_nurbList_handles_set(ListBase *editnurb, short code)
{
/* code==1: set autohandle */
/* code==2: set vectorhandle */
@ -2884,7 +2884,7 @@ void sethandlesNurb(ListBase *editnurb, short code)
}
bezt++;
}
calchandlesNurb(nu);
BKE_nurb_handles_calc(nu);
}
nu= nu->next;
}
@ -2928,7 +2928,7 @@ void sethandlesNurb(ListBase *editnurb, short code)
bezt++;
}
calchandlesNurb(nu);
BKE_nurb_handles_calc(nu);
}
nu= nu->next;
}
@ -2958,7 +2958,7 @@ static void swapdata(void *adr1, void *adr2, int len)
}
}
void switchdirectionNurb(Nurb *nu)
void BKE_nurb_direction_switch(Nurb *nu)
{
BezTriple *bezt1, *bezt2;
BPoint *bp1, *bp2;
@ -3064,9 +3064,9 @@ void switchdirectionNurb(Nurb *nu)
}
float (*curve_getVertexCos(Curve *UNUSED(cu), ListBase *lb, int *numVerts_r))[3]
float (*BKE_curve_vertexCos_get(Curve *UNUSED(cu), ListBase *lb, int *numVerts_r))[3]
{
int i, numVerts = *numVerts_r = count_curveverts(lb);
int i, numVerts = *numVerts_r = BKE_nurbList_verts_count(lb);
float *co, (*cos)[3] = MEM_mallocN(sizeof(*cos)*numVerts, "cu_vcos");
Nurb *nu;
@ -3093,7 +3093,7 @@ float (*curve_getVertexCos(Curve *UNUSED(cu), ListBase *lb, int *numVerts_r))[3]
return cos;
}
void curve_applyVertexCos(Curve *UNUSED(cu), ListBase *lb, float (*vertexCos)[3])
void BK_curve_vertexCos_apply(Curve *UNUSED(cu), ListBase *lb, float (*vertexCos)[3])
{
float *co = vertexCos[0];
Nurb *nu;
@ -3121,9 +3121,9 @@ void curve_applyVertexCos(Curve *UNUSED(cu), ListBase *lb, float (*vertexCos)[3]
}
}
float (*curve_getKeyVertexCos(Curve *UNUSED(cu), ListBase *lb, float *key))[3]
float (*BKE_curve_keyVertexCos_get(Curve *UNUSED(cu), ListBase *lb, float *key))[3]
{
int i, numVerts = count_curveverts(lb);
int i, numVerts = BKE_nurbList_verts_count(lb);
float *co, (*cos)[3] = MEM_mallocN(sizeof(*cos)*numVerts, "cu_vcos");
Nurb *nu;
@ -3152,7 +3152,7 @@ float (*curve_getKeyVertexCos(Curve *UNUSED(cu), ListBase *lb, float *key))[3]
return cos;
}
void curve_applyKeyVertexTilts(Curve *UNUSED(cu), ListBase *lb, float *key)
void BKE_curve_keyVertexTilts_apply(Curve *UNUSED(cu), ListBase *lb, float *key)
{
Nurb *nu;
int i;
@ -3179,7 +3179,7 @@ void curve_applyKeyVertexTilts(Curve *UNUSED(cu), ListBase *lb, float *key)
}
}
int check_valid_nurb_u( struct Nurb *nu )
int BKE_nurb_check_valid_u( struct Nurb *nu )
{
if (nu==NULL) return 0;
if (nu->pntsu <= 1) return 0;
@ -3194,7 +3194,7 @@ int check_valid_nurb_u( struct Nurb *nu )
}
return 1;
}
int check_valid_nurb_v( struct Nurb *nu)
int BKE_nurb_check_valid_v( struct Nurb *nu)
{
if (nu==NULL) return 0;
if (nu->pntsv <= 1) return 0;
@ -3210,7 +3210,7 @@ int check_valid_nurb_v( struct Nurb *nu)
return 1;
}
int clamp_nurb_order_u( struct Nurb *nu )
int BKE_nurb_order_clamp_u( struct Nurb *nu )
{
int change = 0;
if (nu->pntsu<nu->orderu) {
@ -3224,7 +3224,7 @@ int clamp_nurb_order_u( struct Nurb *nu )
return change;
}
int clamp_nurb_order_v( struct Nurb *nu)
int BKE_nurb_order_clamp_v( struct Nurb *nu)
{
int change = 0;
if (nu->pntsv<nu->orderv) {
@ -3239,10 +3239,10 @@ int clamp_nurb_order_v( struct Nurb *nu)
}
/* Get edit nurbs or normal nurbs list */
ListBase *BKE_curve_nurbs(Curve *cu)
ListBase *BKE_curve_nurbs_get(Curve *cu)
{
if (cu->editnurb) {
return curve_editnurbs(cu);
return BKE_curve_editNurbs_get(cu);
}
return &cu->nurb;
@ -3250,20 +3250,20 @@ ListBase *BKE_curve_nurbs(Curve *cu)
/* basic vertex data functions */
int minmax_curve(Curve *cu, float min[3], float max[3])
int BKE_curve_minmax(Curve *cu, float min[3], float max[3])
{
ListBase *nurb_lb= BKE_curve_nurbs(cu);
ListBase *nurb_lb= BKE_curve_nurbs_get(cu);
Nurb *nu;
for (nu= nurb_lb->first; nu; nu= nu->next)
minmaxNurb(nu, min, max);
BKE_nurb_minmax(nu, min, max);
return (nurb_lb->first != NULL);
}
int curve_center_median(Curve *cu, float cent[3])
int BKE_curve_center_median(Curve *cu, float cent[3])
{
ListBase *nurb_lb= BKE_curve_nurbs(cu);
ListBase *nurb_lb= BKE_curve_nurbs_get(cu);
Nurb *nu;
int total= 0;
@ -3297,11 +3297,11 @@ int curve_center_median(Curve *cu, float cent[3])
return (total != 0);
}
int curve_center_bounds(Curve *cu, float cent[3])
int BKE_curve_center_bounds(Curve *cu, float cent[3])
{
float min[3], max[3];
INIT_MINMAX(min, max);
if (minmax_curve(cu, min, max)) {
if (BKE_curve_minmax(cu, min, max)) {
mid_v3_v3v3(cent, min, max);
return 1;
}
@ -3309,9 +3309,9 @@ int curve_center_bounds(Curve *cu, float cent[3])
return 0;
}
void curve_translate(Curve *cu, float offset[3], int do_keys)
void BKE_curve_translate(Curve *cu, float offset[3], int do_keys)
{
ListBase *nurb_lb= BKE_curve_nurbs(cu);
ListBase *nurb_lb= BKE_curve_nurbs_get(cu);
Nurb *nu;
int i;
@ -3346,9 +3346,9 @@ void curve_translate(Curve *cu, float offset[3], int do_keys)
}
}
void curve_delete_material_index(Curve *cu, int index)
void BKE_curve_delete_material_index(Curve *cu, int index)
{
const int curvetype= curve_type(cu);
const int curvetype= BKE_curve_type_get(cu);
if (curvetype == OB_FONT) {
struct CharInfo *info= cu->strinfo;

@ -167,7 +167,7 @@ static void layerCopy_bmesh_elem_py_ptr(const void *UNUSED(source), void *dest,
int i, size = sizeof(void *);
for (i = 0; i < count; ++i) {
void **ptr = (void **)((char *)dest + i * size);
void **ptr = (void **)((char *)dest + i * size);
*ptr = NULL;
}
}
@ -2337,7 +2337,10 @@ int CustomData_layer_has_math(struct CustomData *data, int layer_n)
const LayerTypeInfo *typeInfo = layerType_getInfo(data->layers[layer_n].type);
if (typeInfo->equal && typeInfo->add && typeInfo->multiply &&
typeInfo->initminmax && typeInfo->dominmax) return 1;
typeInfo->initminmax && typeInfo->dominmax)
{
return 1;
}
return 0;
}
@ -2684,7 +2687,9 @@ int CustomData_verify_versions(struct CustomData *data, int index)
if (!typeInfo->defaultname && (index > 0) &&
data->layers[index-1].type == layer->type)
{
keeplayer = 0; /* multiple layers of which we only support one */
}
}
if (!keeplayer) {

@ -479,7 +479,7 @@ void flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_
/* first case; separator . - _ with extensions r R l L */
if (is_char_sep(name[len - 2]) ) {
switch(name[len - 1]) {
switch (name[len - 1]) {
case 'l':
prefix[len - 1] = 0;
strcpy(replace, "r");
@ -500,7 +500,7 @@ void flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_
}
/* case; beginning with r R l L , with separator after it */
else if (is_char_sep(name[1]) ) {
switch(name[0]) {
switch (name[0]) {
case 'l':
strcpy(replace, "r");
BLI_strncpy(suffix, name + 1, sizeof(suffix));

@ -462,7 +462,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
if (ob->parent) {
node2 = dag_get_node(dag,ob->parent);
switch(ob->partype) {
switch (ob->partype) {
case PARSKEL:
dag_add_relation(dag,node2,node,DAG_RL_DATA_DATA|DAG_RL_OB_OB, "Parent");
break;
@ -539,7 +539,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
break;
case OB_MBALL:
{
Object *mom= find_basis_mball(scene, ob);
Object *mom= BKE_metaball_basis_find(scene, ob);
if (mom!=ob) {
node2 = dag_get_node(dag, mom);
@ -2245,7 +2245,7 @@ static void dag_object_time_update_flags(Object *ob)
Curve *cu;
Lattice *lt;
switch(ob->type) {
switch (ob->type) {
case OB_MESH:
me= ob->data;
if (me->key) {

@ -1,4 +1,5 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
@ -228,7 +229,7 @@ void count_displist(ListBase *lb, int *totvert, int *totface)
dl= lb->first;
while (dl) {
switch(dl->type) {
switch (dl->type) {
case DL_SURF:
*totvert+= dl->nr*dl->parts;
*totface+= (dl->nr-1)*(dl->parts-1);
@ -296,7 +297,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, i
else
resolu= nu->resolu;
if (!check_valid_nurb_u(nu));
if (!BKE_nurb_check_valid_u(nu));
else if (nu->type == CU_BEZIER) {
/* count */
@ -351,7 +352,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, i
else {
int j;
for (j=0; j<3; j++) {
forward_diff_bezier( prevbezt->vec[1][j],
BKE_curve_forward_diff_bezier( prevbezt->vec[1][j],
prevbezt->vec[2][j],
bezt->vec[0][j],
bezt->vec[1][j],
@ -384,7 +385,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, i
data= dl->verts;
if (nu->flagu & CU_NURB_CYCLIC) dl->type= DL_POLY;
else dl->type= DL_SEGM;
makeNurbcurve(nu, data, NULL, NULL, NULL, resolu, 3*sizeof(float));
BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, 3*sizeof(float));
}
else if (nu->type == CU_POLY) {
len= nu->pntsu;
@ -672,9 +673,9 @@ void makeDispListMBall(Scene *scene, Object *ob)
freedisplist(&(ob->disp));
if (ob->type==OB_MBALL) {
if (ob==find_basis_mball(scene, ob)) {
metaball_polygonize(scene, ob, &ob->disp);
tex_space_mball(ob);
if (ob==BKE_metaball_basis_find(scene, ob)) {
BKE_metaball_polygonize(scene, ob, &ob->disp);
BKE_metaball_tex_space_calc(ob);
object_deform_mball(ob, &ob->disp);
}
@ -685,8 +686,8 @@ void makeDispListMBall(Scene *scene, Object *ob)
void makeDispListMBall_forRender(Scene *scene, Object *ob, ListBase *dispbase)
{
metaball_polygonize(scene, ob, dispbase);
tex_space_mball(ob);
BKE_metaball_polygonize(scene, ob, dispbase);
BKE_metaball_tex_space_calc(ob);
object_deform_mball(ob, dispbase);
}
@ -730,7 +731,7 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl
ModifierData *md = modifiers_getVirtualModifierList(ob);
ModifierData *pretessellatePoint;
Curve *cu= ob->data;
ListBase *nurb= BKE_curve_nurbs(cu);
ListBase *nurb= BKE_curve_nurbs_get(cu);
int numVerts = 0;
int editmode = (!forRender && cu->editnurb);
float (*originalVerts)[3] = NULL;
@ -753,9 +754,9 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl
* tilts, which is passed through in the modifier stack.
* this is also the reason curves do not use a virtual
* shape key modifier yet. */
deformedVerts= curve_getKeyVertexCos(cu, nurb, keyVerts);
deformedVerts= BKE_curve_keyVertexCos_get(cu, nurb, keyVerts);
originalVerts= MEM_dupallocN(deformedVerts);
numVerts = count_curveverts_without_handles(nurb);
numVerts = BKE_nurbList_verts_count_without_handles(nurb);
}
}
@ -770,7 +771,7 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl
if (mti->type!=eModifierTypeType_OnlyDeform) continue;
if (!deformedVerts) {
deformedVerts = curve_getVertexCos(cu, nurb, &numVerts);
deformedVerts = BKE_curve_vertexCos_get(cu, nurb, &numVerts);
originalVerts = MEM_dupallocN(deformedVerts);
}
@ -782,9 +783,9 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl
}
if (deformedVerts)
curve_applyVertexCos(cu, nurb, deformedVerts);
BK_curve_vertexCos_apply(cu, nurb, deformedVerts);
if (keyVerts) /* these are not passed through modifier stack */
curve_applyKeyVertexTilts(cu, nurb, keyVerts);
BKE_curve_keyVertexTilts_apply(cu, nurb, keyVerts);
if (keyVerts)
MEM_freeN(keyVerts);
@ -834,7 +835,7 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba
ModifierData *md = modifiers_getVirtualModifierList(ob);
ModifierData *pretessellatePoint;
Curve *cu= ob->data;
ListBase *nurb= BKE_curve_nurbs(cu);
ListBase *nurb= BKE_curve_nurbs_get(cu);
int required_mode = 0, totvert = 0;
int editmode = (!forRender && cu->editnurb);
DerivedMesh *dm= NULL, *ndm;
@ -956,7 +957,7 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba
}
if (deformedVerts) {
curve_applyVertexCos(ob->data, nurb, originalVerts);
BK_curve_vertexCos_apply(ob->data, nurb, originalVerts);
MEM_freeN(originalVerts);
MEM_freeN(deformedVerts);
}
@ -1023,7 +1024,7 @@ static void add_orco_dm(Scene *scene, Object *ob, DerivedMesh *dm, DerivedMesh *
dm->getVertCos(dm, orco);
}
else {
orco= (float(*)[3])make_orco_curve(scene, ob);
orco= (float(*)[3])BKE_curve_make_orco(scene, ob);
}
for (a=0; a<totvert; a++) {
@ -1108,7 +1109,7 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase,
float (*deformedVerts)[3];
if (!forRender && cu->editnurb)
nubase= curve_editnurbs(cu);
nubase= BKE_curve_editNurbs_get(cu);
else
nubase= &cu->nurb;
@ -1144,7 +1145,7 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase,
if (nu->flagu & CU_NURB_CYCLIC) dl->type= DL_POLY;
else dl->type= DL_SEGM;
makeNurbcurve(nu, data, NULL, NULL, NULL, resolu, 3*sizeof(float));
BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, 3*sizeof(float));
}
else {
len= (nu->pntsu*resolu) * (nu->pntsv*resolv);
@ -1168,7 +1169,7 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase,
if (nu->flagv & CU_NURB_CYCLIC) dl->flag|= DL_CYCL_U; /* reverse too! */
if (nu->flagu & CU_NURB_CYCLIC) dl->flag|= DL_CYCL_V;
makeNurbfaces(nu, data, 0, resolu, resolv);
BKE_nurb_makeFaces(nu, data, 0, resolu, resolv);
/* gl array drawing: using indices */
displist_surf_indices(dl);
@ -1182,7 +1183,7 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase,
copy_displist(&cu->disp, dispbase);
if (!forRender) {
tex_space_curve(cu);
BKE_curve_tex_space_calc(cu);
}
if (!forOrco)
@ -1262,7 +1263,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
float (*deformedVerts)[3];
int numVerts;
nubase= BKE_curve_nurbs(cu);
nubase= BKE_curve_nurbs_get(cu);
BLI_freelistN(&(cu->bev));
@ -1273,10 +1274,10 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
if (!forOrco) curve_calc_modifiers_pre(scene, ob, forRender, &originalVerts, &deformedVerts, &numVerts);
makeBevelList(ob);
BKE_curve_bevelList_make(ob);
/* If curve has no bevel will return nothing */
makebevelcurve(scene, ob, &dlbev, forRender);
BKE_curve_bevel_make(scene, ob, &dlbev, forRender);
/* no bevel or extrude, and no width correction? */
if (!dlbev.first && cu->width==1.0f) {
@ -1410,7 +1411,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
copy_displist(&cu->disp, dispbase);
if (!forRender) {
tex_space_curve(cu);
BKE_curve_tex_space_calc(cu);
}
if (!forOrco) curve_calc_modifiers_post(scene, ob, dispbase, derivedFinal, forRender, originalVerts, deformedVerts);

@ -231,13 +231,22 @@ static int dynamicPaint_surfaceNumOfPoints(DynamicPaintSurface *surface)
/* checks whether surface's format/type has realtime preview */
int dynamicPaint_surfaceHasColorPreview(DynamicPaintSurface *surface)
{
if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) return 0;
if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) {
return 0;
}
else if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) {
if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE ||
surface->type == MOD_DPAINT_SURFACE_T_WAVE) return 0;
else return 1;
surface->type == MOD_DPAINT_SURFACE_T_WAVE)
{
return 0;
}
else {
return 1;
}
}
else {
return 1;
}
else return 1;
}
/* get currently active surface (in user interface) */
@ -393,11 +402,15 @@ void dynamicPaintSurface_updateType(struct DynamicPaintSurface *surface)
static int surface_totalSamples(DynamicPaintSurface *surface)
{
if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ &&
surface->flags & MOD_DPAINT_ANTIALIAS)
return (surface->data->total_points*5);
surface->flags & MOD_DPAINT_ANTIALIAS)
{
return (surface->data->total_points * 5);
}
if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX &&
surface->flags & MOD_DPAINT_ANTIALIAS && surface->data->adj_data)
surface->flags & MOD_DPAINT_ANTIALIAS && surface->data->adj_data)
{
return (surface->data->total_points+surface->data->adj_data->total_targets);
}
return surface->data->total_points;
}
@ -548,8 +561,7 @@ static int surface_getBrushFlags(DynamicPaintSurface *surface, Scene *scene)
else
base = scene->base.first;
while (base || go)
{
while (base || go) {
brushObj = NULL;
/* select object */
@ -559,8 +571,7 @@ static int surface_getBrushFlags(DynamicPaintSurface *surface, Scene *scene)
else
brushObj = base->object;
if (!brushObj)
{
if (!brushObj) {
if (surface->brush_group) go = go->next;
else base= base->next;
continue;
@ -572,12 +583,10 @@ static int surface_getBrushFlags(DynamicPaintSurface *surface, Scene *scene)
base= base->next;
md = modifiers_findByType(brushObj, eModifierType_DynamicPaint);
if (md && md->mode & (eModifierMode_Realtime | eModifierMode_Render))
{
if (md && md->mode & (eModifierMode_Realtime | eModifierMode_Render)) {
DynamicPaintModifierData *pmd2 = (DynamicPaintModifierData *)md;
if (pmd2->brush)
{
if (pmd2->brush) {
DynamicPaintBrushSettings *brush = pmd2->brush;
if (brush->flags & MOD_DPAINT_USES_VELOCITY)
@ -888,8 +897,10 @@ void surface_freeUnusedData(DynamicPaintSurface *surface)
/* free bakedata if not active or surface is baked */
if (!(surface->flags & MOD_DPAINT_ACTIVE) ||
(surface->pointcache && surface->pointcache->flag & PTCACHE_BAKED))
(surface->pointcache && surface->pointcache->flag & PTCACHE_BAKED))
{
free_bakeData(surface->data);
}
}
void dynamicPaint_freeSurfaceData(DynamicPaintSurface *surface)
@ -1219,9 +1230,13 @@ static int surface_usesAdjData(DynamicPaintSurface *surface)
{
if (surface_usesAdjDistance(surface)) return 1;
if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX &&
surface->flags & MOD_DPAINT_ANTIALIAS) return 1;
return 0;
surface->flags & MOD_DPAINT_ANTIALIAS)
{
return 1;
}
else {
return 0;
}
}
/* initialize surface adjacency data */
@ -1294,10 +1309,12 @@ static void dynamicPaint_initAdjacencyData(DynamicPaintSurface *surface, int for
/* now check if total number of edges+faces for
* each vertex is even, if not -> vertex is on mesh edge */
for (i=0; i<sData->total_points; i++) {
if ((temp_data[i]%2) ||
temp_data[i] < 4)
if ((temp_data[i] % 2) ||
(temp_data[i] < 4))
{
ad->flags[i] |= ADJ_ON_MESH_EDGE;
}
/* reset temp data */
temp_data[i] = 0;
}
@ -1863,8 +1880,10 @@ static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, Scene *scene
/* restore canvas derivedmesh if required */
if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE &&
surface->flags & MOD_DPAINT_DISP_INCREMENTAL && surface->next)
surface->flags & MOD_DPAINT_DISP_INCREMENTAL && surface->next)
{
canvas_copyDerivedMesh(canvas, dm);
}
BKE_ptcache_validate(cache, surface->current_frame);
BKE_ptcache_write(&pid, surface->current_frame);
@ -2042,9 +2061,12 @@ static int dynamicPaint_findNeighbourPixel(PaintUVPoint *tempPoints, DerivedMesh
//printf("connected UV : %f,%f & %f,%f - %f,%f & %f,%f\n", s_uv1[0], s_uv1[1], s_uv2[0], s_uv2[1], t_uv1[0], t_uv1[1], t_uv2[0], t_uv2[1]);
if (((s_uv1[0] == t_uv1[0] && s_uv1[1] == t_uv1[1]) &&
(s_uv2[0] == t_uv2[0] && s_uv2[1] == t_uv2[1]) ) ||
((s_uv2[0] == t_uv1[0] && s_uv2[1] == t_uv1[1]) &&
(s_uv1[0] == t_uv2[0] && s_uv1[1] == t_uv2[1]) )) return ((px+neighX[n_index]) + w*(py+neighY[n_index]));
(s_uv2[0] == t_uv2[0] && s_uv2[1] == t_uv2[1]) ) ||
((s_uv2[0] == t_uv1[0] && s_uv2[1] == t_uv1[1]) &&
(s_uv1[0] == t_uv2[0] && s_uv1[1] == t_uv2[1]) ))
{
return ((px+neighX[n_index]) + w*(py+neighY[n_index]));
}
/*
* Find a point that is relatively at same edge position
@ -2185,11 +2207,9 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface)
*/
if (!error) {
#pragma omp parallel for schedule(static)
for (ty = 0; ty < h; ty++)
{
for (ty = 0; ty < h; ty++) {
int tx;
for (tx = 0; tx < w; tx++)
{
for (tx = 0; tx < w; tx++) {
int i, sample;
int index = tx+w*ty;
PaintUVPoint *tPoint = (&tempPoints[index]);
@ -2257,8 +2277,7 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface)
/* If collision wasn't found but the face is a quad
* do another check for the second half */
if ((!isInside) && mface[i].v4)
{
if ((!isInside) && mface[i].v4) {
/* change d2 to test the other half */
sub_v2_v2v2(d2, tface[i].uv[3], tface[i].uv[0]); // uv3 - uv0
@ -2330,11 +2349,9 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface)
* (To avoid seams on uv island edges)
*/
#pragma omp parallel for schedule(static)
for (ty = 0; ty < h; ty++)
{
for (ty = 0; ty < h; ty++) {
int tx;
for (tx = 0; tx < w; tx++)
{
for (tx = 0; tx < w; tx++) {
int index = tx+w*ty;
PaintUVPoint *tPoint = (&tempPoints[index]);
@ -2408,11 +2425,9 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface)
* When base loop is over convert found neighbor indexes to real ones
* Also count the final number of active surface points
*/
for (ty = 0; ty < h; ty++)
{
for (ty = 0; ty < h; ty++) {
int tx;
for (tx = 0; tx < w; tx++)
{
for (tx = 0; tx < w; tx++) {
int index = tx+w*ty;
PaintUVPoint *tPoint = (&tempPoints[index]);
@ -2440,11 +2455,9 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface)
if (sData->adj_data) {
PaintAdjData *ed = sData->adj_data;
unsigned int n_pos = 0;
for (ty = 0; ty < h; ty++)
{
for (ty = 0; ty < h; ty++) {
int tx;
for (tx = 0; tx < w; tx++)
{
for (tx = 0; tx < w; tx++) {
int i, index = tx+w*ty;
if (tempPoints[index].face_index != -1) {
@ -2576,8 +2589,7 @@ void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface, char* filenam
if (ibuf == NULL) {setError(surface->canvas, "Image save failed: Not enough free memory.");return;}
#pragma omp parallel for schedule(static)
for (index = 0; index < sData->total_points; index++)
{
for (index = 0; index < sData->total_points; index++) {
int pos=f_data->uv_p[index].pixel_index*4; /* image buffer position */
/* Set values of preferred type */
@ -2759,8 +2771,7 @@ static void mesh_faces_spherecast_dp(void *userdata, int index, const BVHTreeRay
{
float dist = bvhtree_ray_tri_intersection(ray, hit->dist, t0, t1, t2);
if (dist >= 0 && dist < hit->dist)
{
if (dist >= 0 && dist < hit->dist) {
hit->index = index;
hit->dist = dist;
hit->no[0] = (quad) ? 1.0f : 0.0f;
@ -2780,7 +2791,7 @@ static void mesh_faces_spherecast_dp(void *userdata, int index, const BVHTreeRay
* To optimize brush detection speed this doesn't calculate hit normal.
* If ray hit the second half of a quad, no[0] is set to 1.0f, else 0.0f
*/
static void mesh_faces_nearest_point_dp(void *userdata, int index, const float *co, BVHTreeNearest *nearest)
static void mesh_faces_nearest_point_dp(void *userdata, int index, const float co[3], BVHTreeNearest *nearest)
{
const BVHTreeFromMesh *data = (BVHTreeFromMesh*) userdata;
MVert *vert = data->vert;
@ -2799,8 +2810,7 @@ static void mesh_faces_nearest_point_dp(void *userdata, int index, const float *
int vertex, edge;
dist = nearest_point_in_tri_surface(t0, t1, t2, co, &vertex, &edge, nearest_tmp);
if (dist < nearest->dist)
{
if (dist < nearest->dist) {
nearest->index = index;
nearest->dist = dist;
copy_v3_v3(nearest->co, nearest_tmp);
@ -3188,8 +3198,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
/* check bounding box collision */
if (grid && meshBrush_boundsIntersect(&grid->grid_bounds, &mesh_bb, brush, brush_radius))
/* Build a bvh tree from transformed vertices */
if (bvhtree_from_mesh_faces(&treeData, dm, 0.0f, 4, 8))
{
if (bvhtree_from_mesh_faces(&treeData, dm, 0.0f, 4, 8)) {
int c_index;
int total_cells = grid->dim[0]*grid->dim[1]*grid->dim[2];
@ -3203,8 +3212,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
/* loop through cell points and process brush */
#pragma omp parallel for schedule(static)
for (id = 0; id < grid->s_num[c_index]; id++)
{
for (id = 0; id < grid->s_num[c_index]; id++) {
int index = grid->t_index[grid->s_pos[c_index] + id];
int ss, samples = bData->s_num[index];
float total_sample = (float)samples;
@ -3220,8 +3228,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
total_sample = gaussianTotal;
/* Supersampling */
for (ss=0; ss<samples; ss++)
{
for (ss=0; ss<samples; ss++) {
float ray_start[3], ray_dir[3];
float sample_factor = 0.0f;
@ -3263,8 +3270,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
/* Check volume collision */
if (brush->collision == MOD_DPAINT_COL_VOLUME || brush->collision == MOD_DPAINT_COL_VOLDIST)
if (BLI_bvhtree_ray_cast(treeData.tree, ray_start, ray_dir, 0.0f, &hit, mesh_faces_spherecast_dp, &treeData) != -1)
{
if (BLI_bvhtree_ray_cast(treeData.tree, ray_start, ray_dir, 0.0f, &hit, mesh_faces_spherecast_dp, &treeData) != -1) {
/* We hit a triangle, now check if collision point normal is facing the point */
/* For optimization sake, hit point normal isn't calculated in ray cast loop */
@ -3277,8 +3283,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
/* If ray and hit face normal are facing same direction
* hit point is inside a closed mesh. */
if (dot>=0)
{
if (dot>=0) {
float dist = hit.dist;
int f_index = hit.index;
@ -3342,8 +3347,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
hit.dist = brush_radius;
/* Do a face normal directional raycast, and use that distance */
if (BLI_bvhtree_ray_cast(treeData.tree, ray_start, proj_ray, 0.0f, &hit, mesh_faces_spherecast_dp, &treeData) != -1)
{
if (BLI_bvhtree_ray_cast(treeData.tree, ray_start, proj_ray, 0.0f, &hit, mesh_faces_spherecast_dp, &treeData) != -1) {
proxDist = hit.dist;
madd_v3_v3v3fl(hitCo, ray_start, proj_ray, hit.dist); /* Calculate final hit coordinates */
hQuad = (hit.no[0] == 1.0f);
@ -3446,8 +3450,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
/*
* Process hit color and alpha
*/
if (surface->type == MOD_DPAINT_SURFACE_T_PAINT)
{
if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
float sampleColor[3];
float alpha_factor = 1.0f;
@ -3589,8 +3592,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface,
BLI_begin_threaded_malloc();
/* only continue if particle bb is close enough to canvas bb */
if (boundsIntersectDist(&grid->grid_bounds, &part_bb, range))
{
if (boundsIntersectDist(&grid->grid_bounds, &part_bb, range)) {
int c_index;
int total_cells = grid->dim[0]*grid->dim[1]*grid->dim[2];
@ -3603,13 +3605,14 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface,
/* check cell bounding box */
if (!grid->s_num[c_index] ||
!boundsIntersectDist(&grid->bounds[c_index], &part_bb, range))
!boundsIntersectDist(&grid->bounds[c_index], &part_bb, range))
{
continue;
}
/* loop through cell points */
#pragma omp parallel for schedule(static)
for (id = 0; id < grid->s_num[c_index]; id++)
{
for (id = 0; id < grid->s_num[c_index]; id++) {
int index = grid->t_index[grid->s_pos[c_index] + id];
float disp_intersect = 0.0f;
float radius = 0.0f;
@ -3714,8 +3717,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface,
}
}
if (strength > 0.001f)
{
if (strength > 0.001f) {
float paintColor[4] = {0.0f};
float depth = 0.0f;
@ -3781,8 +3783,7 @@ static int dynamicPaint_paintSinglePoint(DynamicPaintSurface *surface, float *po
* Loop through every surface point
*/
#pragma omp parallel for schedule(static)
for (index = 0; index < sData->total_points; index++)
{
for (index = 0; index < sData->total_points; index++) {
float distance = len_v3v3(pointCoord, bData->realCoord[bData->s_pos[index]].v);
float colorband[4] = {0.0f};
float strength;
@ -3891,8 +3892,7 @@ static void dynamicPaint_prepareAdjacencyData(DynamicPaintSurface *surface, int
if (!bNeighs) return;
#pragma omp parallel for schedule(static)
for (index = 0; index < sData->total_points; index++)
{
for (index = 0; index < sData->total_points; index++) {
int i;
int numOfNeighs = adj_data->n_num[index];
@ -3911,8 +3911,7 @@ static void dynamicPaint_prepareAdjacencyData(DynamicPaintSurface *surface, int
/* calculate average values (single thread) */
bData->average_dist = 0.0f;
for (index = 0; index < sData->total_points; index++)
{
for (index = 0; index < sData->total_points; index++) {
int i;
int numOfNeighs = adj_data->n_num[index];
@ -4080,8 +4079,7 @@ static int dynamicPaint_prepareEffectStep(DynamicPaintSurface *surface, Scene *s
if (*force) {
#pragma omp parallel for schedule(static)
for (index = 0; index < sData->total_points; index++)
{
for (index = 0; index < sData->total_points; index++) {
float forc[3] = {0};
/* apply force fields */
@ -4121,8 +4119,7 @@ static int dynamicPaint_prepareEffectStep(DynamicPaintSurface *surface, Scene *s
}
/* calculate average values (single thread) */
for (index = 0; index < sData->total_points; index++)
{
for (index = 0; index < sData->total_points; index++) {
average_force += (*force)[index*4+3];
}
average_force /= sData->total_points;
@ -4171,8 +4168,7 @@ static void dynamicPaint_doEffectStep(DynamicPaintSurface *surface, float *force
memcpy(prevPoint, sData->type_data, sData->total_points*sizeof(struct PaintPoint));
#pragma omp parallel for schedule(static)
for (index = 0; index < sData->total_points; index++)
{
for (index = 0; index < sData->total_points; index++) {
int i;
int numOfNeighs = sData->adj_data->n_num[index];
PaintPoint *pPoint = &((PaintPoint*)sData->type_data)[index];
@ -4214,8 +4210,7 @@ static void dynamicPaint_doEffectStep(DynamicPaintSurface *surface, float *force
memcpy(prevPoint, sData->type_data, sData->total_points*sizeof(struct PaintPoint));
#pragma omp parallel for schedule(static)
for (index = 0; index < sData->total_points; index++)
{
for (index = 0; index < sData->total_points; index++) {
int i;
int numOfNeighs = sData->adj_data->n_num[index];
float totalAlpha = 0.0f;
@ -4256,8 +4251,7 @@ static void dynamicPaint_doEffectStep(DynamicPaintSurface *surface, float *force
/*
* Drip Effect
*/
if (surface->effect & MOD_DPAINT_EFFECT_DO_DRIP && force)
{
if (surface->effect & MOD_DPAINT_EFFECT_DO_DRIP && force) {
float eff_scale = distance_scale*EFF_MOVEMENT_PER_FRAME*timescale/2.0f;
/* Copy current surface to the previous points array to read unmodified values */
memcpy(prevPoint, sData->type_data, sData->total_points*sizeof(struct PaintPoint));
@ -4335,8 +4329,7 @@ void dynamicPaint_doWaveStep(DynamicPaintSurface *surface, float timescale)
if (!prevPoint) return;
/* calculate average neigh distance (single thread) */
for (index = 0; index < sData->total_points; index++)
{
for (index = 0; index < sData->total_points; index++) {
int i;
int numOfNeighs = sData->adj_data->n_num[index];
@ -4435,8 +4428,7 @@ static void dynamicPaint_surfacePreStep(DynamicPaintSurface *surface, float time
int index;
#pragma omp parallel for schedule(static)
for (index=0; index<sData->total_points; index++)
{
for (index=0; index<sData->total_points; index++) {
/* Do drying dissolve effects */
if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
PaintPoint *pPoint = &((PaintPoint*)sData->type_data)[index];
@ -4651,8 +4643,7 @@ static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, Scene *sc
* Prepare each surface point for a new step
*/
#pragma omp parallel for schedule(static)
for (index=0; index<sData->total_points; index++)
{
for (index=0; index<sData->total_points; index++) {
float prev_point[3] = {0.0f, 0.0f, 0.0f};
if (do_velocity_data && !new_bdata) {
copy_v3_v3(prev_point, bData->realCoord[bData->s_pos[index]].v);
@ -4796,8 +4787,7 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su
else
base = scene->base.first;
while (base || go)
{
while (base || go) {
brushObj = NULL;
/* select object */
if (surface->brush_group) {
@ -4821,12 +4811,10 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su
/* check if target has an active dp modifier */
md = modifiers_findByType(brushObj, eModifierType_DynamicPaint);
if (md && md->mode & (eModifierMode_Realtime | eModifierMode_Render))
{
if (md && md->mode & (eModifierMode_Realtime | eModifierMode_Render)) {
DynamicPaintModifierData *pmd2 = (DynamicPaintModifierData *)md;
/* make sure we're dealing with a brush */
if (pmd2->brush)
{
if (pmd2->brush) {
DynamicPaintBrushSettings *brush = pmd2->brush;
BrushMaterials bMats = {0};

@ -162,7 +162,7 @@ static void BMEdit_RecalcTessellation_intern(BMEditMesh *tm)
/* no need to ensure the loop order, we know its ok */
else if (f->len == 3) {
BLI_array_growone(looptris);
BLI_array_grow_one(looptris);
l = BM_iter_new(&liter, bm, BM_LOOPS_OF_FACE, f);
for (j=0; l; l=BM_iter_step(&liter), j++) {
looptris[i][j] = l;
@ -171,7 +171,7 @@ static void BMEdit_RecalcTessellation_intern(BMEditMesh *tm)
}
else if (f->len == 4) {
BMLoop *ltmp[4];
BLI_array_growitems(looptris, 2);
BLI_array_grow_items(looptris, 2);
l = BM_iter_new(&liter, bm, BM_LOOPS_OF_FACE, f);
for (j=0; l; l=BM_iter_step(&liter), j++) {
@ -219,7 +219,7 @@ static void BMEdit_RecalcTessellation_intern(BMEditMesh *tm)
BLI_addfilledge(&sf_ctx, firstv, v);
totfilltri = BLI_edgefill_ex(&sf_ctx, FALSE, f->no);
BLI_array_growitems(looptris, totfilltri);
BLI_array_grow_items(looptris, totfilltri);
for (efa = sf_ctx.fillfacebase.first; efa; efa=efa->next) {
BMLoop *l1= efa->v1->tmp.p;

@ -129,7 +129,7 @@ PartDeflect *object_add_collision_fields(int type)
pd->f_damp = 1.0f;
/* set sensible defaults based on type */
switch(type) {
switch (type) {
case PFIELD_VORTEX:
pd->shape = PFIELD_SHAPE_PLANE;
break;
@ -419,8 +419,7 @@ static float eff_calc_visibility(ListBase *colliders, EffectorCache *eff, Effect
len = normalize_v3(norm);
// check all collision objects
for (col = colls->first; col; col = col->next)
{
for (col = colls->first; col; col = col->next) {
CollisionModifierData *collmd = col->collmd;
if (col->ob == eff->ob)
@ -506,7 +505,8 @@ float effector_falloff(EffectorCache *eff, EffectorData *efd, EffectedPoint *UNU
falloff=0.0f;
else if (eff->pd->zdir == PFIELD_Z_NEG && fac > 0.0f)
falloff=0.0f;
else switch(eff->pd->falloff) {
else {
switch (eff->pd->falloff) {
case PFIELD_FALL_SPHERE:
falloff*= falloff_func_dist(eff->pd, efd->distance);
break;
@ -529,6 +529,7 @@ float effector_falloff(EffectorCache *eff, EffectorData *efd, EffectedPoint *UNU
falloff*= falloff_func_rad(eff->pd, r_fac);
break;
}
}
return falloff;
@ -835,7 +836,7 @@ static void do_physical_effector(EffectorCache *eff, EffectorData *efd, Effected
copy_v3_v3(force, efd->vec_to_point);
switch(pd->forcefield) {
switch (pd->forcefield) {
case PFIELD_WIND:
copy_v3_v3(force, efd->nor);
mul_v3_fl(force, strength * efd->falloff);

@ -800,7 +800,7 @@ void calchandles_fcurve (FCurve *fcu)
if (bezt->vec[2][0] < bezt->vec[1][0]) bezt->vec[2][0]= bezt->vec[1][0];
/* calculate auto-handles */
calchandleNurb(bezt, prev, next, 1); /* 1==special autohandle */
BKE_nurb_handle_calc(bezt, prev, next, 1); /* 1==special autohandle */
/* for automatic ease in and out */
if (ELEM(bezt->h1,HD_AUTO,HD_AUTO_ANIM) && ELEM(bezt->h2,HD_AUTO,HD_AUTO_ANIM)) {
@ -1655,8 +1655,7 @@ static float evaluate_driver (ChannelDriver *driver, const float evaltime)
{
driver->curval= 0.0f;
}
else
{
else {
/* this evaluates the expression using Python,and returns its result:
* - on errors it reports, then returns 0.0f
*/

@ -318,8 +318,7 @@ static void fcm_fn_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, floa
/* get function pointer to the func to use:
* WARNING: must perform special argument validation hereto guard against crashes
*/
switch (data->type)
{
switch (data->type) {
/* simple ones */
case FCM_GENERATOR_FN_SIN: /* sine wave */
fn= sin;

@ -68,8 +68,7 @@ void free_vfont(struct VFont *vf)
if (vf == NULL) return;
if (vf->data) {
while (vf->data->characters.first)
{
while (vf->data->characters.first) {
VChar *che = vf->data->characters.first;
while (che->nurbsbase.first) {
@ -136,8 +135,7 @@ struct TmpFont *vfont_find_tmpfont(VFont *vfont)
// Try finding the font from font list
tmpfnt = ttfdata.first;
while (tmpfnt)
{
while (tmpfnt) {
if (tmpfnt->vfont == vfont)
break;
tmpfnt = tmpfnt->next;
@ -280,7 +278,7 @@ VFont *load_vfont(Main *bmain, const char *name)
static VFont *which_vfont(Curve *cu, CharInfo *info)
{
switch(info->flag & (CU_CHINFO_BOLD|CU_CHINFO_ITALIC)) {
switch (info->flag & (CU_CHINFO_BOLD|CU_CHINFO_ITALIC)) {
case CU_CHINFO_BOLD:
if (cu->vfontb) return(cu->vfontb); else return(cu->vfont);
case CU_CHINFO_ITALIC:
@ -397,8 +395,7 @@ static void buildchar(Main *bmain, Curve *cu, unsigned long character, CharInfo
nu1 = che->nurbsbase.first;
// Create the character
while (nu1)
{
while (nu1) {
bezt1 = nu1->bezt;
if (bezt1) {
nu2 =(Nurb*) MEM_mallocN(sizeof(Nurb),"duplichar_nurb");
@ -822,10 +819,15 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m
}
}
else if ((cu->spacemode==CU_JUSTIFY) && (cu->tb[0].w != 0.0f)) {
float curofs= 0.0f;
for (i=0; i<=slen; i++) {
for (j=i; (mem[j]) && (mem[j]!='\n') &&
(mem[j]!='\r') && (chartransdata[j].dobreak==0) && (j<slen); j++);
float curofs = 0.0f;
for (i = 0; i <= slen; i++) {
for (j=i; (mem[j]) && (mem[j]!='\n') &&
(mem[j] != '\r') && (chartransdata[j].dobreak == 0) && (j < slen);
j++)
{
/* pass */
}
if ((mem[j]!='\r') && (mem[j]!='\n') &&
((chartransdata[j].dobreak!=0))) {
if (mem[i]==' ') curofs += (linedata3[ct->linenr]-linedata[ct->linenr])/linedata4[ct->linenr];
@ -833,7 +835,7 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m
}
if (mem[i]=='\n' || mem[i]=='\r' || chartransdata[i].dobreak) curofs= 0;
ct++;
}
}
}
}
@ -950,7 +952,7 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m
if ((mode==FO_CURSUP || mode==FO_PAGEUP) && ct->linenr==0);
else if ((mode==FO_CURSDOWN || mode==FO_PAGEDOWN) && ct->linenr==lnr);
else {
switch(mode) {
switch (mode) {
case FO_CURSUP: lnr= ct->linenr-1; break;
case FO_CURSDOWN: lnr= ct->linenr+1; break;
case FO_PAGEUP: lnr= ct->linenr-10; break;
@ -1009,7 +1011,7 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m
if (mode == FO_EDIT) {
/* make nurbdata */
freeNurblist(&cu->nurb);
BKE_nurbList_free(&cu->nurb);
ct= chartransdata;
if (cu->sepchar==0) {

@ -484,7 +484,7 @@ void IDP_ReplaceGroupInGroup(IDProperty *dest, IDProperty *src)
}
/*
* replaces a property with the same name in a group, or adds
* it if the propery doesn't exist.
* it if the properly doesn't exist.
*/
void IDP_ReplaceInGroup(IDProperty *group, IDProperty *prop)
{
@ -581,8 +581,7 @@ void IDP_FreeIterBeforeEnd(void *vself)
static void IDP_FreeGroup(IDProperty *prop)
{
IDProperty *loop;
for (loop=prop->data.group.first; loop; loop=loop->next)
{
for (loop=prop->data.group.first; loop; loop=loop->next) {
IDP_FreeProperty(loop);
}
BLI_freelistN(&prop->data.group);

@ -578,7 +578,7 @@ static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char
BLI_strncpy(ibuf->name, name, sizeof(ibuf->name));
ibuf->userflags |= IB_BITMAPDIRTY;
switch(uvtestgrid) {
switch (uvtestgrid) {
case 1:
BKE_image_buf_fill_checker(rect, rect_float, width, height);
break;
@ -929,7 +929,7 @@ char BKE_ftype_to_imtype(const int ftype)
int BKE_imtype_is_movie(const char imtype)
{
switch(imtype) {
switch (imtype) {
case R_IMF_IMTYPE_AVIRAW:
case R_IMF_IMTYPE_AVIJPEG:
case R_IMF_IMTYPE_AVICODEC:
@ -946,7 +946,7 @@ int BKE_imtype_is_movie(const char imtype)
int BKE_imtype_supports_zbuf(const char imtype)
{
switch(imtype) {
switch (imtype) {
case R_IMF_IMTYPE_IRIZ:
case R_IMF_IMTYPE_OPENEXR: /* but not R_IMF_IMTYPE_MULTILAYER */
return 1;
@ -956,7 +956,7 @@ int BKE_imtype_supports_zbuf(const char imtype)
int BKE_imtype_supports_compress(const char imtype)
{
switch(imtype) {
switch (imtype) {
case R_IMF_IMTYPE_PNG:
return 1;
}
@ -965,7 +965,7 @@ int BKE_imtype_supports_compress(const char imtype)
int BKE_imtype_supports_quality(const char imtype)
{
switch(imtype) {
switch (imtype) {
case R_IMF_IMTYPE_JPEG90:
case R_IMF_IMTYPE_JP2:
case R_IMF_IMTYPE_AVIJPEG:
@ -979,7 +979,7 @@ char BKE_imtype_valid_channels(const char imtype)
char chan_flag= IMA_CHAN_FLAG_RGB; /* assume all support rgb */
/* alpha */
switch(imtype) {
switch (imtype) {
case R_IMF_IMTYPE_TARGA:
case R_IMF_IMTYPE_IRIS:
case R_IMF_IMTYPE_PNG:
@ -995,7 +995,7 @@ char BKE_imtype_valid_channels(const char imtype)
}
/* bw */
switch(imtype) {
switch (imtype) {
case R_IMF_IMTYPE_PNG:
case R_IMF_IMTYPE_JPEG90:
case R_IMF_IMTYPE_TARGA:
@ -1110,8 +1110,11 @@ int BKE_add_image_extension(char *string, const char imtype)
}
#ifdef WITH_TIFF
else if (imtype==R_IMF_IMTYPE_TIFF) {
if (!BLI_testextensie(string, ".tif") &&
!BLI_testextensie(string, ".tiff")) extension= ".tif";
if (!BLI_testextensie(string, ".tif") &&
!BLI_testextensie(string, ".tiff"))
{
extension= ".tif";
}
}
#endif
#ifdef WITH_OPENEXR
@ -1791,7 +1794,7 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal)
if (ima==NULL)
return;
switch(signal) {
switch (signal) {
case IMA_SIGNAL_FREE:
image_free_buffers(ima);
if (iuser)

@ -169,12 +169,10 @@ static void checker_board_color_fill(unsigned char *rect, float *rect_float, int
hue_step= power_of_2_max_i(width / 8);
if (hue_step < 8) hue_step= 8;
for (y= 0; y < height; y++)
{
for (y= 0; y < height; y++) {
val= 0.1 + (y * (0.4 / height)); /* use a number lower then 1.0 else its too bright */
for (x= 0; x < width; x++)
{
for (x= 0; x < width; x++) {
hue= (float)((double)(x/hue_step) * 1.0 / width * hue_step);
hsv_to_rgb(hue, sat, val, &r, &g, &b);
@ -291,12 +289,10 @@ static void checker_board_text(unsigned char *rect, float *rect_float, int width
BLF_buffer(mono, rect_float, rect, width, height, 4);
for (y= 0; y < height; y+=step)
{
for (y= 0; y < height; y+=step) {
text[1]= '1';
for (x= 0; x < width; x+=step)
{
for (x= 0; x < width; x+=step) {
/* hard coded offset */
pen_x = x + 33;
pen_y = y + 44;

@ -178,8 +178,7 @@ static void print_fvector(float m3[3])
DO_INLINE void print_lfvector(float (*fLongVector)[3], unsigned int verts)
{
unsigned int i = 0;
for (i = 0; i < verts; i++)
{
for (i = 0; i < verts; i++) {
print_fvector(fLongVector[i]);
}
}
@ -193,8 +192,7 @@ DO_INLINE lfVector *create_lfvector(unsigned int verts)
/* delete long vector */
DO_INLINE void del_lfvector(float (*fLongVector)[3])
{
if (fLongVector != NULL)
{
if (fLongVector != NULL) {
MEM_freeN (fLongVector);
// cloth_aligned_free(&MEMORY_BASE, fLongVector);
}
@ -208,8 +206,7 @@ DO_INLINE void cp_lfvector(float (*to)[3], float (*from)[3], unsigned int verts)
DO_INLINE void init_lfvector(float (*fLongVector)[3], float vector[3], unsigned int verts)
{
unsigned int i = 0;
for (i = 0; i < verts; i++)
{
for (i = 0; i < verts; i++) {
copy_v3_v3(fLongVector[i], vector);
}
}
@ -223,8 +220,7 @@ DO_INLINE void mul_lfvectorS(float (*to)[3], float (*fLongVector)[3], float scal
{
unsigned int i = 0;
for (i = 0; i < verts; i++)
{
for (i = 0; i < verts; i++) {
mul_fvector_S(to[i], fLongVector[i], scalar);
}
}
@ -233,8 +229,7 @@ DO_INLINE void mul_lfvectorS(float (*to)[3], float (*fLongVector)[3], float scal
DO_INLINE void submul_lfvectorS(float (*to)[3], float (*fLongVector)[3], float scalar, unsigned int verts)
{
unsigned int i = 0;
for (i = 0; i < verts; i++)
{
for (i = 0; i < verts; i++) {
VECSUBMUL(to[i], fLongVector[i], scalar);
}
}
@ -258,8 +253,7 @@ DO_INLINE void add_lfvector_lfvector(float (*to)[3], float (*fLongVectorA)[3], f
{
unsigned int i = 0;
for (i = 0; i < verts; i++)
{
for (i = 0; i < verts; i++) {
VECADD(to[i], fLongVectorA[i], fLongVectorB[i]);
}
@ -269,8 +263,7 @@ DO_INLINE void add_lfvector_lfvectorS(float (*to)[3], float (*fLongVectorA)[3],
{
unsigned int i = 0;
for (i = 0; i < verts; i++)
{
for (i = 0; i < verts; i++) {
VECADDS(to[i], fLongVectorA[i], fLongVectorB[i], bS);
}
@ -280,8 +273,7 @@ DO_INLINE void add_lfvectorS_lfvectorS(float (*to)[3], float (*fLongVectorA)[3],
{
unsigned int i = 0;
for (i = 0; i < verts; i++)
{
for (i = 0; i < verts; i++) {
VECADDSS(to[i], fLongVectorA[i], aS, fLongVectorB[i], bS);
}
}
@ -289,8 +281,7 @@ DO_INLINE void add_lfvectorS_lfvectorS(float (*to)[3], float (*fLongVectorA)[3],
DO_INLINE void sub_lfvector_lfvectorS(float (*to)[3], float (*fLongVectorA)[3], float (*fLongVectorB)[3], float bS, unsigned int verts)
{
unsigned int i = 0;
for (i = 0; i < verts; i++)
{
for (i = 0; i < verts; i++) {
VECSUBS(to[i], fLongVectorA[i], fLongVectorB[i], bS);
}
@ -300,8 +291,7 @@ DO_INLINE void sub_lfvector_lfvector(float (*to)[3], float (*fLongVectorA)[3], f
{
unsigned int i = 0;
for (i = 0; i < verts; i++)
{
for (i = 0; i < verts; i++) {
sub_v3_v3v3(to[i], fLongVectorA[i], fLongVectorB[i]);
}
@ -350,15 +340,12 @@ DO_INLINE void inverse_fmatrix(float to[3][3], float from[3][3])
unsigned int i, j;
float d;
if ((d=det_fmatrix(from))==0)
{
if ((d=det_fmatrix(from)) == 0) {
printf("can't build inverse");
exit(0);
}
for (i=0;i<3;i++)
{
for (j=0;j<3;j++)
{
for (i=0;i<3;i++) {
for (j=0;j<3;j++) {
int i1=(i+1)%3;
int i2=(i+2)%3;
int j1=(j+1)%3;
@ -535,8 +522,7 @@ DO_INLINE fmatrix3x3 *create_bfmatrix(unsigned int verts, unsigned int springs)
/* delete big matrix */
DO_INLINE void del_bfmatrix(fmatrix3x3 *matrix)
{
if (matrix != NULL)
{
if (matrix != NULL) {
MEM_freeN (matrix);
}
}
@ -554,8 +540,7 @@ DO_INLINE void init_bfmatrix(fmatrix3x3 *matrix, float m3[3][3])
{
unsigned int i;
for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
{
for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) {
cp_fmatrix(matrix[i].m, m3);
}
}
@ -567,12 +552,10 @@ DO_INLINE void initdiag_bfmatrix(fmatrix3x3 *matrix, float m3[3][3])
unsigned int i,j;
float tmatrix[3][3] = {{0,0,0},{0,0,0},{0,0,0}};
for (i = 0; i < matrix[0].vcount; i++)
{
for (i = 0; i < matrix[0].vcount; i++) {
cp_fmatrix(matrix[i].m, m3);
}
for (j = matrix[0].vcount; j < matrix[0].vcount+matrix[0].scount; j++)
{
for (j = matrix[0].vcount; j < matrix[0].vcount+matrix[0].scount; j++) {
cp_fmatrix(matrix[j].m, tmatrix);
}
}
@ -581,8 +564,7 @@ DO_INLINE void initdiag_bfmatrix(fmatrix3x3 *matrix, float m3[3][3])
DO_INLINE void mul_bfmatrix_S(fmatrix3x3 *matrix, float scalar)
{
unsigned int i = 0;
for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
{
for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) {
mul_fmatrix_S(matrix[i].m, scalar);
}
}
@ -601,15 +583,13 @@ DO_INLINE void mul_bfmatrix_lfvector( float (*to)[3], fmatrix3x3 *from, lfVector
{
#pragma omp section
{
for (i = from[0].vcount; i < from[0].vcount+from[0].scount; i++)
{
for (i = from[0].vcount; i < from[0].vcount+from[0].scount; i++) {
muladd_fmatrix_fvector(to[from[i].c], from[i].m, fLongVector[from[i].r]);
}
}
#pragma omp section
{
for (i = 0; i < from[0].vcount+from[0].scount; i++)
{
for (i = 0; i < from[0].vcount+from[0].scount; i++) {
muladd_fmatrix_fvector(temp[from[i].r], from[i].m, fLongVector[from[i].c]);
}
}
@ -627,8 +607,7 @@ DO_INLINE void mul_prevfmatrix_lfvector( float (*to)[3], fmatrix3x3 *from, lfVec
{
unsigned int i = 0;
for (i = 0; i < from[0].vcount; i++)
{
for (i = 0; i < from[0].vcount; i++) {
mul_fmatrix_fvector(to[from[i].r], from[i].m, fLongVector[from[i].c]);
}
}
@ -639,8 +618,7 @@ DO_INLINE void add_bfmatrix_bfmatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmatrix
unsigned int i = 0;
/* process diagonal elements */
for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
{
for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) {
add_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m);
}
@ -651,8 +629,7 @@ DO_INLINE void addadd_bfmatrix_bfmatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmat
unsigned int i = 0;
/* process diagonal elements */
for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
{
for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) {
addadd_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m);
}
@ -663,8 +640,7 @@ DO_INLINE void subadd_bfmatrix_bfmatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmat
unsigned int i = 0;
/* process diagonal elements */
for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
{
for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) {
subadd_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m);
}
@ -675,8 +651,7 @@ DO_INLINE void sub_bfmatrix_bfmatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmatrix
unsigned int i = 0;
/* process diagonal elements */
for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
{
for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) {
sub_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m);
}
@ -687,8 +662,7 @@ DO_INLINE void sub_bfmatrix_Smatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmatrix3
unsigned int i = 0;
/* process diagonal elements */
for (i = 0; i < matrix[0].vcount; i++)
{
for (i = 0; i < matrix[0].vcount; i++) {
sub_fmatrix_fmatrix(to[matrix[i].c].m, from[matrix[i].c].m, matrix[i].m);
}
@ -699,8 +673,7 @@ DO_INLINE void addsub_bfmatrix_bfmatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmat
unsigned int i = 0;
/* process diagonal elements */
for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
{
for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) {
addsub_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m);
}
@ -713,8 +686,7 @@ DO_INLINE void subadd_bfmatrixS_bfmatrixS( fmatrix3x3 *to, fmatrix3x3 *from, flo
unsigned int i = 0;
/* process diagonal elements */
for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
{
for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) {
subadd_fmatrixS_fmatrixS(to[i].m, from[i].m, aS, matrix[i].m, bS);
}
@ -772,12 +744,10 @@ int implicit_init (Object *UNUSED(ob), ClothModifierData *clmd)
id->dV = create_lfvector(cloth->numverts);
id->z = create_lfvector(cloth->numverts);
for (i=0;i<cloth->numverts;i++)
{
for (i=0;i<cloth->numverts;i++) {
id->A[i].r = id->A[i].c = id->dFdV[i].r = id->dFdV[i].c = id->dFdX[i].r = id->dFdX[i].c = id->P[i].c = id->P[i].r = id->Pinv[i].c = id->Pinv[i].r = id->bigI[i].c = id->bigI[i].r = id->M[i].r = id->M[i].c = i;
if (verts [i].flags & CLOTH_VERT_FLAG_PINNED)
{
if (verts [i].flags & CLOTH_VERT_FLAG_PINNED) {
id->S[pinned].pinned = 1;
id->S[pinned].c = id->S[pinned].r = i;
pinned++;
@ -791,8 +761,7 @@ int implicit_init (Object *UNUSED(ob), ClothModifierData *clmd)
// init springs
search = cloth->springs;
for (i=0;i<cloth->numsprings;i++)
{
for (i=0;i<cloth->numsprings;i++) {
spring = search->link;
// dFdV_start[i].r = big_I[i].r = big_zero[i].r =
@ -810,8 +779,7 @@ int implicit_init (Object *UNUSED(ob), ClothModifierData *clmd)
initdiag_bfmatrix(id->bigI, I);
for (i = 0; i < cloth->numverts; i++)
{
for (i = 0; i < cloth->numverts; i++) {
copy_v3_v3(id->X[i], verts[i].x);
}
@ -823,12 +791,10 @@ int implicit_free (ClothModifierData *clmd)
Cloth *cloth;
cloth = (Cloth *)clmd->clothObject;
if (cloth)
{
if (cloth) {
id = cloth->implicit;
if (id)
{
if (id) {
del_bfmatrix(id->A);
del_bfmatrix(id->dFdV);
del_bfmatrix(id->dFdX);
@ -886,12 +852,10 @@ DO_INLINE float fbstar_jacobi(float length, float L, float kb, float cb)
float tempfb = kb * fb(length, L);
float fbstar = cb * (length - L);
if (tempfb < fbstar)
{
if (tempfb < fbstar) {
return cb;
}
else
{
else {
return kb * fbderiv(length, L);
}
}
@ -900,8 +864,7 @@ DO_INLINE void filter(lfVector *V, fmatrix3x3 *S)
{
unsigned int i=0;
for (i=0;i<S[0].vcount;i++)
{
for (i = 0; i < S[0].vcount; i++) {
mul_fvector_fmatrix(V[S[i].r], V[S[i].r], S[i].m);
}
}
@ -936,8 +899,7 @@ static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z
s = dot_lfvector(r, r, numverts);
starget = s * sqrt(conjgrad_epsilon);
while (s>starget && conjgrad_loopcount < conjgrad_looplimit)
{
while (s>starget && conjgrad_loopcount < conjgrad_looplimit) {
// Mul(q,A,d); // q = A*d;
mul_bfmatrix_lfvector(q, lA, d);
@ -979,8 +941,7 @@ DO_INLINE void BuildPPinv(fmatrix3x3 *lA, fmatrix3x3 *P, fmatrix3x3 *Pinv)
// Take only the diagonal blocks of A
// #pragma omp parallel for private(i) if (lA[0].vcount > CLOTH_OPENMP_LIMIT)
for (i = 0; i<lA[0].vcount; i++)
{
for (i = 0; i<lA[0].vcount; i++) {
// block diagonalizer
cp_fmatrix(P[i].m, lA[i].m);
inverse_fmatrix(Pinv[i].m, P[i].m);
@ -1255,8 +1216,7 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
s->flags &= ~CLOTH_SPRING_FLAG_NEEDED;
if (length > ALMOST_ZERO)
{
if (length > ALMOST_ZERO) {
/*
if (length>L)
{
@ -1270,16 +1230,13 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
*/
mul_fvector_S(dir, extent, 1.0f/length);
}
else
{
else {
mul_fvector_S(dir, extent, 0.0f);
}
// calculate force of structural + shear springs
if ((s->type & CLOTH_SPRING_TYPE_STRUCTURAL) || (s->type & CLOTH_SPRING_TYPE_SHEAR))
{
if (length > L || no_compress)
{
if ((s->type & CLOTH_SPRING_TYPE_STRUCTURAL) || (s->type & CLOTH_SPRING_TYPE_SHEAR)) {
if (length > L || no_compress) {
s->flags |= CLOTH_SPRING_FLAG_NEEDED;
k = clmd->sim_parms->structural;
@ -1337,10 +1294,8 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
// dfdx_spring(s->dfdx, dir, length, 0.0, k);
// dfdv_damp(s->dfdv, dir, MIN2(1.0, (clmd->sim_parms->goalfrict/100.0)));
}
else // calculate force of bending springs
{
if (length < L)
{
else { /* calculate force of bending springs */
if (length < L) {
s->flags |= CLOTH_SPRING_FLAG_NEEDED;
k = clmd->sim_parms->bending;
@ -1358,10 +1313,8 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
DO_INLINE void cloth_apply_spring_force(ClothModifierData *UNUSED(clmd), ClothSpring *s, lfVector *lF, lfVector *UNUSED(X), lfVector *UNUSED(V), fmatrix3x3 *dFdV, fmatrix3x3 *dFdX)
{
if (s->flags & CLOTH_SPRING_FLAG_NEEDED)
{
if (!(s->type & CLOTH_SPRING_TYPE_BENDING))
{
if (s->flags & CLOTH_SPRING_FLAG_NEEDED) {
if (!(s->type & CLOTH_SPRING_TYPE_BENDING)) {
sub_fmatrix_fmatrix(dFdV[s->ij].m, dFdV[s->ij].m, s->dfdv);
sub_fmatrix_fmatrix(dFdV[s->kl].m, dFdV[s->kl].m, s->dfdv);
add_fmatrix_fmatrix(dFdV[s->matrix_index].m, dFdV[s->matrix_index].m, s->dfdv);
@ -1486,8 +1439,7 @@ static void hair_velocity_smoothing(ClothModifierData *clmd, lfVector *lF, lfVec
}
/* gather colliders */
if (colliders && collfac > 0.0f) for (col = colliders->first; col; col = col->next)
{
if (colliders && collfac > 0.0f) for (col = colliders->first; col; col = col->next) {
MVert *loc0 = col->collmd->x;
MVert *loc1 = col->collmd->xnew;
float vel[3];
@ -1593,8 +1545,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec
/* multiply lF with mass matrix
* force = mass * acceleration (in this case: gravity)
*/
for (i = 0; i < numverts; i++)
{
for (i = 0; i < numverts; i++) {
float temp[3];
copy_v3_v3(temp, lF[i]);
mul_fmatrix_fvector(lF[i], M[i].m, temp);
@ -1603,8 +1554,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec
submul_lfvectorS(lF, lV, spring_air, numverts);
/* handle external forces like wind */
if (effectors)
{
if (effectors) {
// 0 = force, 1 = normalized force
winvec = create_lfvector(cloth->numverts);
@ -1612,14 +1562,12 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec
printf("winvec: out of memory in implicit.c\n");
// precalculate wind forces
for (i = 0; i < cloth->numverts; i++)
{
for (i = 0; i < cloth->numverts; i++) {
pd_point_from_loc(clmd->scene, (float*)lX[i], (float*)lV[i], i, &epoint);
pdDoEffectors(effectors, NULL, clmd->sim_parms->effector_weights, &epoint, winvec[i], NULL);
}
for (i = 0; i < cloth->numfaces; i++)
{
for (i = 0; i < cloth->numfaces; i++) {
float trinormal[3]={0,0,0}; // normalized triangle normal
float triunnormal[3]={0,0,0}; // not-normalized-triangle normal
float tmp[3]={0,0,0};
@ -1650,8 +1598,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec
VECADDS(lF[mfaces[i].v3], lF[mfaces[i].v3], tmp, factor);
// add wind from v4
if (mfaces[i].v4)
{
if (mfaces[i].v4) {
copy_v3_v3(tmp, trinormal);
mul_v3_fl(tmp, calculateVertexWindForce(winvec[mfaces[i].v4], triunnormal));
VECADDS(lF[mfaces[i].v4], lF[mfaces[i].v4], tmp, factor);
@ -1692,8 +1639,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec
// calculate spring forces
search = cloth->springs;
while (search)
{
while (search) {
// only handle active springs
// if (((clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED) && !(springs[i].flags & CSPRING_FLAG_DEACTIVATE))|| !(clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED)) {}
cloth_calc_spring_force(clmd, search->link, lF, lX, lV, dFdV, dFdX, time);
@ -1703,8 +1649,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec
// apply spring forces
search = cloth->springs;
while (search)
{
while (search) {
// only handle active springs
// if (((clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED) && !(springs[i].flags & CSPRING_FLAG_DEACTIVATE))|| !(clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED))
cloth_apply_spring_force(clmd, search->link, lF, lX, lV, dFdV, dFdX);
@ -1836,21 +1781,17 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
Implicit_Data *id = cloth->implicit;
int do_extra_solve;
if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) /* do goal stuff */
{
for (i = 0; i < numverts; i++)
{
if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) { /* do goal stuff */
for (i = 0; i < numverts; i++) {
// update velocities with constrained velocities from pinned verts
if (verts [i].flags & CLOTH_VERT_FLAG_PINNED)
{
if (verts [i].flags & CLOTH_VERT_FLAG_PINNED) {
sub_v3_v3v3(id->V[i], verts[i].xconst, verts[i].xold);
// mul_v3_fl(id->V[i], clmd->sim_parms->stepsPerFrame);
}
}
}
while (step < tf)
{
while (step < tf) {
// damping velocity for artistic reasons
mul_lfvectorS(id->V, id->V, clmd->sim_parms->vel_damping, numverts);
@ -1864,13 +1805,10 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
add_lfvector_lfvectorS(id->Xnew, id->X, id->Vnew, dt, numverts);
/* move pinned verts to correct position */
for (i = 0; i < numverts; i++)
{
if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL)
{
if (verts [i].flags & CLOTH_VERT_FLAG_PINNED)
{
float tvect[3] = {.0,.0,.0};
for (i = 0; i < numverts; i++) {
if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) {
if (verts[i].flags & CLOTH_VERT_FLAG_PINNED) {
float tvect[3] = {0.0f, 0.0f, 0.0f};
sub_v3_v3v3(tvect, verts[i].xconst, verts[i].xold);
mul_fvector_S(tvect, tvect, step+dt);
VECADD(tvect, tvect, verts[i].xold);
@ -1881,14 +1819,12 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
copy_v3_v3(verts[i].txold, id->X[i]);
}
if (clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_ENABLED && clmd->clothObject->bvhtree)
{
if (clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_ENABLED && clmd->clothObject->bvhtree) {
// collisions
// itstart();
// update verts to current positions
for (i = 0; i < numverts; i++)
{
for (i = 0; i < numverts; i++) {
copy_v3_v3(verts[i].tx, id->Xnew[i]);
sub_v3_v3v3(verts[i].tv, verts[i].tx, verts[i].txold);
@ -1904,8 +1840,7 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
do_extra_solve = cloth_bvh_objcollision(ob, clmd, step/clmd->sim_parms->timescale, dt/clmd->sim_parms->timescale);
// copy corrected positions back to simulation
for (i = 0; i < numverts; i++)
{
for (i = 0; i < numverts; i++) {
// correct velocity again, just to be sure we had to change it due to adaptive collisions
sub_v3_v3v3(verts[i].tv, verts[i].tx, id->X[i]);
}
@ -1913,11 +1848,9 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
//if (do_extra_solve)
// cloth_calc_helper_forces(ob, clmd, initial_cos, step/clmd->sim_parms->timescale, dt/clmd->sim_parms->timescale);
for (i = 0; i < numverts; i++)
{
for (i = 0; i < numverts; i++) {
if (do_extra_solve)
{
if (do_extra_solve) {
if ((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) && (verts [i].flags & CLOTH_VERT_FLAG_PINNED))
continue;
@ -1933,8 +1866,7 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
// if there were collisions, advance the velocity from v_n+1/2 to v_n+1
if (do_extra_solve)
{
if (do_extra_solve) {
// V = Vnew;
cp_lfvector(id->V, id->Vnew, numverts);
@ -1944,8 +1876,7 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
simulate_implicit_euler(id->Vnew, id->X, id->V, id->F, id->dFdV, id->dFdX, dt / 2.0f, id->A, id->B, id->dV, id->S, id->z, id->olddV, id->P, id->Pinv, id->M, id->bigI);
}
}
else
{
else {
// X = Xnew;
cp_lfvector(id->X, id->Xnew, numverts);
}
@ -1959,16 +1890,13 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
step += dt;
}
for (i = 0; i < numverts; i++)
{
if ((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) && (verts [i].flags & CLOTH_VERT_FLAG_PINNED))
{
for (i = 0; i < numverts; i++) {
if ((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) && (verts [i].flags & CLOTH_VERT_FLAG_PINNED)) {
copy_v3_v3(verts[i].txold, verts[i].xconst); // TODO: test --> should be .x
copy_v3_v3(verts[i].x, verts[i].xconst);
copy_v3_v3(verts[i].v, id->V[i]);
}
else
{
else {
copy_v3_v3(verts[i].txold, id->X[i]);
copy_v3_v3(verts[i].x, id->X[i]);
copy_v3_v3(verts[i].v, id->V[i]);
@ -1987,8 +1915,7 @@ void implicit_set_positions (ClothModifierData *clmd)
unsigned int numverts = cloth->numverts, i;
Implicit_Data *id = cloth->implicit;
for (i = 0; i < numverts; i++)
{
for (i = 0; i < numverts; i++) {
copy_v3_v3(id->X[i], verts[i].x);
copy_v3_v3(id->V[i], verts[i].v);
}

@ -1906,7 +1906,7 @@ void do_versions_ipos_to_animato(Main *main)
AnimData *adt= BKE_id_add_animdata(id);
SEQ_BEGIN(ed, seq) {
SEQ_BEGIN (ed, seq) {
IpoCurve *icu = (seq->ipo) ? seq->ipo->curve.first : NULL;
short adrcode = SEQ_FAC1;

@ -1594,7 +1594,7 @@ void curve_to_key(Curve *cu, KeyBlock *kb, ListBase *nurb)
int a, tot;
/* count */
tot = count_curveverts(nurb);
tot = BKE_nurbList_verts_count(nurb);
if (tot == 0) return;
if (kb->data) MEM_freeN(kb->data);
@ -1647,7 +1647,7 @@ void key_to_curve(KeyBlock *kb, Curve *UNUSED(cu), ListBase *nurb)
nu = nurb->first;
fp = kb->data;
tot = count_curveverts(nurb);
tot = BKE_nurbList_verts_count(nurb);
tot = MIN2(kb->totelem, tot);
@ -1742,7 +1742,7 @@ float (*key_to_vertcos(Object * ob, KeyBlock * kb))[3]
}
else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
Curve *cu = (Curve *)ob->data;
tot = count_curveverts(&cu->nurb);
tot = BKE_nurbList_verts_count(&cu->nurb);
}
if (tot == 0) return NULL;
@ -1822,7 +1822,7 @@ void vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3])
else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
Curve *cu = (Curve *)ob->data;
elemsize = cu->key->elemsize;
tot = count_curveverts(&cu->nurb);
tot = BKE_nurbList_verts_count(&cu->nurb);
}
if (tot == 0) {

@ -342,7 +342,7 @@ void init_latt_deform(Object *oblatt, Object *ob)
}
}
void calc_latt_deform(Object *ob, float *co, float weight)
void calc_latt_deform(Object *ob, float co[3], float weight)
{
Lattice *lt= ob->data;
float u, v, w, tu[4], tv[4], tw[4];

@ -182,7 +182,7 @@ int id_make_local(ID *id, int test)
if (id->flag & LIB_INDIRECT)
return 0;
switch(GS(id->name)) {
switch (GS(id->name)) {
case ID_SCE:
return 0; /* not implemented */
case ID_LI:
@ -198,12 +198,12 @@ int id_make_local(ID *id, int test)
return 1;
case ID_CU:
if (!test) {
make_local_curve((Curve*)id);
BKE_curve_make_local((Curve*)id);
make_local_key(((Curve*)id)->key);
}
return 1;
case ID_MB:
if (!test) make_local_mball((MetaBall*)id);
if (!test) BKE_metaball_make_local((MetaBall*)id);
return 1;
case ID_MA:
if (!test) make_local_material((Material*)id);
@ -279,7 +279,7 @@ int id_copy(ID *id, ID **newid, int test)
/* conventions:
* - make shallow copy, only this ID block
* - id.us of the new ID is set to 1 */
switch(GS(id->name)) {
switch (GS(id->name)) {
case ID_SCE:
return 0; /* can't be copied from here */
case ID_LI:
@ -291,10 +291,10 @@ int id_copy(ID *id, ID **newid, int test)
if (!test) *newid= (ID*)copy_mesh((Mesh*)id);
return 1;
case ID_CU:
if (!test) *newid= (ID*)copy_curve((Curve*)id);
if (!test) *newid= (ID*)BKE_curve_copy((Curve*)id);
return 1;
case ID_MB:
if (!test) *newid= (ID*)copy_mball((MetaBall*)id);
if (!test) *newid= (ID*)BKE_metaball_copy((MetaBall*)id);
return 1;
case ID_MA:
if (!test) *newid= (ID*)copy_material((Material*)id);
@ -368,7 +368,7 @@ int id_unlink(ID *id, int test)
Main *mainlib= G.main;
ListBase *lb;
switch(GS(id->name)) {
switch (GS(id->name)) {
case ID_TXT:
if (test) return 1;
unlink_text(mainlib, (Text*)id);
@ -425,7 +425,7 @@ int id_single_user(bContext *C, ID *id, PointerRNA *ptr, PropertyRNA *prop)
ListBase *which_libbase(Main *mainlib, short type)
{
switch( type ) {
switch ( type ) {
case ID_SCE:
return &(mainlib->scene);
case ID_LI:
@ -589,7 +589,7 @@ static ID *alloc_libblock_notest(short type)
{
ID *id= NULL;
switch( type ) {
switch ( type ) {
case ID_SCE:
id= MEM_callocN(sizeof(Scene), "scene");
break;
@ -796,7 +796,7 @@ void free_libblock(ListBase *lb, void *idv)
BPY_id_release(id);
#endif
switch( GS(id->name) ) { /* GetShort from util.h */
switch ( GS(id->name) ) { /* GetShort from util.h */
case ID_SCE:
free_scene((Scene *)id);
break;
@ -810,10 +810,10 @@ void free_libblock(ListBase *lb, void *idv)
free_mesh((Mesh *)id, 1);
break;
case ID_CU:
free_curve((Curve *)id);
BKE_curve_free((Curve *)id);
break;
case ID_MB:
free_mball((MetaBall *)id);
BKE_metaball_free((MetaBall *)id);
break;
case ID_MA:
free_material((Material *)id);
@ -886,7 +886,7 @@ void free_libblock(ListBase *lb, void *idv)
free_gpencil_data((bGPdata *)id);
break;
case ID_MC:
free_movieclip((MovieClip *)id);
BKE_movieclip_free((MovieClip *)id);
break;
}
@ -1010,8 +1010,7 @@ static void IDnames_to_dyn_pupstring(DynStr *pupds, ListBase *lb, ID *link, shor
BLI_dynstr_append(pupds, numstr);
/* icon */
switch(GS(id->name))
{
switch (GS(id->name)) {
case ID_MA: /* fall through */
case ID_TE: /* fall through */
case ID_IM: /* fall through */

@ -493,7 +493,7 @@ short *give_totcolp(Object *ob)
/* same as above but for ID's */
Material ***give_matarar_id(ID *id)
{
switch(GS(id->name)) {
switch (GS(id->name)) {
case ID_ME:
return &(((Mesh *)id)->mat);
break;
@ -509,7 +509,7 @@ Material ***give_matarar_id(ID *id)
short *give_totcolp_id(ID *id)
{
switch(GS(id->name)) {
switch (GS(id->name)) {
case ID_ME:
return &(((Mesh *)id)->totcol);
break;
@ -525,12 +525,12 @@ short *give_totcolp_id(ID *id)
static void data_delete_material_index_id(ID *id, short index)
{
switch(GS(id->name)) {
switch (GS(id->name)) {
case ID_ME:
mesh_delete_material_index((Mesh *)id, index);
break;
case ID_CU:
curve_delete_material_index((Curve *)id, index);
BKE_curve_delete_material_index((Curve *)id, index);
break;
case ID_MB:
/* meta-elems don't have materials atm */

@ -65,6 +65,106 @@
#include "BKE_object.h"
#include "BKE_material.h"
/* Data types */
typedef struct point { /* a three-dimensional point */
float x, y, z; /* its coordinates */
} MB_POINT;
typedef struct vertex { /* surface vertex */
MB_POINT position, normal; /* position and surface normal */
} VERTEX;
typedef struct vertices { /* list of vertices in polygonization */
int count, max; /* # vertices, max # allowed */
VERTEX *ptr; /* dynamically allocated */
} VERTICES;
typedef struct corner { /* corner of a cube */
int i, j, k; /* (i, j, k) is index within lattice */
float x, y, z, value; /* location and function value */
struct corner *next;
} CORNER;
typedef struct cube { /* partitioning cell (cube) */
int i, j, k; /* lattice location of cube */
CORNER *corners[8]; /* eight corners */
} CUBE;
typedef struct cubes { /* linked list of cubes acting as stack */
CUBE cube; /* a single cube */
struct cubes *next; /* remaining elements */
} CUBES;
typedef struct centerlist { /* list of cube locations */
int i, j, k; /* cube location */
struct centerlist *next; /* remaining elements */
} CENTERLIST;
typedef struct edgelist { /* list of edges */
int i1, j1, k1, i2, j2, k2; /* edge corner ids */
int vid; /* vertex id */
struct edgelist *next; /* remaining elements */
} EDGELIST;
typedef struct intlist { /* list of integers */
int i; /* an integer */
struct intlist *next; /* remaining elements */
} INTLIST;
typedef struct intlists { /* list of list of integers */
INTLIST *list; /* a list of integers */
struct intlists *next; /* remaining elements */
} INTLISTS;
typedef struct process { /* parameters, function, storage */
/* what happens here? floats, I think. */
/* float (*function)(void); */ /* implicit surface function */
float (*function)(float, float, float);
float size, delta; /* cube size, normal delta */
int bounds; /* cube range within lattice */
CUBES *cubes; /* active cubes */
VERTICES vertices; /* surface vertices */
CENTERLIST **centers; /* cube center hash table */
CORNER **corners; /* corner value hash table */
EDGELIST **edges; /* edge and vertex id hash table */
} PROCESS;
/* dividing scene using octal tree makes polygonisation faster */
typedef struct ml_pointer {
struct ml_pointer *next, *prev;
struct MetaElem *ml;
} ml_pointer;
typedef struct octal_node {
struct octal_node *nodes[8]; /* children of current node */
struct octal_node *parent; /* parent of current node */
struct ListBase elems; /* ListBase of MetaElem pointers (ml_pointer) */
float x_min, y_min, z_min; /* 1st border point */
float x_max, y_max, z_max; /* 7th border point */
float x,y,z; /* center of node */
int pos, neg; /* number of positive and negative MetaElements in the node */
int count; /* number of MetaElems, which belongs to the node */
} octal_node;
typedef struct octal_tree {
struct octal_node *first; /* first node */
int pos, neg; /* number of positive and negative MetaElements in the scene */
short depth; /* number of scene subdivision */
} octal_tree;
struct pgn_elements {
struct pgn_elements *next, *prev;
char *data;
};
/* Forward declarations */
static int vertid(CORNER *c1, CORNER *c2, PROCESS *p, MetaBall *mb);
static int setcenter(CENTERLIST *table[], int i, int j, int k);
static CORNER *setcorner(PROCESS* p, int i, int j, int k);
static void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2,
float (*function)(float, float, float), MB_POINT *p, MetaBall *mb, int f);
/* Global variables */
static float thresh= 0.6f;
@ -73,7 +173,7 @@ static MetaElem **mainb;
static octal_tree *metaball_tree = NULL;
/* Functions */
void unlink_mball(MetaBall *mb)
void BKE_metaball_unlink(MetaBall *mb)
{
int a;
@ -85,9 +185,9 @@ void unlink_mball(MetaBall *mb)
/* do not free mball itself */
void free_mball(MetaBall *mb)
void BKE_metaball_free(MetaBall *mb)
{
unlink_mball(mb);
BKE_metaball_unlink(mb);
if (mb->adt) {
BKE_free_animdata((ID *)mb);
@ -99,7 +199,7 @@ void free_mball(MetaBall *mb)
if (mb->disp.first) freedisplist(&mb->disp);
}
MetaBall *add_mball(const char *name)
MetaBall *BKE_metaball_add(const char *name)
{
MetaBall *mb;
@ -115,7 +215,7 @@ MetaBall *add_mball(const char *name)
return mb;
}
MetaBall *copy_mball(MetaBall *mb)
MetaBall *BKE_metaball_copy(MetaBall *mb)
{
MetaBall *mbn;
int a;
@ -143,7 +243,7 @@ static void extern_local_mball(MetaBall *mb)
}
}
void make_local_mball(MetaBall *mb)
void BKE_metaball_make_local(MetaBall *mb)
{
Main *bmain= G.main;
Object *ob;
@ -174,7 +274,7 @@ void make_local_mball(MetaBall *mb)
extern_local_mball(mb);
}
else if (is_local && is_lib) {
MetaBall *mb_new= copy_mball(mb);
MetaBall *mb_new= BKE_metaball_copy(mb);
mb_new->id.us= 0;
/* Remap paths of new ID using old library as base. */
@ -194,7 +294,7 @@ void make_local_mball(MetaBall *mb)
/* most simple meta-element adding function
* don't do context manipulation here (rna uses) */
MetaElem *add_metaball_element(MetaBall *mb, const int type)
MetaElem *BKE_metaball_element_add(MetaBall *mb, const int type)
{
MetaElem *ml= MEM_callocN(sizeof(MetaElem), "metaelem");
@ -204,7 +304,7 @@ MetaElem *add_metaball_element(MetaBall *mb, const int type)
ml->s= 2.0;
ml->flag= MB_SCALE_RAD;
switch(type) {
switch (type) {
case MB_BALL:
ml->type = MB_BALL;
ml->expx= ml->expy= ml->expz= 1.0;
@ -246,7 +346,7 @@ MetaElem *add_metaball_element(MetaBall *mb, const int type)
* basic MetaBall (usually with name Meta). All other MetaBalls (with
* names Meta.001, Meta.002, etc) are included in this Bounding Box.
*/
void tex_space_mball(Object *ob)
void BKE_metaball_tex_space_calc(Object *ob)
{
DispList *dl;
BoundBox *bb;
@ -290,7 +390,7 @@ void tex_space_mball(Object *ob)
boundbox_set_from_min_max(bb, min, max);
}
float *make_orco_mball(Object *ob, ListBase *dispbase)
float *BKE_metaball_make_orco(Object *ob, ListBase *dispbase)
{
BoundBox *bb;
DispList *dl;
@ -342,7 +442,7 @@ float *make_orco_mball(Object *ob, ListBase *dispbase)
* It test last character of Object ID name. If last character
* is digit it return 0, else it return 1.
*/
int is_basis_mball(Object *ob)
int BKE_metaball_is_basis(Object *ob)
{
int len;
@ -353,7 +453,7 @@ int is_basis_mball(Object *ob)
}
/* return nonzero if ob1 is a basis mball for ob */
int is_mball_basis_for (Object *ob1, Object *ob2)
int BKE_metaball_is_basis_for (Object *ob1, Object *ob2)
{
int basis1nr, basis2nr;
char basis1name[MAX_ID_NAME], basis2name[MAX_ID_NAME];
@ -361,7 +461,7 @@ int is_mball_basis_for (Object *ob1, Object *ob2)
BLI_split_name_num(basis1name, &basis1nr, ob1->id.name+2, '.');
BLI_split_name_num(basis2name, &basis2nr, ob2->id.name+2, '.');
if (!strcmp(basis1name, basis2name)) return is_basis_mball(ob1);
if (!strcmp(basis1name, basis2name)) return BKE_metaball_is_basis(ob1);
else return 0;
}
@ -371,7 +471,7 @@ int is_mball_basis_for (Object *ob1, Object *ob2)
* are copied to all metaballs in same "group" (metaballs with same base name: MBall,
* MBall.001, MBall.002, etc). The most important is to copy properties to the base metaball,
* because this metaball influence polygonisation of metaballs. */
void copy_mball_properties(Scene *scene, Object *active_object)
void BKE_metaball_properties_copy(Scene *scene, Object *active_object)
{
Scene *sce_iter= scene;
Base *base;
@ -416,7 +516,7 @@ void copy_mball_properties(Scene *scene, Object *active_object)
*
* warning!, is_basis_mball() can fail on returned object, see long note above.
*/
Object *find_basis_mball(Scene *scene, Object *basis)
Object *BKE_metaball_basis_find(Scene *scene, Object *basis)
{
Scene *sce_iter= scene;
Base *base;
@ -522,14 +622,14 @@ Object *find_basis_mball(Scene *scene, Object *basis)
/* **************** POLYGONIZATION ************************ */
void calc_mballco(MetaElem *ml, float vec[3])
static void calc_mballco(MetaElem *ml, float vec[3])
{
if (ml->mat) {
mul_m4_v3((float ( * )[4])ml->mat, vec);
mul_m4_v3((float (*)[4])ml->mat, vec);
}
}
float densfunc(MetaElem *ball, float x, float y, float z)
static float densfunc(MetaElem *ball, float x, float y, float z)
{
float dist2 = 0.0, dx, dy, dz;
float vec[3];
@ -537,7 +637,7 @@ float densfunc(MetaElem *ball, float x, float y, float z)
vec[0]= x;
vec[1]= y;
vec[2]= z;
mul_m4_v3((float ( * )[4])ball->imat, vec);
mul_m4_v3((float (*)[4])ball->imat, vec);
dx= vec[0];
dy= vec[1];
dz= vec[2];
@ -605,7 +705,7 @@ float densfunc(MetaElem *ball, float x, float y, float z)
}
}
octal_node* find_metaball_octal_node(octal_node *node, float x, float y, float z, short depth)
static octal_node* find_metaball_octal_node(octal_node *node, float x, float y, float z, short depth)
{
if (!depth) return node;
@ -673,7 +773,7 @@ octal_node* find_metaball_octal_node(octal_node *node, float x, float y, float z
return node;
}
float metaball(float x, float y, float z)
static float metaball(float x, float y, float z)
/* float x, y, z; */
{
struct octal_node *node;
@ -713,7 +813,7 @@ static int *indices=NULL;
static int totindex, curindex;
void accum_mballfaces(int i1, int i2, int i3, int i4)
static void accum_mballfaces(int i1, int i2, int i3, int i4)
{
int *newi, *cur;
/* static int i=0; I would like to delete altogether, but I don't dare to, yet */
@ -746,7 +846,7 @@ void accum_mballfaces(int i1, int i2, int i3, int i4)
}
/* ******************* MEMORY MANAGEMENT *********************** */
void *new_pgn_element(int size)
static void *new_pgn_element(int size)
{
/* during polygonize 1000s of elements are allocated
* and never freed in between. Freeing only done at the end.
@ -789,7 +889,7 @@ void *new_pgn_element(int size)
return cur->data;
}
void freepolygonize(PROCESS *p)
static void freepolygonize(PROCESS *p)
{
MEM_freeN(p->corners);
MEM_freeN(p->edges);
@ -832,7 +932,7 @@ static int rightface[12] = {
/* docube: triangulate the cube directly, without decomposition */
void docube(CUBE *cube, PROCESS *p, MetaBall *mb)
static void docube(CUBE *cube, PROCESS *p, MetaBall *mb)
{
INTLISTS *polys;
CORNER *c1, *c2;
@ -853,7 +953,7 @@ void docube(CUBE *cube, PROCESS *p, MetaBall *mb)
count++;
}
if (count>2) {
switch(count) {
switch (count) {
case 3:
accum_mballfaces(indexar[2], indexar[1], indexar[0], 0);
break;
@ -900,7 +1000,7 @@ void docube(CUBE *cube, PROCESS *p, MetaBall *mb)
* if surface crosses face, compute other four corners of adjacent cube
* and add new cube to cube stack */
void testface(int i, int j, int k, CUBE* old, int bit, int c1, int c2, int c3, int c4, PROCESS *p)
static void testface(int i, int j, int k, CUBE* old, int bit, int c1, int c2, int c3, int c4, PROCESS *p)
{
CUBE newc;
CUBES *oldcubes = p->cubes;
@ -951,7 +1051,7 @@ void testface(int i, int j, int k, CUBE* old, int bit, int c1, int c2, int c3, i
/* setcorner: return corner with the given lattice location
* set (and cache) its function value */
CORNER *setcorner (PROCESS* p, int i, int j, int k)
static CORNER *setcorner (PROCESS* p, int i, int j, int k)
{
/* for speed, do corner value caching here */
CORNER *c;
@ -986,7 +1086,7 @@ CORNER *setcorner (PROCESS* p, int i, int j, int k)
/* nextcwedge: return next clockwise edge from given edge around given face */
int nextcwedge (int edge, int face)
static int nextcwedge (int edge, int face)
{
switch (edge) {
case LB:
@ -1020,7 +1120,7 @@ int nextcwedge (int edge, int face)
/* otherface: return face adjoining edge that is not the given face */
int otherface (int edge, int face)
static int otherface (int edge, int face)
{
int other = leftface[edge];
return face == other? rightface[edge] : other;
@ -1029,7 +1129,7 @@ int otherface (int edge, int face)
/* makecubetable: create the 256 entry table for cubical polygonization */
void makecubetable (void)
static void makecubetable (void)
{
static int isdone= 0;
int i, e, c, done[12], pos[8];
@ -1070,7 +1170,7 @@ void makecubetable (void)
}
}
void BKE_freecubetable(void)
void BKE_metaball_cubeTable_free(void)
{
int i;
INTLISTS *lists, *nlists;
@ -1100,7 +1200,7 @@ void BKE_freecubetable(void)
/* setcenter: set (i,j,k) entry of table[]
* return 1 if already set; otherwise, set and return 0 */
int setcenter(CENTERLIST *table[], int i, int j, int k)
static int setcenter(CENTERLIST *table[], int i, int j, int k)
{
int index;
CENTERLIST *newc, *l, *q;
@ -1125,7 +1225,7 @@ int setcenter(CENTERLIST *table[], int i, int j, int k)
/* setedge: set vertex id for edge */
void setedge (EDGELIST *table[],
static void setedge (EDGELIST *table[],
int i1, int j1,
int k1, int i2,
int j2, int k2,
@ -1161,7 +1261,7 @@ void setedge (EDGELIST *table[],
/* getedge: return vertex id for edge; return -1 if not set */
int getedge (EDGELIST *table[],
static int getedge (EDGELIST *table[],
int i1, int j1, int k1,
int i2, int j2, int k2)
{
@ -1179,10 +1279,13 @@ int getedge (EDGELIST *table[],
k2=t;
}
q = table[HASH(i1, j1, k1)+HASH(i2, j2, k2)];
for (; q != NULL; q = q->next)
for (; q != NULL; q = q->next) {
if (q->i1 == i1 && q->j1 == j1 && q->k1 == k1 &&
q->i2 == i2 && q->j2 == j2 && q->k2 == k2)
{
return q->vid;
}
}
return -1;
}
@ -1199,7 +1302,7 @@ int getedge (EDGELIST *table[],
/* addtovertices: add v to sequence of vertices */
void addtovertices (VERTICES *vertices, VERTEX v)
static void addtovertices (VERTICES *vertices, VERTEX v)
{
if (vertices->count == vertices->max) {
int i;
@ -1217,7 +1320,7 @@ void addtovertices (VERTICES *vertices, VERTEX v)
/* vnormal: compute unit length surface normal at point */
void vnormal (MB_POINT *point, PROCESS *p, MB_POINT *v)
static void vnormal (MB_POINT *point, PROCESS *p, MB_POINT *v)
{
float delta= 0.2f*p->delta;
float f = p->function(point->x, point->y, point->z);
@ -1267,7 +1370,7 @@ void vnormal (MB_POINT *point, PROCESS *p, MB_POINT *v)
}
int vertid (CORNER *c1, CORNER *c2, PROCESS *p, MetaBall *mb)
static int vertid (CORNER *c1, CORNER *c2, PROCESS *p, MetaBall *mb)
{
VERTEX v;
MB_POINT a, b;
@ -1296,7 +1399,7 @@ int vertid (CORNER *c1, CORNER *c2, PROCESS *p, MetaBall *mb)
/* converge: from two points of differing sign, converge to zero crossing */
/* watch it: p1 and p2 are used to calculate */
void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2,
static void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2,
float (*function)(float, float, float), MB_POINT *p, MetaBall *mb, int f)
{
int i = 0;
@ -1396,7 +1499,7 @@ void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2,
}
/* ************************************** */
void add_cube(PROCESS *mbproc, int i, int j, int k, int count)
static void add_cube(PROCESS *mbproc, int i, int j, int k, int count)
{
CUBES *ncube;
int n;
@ -1426,7 +1529,7 @@ void add_cube(PROCESS *mbproc, int i, int j, int k, int count)
}
void find_first_points(PROCESS *mbproc, MetaBall *mb, int a)
static void find_first_points(PROCESS *mbproc, MetaBall *mb, int a)
{
MB_POINT IN, in, OUT, out; /*point;*/
MetaElem *ml;
@ -1546,7 +1649,7 @@ void find_first_points(PROCESS *mbproc, MetaBall *mb, int a)
}
}
void polygonize(PROCESS *mbproc, MetaBall *mb)
static void polygonize(PROCESS *mbproc, MetaBall *mb)
{
CUBE c;
int a;
@ -1586,7 +1689,7 @@ void polygonize(PROCESS *mbproc, MetaBall *mb)
}
}
float init_meta(Scene *scene, Object *ob) /* return totsize */
static float init_meta(Scene *scene, Object *ob) /* return totsize */
{
Scene *sce_iter= scene;
Base *base;
@ -1738,7 +1841,7 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */
/* transformation of Metalem bb */
for (i=0; i<8; i++)
mul_m4_v3((float ( * )[4])mat, mainb[a]->bb->vec[i]);
mul_m4_v3((float (*)[4])mat, mainb[a]->bb->vec[i]);
/* find max and min of transformed bb */
for (i=0; i<8; i++) {
@ -1812,7 +1915,7 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */
/* if MetaElem lies in node, then node includes MetaElem pointer (ml_p)
* pointing at MetaElem (ml)
*/
void fill_metaball_octal_node(octal_node *node, MetaElem *ml, short i)
static void fill_metaball_octal_node(octal_node *node, MetaElem *ml, short i)
{
ml_pointer *ml_p;
@ -1844,7 +1947,7 @@ void fill_metaball_octal_node(octal_node *node, MetaElem *ml, short i)
* +------+------+
*
*/
void subdivide_metaball_octal_node(octal_node *node, float size_x, float size_y, float size_z, short depth)
static void subdivide_metaball_octal_node(octal_node *node, float size_x, float size_y, float size_z, short depth)
{
MetaElem *ml;
ml_pointer *ml_p;
@ -2101,7 +2204,7 @@ void subdivide_metaball_octal_node(octal_node *node, float size_x, float size_y,
}
/* free all octal nodes recursively */
void free_metaball_octal_node(octal_node *node)
static void free_metaball_octal_node(octal_node *node)
{
int a;
for (a=0;a<8;a++) {
@ -2112,7 +2215,7 @@ void free_metaball_octal_node(octal_node *node)
}
/* If scene include more then one MetaElem, then octree is used */
void init_metaball_octal_tree(int depth)
static void init_metaball_octal_tree(int depth)
{
struct octal_node *node;
ml_pointer *ml_p;
@ -2170,7 +2273,7 @@ void init_metaball_octal_tree(int depth)
subdivide_metaball_octal_node(node, size[0], size[1], size[2], metaball_tree->depth);
}
void metaball_polygonize(Scene *scene, Object *ob, ListBase *dispbase)
void BKE_metaball_polygonize(Scene *scene, Object *ob, ListBase *dispbase)
{
PROCESS mbproc;
MetaBall *mb;

@ -128,18 +128,22 @@ static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2
CustomDataLayer *l1, *l2;
int i, i1=0, i2=0, tot, j;
for (i=0; i<c1->totlayer; i++) {
if (ELEM7(c1->layers[i].type, CD_MVERT, CD_MEDGE, CD_MPOLY,
CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT))
for (i = 0; i < c1->totlayer; i++) {
if (ELEM7(c1->layers[i].type, CD_MVERT, CD_MEDGE, CD_MPOLY,
CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT))
{
i1++;
}
}
for (i=0; i<c2->totlayer; i++) {
if (ELEM7(c2->layers[i].type, CD_MVERT, CD_MEDGE, CD_MPOLY,
CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT))
for (i = 0; i < c2->totlayer; i++) {
if (ELEM7(c2->layers[i].type, CD_MVERT, CD_MEDGE, CD_MPOLY,
CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT))
{
i2++;
}
}
if (i1 != i2)
return MESHCMP_CDLAYERS_MISMATCH;
@ -148,12 +152,16 @@ static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2
i1 = 0; i2 = 0;
for (i=0; i < tot; i++) {
while (i1 < c1->totlayer && !ELEM7(l1->type, CD_MVERT, CD_MEDGE, CD_MPOLY,
CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT))
CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT))
{
i1++, l1++;
}
while (i2 < c2->totlayer && !ELEM7(l2->type, CD_MVERT, CD_MEDGE, CD_MPOLY,
CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT))
while (i2 < c2->totlayer && !ELEM7(l2->type, CD_MVERT, CD_MEDGE, CD_MPOLY,
CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT))
{
i2++, l2++;
}
if (l1->type == CD_MVERT) {
MVert *v1 = l1->data;
@ -327,7 +335,7 @@ static void mesh_ensure_tessellation_customdata(Mesh *me)
/* TODO - add some --debug-mesh option */
if (G.debug & G_DEBUG) {
/* note: this warning may be un-called for if we are inirializing the mesh for the
/* note: this warning may be un-called for if we are initializing the mesh for the
* first time from bmesh, rather then giving a warning about this we could be smarter
* and check if there was any data to begin with, for now just print the warning with
* some info to help troubleshoot whats going on - campbell */
@ -1104,7 +1112,7 @@ void mesh_strip_loose_polysloops(Mesh *me)
b++;
}
else {
/* XXX Theorically, we should be able to not do this, as no remaining poly
/* XXX Theoretically, we should be able to not do this, as no remaining poly
* should use any stripped loop. But for security's sake... */
new_idx[a] = -a;
}
@ -1128,7 +1136,7 @@ void mesh_strip_loose_edges(Mesh *me)
MEdge *e;
MLoop *l;
int a, b;
unsigned int *new_idx = MEM_mallocN(sizeof(int) * me->totedge, "strip_loose_edges old2new idx mapping for loops.");
unsigned int *new_idx = MEM_mallocN(sizeof(int) * me->totedge, __func__);
for (a = b = 0, e = me->medge; a < me->totedge; a++, e++) {
if (e->v1 != e->v2) {
@ -1154,6 +1162,8 @@ void mesh_strip_loose_edges(Mesh *me)
for (a = 0, l = me->mloop; a < me->totloop; a++, l++) {
l->e = new_idx[l->e];
}
MEM_freeN(new_idx);
}
void mball_to_mesh(ListBase *lb, Mesh *me)
@ -1606,7 +1616,7 @@ void mesh_to_curve(Scene *scene, Object *ob)
BLI_edgehash_free(eh, NULL);
if (edges.first) {
Curve *cu = add_curve(ob->id.name+2, OB_CURVE);
Curve *cu = BKE_curve_add(ob->id.name+2, OB_CURVE);
cu->flag |= CU_3D;
while (edges.first) {
@ -1865,8 +1875,8 @@ void mesh_calc_normals(MVert *mverts, int numVerts, MLoop *mloop, MPoly *mpolys,
BLI_array_empty(vertcos);
BLI_array_empty(vertnos);
BLI_array_growitems(vertcos, mp->totloop);
BLI_array_growitems(vertnos, mp->totloop);
BLI_array_grow_items(vertcos, mp->totloop);
BLI_array_grow_items(vertnos, mp->totloop);
for (j=0; j < mp->totloop; j++) {
int vindex = ml[j].v;
@ -1875,7 +1885,7 @@ void mesh_calc_normals(MVert *mverts, int numVerts, MLoop *mloop, MPoly *mpolys,
}
BLI_array_empty(edgevecbuf);
BLI_array_growitems(edgevecbuf, mp->totloop);
BLI_array_grow_items(edgevecbuf, mp->totloop);
accumulate_vertex_normals_poly(vertnos, pnors[i], vertcos, edgevecbuf, mp->totloop);
}
@ -2412,8 +2422,8 @@ int mesh_recalcTessellation(CustomData *fdata,
#ifdef USE_TESSFACE_SPEEDUP
#define ML_TO_MF(i1, i2, i3) \
BLI_array_growone(mface_to_poly_map); \
BLI_array_growone(mface); \
BLI_array_grow_one(mface_to_poly_map); \
BLI_array_grow_one(mface); \
mface_to_poly_map[mface_index] = poly_index; \
mf= &mface[mface_index]; \
/* set loop indices, transformed to vert indices later */ \
@ -2431,8 +2441,8 @@ int mesh_recalcTessellation(CustomData *fdata,
/* ALMOST IDENTICAL TO DEFINE ABOVE (see EXCEPTION) */
#define ML_TO_MF_QUAD() \
BLI_array_growone(mface_to_poly_map); \
BLI_array_growone(mface); \
BLI_array_grow_one(mface_to_poly_map); \
BLI_array_grow_one(mface); \
mface_to_poly_map[mface_index] = poly_index; \
mf= &mface[mface_index]; \
/* set loop indices, transformed to vert indices later */ \
@ -2490,10 +2500,10 @@ int mesh_recalcTessellation(CustomData *fdata,
totfilltri = BLI_edgefill(&sf_ctx, FALSE);
if (totfilltri) {
BLI_array_growitems(mface_to_poly_map, totfilltri);
BLI_array_growitems(mface, totfilltri);
BLI_array_grow_items(mface_to_poly_map, totfilltri);
BLI_array_grow_items(mface, totfilltri);
if (poly_orig_index) {
BLI_array_growitems(mface_orig_index, totfilltri);
BLI_array_grow_items(mface_orig_index, totfilltri);
}
for (f = sf_ctx.fillfacebase.first; f; f = f->next, mf++) {
@ -2662,7 +2672,7 @@ int mesh_mpoly_to_mface(struct CustomData *fdata, struct CustomData *ldata,
k = 0;
for (i = 0; i<totpoly; i++, mp++) {
if (ELEM(mp->totloop, 3, 4)) {
BLI_array_growone(mface);
BLI_array_grow_one(mface);
mf = &mface[k];
mf->mat_nr = mp->mat_nr;
@ -3052,10 +3062,13 @@ void mesh_flush_hidden_from_verts(const MVert *mvert,
for (i = 0; i < totedge; i++) {
MEdge *e = &medge[i];
if (mvert[e->v1].flag & ME_HIDE ||
mvert[e->v2].flag & ME_HIDE)
mvert[e->v2].flag & ME_HIDE)
{
e->flag |= ME_HIDE;
else
}
else {
e->flag &= ~ME_HIDE;
}
}
for (i = 0; i < totpoly; i++) {
MPoly *p = &mpoly[i];

@ -240,9 +240,23 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
PRINT(" loop %u has invalid vert reference (%u)\n", sp->loopstart + j, ml->v);
sp->invalid = TRUE;
}
mverts[ml->v].flag |= ME_VERT_TMP_TAG;
*v = ml->v;
}
/* is the same vertex used more then once */
if (!sp->invalid) {
v = sp->verts;
for (j = 0; j < mp->totloop; j++, v++) {
if ((mverts[*v].flag & ME_VERT_TMP_TAG) == 0) {
PRINT(" poly %u has duplicate vert reference at corner (%u)\n", i, j);
sp->invalid = TRUE;
}
mverts[*v].flag &= ~ME_VERT_TMP_TAG;
}
}
if (sp->invalid)
continue;

@ -117,8 +117,8 @@ void DM_to_bmesh_ex(DerivedMesh *dm, BMesh *bm)
BLI_array_empty(verts);
BLI_array_empty(edges);
BLI_array_growitems(verts, mp->totloop);
BLI_array_growitems(edges, mp->totloop);
BLI_array_grow_items(verts, mp->totloop);
BLI_array_grow_items(edges, mp->totloop);
ml = mloop + mp->loopstart;
for (j = 0; j < mp->totloop; j++, ml++) {

@ -450,7 +450,7 @@ static MovieClip *movieclip_alloc(const char *name)
* otherwise creates new.
* does not load ibuf itself
* pass on optional frame for #name images */
MovieClip *BKE_add_movieclip_file(const char *name)
MovieClip *BKE_movieclip_file_add(const char *name)
{
MovieClip *clip;
MovieClipUser user;
@ -517,7 +517,7 @@ static void real_ibuf_size(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, in
*height = ibuf->y;
if (clip->flag & MCLIP_USE_PROXY) {
switch(user->render_size) {
switch (user->render_size) {
case MCLIP_PROXY_RENDER_SIZE_25:
(*width) *= 4;
(*height) *= 4;
@ -1149,14 +1149,14 @@ void BKE_movieclip_build_proxy_frame(MovieClip *clip, int clip_flag, struct Movi
}
}
void free_movieclip(MovieClip *clip)
void BKE_movieclip_free(MovieClip *clip)
{
free_buffers(clip);
BKE_tracking_free(&clip->tracking);
}
void unlink_movieclip(Main *bmain, MovieClip *clip)
void BKE_movieclip_unlink(Main *bmain, MovieClip *clip)
{
bScreen *scr;
ScrArea *area;

@ -835,7 +835,7 @@ static void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl
MDisps *mdisps;
int lvl= mmd->totlvl;
if (totlvl > multires_max_levels)
if ((totlvl > multires_max_levels) || (me->totpoly == 0))
return;
multires_force_update(ob);
@ -1017,7 +1017,7 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm
column_vectors_to_mat3(mat, tx, ty, no);
switch(op) {
switch (op) {
case APPLY_DISPLACEMENTS:
/* Convert displacement to object space
* and add to grid points */

@ -57,8 +57,7 @@ BLI_INLINE int left(const float* a, const float* b, const float* c)
int polyNumVerts(const unsigned short* p, const int vertsPerPoly)
{
int i, nv = 0;
for (i=0; i<vertsPerPoly; i++)
{
for (i=0; i<vertsPerPoly; i++) {
if (p[i]==0xffff)
break;
nv++;
@ -71,8 +70,7 @@ int polyIsConvex(const unsigned short* p, const int vertsPerPoly, const float* v
int j, nv = polyNumVerts(p, vertsPerPoly);
if (nv<3)
return 0;
for (j=0; j<nv; j++)
{
for (j=0; j<nv; j++) {
const float* v = &verts[3*p[j]];
const float* v_next = &verts[3*p[(j+1)%nv]];
const float* v_prev = &verts[3*p[(nv+j-1)%nv]];
@ -119,8 +117,7 @@ int buildRawVertIndicesData(DerivedMesh* dm, int *nverts_r, float **verts_r,
MFace *faces;
nverts = dm->getNumVerts(dm);
if (nverts>=0xffff)
{
if (nverts>=0xffff) {
printf("Converting navmesh: Error! Too many vertices. Max number of vertices %d\n", 0xffff);
return 0;
}
@ -128,8 +125,7 @@ int buildRawVertIndicesData(DerivedMesh* dm, int *nverts_r, float **verts_r,
dm->getVertCos(dm, (float(*)[3])verts);
//flip coordinates
for (vi=0; vi<nverts; vi++)
{
for (vi=0; vi<nverts; vi++) {
SWAP(float, verts[3*vi+1], verts[3*vi+2]);
}
@ -137,8 +133,7 @@ int buildRawVertIndicesData(DerivedMesh* dm, int *nverts_r, float **verts_r,
nfaces = dm->getNumTessFaces(dm);
faces = dm->getTessFaceArray(dm);
ntris = nfaces;
for (fi=0; fi<nfaces; fi++)
{
for (fi=0; fi<nfaces; fi++) {
MFace* face = &faces[fi];
if (face->v4)
ntris++;
@ -149,15 +144,13 @@ int buildRawVertIndicesData(DerivedMesh* dm, int *nverts_r, float **verts_r,
tris = MEM_callocN(sizeof(unsigned short)*3*ntris, "buildRawVertIndicesData tris");
tri = tris;
triIdx = 0;
for (fi=0; fi<nfaces; fi++)
{
for (fi=0; fi<nfaces; fi++) {
MFace* face = &faces[fi];
tri[3*triIdx+0] = (unsigned short) face->v1;
tri[3*triIdx+1] = (unsigned short) face->v3;
tri[3*triIdx+2] = (unsigned short) face->v2;
trisToFacesMap[triIdx++]=fi;
if (face->v4)
{
if (face->v4) {
tri[3*triIdx+0] = (unsigned short) face->v1;
tri[3*triIdx+1] = (unsigned short) face->v4;
tri[3*triIdx+2] = (unsigned short) face->v3;
@ -187,8 +180,7 @@ int buildPolygonsByDetailedMeshes(const int vertsPerPoly, const int npolys,
unsigned short* newPoly = MEM_callocN(sizeof(unsigned short)*capacity, "buildPolygonsByDetailedMeshes newPoly");
memset(newPoly, 0xff, sizeof(unsigned short)*capacity);
for (polyidx=0; polyidx<npolys; polyidx++)
{
for (polyidx=0; polyidx<npolys; polyidx++) {
size_t i;
int j, k;
int nv = 0;
@ -202,22 +194,18 @@ int buildPolygonsByDetailedMeshes(const int vertsPerPoly, const int npolys,
int adjustedNv;
int allBorderTraversed;
for (j=0; j<dtrisNum && btri==-1;j++)
{
for (j=0; j<dtrisNum && btri==-1;j++) {
int curpolytri = dtrisBase+j;
for (k=0; k<3; k++)
{
for (k=0; k<3; k++) {
unsigned short neighbortri = dtris[curpolytri*3*2+3+k];
if ( neighbortri==0xffff || dtrisToPolysMap[neighbortri]!=polyidx+1)
{
if ( neighbortri==0xffff || dtrisToPolysMap[neighbortri]!=polyidx+1) {
btri = curpolytri;
bedge = k;
break;
}
}
}
if (btri==-1 || bedge==-1)
{
if (btri==-1 || bedge==-1) {
//can't find triangle with border edge
MEM_freeN(traversedTris);
MEM_freeN(newPoly);
@ -229,13 +217,10 @@ int buildPolygonsByDetailedMeshes(const int vertsPerPoly, const int npolys,
tri = btri;
edge = (bedge+1)%3;
traversedTris[tri-dtrisBase] = 1;
while (tri!=btri || edge!=bedge)
{
while (tri != btri || edge != bedge) {
int neighbortri = dtris[tri*3*2+3+edge];
if (neighbortri==0xffff || dtrisToPolysMap[neighbortri]!=polyidx+1)
{
if (nv==capacity)
{
if (neighbortri==0xffff || dtrisToPolysMap[neighbortri]!=polyidx+1) {
if (nv==capacity) {
unsigned short* newPolyBig;
capacity += vertsPerPoly;
newPolyBig = MEM_callocN(sizeof(unsigned short)*capacity, "buildPolygonsByDetailedMeshes newPolyBig");
@ -251,16 +236,13 @@ int buildPolygonsByDetailedMeshes(const int vertsPerPoly, const int npolys,
else {
//move to next tri
int twinedge = -1;
for (k=0; k<3; k++)
{
if (dtris[neighbortri*3*2+3+k] == tri)
{
for (k=0; k<3; k++) {
if (dtris[neighbortri*3*2+3+k] == tri) {
twinedge = k;
break;
}
}
if (twinedge==-1)
{
if (twinedge==-1) {
printf("Converting navmesh: Error! Can't find neighbor edge - invalid adjacency info\n");
MEM_freeN(traversedTris);
goto returnLabel;
@ -273,8 +255,7 @@ int buildPolygonsByDetailedMeshes(const int vertsPerPoly, const int npolys,
adjustedPoly = MEM_callocN(sizeof(unsigned short)*nv, "buildPolygonsByDetailedMeshes adjustedPoly");
adjustedNv = 0;
for (i=0; i<nv; i++)
{
for (i=0; i<nv; i++) {
unsigned short prev = newPoly[(nv+i-1)%nv];
unsigned short cur = newPoly[i];
unsigned short next = newPoly[(i+1)%nv];
@ -288,17 +269,13 @@ int buildPolygonsByDetailedMeshes(const int vertsPerPoly, const int npolys,
nv = adjustedNv;
allBorderTraversed = 1;
for (i=0; i<dtrisNum; i++)
{
if (traversedTris[i]==0)
{
for (i=0; i<dtrisNum; i++) {
if (traversedTris[i]==0) {
//check whether it has border edges
int curpolytri = dtrisBase+i;
for (k=0; k<3; k++)
{
for (k=0; k<3; k++) {
unsigned short neighbortri = dtris[curpolytri*3*2+3+k];
if ( neighbortri==0xffff || dtrisToPolysMap[neighbortri]!=polyidx+1)
{
if ( neighbortri==0xffff || dtrisToPolysMap[neighbortri]!=polyidx+1) {
allBorderTraversed = 0;
break;
}
@ -306,10 +283,8 @@ int buildPolygonsByDetailedMeshes(const int vertsPerPoly, const int npolys,
}
}
if (nv<=vertsPerPoly && allBorderTraversed)
{
for (i=0; i<nv; i++)
{
if (nv<=vertsPerPoly && allBorderTraversed) {
for (i=0; i<nv; i++) {
polys[polyidx*vertsPerPoly*2+i] = newPoly[i];
}
}
@ -353,8 +328,7 @@ int buildNavMeshData(const int nverts, const float* verts,
unsigned short *dtris, *dmeshes, *polys;
int *dtrisToPolysMap, *dtrisToTrisMap;
if (!recastData)
{
if (!recastData) {
printf("Converting navmesh: Error! Can't find recast custom data\n");
return 0;
}
@ -370,17 +344,14 @@ int buildNavMeshData(const int nverts, const float* verts,
//search first valid triangle - triangle of convex polygon
validTriStart = -1;
for (i=0; i< ntris; i++)
{
if (recastData[trisToFacesMap[trisMapping[i]]]>0)
{
for (i=0; i< ntris; i++) {
if (recastData[trisToFacesMap[trisMapping[i]]]>0) {
validTriStart = i;
break;
}
}
if (validTriStart<0)
{
if (validTriStart<0) {
printf("Converting navmesh: Error! No valid polygons in mesh\n");
MEM_freeN(trisMapping);
return 0;
@ -396,8 +367,7 @@ int buildNavMeshData(const int nverts, const float* verts,
//and reserve memory for adjacency info
dtris = MEM_callocN(sizeof(unsigned short)*3*2*ndtris, "buildNavMeshData dtris");
memset(dtris, 0xffff, sizeof(unsigned short)*3*2*ndtris);
for (i=0; i<ndtris; i++)
{
for (i=0; i<ndtris; i++) {
memcpy(dtris+3*2*i, tris+3*dtrisToTrisMap[i], sizeof(unsigned short)*3);
}
@ -405,11 +375,9 @@ int buildNavMeshData(const int nverts, const float* verts,
prevPolyIdx = -1;
newPolyIdx = 0;
dtrisToPolysMap = MEM_callocN(sizeof(int)*ndtris, "buildNavMeshData dtrisToPolysMap");
for (i=0; i<ndtris; i++)
{
for (i=0; i<ndtris; i++) {
curPolyIdx = recastData[trisToFacesMap[dtrisToTrisMap[i]]];
if (curPolyIdx!=prevPolyIdx)
{
if (curPolyIdx!=prevPolyIdx) {
newPolyIdx++;
prevPolyIdx=curPolyIdx;
}
@ -426,13 +394,10 @@ int buildNavMeshData(const int nverts, const float* verts,
memset(dmeshes, 0, npolys*4*sizeof(unsigned short));
dmesh = NULL;
prevpolyidx = 0;
for (i=0; i<ndtris; i++)
{
for (i=0; i<ndtris; i++) {
int curpolyidx = dtrisToPolysMap[i];
if (curpolyidx!=prevpolyidx)
{
if (curpolyidx!=prevpolyidx+1)
{
if (curpolyidx!=prevpolyidx) {
if (curpolyidx!=prevpolyidx+1) {
printf("Converting navmesh: Error! Wrong order of detailed mesh faces\n");
return 0;
}
@ -476,8 +441,7 @@ int buildNavMeshDataByDerivedMesh(DerivedMesh *dm, int *vertsPerPoly,
unsigned short *tris=NULL;
res = buildRawVertIndicesData(dm, nverts, verts, &ntris, &tris, trisToFacesMap, &recastData);
if (!res)
{
if (!res) {
printf("Converting navmesh: Error! Can't get vertices and indices from mesh\n");
goto exit;
}
@ -485,8 +449,7 @@ int buildNavMeshDataByDerivedMesh(DerivedMesh *dm, int *vertsPerPoly,
res = buildNavMeshData(*nverts, *verts, ntris, tris, recastData, *trisToFacesMap,
ndtris, dtris, npolys, dmeshes,polys, vertsPerPoly,
dtrisToPolysMap, dtrisToTrisMap);
if (!res)
{
if (!res) {
printf("Converting navmesh: Error! Can't get vertices and indices from mesh\n");
goto exit;
}
@ -501,12 +464,10 @@ exit:
int polyFindVertex(const unsigned short* p, const int vertsPerPoly, unsigned short vertexIdx)
{
int i, res = -1;
for (i=0; i<vertsPerPoly; i++)
{
for (i=0; i<vertsPerPoly; i++) {
if (p[i]==0xffff)
break;
if (p[i]==vertexIdx)
{
if (p[i] == vertexIdx) {
res = i;
break;
}

@ -357,7 +357,7 @@ NlaStrip *add_nla_soundstrip (Scene *scene, Speaker *speaker)
strip->end = (float)ceil((double)info.length * FPS);
}
else
else
#endif
{
strip->end = 10.0f;
@ -373,7 +373,7 @@ NlaStrip *add_nla_soundstrip (Scene *scene, Speaker *speaker)
strip->extendmode = NLASTRIP_EXTEND_NOTHING; /* nothing to extend... */
/* strip should be referenced as-is */
strip->scale= 1.0f;
strip->scale = 1.0f;
strip->repeat = 1.0f;
/* return this strip */

@ -319,8 +319,8 @@ void free_object(Object *ob)
id->us--;
if (id->us==0) {
if (ob->type==OB_MESH) unlink_mesh(ob->data);
else if (ob->type==OB_CURVE) unlink_curve(ob->data);
else if (ob->type==OB_MBALL) unlink_mball(ob->data);
else if (ob->type==OB_CURVE) BKE_curve_unlink(ob->data);
else if (ob->type==OB_MBALL) BKE_metaball_unlink(ob->data);
}
ob->data= NULL;
}
@ -459,7 +459,7 @@ void unlink_object(Object *ob)
}
}
else if (ELEM(OB_MBALL, ob->type, obt->type)) {
if (is_mball_basis_for (obt, ob))
if (BKE_metaball_is_basis_for (obt, ob))
obt->recalc|= OB_RECALC_DATA;
}
@ -625,10 +625,11 @@ void unlink_object(Object *ob)
#endif
if (sce->ed) {
Sequence *seq;
SEQ_BEGIN(sce->ed, seq)
if (seq->scene_camera==ob) {
seq->scene_camera= NULL;
SEQ_BEGIN (sce->ed, seq) {
if (seq->scene_camera == ob) {
seq->scene_camera = NULL;
}
}
SEQ_END
}
}
@ -748,10 +749,10 @@ static void *add_obdata_from_type(int type)
{
switch (type) {
case OB_MESH: return add_mesh("Mesh");
case OB_CURVE: return add_curve("Curve", OB_CURVE);
case OB_SURF: return add_curve("Surf", OB_SURF);
case OB_FONT: return add_curve("Text", OB_FONT);
case OB_MBALL: return add_mball("Meta");
case OB_CURVE: return BKE_curve_add("Curve", OB_CURVE);
case OB_SURF: return BKE_curve_add("Surf", OB_SURF);
case OB_FONT: return BKE_curve_add("Text", OB_FONT);
case OB_MBALL: return BKE_metaball_add("Meta");
case OB_CAMERA: return add_camera("Camera");
case OB_LAMP: return add_lamp("Lamp");
case OB_LATTICE: return add_lattice("Lattice");
@ -1483,7 +1484,7 @@ void object_rot_to_mat3(Object *ob, float mat[][3])
void object_mat3_to_rot(Object *ob, float mat[][3], short use_compat)
{
switch(ob->rotmode) {
switch (ob->rotmode) {
case ROT_MODE_QUAT:
{
float dquat[4];
@ -1821,7 +1822,7 @@ static void give_parvert(Object *par, int nr, float vec[3])
ListBase *nurbs;
cu= par->data;
nurbs= BKE_curve_nurbs(cu);
nurbs= BKE_curve_nurbs_get(cu);
nu= nurbs->first;
count= 0;
@ -2025,7 +2026,7 @@ static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[
if (ob->partype & PARSLOW) copy_m4_m4(slowmat, obmat);
switch(ob->partype & PARTYPE) {
switch (ob->partype & PARTYPE) {
case PAROBJECT:
ok= 0;
if (par->type==OB_CURVE) {
@ -2260,14 +2261,14 @@ void minmax_object(Object *ob, float min[3], float max[3])
int a;
short change= FALSE;
switch(ob->type) {
switch (ob->type) {
case OB_CURVE:
case OB_FONT:
case OB_SURF:
{
Curve *cu= ob->data;
if (cu->bb==NULL) tex_space_curve(cu);
if (cu->bb==NULL) BKE_curve_tex_space_calc(cu);
bb= *(cu->bb);
for (a=0; a<8; a++) {
@ -2568,7 +2569,7 @@ void object_handle_update(Scene *scene, Object *ob)
}
/* includes all keys and modifiers */
switch(ob->type) {
switch (ob->type) {
case OB_MESH:
{
#if 0 // XXX, comment for 2.56a release, background wont set 'scene->customdata_mask'
@ -2784,8 +2785,7 @@ int ray_hit_boundbox(struct BoundBox *bb, float ray_start[3], float ray_normal[3
int result = 0;
int i;
for (i = 0; i < 12 && result == 0; i++)
{
for (i = 0; i < 12 && result == 0; i++) {
float lambda;
int v1, v2, v3;
v1 = triangle_indexes[i][0];
@ -2812,8 +2812,7 @@ int object_insert_ptcache(Object *ob)
BLI_sortlist(&ob->pc_ids, pc_cmp);
for (link=ob->pc_ids.first, i = 0; link; link=link->next, i++)
{
for (link=ob->pc_ids.first, i = 0; link; link=link->next, i++) {
int index = GET_INT_FROM_POINTER(link->data);
if (i < index)
@ -2931,7 +2930,7 @@ static KeyBlock *insert_curvekey(Scene *scene, Object *ob, const char *name, int
Curve *cu= ob->data;
Key *key= cu->key;
KeyBlock *kb;
ListBase *lb= BKE_curve_nurbs(cu);
ListBase *lb= BKE_curve_nurbs_get(cu);
int newkey= 0;
if (key==NULL) {
@ -2958,7 +2957,7 @@ static KeyBlock *insert_curvekey(Scene *scene, Object *ob, const char *name, int
/* create new block with prepared data */
kb = add_keyblock_ctime(key, name, FALSE);
kb->totelem= count_curveverts(lb);
kb->totelem= BKE_nurbList_verts_count(lb);
kb->data= data;
}

@ -196,15 +196,13 @@ static float Ph(struct Ocean* o, float kx,float kz )
float tmp;
float k2 = kx*kx + kz*kz;
if (k2 == 0.0f)
{
if (k2 == 0.0f) {
return 0.0f; // no DC component
}
// damp out the waves going in the direction opposite the wind
tmp = (o->_wx * kx + o->_wz * kz)/sqrtf(k2);
if (tmp < 0)
{
if (tmp < 0) {
tmp *= o->_damp_reflections;
}
@ -421,18 +419,15 @@ void BKE_ocean_eval_uv_catrom(struct Ocean *oc, struct OceanResult *ocr, float u
frac_z)
{
if (oc->_do_disp_y)
{
if (oc->_do_disp_y) {
ocr->disp[1] = INTERP(oc->_disp_y);
}
if (oc->_do_normals)
{
if (oc->_do_normals) {
ocr->normal[0] = INTERP(oc->_N_x);
ocr->normal[1] = oc->_N_y/*INTERP(oc->_N_y) (MEM01)*/;
ocr->normal[2] = INTERP(oc->_N_z);
}
if (oc->_do_chop)
{
if (oc->_do_chop) {
ocr->disp[0] = INTERP(oc->_disp_x);
ocr->disp[2] = INTERP(oc->_disp_z);
}
@ -441,8 +436,7 @@ void BKE_ocean_eval_uv_catrom(struct Ocean *oc, struct OceanResult *ocr, float u
ocr->disp[2] = 0.0;
}
if (oc->_do_jacobian)
{
if (oc->_do_jacobian) {
compute_eigenstuff(ocr, INTERP(oc->_Jxx),INTERP(oc->_Jzz),INTERP(oc->_Jxz));
}
}
@ -474,8 +468,7 @@ void BKE_ocean_eval_ij(struct Ocean *oc, struct OceanResult *ocr, int i,int j)
ocr->disp[1] = oc->_do_disp_y ? oc->_disp_y[i*oc->_N+j] : 0.0f;
if (oc->_do_chop)
{
if (oc->_do_chop) {
ocr->disp[0] = oc->_disp_x[i*oc->_N+j];
ocr->disp[2] = oc->_disp_z[i*oc->_N+j];
}
@ -484,8 +477,7 @@ void BKE_ocean_eval_ij(struct Ocean *oc, struct OceanResult *ocr, int i,int j)
ocr->disp[2] = 0.0f;
}
if (oc->_do_normals)
{
if (oc->_do_normals) {
ocr->normal[0] = oc->_N_x[i*oc->_N+j];
ocr->normal[1] = oc->_N_y/*oc->_N_y[i*oc->_N+j] (MEM01)*/;
ocr->normal[2] = oc->_N_z[i*oc->_N+j];
@ -493,8 +485,7 @@ void BKE_ocean_eval_ij(struct Ocean *oc, struct OceanResult *ocr, int i,int j)
normalize_v3(ocr->normal);
}
if (oc->_do_jacobian)
{
if (oc->_do_jacobian) {
compute_eigenstuff(ocr, oc->_Jxx[i*oc->_N+j],oc->_Jzz[i*oc->_N+j],oc->_Jxz[i*oc->_N+j]);
}
@ -511,12 +502,10 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount
// compute a new htilda
#pragma omp parallel for private(i, j)
for (i = 0 ; i < o->_M ; ++i)
{
for (i = 0 ; i < o->_M ; ++i) {
// note the <= _N/2 here, see the fftw doco about
// the mechanics of the complex->real fft storage
for ( j = 0 ; j <= o->_N / 2 ; ++j)
{
for ( j = 0 ; j <= o->_N / 2 ; ++j) {
fftw_complex exp_param1;
fftw_complex exp_param2;
fftw_complex conj_param;
@ -541,8 +530,7 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount
#pragma omp section
{
if (o->_do_disp_y)
{
if (o->_do_disp_y) {
// y displacement
fftw_execute(o->_disp_y_plan);
}
@ -550,13 +538,10 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount
#pragma omp section
{
if (o->_do_chop)
{
if (o->_do_chop) {
// x displacement
for ( i = 0 ; i < o->_M ; ++i)
{
for ( j = 0 ; j <= o->_N / 2 ; ++j)
{
for ( i = 0 ; i < o->_M ; ++i) {
for ( j = 0 ; j <= o->_N / 2 ; ++j) {
fftw_complex mul_param;
fftw_complex minus_i;
@ -575,13 +560,10 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount
#pragma omp section
{
if (o->_do_chop)
{
if (o->_do_chop) {
// z displacement
for ( i = 0 ; i < o->_M ; ++i)
{
for ( j = 0 ; j <= o->_N / 2 ; ++j)
{
for ( i = 0 ; i < o->_M ; ++i) {
for ( j = 0 ; j <= o->_N / 2 ; ++j) {
fftw_complex mul_param;
fftw_complex minus_i;
@ -600,13 +582,10 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount
#pragma omp section
{
if (o->_do_jacobian)
{
if (o->_do_jacobian) {
// Jxx
for ( i = 0 ; i < o->_M ; ++i)
{
for ( j = 0 ; j <= o->_N / 2 ; ++j)
{
for ( i = 0 ; i < o->_M ; ++i) {
for ( j = 0 ; j <= o->_N / 2 ; ++j) {
fftw_complex mul_param;
//init_complex(mul_param, -scale, 0);
@ -620,10 +599,8 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount
}
fftw_execute(o->_Jxx_plan);
for ( i = 0 ; i < o->_M ; ++i)
{
for ( j = 0 ; j < o->_N ; ++j)
{
for ( i = 0 ; i < o->_M ; ++i) {
for ( j = 0 ; j < o->_N ; ++j) {
o->_Jxx[i*o->_N+j] += 1.0;
}
}
@ -632,13 +609,10 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount
#pragma omp section
{
if (o->_do_jacobian)
{
if (o->_do_jacobian) {
// Jzz
for ( i = 0 ; i < o->_M ; ++i)
{
for ( j = 0 ; j <= o->_N / 2 ; ++j)
{
for ( i = 0 ; i < o->_M ; ++i) {
for ( j = 0 ; j <= o->_N / 2 ; ++j) {
fftw_complex mul_param;
//init_complex(mul_param, -scale, 0);
@ -651,10 +625,8 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount
}
}
fftw_execute(o->_Jzz_plan);
for ( i = 0 ; i < o->_M ; ++i)
{
for ( j = 0 ; j < o->_N ; ++j)
{
for ( i = 0 ; i < o->_M ; ++i) {
for ( j = 0 ; j < o->_N ; ++j) {
o->_Jzz[i*o->_N+j] += 1.0;
}
}
@ -663,13 +635,10 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount
#pragma omp section
{
if (o->_do_jacobian)
{
if (o->_do_jacobian) {
// Jxz
for ( i = 0 ; i < o->_M ; ++i)
{
for ( j = 0 ; j <= o->_N / 2 ; ++j)
{
for ( i = 0 ; i < o->_M ; ++i) {
for ( j = 0 ; j <= o->_N / 2 ; ++j) {
fftw_complex mul_param;
//init_complex(mul_param, -scale, 0);
@ -688,12 +657,9 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount
#pragma omp section
{
// fft normals
if (o->_do_normals)
{
for ( i = 0 ; i < o->_M ; ++i)
{
for ( j = 0 ; j <= o->_N / 2 ; ++j)
{
if (o->_do_normals) {
for ( i = 0 ; i < o->_M ; ++i) {
for ( j = 0 ; j <= o->_N / 2 ; ++j) {
fftw_complex mul_param;
init_complex(mul_param, 0.0, -1.0);
@ -709,12 +675,9 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount
#pragma omp section
{
if (o->_do_normals)
{
for ( i = 0 ; i < o->_M ; ++i)
{
for ( j = 0 ; j <= o->_N / 2 ; ++j)
{
if (o->_do_normals) {
for ( i = 0 ; i < o->_M ; ++i) {
for ( j = 0 ; j <= o->_N / 2 ; ++j) {
fftw_complex mul_param;
init_complex(mul_param, 0.0, -1.0);
@ -757,12 +720,9 @@ static void set_height_normalize_factor(struct Ocean *oc)
BLI_rw_mutex_lock(&oc->oceanmutex, THREAD_LOCK_READ);
for (i = 0; i < oc->_M; ++i)
{
for (j = 0; j < oc->_N; ++j)
{
if ( max_h < fabsf(oc->_disp_y[i*oc->_N+j]))
{
for (i = 0; i < oc->_M; ++i) {
for (j = 0; j < oc->_N; ++j) {
if ( max_h < fabsf(oc->_disp_y[i*oc->_N+j])) {
max_h = fabsf(oc->_disp_y[i*oc->_N+j]);
}
}
@ -851,10 +811,8 @@ void BKE_init_ocean(struct Ocean* o, int M,int N, float Lx, float Lz, float V, f
/*srand(seed);*/
BLI_srand(seed);
for (i = 0 ; i < o->_M ; ++i)
{
for (j = 0 ; j < o->_N ; ++j)
{
for (i = 0 ; i < o->_M ; ++i) {
for (j = 0 ; j < o->_N ; ++j) {
float r1 = gaussRand();
float r2 = gaussRand();
@ -921,14 +879,12 @@ void BKE_free_ocean_data(struct Ocean *oc)
BLI_rw_mutex_lock(&oc->oceanmutex, THREAD_LOCK_WRITE);
if (oc->_do_disp_y)
{
if (oc->_do_disp_y) {
fftw_destroy_plan(oc->_disp_y_plan);
MEM_freeN(oc->_disp_y);
}
if (oc->_do_normals)
{
if (oc->_do_normals) {
MEM_freeN(oc->_fft_in_nx);
MEM_freeN(oc->_fft_in_nz);
fftw_destroy_plan(oc->_N_x_plan);
@ -938,8 +894,7 @@ void BKE_free_ocean_data(struct Ocean *oc)
MEM_freeN(oc->_N_z);
}
if (oc->_do_chop)
{
if (oc->_do_chop) {
MEM_freeN(oc->_fft_in_x);
MEM_freeN(oc->_fft_in_z);
fftw_destroy_plan(oc->_disp_x_plan);
@ -948,8 +903,7 @@ void BKE_free_ocean_data(struct Ocean *oc)
MEM_freeN(oc->_disp_z);
}
if (oc->_do_jacobian)
{
if (oc->_do_jacobian) {
MEM_freeN(oc->_fft_in_jxx);
MEM_freeN(oc->_fft_in_jzz);
MEM_freeN(oc->_fft_in_jxz);
@ -1002,7 +956,7 @@ static void cache_filename(char *string, const char *path, const char *relbase,
char cachepath[FILE_MAX];
const char *fname;
switch(type) {
switch (type) {
case CACHE_TYPE_FOAM:
fname= "foam_";
break;
@ -1043,8 +997,7 @@ void BKE_free_ocean_cache(struct OceanCache *och)
if (!och) return;
if (och->ibufs_disp) {
for (i=och->start, f=0; i<=och->end; i++, f++)
{
for (i=och->start, f=0; i<=och->end; i++, f++) {
if (och->ibufs_disp[f]) {
IMB_freeImBuf(och->ibufs_disp[f]);
}
@ -1053,8 +1006,7 @@ void BKE_free_ocean_cache(struct OceanCache *och)
}
if (och->ibufs_foam) {
for (i=och->start, f=0; i<=och->end; i++, f++)
{
for (i=och->start, f=0; i<=och->end; i++, f++) {
if (och->ibufs_foam[f]) {
IMB_freeImBuf(och->ibufs_foam[f]);
}
@ -1063,8 +1015,7 @@ void BKE_free_ocean_cache(struct OceanCache *och)
}
if (och->ibufs_norm) {
for (i=och->start, f=0; i<=och->end; i++, f++)
{
for (i=och->start, f=0; i<=och->end; i++, f++) {
if (och->ibufs_norm[f]) {
IMB_freeImBuf(och->ibufs_norm[f]);
}

@ -72,7 +72,7 @@ int seekPackedFile(PackedFile *pf, int offset, int whence)
if (pf) {
oldseek = pf->seek;
switch(whence) {
switch (whence) {
case SEEK_CUR:
seek = oldseek + offset;
break;
@ -392,7 +392,7 @@ int checkPackedFile(const char *filename, PackedFile *pf)
/* unpackFile() looks at the existing files (abs_name, local_name) and a packed file.
*
* It returns a char *to the existing file name / new file name or NULL when
* there was an error or when the user desides to cancel the operation.
* there was an error or when the user decides to cancel the operation.
*/
char *unpackFile(ReportList *reports, const char *abs_name, const char *local_name, PackedFile *pf, int how)

@ -59,7 +59,7 @@ Paint *paint_get_active(Scene *sce)
ToolSettings *ts = sce->toolsettings;
if (sce->basact && sce->basact->object) {
switch(sce->basact->object->mode) {
switch (sce->basact->object->mode) {
case OB_MODE_SCULPT:
return &ts->sculpt->paint;
case OB_MODE_VERTEX_PAINT:

@ -1572,7 +1572,7 @@ static float psys_interpolate_value_from_verts(DerivedMesh *dm, short from, int
if (values==0 || index==-1)
return 0.0;
switch(from) {
switch (from) {
case PART_FROM_VERT:
return values[index];
case PART_FROM_FACE:
@ -1936,7 +1936,7 @@ static void do_kink(ParticleKey *state, ParticleKey *par, float *par_rot, float
copy_v3_v3(result, state->co);
sub_v3_v3v3(par_vec, par->co, state->co);
switch(type) {
switch (type) {
case PART_KINK_CURL:
{
negate_v3(par_vec);
@ -2846,7 +2846,7 @@ static void cache_key_incremental_rotation(ParticleCacheKey *key0, ParticleCache
{
float cosangle, angle, tangent[3], normal[3], q[4];
switch(i) {
switch (i) {
case 0:
/* start from second key */
break;
@ -3778,7 +3778,7 @@ static void get_cpa_texture(DerivedMesh *dm, ParticleSystem *psys, ParticleSetti
if (ELEM(texco, TEXCO_UV, TEXCO_ORCO) && (ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME) == 0 || part->distr == PART_DISTR_GRID))
texco = TEXCO_GLOB;
switch(texco) {
switch (texco) {
case TEXCO_GLOB:
copy_v3_v3(texvec, par->state.co);
break;
@ -3846,7 +3846,7 @@ void psys_get_texture(ParticleSimulationData *sim, ParticleData *pa, ParticleTex
if (texco == TEXCO_UV && (ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME) == 0 || part->distr == PART_DISTR_GRID))
texco = TEXCO_GLOB;
switch(texco) {
switch (texco) {
case TEXCO_GLOB:
copy_v3_v3(texvec, pa->state.co);
break;

@ -787,7 +787,7 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch
pa->num = i = ctx->index[p];
mface = dm->getTessFaceData(dm,i,CD_MFACE);
switch(distr) {
switch (distr) {
case PART_DISTR_JIT:
if (ctx->jitlevel == 1) {
if (mface->v4)
@ -855,13 +855,15 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch
}
if (intersect==0)
pa->foffset=0.0;
else switch(distr) {
case PART_DISTR_JIT:
pa->foffset*= ctx->jit[p%(2*ctx->jitlevel)];
break;
case PART_DISTR_RAND:
pa->foffset*=BLI_frand();
break;
else {
switch (distr) {
case PART_DISTR_JIT:
pa->foffset *= ctx->jit[p % (2 * ctx->jitlevel)];
break;
case PART_DISTR_RAND:
pa->foffset *= BLI_frand();
break;
}
}
}
}
@ -1575,7 +1577,7 @@ static void initialize_all_particles(ParticleSimulationData *sim)
static void get_angular_velocity_vector(short avemode, ParticleKey *state, float *vec)
{
switch(avemode) {
switch (avemode) {
case PART_AVE_VELOCITY:
copy_v3_v3(vec, state->vel);
break;
@ -1779,7 +1781,7 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P
if (part->rotmode) {
/* create vector into which rotation is aligned */
switch(part->rotmode) {
switch (part->rotmode) {
case PART_ROT_NOR:
copy_v3_v3(rot_vec, nor);
break;
@ -2141,7 +2143,7 @@ static void integrate_particle(ParticleSettings *part, ParticleData *pa, float d
if (pa->prev_state.time < 0.f && integrator == PART_INT_VERLET)
integrator = PART_INT_EULER;
switch(integrator) {
switch (integrator) {
case PART_INT_EULER:
steps=1;
break;
@ -2175,7 +2177,7 @@ static void integrate_particle(ParticleSettings *part, ParticleData *pa, float d
/* calculate next state */
add_v3_v3(states[i].vel, impulse);
switch(integrator) {
switch (integrator) {
case PART_INT_EULER:
madd_v3_v3v3fl(pa->state.co, states->co, states->vel, dtime);
madd_v3_v3v3fl(pa->state.vel, states->vel, acceleration, dtime);
@ -2193,7 +2195,7 @@ static void integrate_particle(ParticleSettings *part, ParticleData *pa, float d
}
break;
case PART_INT_RK4:
switch(i) {
switch (i) {
case 0:
copy_v3_v3(dx[0], states->vel);
mul_v3_fl(dx[0], dtime);
@ -2859,7 +2861,7 @@ static float collision_point_distance_with_normal(float p[3], ParticleCollisionE
if (fac >= 0.f)
collision_interpolate_element(pce, 0.f, fac, col);
switch(pce->tot) {
switch (pce->tot) {
case 1:
{
sub_v3_v3v3(nor, p, pce->x0);
@ -2884,7 +2886,7 @@ static void collision_point_on_surface(float p[3], ParticleCollisionElement *pce
{
collision_interpolate_element(pce, 0.f, fac, col);
switch(pce->tot) {
switch (pce->tot) {
case 1:
{
sub_v3_v3v3(co, p, pce->x0);
@ -3833,7 +3835,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
sim->colliders = get_collider_cache(sim->scene, sim->ob, NULL);
/* initialize physics type specific stuff */
switch(part->phystype) {
switch (part->phystype) {
case PART_PHYS_BOIDS:
{
ParticleTarget *pt = psys->targets.first;
@ -3908,7 +3910,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
pa->state.time = -1.f;
}
switch(part->phystype) {
switch (part->phystype) {
case PART_PHYS_NEWTON:
{
LOOP_DYNAMIC_PARTICLES {
@ -4499,7 +4501,7 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys)
/* setup necessary physics type dependent additional data if it doesn't yet exist */
psys_prepare_physics(&sim);
switch(part->type) {
switch (part->type) {
case PART_HAIR:
{
/* nothing to do so bail out early */
@ -4551,7 +4553,7 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys)
}
default:
{
switch(part->phystype) {
switch (part->phystype) {
case PART_PHYS_NO:
case PART_PHYS_KEYED:
{

Some files were not shown because too many files have changed in this diff Show More