Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2011-12-19 14:39:40 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2011-12-19 14:39:40 +0400
commit737648a0bf6aa38707adf0d444902cab981f86cf (patch)
tree9911809833f690eec95ef9e259729d29160d7a02 /source
parent5d15d8d2eebc98d7122e811dae2979b9a6c38b9d (diff)
parent90ef435145416313596cafa6f8c4c6c6aebe4e44 (diff)
Merging r42648 through r42722 from trunk into soc-2011-tomato
Diffstat (limited to 'source')
-rw-r--r--source/blender/avi/intern/avi.c57
-rw-r--r--source/blender/avi/intern/codecs.c15
-rw-r--r--source/blender/avi/intern/endian.c30
-rw-r--r--source/blender/avi/intern/mjpeg.c57
-rw-r--r--source/blender/avi/intern/options.c3
-rw-r--r--source/blender/avi/intern/rgb32.c6
-rw-r--r--source/blender/blenkernel/BKE_customdata.h4
-rw-r--r--source/blender/blenkernel/BKE_node.h1
-rw-r--r--source/blender/blenkernel/BKE_object.h2
-rw-r--r--source/blender/blenkernel/intern/CCGSubSurf.c36
-rw-r--r--source/blender/blenkernel/intern/CCGSubSurf.h24
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c150
-rw-r--r--source/blender/blenkernel/intern/anim.c38
-rw-r--r--source/blender/blenkernel/intern/armature.c26
-rw-r--r--source/blender/blenkernel/intern/boids.c3
-rw-r--r--source/blender/blenkernel/intern/camera.c2
-rw-r--r--source/blender/blenkernel/intern/cdderivedmesh.c10
-rw-r--r--source/blender/blenkernel/intern/constraint.c72
-rw-r--r--source/blender/blenkernel/intern/customdata.c40
-rw-r--r--source/blender/blenkernel/intern/deform.c2
-rw-r--r--source/blender/blenkernel/intern/dynamicpaint.c4
-rw-r--r--source/blender/blenkernel/intern/fcurve.c2
-rw-r--r--source/blender/blenkernel/intern/image.c10
-rw-r--r--source/blender/blenkernel/intern/image_gen.c18
-rw-r--r--source/blender/blenkernel/intern/lattice.c4
-rw-r--r--source/blender/blenkernel/intern/mball.c6
-rw-r--r--source/blender/blenkernel/intern/node.c1
-rw-r--r--source/blender/blenkernel/intern/object.c18
-rw-r--r--source/blender/blenkernel/intern/ocean.c3
-rw-r--r--source/blender/blenkernel/intern/particle.c6
-rw-r--r--source/blender/blenkernel/intern/pointcache.c6
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c19
-rw-r--r--source/blender/blenkernel/intern/suggestions.c54
-rw-r--r--source/blender/blenkernel/intern/text.c12
-rw-r--r--source/blender/blenkernel/intern/tracking.c6
-rw-r--r--source/blender/blenlib/BLI_ghash.h10
-rw-r--r--source/blender/blenlib/BLI_math_base.h5
-rw-r--r--source/blender/blenlib/BLI_math_matrix.h6
-rw-r--r--source/blender/blenlib/BLI_math_vector.h1
-rw-r--r--source/blender/blenlib/BLI_utildefines.h24
-rw-r--r--source/blender/blenlib/intern/BLI_dynstr.c9
-rw-r--r--source/blender/blenlib/intern/BLI_ghash.c89
-rw-r--r--source/blender/blenlib/intern/BLI_linklist.c24
-rw-r--r--source/blender/blenlib/intern/BLI_memarena.c18
-rw-r--r--source/blender/blenlib/intern/bpath.c18
-rw-r--r--source/blender/blenlib/intern/edgehash.c45
-rw-r--r--source/blender/blenlib/intern/math_base_inline.c26
-rw-r--r--source/blender/blenlib/intern/math_matrix.c18
-rw-r--r--source/blender/blenlib/intern/math_rotation.c6
-rw-r--r--source/blender/blenlib/intern/math_vector.c9
-rw-r--r--source/blender/blenlib/intern/rand.c39
-rw-r--r--source/blender/blenlib/intern/winstuff.c18
-rw-r--r--source/blender/collada/AnimationExporter.cpp4
-rw-r--r--source/blender/collada/AnimationImporter.cpp14
-rw-r--r--source/blender/collada/ArmatureExporter.cpp6
-rw-r--r--source/blender/collada/ArmatureImporter.cpp10
-rw-r--r--source/blender/collada/DocumentImporter.cpp2
-rw-r--r--source/blender/collada/TransformReader.cpp2
-rw-r--r--source/blender/collada/TransformWriter.cpp4
-rw-r--r--source/blender/collada/collada_utils.cpp2
-rw-r--r--source/blender/editors/animation/keyingsets.c6
-rw-r--r--source/blender/editors/armature/editarmature.c4
-rw-r--r--source/blender/editors/curve/curve_ops.c3
-rw-r--r--source/blender/editors/curve/editcurve.c2
-rw-r--r--source/blender/editors/include/ED_mesh.h4
-rw-r--r--source/blender/editors/interface/interface.c2
-rw-r--r--source/blender/editors/interface/interface_draw.c12
-rw-r--r--source/blender/editors/interface/interface_intern.h1
-rw-r--r--source/blender/editors/interface/interface_panel.c1
-rw-r--r--source/blender/editors/interface/interface_regions.c23
-rw-r--r--source/blender/editors/interface/interface_widgets.c18
-rw-r--r--source/blender/editors/mesh/editmesh_lib.c4
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c2
-rw-r--r--source/blender/editors/mesh/mesh_navmesh.c3
-rw-r--r--source/blender/editors/mesh/meshtools.c141
-rw-r--r--source/blender/editors/object/object_add.c37
-rw-r--r--source/blender/editors/object/object_constraint.c2
-rw-r--r--source/blender/editors/object/object_hook.c2
-rw-r--r--source/blender/editors/object/object_relations.c16
-rw-r--r--source/blender/editors/object/object_vgroup.c6
-rw-r--r--source/blender/editors/physics/physics_pointcache.c3
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c4
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c15
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c6
-rw-r--r--source/blender/editors/sound/sound_ops.c198
-rw-r--r--source/blender/editors/space_action/action_select.c2
-rw-r--r--source/blender/editors/space_clip/tracking_ops.c12
-rw-r--r--source/blender/editors/space_graph/graph_select.c13
-rw-r--r--source/blender/editors/space_node/node_draw.c87
-rw-r--r--source/blender/editors/space_node/node_edit.c286
-rw-r--r--source/blender/editors/space_node/node_intern.h15
-rw-r--r--source/blender/editors/space_node/node_ops.c4
-rw-r--r--source/blender/editors/space_node/node_select.c204
-rw-r--r--source/blender/editors/space_node/node_state.c154
-rw-r--r--source/blender/editors/space_outliner/outliner_select.c2
-rw-r--r--source/blender/editors/space_view3d/drawanimviz.c266
-rw-r--r--source/blender/editors/space_view3d/drawobject.c2
-rw-r--r--source/blender/editors/space_view3d/drawvolume.c23
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c4
-rw-r--r--source/blender/editors/space_view3d/view3d_buttons.c11
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c10
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c4
-rw-r--r--source/blender/editors/space_view3d/view3d_fly.c4
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_snap.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c10
-rw-r--r--source/blender/editors/transform/transform.c30
-rw-r--r--source/blender/editors/transform/transform_constraints.c36
-rw-r--r--source/blender/editors/transform/transform_conversions.c20
-rw-r--r--source/blender/editors/transform/transform_generics.c2
-rw-r--r--source/blender/editors/transform/transform_manipulator.c4
-rw-r--r--source/blender/editors/transform/transform_ops.c2
-rw-r--r--source/blender/editors/transform/transform_orientations.c33
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c3
-rw-r--r--source/blender/gpu/intern/gpu_codegen.c6
-rw-r--r--source/blender/gpu/intern/gpu_draw.c20
-rw-r--r--source/blender/gpu/intern/gpu_extensions.c29
-rw-r--r--source/blender/gpu/intern/gpu_material.c8
-rw-r--r--source/blender/ikplugin/intern/iksolver_plugin.c10
-rw-r--r--source/blender/ikplugin/intern/itasc_plugin.cpp12
-rw-r--r--source/blender/imbuf/intern/anim_movie.c52
-rw-r--r--source/blender/imbuf/intern/bmp.c6
-rw-r--r--source/blender/imbuf/intern/jp2.c26
-rw-r--r--source/blender/imbuf/intern/util.c15
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c10
-rw-r--r--source/blender/makesrna/intern/rna_nodetree_types.h1
-rw-r--r--source/blender/makesrna/intern/rna_object.c8
-rw-r--r--source/blender/makesrna/intern/rna_object_api.c18
-rw-r--r--source/blender/makesrna/intern/rna_space.c17
-rw-r--r--source/blender/modifiers/intern/MOD_array.c4
-rw-r--r--source/blender/modifiers/intern/MOD_boolean_util.c2
-rw-r--r--source/blender/modifiers/intern/MOD_cast.c4
-rw-r--r--source/blender/modifiers/intern/MOD_hook.c2
-rw-r--r--source/blender/modifiers/intern/MOD_meshdeform.c4
-rw-r--r--source/blender/modifiers/intern/MOD_mirror.c2
-rw-r--r--source/blender/modifiers/intern/MOD_screw.c2
-rw-r--r--source/blender/modifiers/intern/MOD_solidify.c4
-rw-r--r--source/blender/modifiers/intern/MOD_uvproject.c40
-rw-r--r--source/blender/modifiers/intern/MOD_warp.c6
-rw-r--r--source/blender/modifiers/intern/MOD_wave.c2
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgproximity.c14
-rw-r--r--source/blender/nodes/CMakeLists.txt1
-rw-r--r--source/blender/nodes/NOD_shader.h1
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_gamma.c63
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_normal.c2
-rw-r--r--source/blender/python/generic/bgl.c4
-rw-r--r--source/blender/python/generic/idprop_py_api.c6
-rw-r--r--source/blender/python/generic/py_capi_utils.c2
-rw-r--r--source/blender/python/intern/bpy_app.c1
-rw-r--r--source/blender/python/intern/bpy_app_handlers.c13
-rw-r--r--source/blender/python/intern/bpy_driver.c10
-rw-r--r--source/blender/python/intern/bpy_props.c16
-rw-r--r--source/blender/python/intern/bpy_rna.c20
-rw-r--r--source/blender/python/intern/bpy_rna_anim.c4
-rw-r--r--source/blender/python/intern/bpy_rna_callback.c15
-rw-r--r--source/blender/python/intern/gpu.c9
-rw-r--r--source/blender/python/mathutils/mathutils.c122
-rw-r--r--source/blender/python/mathutils/mathutils.h1
-rw-r--r--source/blender/python/mathutils/mathutils_Color.c2
-rw-r--r--source/blender/python/mathutils/mathutils_Euler.c4
-rw-r--r--source/blender/python/mathutils/mathutils_Matrix.c135
-rw-r--r--source/blender/python/mathutils/mathutils_Matrix.h26
-rw-r--r--source/blender/python/mathutils/mathutils_Quaternion.c16
-rw-r--r--source/blender/python/mathutils/mathutils_Vector.c528
-rw-r--r--source/blender/python/mathutils/mathutils_Vector.h3
-rw-r--r--source/blender/python/mathutils/mathutils_geometry.c119
-rw-r--r--source/blender/python/mathutils/mathutils_noise.c2
-rw-r--r--source/blender/quicktime/apple/qtkit_export.m4
-rw-r--r--source/blender/quicktime/apple/quicktime_export.c2
-rw-r--r--source/blender/render/intern/source/convertblender.c44
-rw-r--r--source/blender/render/intern/source/envmap.c16
-rw-r--r--source/blender/render/intern/source/pointdensity.c2
-rw-r--r--source/blender/render/intern/source/render_texture.c4
-rw-r--r--source/blender/render/intern/source/shadbuf.c6
-rw-r--r--source/blender/render/intern/source/shadeinput.c2
-rw-r--r--source/blender/render/intern/source/strand.c2
-rw-r--r--source/blender/render/intern/source/volumetric.c2
-rw-r--r--source/blender/render/intern/source/zbuf.c10
-rw-r--r--source/blender/windowmanager/intern/wm_draw.c35
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c1
-rw-r--r--source/gameengine/Converter/BL_ArmatureChannel.cpp2
-rw-r--r--source/gameengine/Ketsji/BL_Texture.cpp18
-rw-r--r--source/gameengine/Ketsji/KX_PythonInit.cpp10
-rw-r--r--source/gameengine/Rasterizer/RAS_2DFilterManager.cpp2
184 files changed, 2529 insertions, 2000 deletions
diff --git a/source/blender/avi/intern/avi.c b/source/blender/avi/intern/avi.c
index a021695b7c9..c6fdd2e1adc 100644
--- a/source/blender/avi/intern/avi.c
+++ b/source/blender/avi/intern/avi.c
@@ -63,7 +63,8 @@ char *tcc_to_char (unsigned int tcc);
/* implemetation */
-unsigned int GET_FCC (FILE *fp) {
+unsigned int GET_FCC (FILE *fp)
+{
unsigned char tmp[4];
tmp[0] = getc(fp);
@@ -74,7 +75,8 @@ unsigned int GET_FCC (FILE *fp) {
return FCC (tmp);
}
-unsigned int GET_TCC (FILE *fp) {
+unsigned int GET_TCC (FILE *fp)
+{
char tmp[5];
tmp[0] = getc(fp);
@@ -85,7 +87,8 @@ unsigned int GET_TCC (FILE *fp) {
return FCC (tmp);
}
-char *fcc_to_char (unsigned int fcc) {
+char *fcc_to_char (unsigned int fcc)
+{
DEBUG_FCC[0]= (fcc)&127;
DEBUG_FCC[1]= (fcc>>8)&127;
DEBUG_FCC[2]= (fcc>>16)&127;
@@ -94,7 +97,8 @@ char *fcc_to_char (unsigned int fcc) {
return DEBUG_FCC;
}
-char *tcc_to_char (unsigned int tcc) {
+char *tcc_to_char (unsigned int tcc)
+{
DEBUG_FCC[0]= (tcc)&127;
DEBUG_FCC[1]= (tcc>>8)&127;
DEBUG_FCC[2]= 0;
@@ -103,7 +107,8 @@ char *tcc_to_char (unsigned int tcc) {
return DEBUG_FCC;
}
-int AVI_get_stream (AviMovie *movie, int avist_type, int stream_num) {
+int AVI_get_stream (AviMovie *movie, int avist_type, int stream_num)
+{
int cur_stream;
if (movie == NULL)
@@ -121,7 +126,8 @@ int AVI_get_stream (AviMovie *movie, int avist_type, int stream_num) {
return -AVI_ERROR_FOUND;
}
-static int fcc_get_stream (int fcc) {
+static int fcc_get_stream (int fcc)
+{
char fccs[4];
fccs[0] = fcc;
@@ -132,7 +138,8 @@ static int fcc_get_stream (int fcc) {
return 10*(fccs[0]-'0') + (fccs[1]-'0');
}
-static int fcc_is_data (int fcc) {
+static int fcc_is_data (int fcc)
+{
char fccs[4];
fccs[0] = fcc;
@@ -148,7 +155,8 @@ static int fcc_is_data (int fcc) {
return 1;
}
-AviError AVI_print_error (AviError in_error) {
+AviError AVI_print_error (AviError in_error)
+{
int error;
if ((int) in_error < 0)
@@ -190,12 +198,14 @@ AviError AVI_print_error (AviError in_error) {
return in_error;
}
/*
-void AVI_set_debug (int mode) {
+void AVI_set_debug (int mode)
+{
AVI_DEBUG= mode;
}
*/
/*
-int AVI_is_avi (char *name) {
+int AVI_is_avi (char *name)
+{
FILE *fp;
int ret;
@@ -216,7 +226,8 @@ int AVI_is_avi (char *name) {
}
*/
-int AVI_is_avi (const char *name) {
+int AVI_is_avi (const char *name)
+{
int temp, fcca, j;
AviMovie movie= {NULL};
AviMainHeader header;
@@ -407,7 +418,8 @@ int AVI_is_avi (const char *name) {
}
-AviError AVI_open_movie (const char *name, AviMovie *movie) {
+AviError AVI_open_movie (const char *name, AviMovie *movie)
+{
int temp, fcca, size, j;
DEBUG_PRINT("opening movie\n");
@@ -619,7 +631,11 @@ AviError AVI_open_movie (const char *name, AviMovie *movie) {
movie->entries[temp].Offset = GET_FCC (movie->fp);
movie->entries[temp].Size = GET_FCC (movie->fp);
- if (AVI_DEBUG) printf ("Index entry %04d: ChunkId:%s Flags:%d Offset:%d Size:%d\n", temp, fcc_to_char(movie->entries[temp].ChunkId), movie->entries[temp].Flags, movie->entries[temp].Offset, movie->entries[temp].Size);
+ if (AVI_DEBUG) {
+ printf("Index entry %04d: ChunkId:%s Flags:%d Offset:%d Size:%d\n",
+ temp, fcc_to_char(movie->entries[temp].ChunkId), movie->entries[temp].Flags,
+ movie->entries[temp].Offset, movie->entries[temp].Size);
+ }
}
/* Some AVI's have offset entries in absolute coordinates
@@ -637,7 +653,8 @@ AviError AVI_open_movie (const char *name, AviMovie *movie) {
return AVI_ERROR_NONE;
}
-void *AVI_read_frame (AviMovie *movie, AviFormat format, int frame, int stream) {
+void *AVI_read_frame (AviMovie *movie, AviFormat format, int frame, int stream)
+{
int cur_frame=-1, temp, i=0, rewind=1;
void *buffer;
@@ -681,7 +698,8 @@ void *AVI_read_frame (AviMovie *movie, AviFormat format, int frame, int stream)
return buffer;
}
-AviError AVI_close (AviMovie *movie) {
+AviError AVI_close (AviMovie *movie)
+{
int i;
fclose (movie->fp);
@@ -703,7 +721,8 @@ AviError AVI_close (AviMovie *movie) {
return AVI_ERROR_NONE;
}
-AviError AVI_open_compress (char *name, AviMovie *movie, int streams, ...) {
+AviError AVI_open_compress (char *name, AviMovie *movie, int streams, ...)
+{
va_list ap;
AviList list;
AviChunk chunk;
@@ -892,7 +911,8 @@ AviError AVI_open_compress (char *name, AviMovie *movie, int streams, ...) {
return AVI_ERROR_NONE;
}
-AviError AVI_write_frame (AviMovie *movie, int frame_num, ...) {
+AviError AVI_write_frame (AviMovie *movie, int frame_num, ...)
+{
AviList list;
AviChunk chunk;
AviIndexEntry *temp;
@@ -999,7 +1019,8 @@ AviError AVI_write_frame (AviMovie *movie, int frame_num, ...) {
return AVI_ERROR_NONE;
}
-AviError AVI_close_compress (AviMovie *movie) {
+AviError AVI_close_compress (AviMovie *movie)
+{
int temp, movi_size, i;
fseek (movie->fp, 0L, SEEK_END);
diff --git a/source/blender/avi/intern/codecs.c b/source/blender/avi/intern/codecs.c
index 78d8d4a32b2..73af7097994 100644
--- a/source/blender/avi/intern/codecs.c
+++ b/source/blender/avi/intern/codecs.c
@@ -40,7 +40,8 @@
#include "mjpeg.h"
#include "rgb32.h"
-void *avi_format_convert (AviMovie *movie, int stream, void *buffer, AviFormat from, AviFormat to, int *size) {
+void *avi_format_convert (AviMovie *movie, int stream, void *buffer, AviFormat from, AviFormat to, int *size)
+{
if (from == to)
return buffer;
@@ -82,7 +83,8 @@ void *avi_format_convert (AviMovie *movie, int stream, void *buffer, AviFormat f
return buffer;
}
-int avi_get_data_id (AviFormat format, int stream) {
+int avi_get_data_id (AviFormat format, int stream)
+{
char fcc[5];
if (avi_get_format_type (format) == FCC("vids"))
@@ -95,7 +97,8 @@ int avi_get_data_id (AviFormat format, int stream) {
return FCC(fcc);
}
-int avi_get_format_type (AviFormat format) {
+int avi_get_format_type (AviFormat format)
+{
switch (format) {
case AVI_FORMAT_RGB24:
case AVI_FORMAT_RGB32:
@@ -109,7 +112,8 @@ int avi_get_format_type (AviFormat format) {
}
}
-int avi_get_format_fcc (AviFormat format) {
+int avi_get_format_fcc (AviFormat format)
+{
switch (format) {
case AVI_FORMAT_RGB24:
case AVI_FORMAT_RGB32:
@@ -125,7 +129,8 @@ int avi_get_format_fcc (AviFormat format) {
}
}
-int avi_get_format_compression (AviFormat format) {
+int avi_get_format_compression (AviFormat format)
+{
switch (format) {
case AVI_FORMAT_RGB24:
case AVI_FORMAT_RGB32:
diff --git a/source/blender/avi/intern/endian.c b/source/blender/avi/intern/endian.c
index 194880605b6..29b3047eca4 100644
--- a/source/blender/avi/intern/endian.c
+++ b/source/blender/avi/intern/endian.c
@@ -43,7 +43,8 @@
#include "avi_intern.h"
#ifdef __BIG_ENDIAN__
-static void invert (int *num) {
+static void invert (int *num)
+{
int new=0,i,j;
for (j=0; j < 4; j++) {
@@ -55,7 +56,8 @@ static void invert (int *num) {
*num = new;
}
-static void sinvert (short int *num) {
+static void sinvert (short int *num)
+{
short int new=0;
int i,j;
@@ -68,20 +70,23 @@ static void sinvert (short int *num) {
*num = new;
}
-static void Ichunk (AviChunk *chunk) {
+static void Ichunk (AviChunk *chunk)
+{
invert (&chunk->fcc);
invert (&chunk->size);
}
#endif
#ifdef __BIG_ENDIAN__
-static void Ilist (AviList *list){
+static void Ilist (AviList *list)
+{
invert (&list->fcc);
invert (&list->size);
invert (&list->ids);
}
-static void Imainh (AviMainHeader *mainh) {
+static void Imainh (AviMainHeader *mainh)
+{
invert (&mainh->fcc);
invert (&mainh->size);
invert (&mainh->MicroSecPerFrame);
@@ -100,7 +105,8 @@ static void Imainh (AviMainHeader *mainh) {
invert (&mainh->Reserved[3]);
}
-static void Istreamh (AviStreamHeader *streamh) {
+static void Istreamh (AviStreamHeader *streamh)
+{
invert (&streamh->fcc);
invert (&streamh->size);
invert (&streamh->Type);
@@ -122,7 +128,8 @@ static void Istreamh (AviStreamHeader *streamh) {
sinvert (&streamh->bottom);
}
-static void Ibitmaph (AviBitmapInfoHeader *bitmaph) {
+static void Ibitmaph (AviBitmapInfoHeader *bitmaph)
+{
invert (&bitmaph->fcc);
invert (&bitmaph->size);
invert (&bitmaph->Size);
@@ -138,7 +145,8 @@ static void Ibitmaph (AviBitmapInfoHeader *bitmaph) {
invert (&bitmaph->ClrImportant);
}
-static void Imjpegu (AviMJPEGUnknown *mjpgu) {
+static void Imjpegu (AviMJPEGUnknown *mjpgu)
+{
invert (&mjpgu->a);
invert (&mjpgu->b);
invert (&mjpgu->c);
@@ -148,7 +156,8 @@ static void Imjpegu (AviMJPEGUnknown *mjpgu) {
invert (&mjpgu->g);
}
-static void Iindexe (AviIndexEntry *indexe) {
+static void Iindexe (AviIndexEntry *indexe)
+{
invert (&indexe->ChunkId);
invert (&indexe->Flags);
invert (&indexe->Offset);
@@ -156,7 +165,8 @@ static void Iindexe (AviIndexEntry *indexe) {
}
#endif /* __BIG_ENDIAN__ */
-void awrite (AviMovie *movie, void *datain, int block, int size, FILE *fp, int type) {
+void awrite (AviMovie *movie, void *datain, int block, int size, FILE *fp, int type)
+{
#ifdef __BIG_ENDIAN__
void *data;
diff --git a/source/blender/avi/intern/mjpeg.c b/source/blender/avi/intern/mjpeg.c
index e55549bd05e..dab0b213d95 100644
--- a/source/blender/avi/intern/mjpeg.c
+++ b/source/blender/avi/intern/mjpeg.c
@@ -50,7 +50,8 @@ static void jpegmemsrcmgr_build (j_decompress_ptr dinfo, unsigned char *buffer,
static int numbytes;
-static void add_huff_table (j_decompress_ptr dinfo, JHUFF_TBL **htblptr, const UINT8 *bits, const UINT8 *val) {
+static void add_huff_table (j_decompress_ptr dinfo, JHUFF_TBL **htblptr, const UINT8 *bits, const UINT8 *val)
+{
if (*htblptr == NULL)
*htblptr = jpeg_alloc_huff_table((j_common_ptr) dinfo);
@@ -64,7 +65,8 @@ static void add_huff_table (j_decompress_ptr dinfo, JHUFF_TBL **htblptr, const U
/* Set up the standard Huffman tables (cf. JPEG standard section K.3) */
/* IMPORTANT: these are only valid for 8-bit data precision! */
-static void std_huff_tables (j_decompress_ptr dinfo) {
+static void std_huff_tables (j_decompress_ptr dinfo)
+{
static const UINT8 bits_dc_luminance[17] =
{ /* 0-base */
0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 };
@@ -142,7 +144,8 @@ static void std_huff_tables (j_decompress_ptr dinfo) {
bits_ac_chrominance, val_ac_chrominance);
}
-static int Decode_JPEG(unsigned char *inBuffer, unsigned char *outBuffer, unsigned int width, unsigned int height, int bufsize) {
+static int Decode_JPEG(unsigned char *inBuffer, unsigned char *outBuffer, unsigned int width, unsigned int height, int bufsize)
+{
int rowstride;
unsigned int y;
struct jpeg_decompress_struct dinfo;
@@ -194,7 +197,8 @@ static int Decode_JPEG(unsigned char *inBuffer, unsigned char *outBuffer, unsign
return 1;
}
-static void Compress_JPEG(int quality, unsigned char *outbuffer, unsigned char *inBuffer, int width, int height, int bufsize) {
+static void Compress_JPEG(int quality, unsigned char *outbuffer, unsigned char *inBuffer, int width, int height, int bufsize)
+{
int i, rowstride;
unsigned int y;
struct jpeg_compress_struct cinfo;
@@ -255,7 +259,8 @@ static void Compress_JPEG(int quality, unsigned char *outbuffer, unsigned char *
jpeg_destroy_compress(&cinfo);
}
-static void interlace(unsigned char *to, unsigned char *from, int width, int height) {
+static void interlace(unsigned char *to, unsigned char *from, int width, int height)
+{
int i, rowstride= width*3;
for (i=0; i<height; i++) {
@@ -266,7 +271,8 @@ static void interlace(unsigned char *to, unsigned char *from, int width, int hei
}
}
-static void deinterlace(int odd, unsigned char *to, unsigned char *from, int width, int height) {
+static void deinterlace(int odd, unsigned char *to, unsigned char *from, int width, int height)
+{
int i, rowstride= width*3;
for (i=0; i<height; i++) {
@@ -277,7 +283,8 @@ static void deinterlace(int odd, unsigned char *to, unsigned char *from, int wid
}
}
-static int check_and_decode_jpeg(unsigned char *inbuf, unsigned char *outbuf, int width, int height, int bufsize) {
+static int check_and_decode_jpeg(unsigned char *inbuf, unsigned char *outbuf, int width, int height, int bufsize)
+{
/* JPEG's are always multiples of 16, extra is cropped out AVI's */
if ((width&0xF) || (height&0xF)) {
int i, rrowstride, jrowstride;
@@ -299,7 +306,8 @@ static int check_and_decode_jpeg(unsigned char *inbuf, unsigned char *outbuf, in
}
}
-static void check_and_compress_jpeg(int quality, unsigned char *outbuf, unsigned char *inbuf, int width, int height, int bufsize) {
+static void check_and_compress_jpeg(int quality, unsigned char *outbuf, unsigned char *inbuf, int width, int height, int bufsize)
+{
/* JPEG's are always multiples of 16, extra is ignored in AVI's */
if ((width&0xF) || (height&0xF)) {
int i, rrowstride, jrowstride;
@@ -326,7 +334,8 @@ static void check_and_compress_jpeg(int quality, unsigned char *outbuf, unsigned
}
}
-void *avi_converter_from_mjpeg (AviMovie *movie, int stream, unsigned char *buffer, int *size) {
+void *avi_converter_from_mjpeg (AviMovie *movie, int stream, unsigned char *buffer, int *size)
+{
int deint;
unsigned char *buf;
@@ -349,7 +358,8 @@ void *avi_converter_from_mjpeg (AviMovie *movie, int stream, unsigned char *buff
return buf;
}
-void *avi_converter_to_mjpeg (AviMovie *movie, int stream, unsigned char *buffer, int *size) {
+void *avi_converter_to_mjpeg (AviMovie *movie, int stream, unsigned char *buffer, int *size)
+{
unsigned char *buf;
int bufsize= *size;
@@ -380,22 +390,26 @@ void *avi_converter_to_mjpeg (AviMovie *movie, int stream, unsigned char *buffer
/* Compression from memory */
-static void jpegmemdestmgr_init_destination(j_compress_ptr cinfo) {
+static void jpegmemdestmgr_init_destination(j_compress_ptr cinfo)
+{
(void)cinfo; /* unused */
}
-static boolean jpegmemdestmgr_empty_output_buffer(j_compress_ptr cinfo) {
+static boolean jpegmemdestmgr_empty_output_buffer(j_compress_ptr cinfo)
+{
(void)cinfo; /* unused */
return TRUE;
}
-static void jpegmemdestmgr_term_destination(j_compress_ptr cinfo) {
+static void jpegmemdestmgr_term_destination(j_compress_ptr cinfo)
+{
numbytes-= cinfo->dest->free_in_buffer;
MEM_freeN(cinfo->dest);
}
-static void jpegmemdestmgr_build(j_compress_ptr cinfo, unsigned char *buffer, int bufsize) {
+static void jpegmemdestmgr_build(j_compress_ptr cinfo, unsigned char *buffer, int bufsize)
+{
cinfo->dest= MEM_mallocN(sizeof(*(cinfo->dest)), "avi.jpegmemdestmgr_build");
cinfo->dest->init_destination= jpegmemdestmgr_init_destination;
@@ -410,11 +424,13 @@ static void jpegmemdestmgr_build(j_compress_ptr cinfo, unsigned char *buffer, in
/* Decompression from memory */
-static void jpegmemsrcmgr_init_source(j_decompress_ptr dinfo) {
+static void jpegmemsrcmgr_init_source(j_decompress_ptr dinfo)
+{
(void)dinfo;
}
-static boolean jpegmemsrcmgr_fill_input_buffer(j_decompress_ptr dinfo) {
+static boolean jpegmemsrcmgr_fill_input_buffer(j_decompress_ptr dinfo)
+{
unsigned char *buf= (unsigned char*) dinfo->src->next_input_byte-2;
/* if we get called, must have run out of data */
@@ -429,7 +445,8 @@ static boolean jpegmemsrcmgr_fill_input_buffer(j_decompress_ptr dinfo) {
return TRUE;
}
-static void jpegmemsrcmgr_skip_input_data(j_decompress_ptr dinfo, long skipcnt) {
+static void jpegmemsrcmgr_skip_input_data(j_decompress_ptr dinfo, long skipcnt)
+{
if (dinfo->src->bytes_in_buffer<skipcnt)
skipcnt= dinfo->src->bytes_in_buffer;
@@ -437,13 +454,15 @@ static void jpegmemsrcmgr_skip_input_data(j_decompress_ptr dinfo, long skipcnt)
dinfo->src->bytes_in_buffer-= skipcnt;
}
-static void jpegmemsrcmgr_term_source(j_decompress_ptr dinfo) {
+static void jpegmemsrcmgr_term_source(j_decompress_ptr dinfo)
+{
numbytes-= dinfo->src->bytes_in_buffer;
MEM_freeN(dinfo->src);
}
-static void jpegmemsrcmgr_build(j_decompress_ptr dinfo, unsigned char *buffer, int bufsize) {
+static void jpegmemsrcmgr_build(j_decompress_ptr dinfo, unsigned char *buffer, int bufsize)
+{
dinfo->src= MEM_mallocN(sizeof(*(dinfo->src)), "avi.jpegmemsrcmgr_build");
dinfo->src->init_source= jpegmemsrcmgr_init_source;
diff --git a/source/blender/avi/intern/options.c b/source/blender/avi/intern/options.c
index bda153d0cd3..483b708bee6 100644
--- a/source/blender/avi/intern/options.c
+++ b/source/blender/avi/intern/options.c
@@ -43,7 +43,8 @@
/* avi_set_compress_options gets its own file... now don't WE feel important? */
-AviError AVI_set_compress_option (AviMovie *movie, int option_type, int stream, AviOption option, void *opt_data) {
+AviError AVI_set_compress_option (AviMovie *movie, int option_type, int stream, AviOption option, void *opt_data)
+{
int i;
int useconds;
diff --git a/source/blender/avi/intern/rgb32.c b/source/blender/avi/intern/rgb32.c
index 4d088377c9e..e3be082cca6 100644
--- a/source/blender/avi/intern/rgb32.c
+++ b/source/blender/avi/intern/rgb32.c
@@ -40,7 +40,8 @@
#include "MEM_guardedalloc.h"
#include "rgb32.h"
-void *avi_converter_from_rgb32 (AviMovie *movie, int stream, unsigned char *buffer, int *size) {
+void *avi_converter_from_rgb32 (AviMovie *movie, int stream, unsigned char *buffer, int *size)
+{
int y, x, rowstridea, rowstrideb;
unsigned char *buf;
@@ -65,7 +66,8 @@ void *avi_converter_from_rgb32 (AviMovie *movie, int stream, unsigned char *buff
return buf;
}
-void *avi_converter_to_rgb32 (AviMovie *movie, int stream, unsigned char *buffer, int *size) {
+void *avi_converter_to_rgb32 (AviMovie *movie, int stream, unsigned char *buffer, int *size)
+{
int i;
unsigned char *buf;
unsigned char *to, *from;
diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h
index f6b4240a026..1d344c6e810 100644
--- a/source/blender/blenkernel/BKE_customdata.h
+++ b/source/blender/blenkernel/BKE_customdata.h
@@ -121,9 +121,9 @@ int CustomData_number_of_layers(const struct CustomData *data, int type);
/* duplicate data of a layer with flag NOFREE, and remove that flag.
* returns the layer data */
-void *CustomData_duplicate_referenced_layer(struct CustomData *data, int type);
+void *CustomData_duplicate_referenced_layer(struct CustomData *data, const int type, const int totelem);
void *CustomData_duplicate_referenced_layer_named(struct CustomData *data,
- int type, const char *name);
+ const int type, const char *name, const int totelem);
/* set the CD_FLAG_NOCOPY flag in custom data layers where the mask is
* zero for the layer type, so only layer types specified by the mask
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 5dbf22b54bf..378e5872791 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -521,6 +521,7 @@ struct ShadeResult;
#define SH_NODE_LAYER_WEIGHT 160
#define SH_NODE_VOLUME_TRANSPARENT 161
#define SH_NODE_VOLUME_ISOTROPIC 162
+#define SH_NODE_GAMMA 163
/* custom defines options for Material node */
#define SH_NODE_MAT_DIFF 1
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index b5a5090a5eb..828b0b47e3a 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -120,6 +120,8 @@ void BKE_scene_foreach_display_point(
const short flag,
void (*func_cb)(const float[3], void *), void *user_data);
+int BKE_object_parent_loop_check(const struct Object *parent, const struct Object *ob);
+
void solve_tracking (struct Object *ob, float targetmat[][4]);
int ray_hit_boundbox(struct BoundBox *bb, float ray_start[3], float ray_normal[3]);
diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c
index 140f596f78c..3ab52a7c17b 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf.c
+++ b/source/blender/blenkernel/intern/CCGSubSurf.c
@@ -218,7 +218,7 @@ static CCGAllocatorIFC *_getStandardAllocatorIFC(void) {
/***/
-static int VertDataEqual(float *a, float *b) {
+static int VertDataEqual(const float *a, const float *b) {
return a[0]==b[0] && a[1]==b[1] && a[2]==b[2];
}
#define VertDataZero(av) { float *_a = (float*) av; _a[0] = _a[1] = _a[2] = 0.0f; }
@@ -238,7 +238,7 @@ static int VertDataEqual(float *a, float *b) {
#define NormAdd(av, bv) { float *_a = (float*) av, *_b = (float*) bv; _a[0]+=_b[0]; _a[1]+=_b[1]; _a[2]+=_b[2]; }
-static int _edge_isBoundary(CCGEdge *e);
+static int _edge_isBoundary(const CCGEdge *e);
/***/
@@ -392,7 +392,7 @@ static void _vert_addFace(CCGVert *v, CCGFace *f, CCGSubSurf *ss) {
v->faces = CCGSUBSURF_realloc(ss, v->faces, (v->numFaces+1)*sizeof(*v->faces), v->numFaces*sizeof(*v->faces));
v->faces[v->numFaces++] = f;
}
-static CCGEdge *_vert_findEdgeTo(CCGVert *v, CCGVert *vQ) {
+static CCGEdge *_vert_findEdgeTo(const CCGVert *v, const CCGVert *vQ) {
int i;
for (i=0; i<v->numEdges; i++) {
CCGEdge *e = v->edges[v->numEdges-1-i]; // XXX, note reverse
@@ -402,7 +402,7 @@ static CCGEdge *_vert_findEdgeTo(CCGVert *v, CCGVert *vQ) {
}
return NULL;
}
-static int _vert_isBoundary(CCGVert *v) {
+static int _vert_isBoundary(const CCGVert *v) {
int i;
for (i=0; i<v->numEdges; i++)
if (_edge_isBoundary(v->edges[i]))
@@ -423,7 +423,7 @@ static void _vert_free(CCGVert *v, CCGSubSurf *ss) {
CCGSUBSURF_free(ss, v);
}
-static int VERT_seam(CCGVert *v) {
+static int VERT_seam(const CCGVert *v) {
return ((v->flags & Vert_eSeam) != 0);
}
@@ -462,7 +462,7 @@ static void _edge_addFace(CCGEdge *e, CCGFace *f, CCGSubSurf *ss) {
e->faces = CCGSUBSURF_realloc(ss, e->faces, (e->numFaces+1)*sizeof(*e->faces), e->numFaces*sizeof(*e->faces));
e->faces[e->numFaces++] = f;
}
-static int _edge_isBoundary(CCGEdge *e) {
+static int _edge_isBoundary(const CCGEdge *e) {
return e->numFaces<2;
}
@@ -900,7 +900,7 @@ CCGError ccgSubSurf_syncFaceDel(CCGSubSurf *ss, CCGFaceHDL fHDL) {
return eCCGError_None;
}
-CCGError ccgSubSurf_syncVert(CCGSubSurf *ss, CCGVertHDL vHDL, void *vertData, int seam, CCGVert **v_r) {
+CCGError ccgSubSurf_syncVert(CCGSubSurf *ss, CCGVertHDL vHDL, const void *vertData, int seam, CCGVert **v_r) {
void **prevp;
CCGVert *v = NULL;
short seamflag = (seam)? Vert_eSeam: 0;
@@ -2484,13 +2484,13 @@ CCGError ccgSubSurf_updateLevels(CCGSubSurf *ss, int lvl, CCGFace **effectedF, i
/*** External API accessor functions ***/
-int ccgSubSurf_getNumVerts(CCGSubSurf *ss) {
+int ccgSubSurf_getNumVerts(const CCGSubSurf *ss) {
return ss->vMap->numEntries;
}
-int ccgSubSurf_getNumEdges(CCGSubSurf *ss) {
+int ccgSubSurf_getNumEdges(const CCGSubSurf *ss) {
return ss->eMap->numEntries;
}
-int ccgSubSurf_getNumFaces(CCGSubSurf *ss) {
+int ccgSubSurf_getNumFaces(const CCGSubSurf *ss) {
return ss->fMap->numEntries;
}
@@ -2504,23 +2504,23 @@ CCGFace *ccgSubSurf_getFace(CCGSubSurf *ss, CCGFaceHDL f) {
return (CCGFace*) _ehash_lookup(ss->fMap, f);
}
-int ccgSubSurf_getSubdivisionLevels(CCGSubSurf *ss) {
+int ccgSubSurf_getSubdivisionLevels(const CCGSubSurf *ss) {
return ss->subdivLevels;
}
-int ccgSubSurf_getEdgeSize(CCGSubSurf *ss) {
+int ccgSubSurf_getEdgeSize(const CCGSubSurf *ss) {
return ccgSubSurf_getEdgeLevelSize(ss, ss->subdivLevels);
}
-int ccgSubSurf_getEdgeLevelSize(CCGSubSurf *ss, int level) {
+int ccgSubSurf_getEdgeLevelSize(const CCGSubSurf *ss, int level) {
if (level<1 || level>ss->subdivLevels) {
return -1;
} else {
return 1 + (1<<level);
}
}
-int ccgSubSurf_getGridSize(CCGSubSurf *ss) {
+int ccgSubSurf_getGridSize(const CCGSubSurf *ss) {
return ccgSubSurf_getGridLevelSize(ss, ss->subdivLevels);
}
-int ccgSubSurf_getGridLevelSize(CCGSubSurf *ss, int level) {
+int ccgSubSurf_getGridLevelSize(const CCGSubSurf *ss, int level) {
if (level<1 || level>ss->subdivLevels) {
return -1;
} else {
@@ -2736,19 +2736,19 @@ void ccgFaceIterator_free(CCGFaceIterator *vi) {
/*** Extern API final vert/edge/face interface ***/
-int ccgSubSurf_getNumFinalVerts(CCGSubSurf *ss) {
+int ccgSubSurf_getNumFinalVerts(const CCGSubSurf *ss) {
int edgeSize = 1 + (1<<ss->subdivLevels);
int gridSize = 1 + (1<<(ss->subdivLevels-1));
int numFinalVerts = ss->vMap->numEntries + ss->eMap->numEntries*(edgeSize-2) + ss->fMap->numEntries + ss->numGrids*((gridSize-2) + ((gridSize-2)*(gridSize-2)));
return numFinalVerts;
}
-int ccgSubSurf_getNumFinalEdges(CCGSubSurf *ss) {
+int ccgSubSurf_getNumFinalEdges(const CCGSubSurf *ss) {
int edgeSize = 1 + (1<<ss->subdivLevels);
int gridSize = 1 + (1<<(ss->subdivLevels-1));
int numFinalEdges = ss->eMap->numEntries*(edgeSize-1) + ss->numGrids*((gridSize-1) + 2*((gridSize-2)*(gridSize-1)));
return numFinalEdges;
}
-int ccgSubSurf_getNumFinalFaces(CCGSubSurf *ss) {
+int ccgSubSurf_getNumFinalFaces(const CCGSubSurf *ss) {
int gridSize = 1 + (1<<(ss->subdivLevels-1));
int numFinalFaces = ss->numGrids*((gridSize-1)*(gridSize-1));
return numFinalFaces;
diff --git a/source/blender/blenkernel/intern/CCGSubSurf.h b/source/blender/blenkernel/intern/CCGSubSurf.h
index 457ad2af353..543411f26f4 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf.h
+++ b/source/blender/blenkernel/intern/CCGSubSurf.h
@@ -56,7 +56,7 @@ CCGError ccgSubSurf_sync (CCGSubSurf *ss);
CCGError ccgSubSurf_initFullSync (CCGSubSurf *ss);
CCGError ccgSubSurf_initPartialSync (CCGSubSurf *ss);
-CCGError ccgSubSurf_syncVert (CCGSubSurf *ss, CCGVertHDL vHDL, void *vertData, int seam, CCGVert **v_r);
+CCGError ccgSubSurf_syncVert (CCGSubSurf *ss, CCGVertHDL vHDL, const void *vertData, int seam, CCGVert **v_r);
CCGError ccgSubSurf_syncEdge (CCGSubSurf *ss, CCGEdgeHDL eHDL, CCGVertHDL e_vHDL0, CCGVertHDL e_vHDL1, float crease, CCGEdge **e_r);
CCGError ccgSubSurf_syncFace (CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGVertHDL *vHDLs, CCGFace **f_r);
@@ -84,15 +84,15 @@ CCGError ccgSubSurf_setCalcVertexNormals (CCGSubSurf *ss, int useVertNormals, i
/***/
-int ccgSubSurf_getNumVerts (CCGSubSurf *ss);
-int ccgSubSurf_getNumEdges (CCGSubSurf *ss);
-int ccgSubSurf_getNumFaces (CCGSubSurf *ss);
+int ccgSubSurf_getNumVerts (const CCGSubSurf *ss);
+int ccgSubSurf_getNumEdges (const CCGSubSurf *ss);
+int ccgSubSurf_getNumFaces (const CCGSubSurf *ss);
-int ccgSubSurf_getSubdivisionLevels (CCGSubSurf *ss);
-int ccgSubSurf_getEdgeSize (CCGSubSurf *ss);
-int ccgSubSurf_getEdgeLevelSize (CCGSubSurf *ss, int level);
-int ccgSubSurf_getGridSize (CCGSubSurf *ss);
-int ccgSubSurf_getGridLevelSize (CCGSubSurf *ss, int level);
+int ccgSubSurf_getSubdivisionLevels (const CCGSubSurf *ss);
+int ccgSubSurf_getEdgeSize (const CCGSubSurf *ss);
+int ccgSubSurf_getEdgeLevelSize (const CCGSubSurf *ss, int level);
+int ccgSubSurf_getGridSize (const CCGSubSurf *ss);
+int ccgSubSurf_getGridLevelSize (const CCGSubSurf *ss, int level);
CCGVert* ccgSubSurf_getVert (CCGSubSurf *ss, CCGVertHDL v);
CCGVertHDL ccgSubSurf_getVertVertHandle (CCGVert *v);
@@ -135,9 +135,9 @@ void* ccgSubSurf_getFaceGridEdgeData (CCGSubSurf *ss, CCGFace *f, int gridInde
void* ccgSubSurf_getFaceGridDataArray (CCGSubSurf *ss, CCGFace *f, int gridIndex);
void* ccgSubSurf_getFaceGridData (CCGSubSurf *ss, CCGFace *f, int gridIndex, int x, int y);
-int ccgSubSurf_getNumFinalVerts (CCGSubSurf *ss);
-int ccgSubSurf_getNumFinalEdges (CCGSubSurf *ss);
-int ccgSubSurf_getNumFinalFaces (CCGSubSurf *ss);
+int ccgSubSurf_getNumFinalVerts (const CCGSubSurf *ss);
+int ccgSubSurf_getNumFinalEdges (const CCGSubSurf *ss);
+int ccgSubSurf_getNumFinalFaces (const CCGSubSurf *ss);
/***/
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 0087b91c615..3bc2ee61e7b 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -642,67 +642,71 @@ enum {
CALC_WP_AUTO_NORMALIZE= (1<<1)
};
+void weightpaint_color(unsigned char r_col[4], ColorBand *coba, const float input)
+{
+ float colf[4];
+
+ if(coba) do_colorband(coba, input, colf);
+ else weight_to_rgb(colf, input);
+
+ r_col[3] = (unsigned char)(colf[0] * 255.0f);
+ r_col[2] = (unsigned char)(colf[1] * 255.0f);
+ r_col[1] = (unsigned char)(colf[2] * 255.0f);
+ r_col[0] = 255;
+}
+
+
static void calc_weightpaint_vert_color(
- Object *ob, const int defbase_tot, ColorBand *coba, int vert, unsigned char *col,
- const char *dg_flags, int selected, int UNUSED(unselected), const int draw_flag)
+ unsigned char r_col[4],
+ MDeformVert *dv, ColorBand *coba,
+ const int defbase_tot, const int defbase_act,
+ const char *dg_flags,
+ const int selected, const int draw_flag)
{
- Mesh *me = ob->data;
float input = 0.0f;
int make_black= FALSE;
- if (me->dvert) {
- MDeformVert *dvert= &me->dvert[vert];
-
- if ((selected > 1) && (draw_flag & CALC_WP_MULTIPAINT)) {
- int was_a_nonzero= FALSE;
- int i;
-
- MDeformWeight *dw= dvert->dw;
- for (i = dvert->totweight; i > 0; i--, dw++) {
- /* in multipaint, get the average if auto normalize is inactive
- * get the sum if it is active */
- if (dw->def_nr < defbase_tot) {
- if (dg_flags[dw->def_nr]) {
- if (dw->weight) {
- input += dw->weight;
- was_a_nonzero= TRUE;
- }
+ if ((selected > 1) && (draw_flag & CALC_WP_MULTIPAINT)) {
+ int was_a_nonzero= FALSE;
+ int i;
+
+ MDeformWeight *dw= dv->dw;
+ for (i = dv->totweight; i > 0; i--, dw++) {
+ /* in multipaint, get the average if auto normalize is inactive
+ * get the sum if it is active */
+ if (dw->def_nr < defbase_tot) {
+ if (dg_flags[dw->def_nr]) {
+ if (dw->weight) {
+ input += dw->weight;
+ was_a_nonzero= TRUE;
}
}
}
+ }
- /* make it black if the selected groups have no weight on a vertex */
- if (was_a_nonzero == FALSE) {
- make_black = TRUE;
- }
- else if ((draw_flag & CALC_WP_AUTO_NORMALIZE) == FALSE) {
- input /= selected; /* get the average */
- }
+ /* make it black if the selected groups have no weight on a vertex */
+ if (was_a_nonzero == FALSE) {
+ make_black = TRUE;
}
- else {
- /* default, non tricky behavior */
- input= defvert_find_weight(dvert, ob->actdef-1);
+ else if ((draw_flag & CALC_WP_AUTO_NORMALIZE) == FALSE) {
+ input /= selected; /* get the average */
}
}
-
- if (make_black) {
- col[3] = 0;
- col[2] = 0;
- col[1] = 0;
- col[0] = 255;
+ else {
+ /* default, non tricky behavior */
+ input= defvert_find_weight(dv, defbase_act);
+ }
+
+ if (make_black) { /* TODO, theme color */
+ r_col[3] = 0;
+ r_col[2] = 0;
+ r_col[1] = 0;
+ r_col[0] = 255;
}
else {
- float colf[4];
CLAMP(input, 0.0f, 1.0f);
-
- if(coba) do_colorband(coba, input, colf);
- else weight_to_rgb(colf, input);
-
- col[3] = (unsigned char)(colf[0] * 255.0f);
- col[2] = (unsigned char)(colf[1] * 255.0f);
- col[1] = (unsigned char)(colf[2] * 255.0f);
- col[0] = 255;
+ weightpaint_color(r_col, coba, input);
}
}
@@ -716,28 +720,41 @@ void vDM_ColorBand_store(ColorBand *coba)
static void add_weight_mcol_dm(Object *ob, DerivedMesh *dm, int const draw_flag)
{
Mesh *me = ob->data;
- MFace *mf = me->mface;
ColorBand *coba= stored_cb; /* warning, not a local var */
- unsigned char *wtcol;
- int i;
-
- int defbase_tot = BLI_countlist(&ob->defbase);
- char *defbase_sel = MEM_mallocN(defbase_tot * sizeof(char), __func__);
- int selected = get_selected_defgroups(ob, defbase_sel, defbase_tot);
- int unselected = defbase_tot - selected;
- wtcol = MEM_callocN (sizeof (unsigned char) * me->totface*4*4, "weightmap");
-
- memset(wtcol, 0x55, sizeof (unsigned char) * me->totface*4*4);
- for (i=0; i<me->totface; i++, mf++) {
- calc_weightpaint_vert_color(ob, defbase_tot, coba, mf->v1, &wtcol[(i*4 + 0)*4], defbase_sel, selected, unselected, draw_flag);
- calc_weightpaint_vert_color(ob, defbase_tot, coba, mf->v2, &wtcol[(i*4 + 1)*4], defbase_sel, selected, unselected, draw_flag);
- calc_weightpaint_vert_color(ob, defbase_tot, coba, mf->v3, &wtcol[(i*4 + 2)*4], defbase_sel, selected, unselected, draw_flag);
- if (mf->v4)
- calc_weightpaint_vert_color(ob, defbase_tot, coba, mf->v4, &wtcol[(i*4 + 3)*4], defbase_sel, selected, unselected, draw_flag);
+ unsigned char *wtcol = MEM_mallocN (sizeof (unsigned char) * me->totface*4*4, "weightmap");
+
+ if (me->dvert) {
+ MDeformVert *dvert= me->dvert;
+ MFace *mf = me->mface;
+
+ const int defbase_tot = BLI_countlist(&ob->defbase);
+ const int defbase_act = ob->actdef-1;
+ char *dg_flags = MEM_mallocN(defbase_tot * sizeof(char), __func__);
+ const int selected = get_selected_defgroups(ob, dg_flags, defbase_tot);
+ /* const int unselected = defbase_tot - selected; */ /* UNUSED */
+
+ int i;
+
+ memset(wtcol, 0x55, sizeof (unsigned char) * me->totface*4*4);
+ for (i=0; i<me->totface; i++, mf++) {
+ unsigned int fidx= mf->v4 ? 3:2;
+ do {
+ calc_weightpaint_vert_color(&wtcol[(i*4 + fidx)*4],
+ &dvert[*(&mf->v1 + fidx)], coba,
+ defbase_tot, defbase_act,
+ dg_flags, selected, draw_flag);
+ } while (fidx--);
+ }
+
+ MEM_freeN(dg_flags);
+ }
+ else {
+ /* no weights, fill in zero */
+ int col_i;
+ weightpaint_color((unsigned char *)&col_i, coba, 0.0f);
+ fill_vn_i((int *)wtcol, me->totface*4, col_i);
}
-
- MEM_freeN(defbase_sel);
CustomData_add_layer(&dm->faceData, CD_WEIGHT_MCOL, CD_ASSIGN, wtcol, dm->numFaceData);
}
@@ -2006,13 +2023,8 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs,
tfdata = fdata;
/* calc auto bump scale if necessary */
-#if 0
if(dm->auto_bump_scale<=0.0f)
DM_calc_auto_bump_scale(dm);
-#else
- dm->auto_bump_scale = 1.0f; // will revert this after release
-#endif
-
/* add a tangent layer if necessary */
for(b = 0; b < gattribs->totlayer; b++)
diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c
index 0cd8845c53b..89bad72044e 100644
--- a/source/blender/blenkernel/intern/anim.c
+++ b/source/blender/blenkernel/intern/anim.c
@@ -726,10 +726,10 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, i
if(!is_zero_v3(group->dupli_ofs)) {
copy_m4_m4(tmat, go->ob->obmat);
sub_v3_v3v3(tmat[3], tmat[3], group->dupli_ofs);
- mul_m4_m4m4(mat, tmat, ob->obmat);
+ mult_m4_m4m4(mat, ob->obmat, tmat);
}
else {
- mul_m4_m4m4(mat, go->ob->obmat, ob->obmat);
+ mult_m4_m4m4(mat, ob->obmat, go->ob->obmat);
}
dob= new_dupli_object(lb, go->ob, mat, ob->lay, 0, OB_DUPLIGROUP, animated);
@@ -955,7 +955,7 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl
when par_space_mat is NULL ob->obmat can be used instead of ob__obmat
*/
if(par_space_mat)
- mul_m4_m4m4(vdd.obmat, ob->obmat, par_space_mat);
+ mult_m4_m4m4(vdd.obmat, par_space_mat, ob->obmat);
else
copy_m4_m4(vdd.obmat, ob->obmat);
@@ -1084,7 +1084,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
when par_space_mat is NULL ob->obmat can be used instead of ob__obmat
*/
if(par_space_mat)
- mul_m4_m4m4(ob__obmat, ob->obmat, par_space_mat);
+ mult_m4_m4m4(ob__obmat, par_space_mat, ob->obmat);
else
copy_m4_m4(ob__obmat, ob->obmat);
@@ -1143,21 +1143,17 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
madd_v3_v3v3fl(dob->orco, dob->orco, orco[mv1], w);
madd_v3_v3v3fl(dob->orco, dob->orco, orco[mv2], w);
madd_v3_v3v3fl(dob->orco, dob->orco, orco[mv3], w);
- if(mv4)
+ if (mv4) {
madd_v3_v3v3fl(dob->orco, dob->orco, orco[mv4], w);
+ }
}
if(mtface) {
- dob->uv[0] += w*mtface[a].uv[0][0];
- dob->uv[1] += w*mtface[a].uv[0][1];
- dob->uv[0] += w*mtface[a].uv[1][0];
- dob->uv[1] += w*mtface[a].uv[1][1];
- dob->uv[0] += w*mtface[a].uv[2][0];
- dob->uv[1] += w*mtface[a].uv[2][1];
-
- if(mv4) {
- dob->uv[0] += w*mtface[a].uv[3][0];
- dob->uv[1] += w*mtface[a].uv[3][1];
+ madd_v2_v2v2fl(dob->uv, dob->uv, mtface[a].uv[0], w);
+ madd_v2_v2v2fl(dob->uv, dob->uv, mtface[a].uv[1], w);
+ madd_v2_v2v2fl(dob->uv, dob->uv, mtface[a].uv[2], w);
+ if (mv4) {
+ madd_v2_v2v2fl(dob->uv, dob->uv, mtface[a].uv[3], w);
}
}
}
@@ -1396,15 +1392,15 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
if(!is_zero_v3(part->dup_group->dupli_ofs)) {
copy_m4_m4(tmat, oblist[b]->obmat);
sub_v3_v3v3(tmat[3], tmat[3], part->dup_group->dupli_ofs);
- mul_m4_m4m4(tmat, tmat, pamat);
+ mult_m4_m4m4(tmat, pamat, tmat);
}
else {
- mul_m4_m4m4(tmat, oblist[b]->obmat, pamat);
+ mult_m4_m4m4(tmat, pamat, oblist[b]->obmat);
}
mul_mat3_m4_fl(tmat, size*scale);
if(par_space_mat)
- mul_m4_m4m4(mat, tmat, par_space_mat);
+ mult_m4_m4m4(mat, par_space_mat, tmat);
else
copy_m4_m4(mat, tmat);
@@ -1435,15 +1431,15 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
* remove the real emitter's transformation before 2nd order duplication.
*/
if(par_space_mat && GS(id->name) != ID_GR)
- mul_m4_m4m4(mat, pamat, psys->imat);
+ mult_m4_m4m4(mat, psys->imat, pamat);
else
copy_m4_m4(mat, pamat);
- mul_m4_m4m4(tmat, obmat, mat);
+ mult_m4_m4m4(tmat, mat, obmat);
mul_mat3_m4_fl(tmat, size*scale);
if(par_space_mat)
- mul_m4_m4m4(mat, tmat, par_space_mat);
+ mult_m4_m4m4(mat, par_space_mat, tmat);
else
copy_m4_m4(mat, tmat);
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index 4035db36a39..ae04b7760c2 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -505,9 +505,9 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest)
if(prev->bone->segments==1) {
/* find the previous roll to interpolate */
if(rest)
- mul_m4_m4m4(difmat, prev->bone->arm_mat, imat);
+ mult_m4_m4m4(difmat, imat, prev->bone->arm_mat);
else
- mul_m4_m4m4(difmat, prev->pose_mat, imat);
+ mult_m4_m4m4(difmat, imat, prev->pose_mat);
copy_m3_m4(result, difmat); // the desired rotation at beginning of next bone
vec_roll_to_mat3(h1, 0.0f, mat3); // the result of vec_roll without roll
@@ -538,9 +538,9 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest)
/* find the next roll to interpolate as well */
if(rest)
- mul_m4_m4m4(difmat, next->bone->arm_mat, imat);
+ mult_m4_m4m4(difmat, imat, next->bone->arm_mat);
else
- mul_m4_m4m4(difmat, next->pose_mat, imat);
+ mult_m4_m4m4(difmat, imat, next->pose_mat);
copy_m3_m4(result, difmat); // the desired rotation at beginning of next bone
vec_roll_to_mat3(h2, 0.0f, mat3); // the result of vec_roll without roll
@@ -837,7 +837,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm,
invert_m4_m4(obinv, target->obmat);
copy_m4_m4(premat, target->obmat);
- mul_m4_m4m4(postmat, armOb->obmat, obinv);
+ mult_m4_m4m4(postmat, obinv, armOb->obmat);
invert_m4_m4(premat, postmat);
/* bone defmats are already in the channels, chan_mat */
@@ -1103,7 +1103,7 @@ void armature_mat_world_to_pose(Object *ob, float inmat[][4], float outmat[][4])
invert_m4_m4(obmat, ob->obmat);
/* multiply given matrix by object's-inverse to find pose-space matrix */
- mul_m4_m4m4(outmat, obmat, inmat);
+ mult_m4_m4m4(outmat, inmat, obmat);
}
/* Convert Wolrd-Space Location to Pose-Space Location
@@ -1174,7 +1174,7 @@ void armature_mat_pose_to_bone(bPoseChannel *pchan, float inmat[][4], float outm
* This should leave behind the effects of restpose +
* parenting + constraints
*/
- mul_m4_m4m4(pc_posemat, inv_trans, pose_mat);
+ mult_m4_m4m4(pc_posemat, pose_mat, inv_trans);
/* get the inverse of the leftovers so that we can remove
* that component from the supplied matrix
@@ -1182,7 +1182,7 @@ void armature_mat_pose_to_bone(bPoseChannel *pchan, float inmat[][4], float outm
invert_m4_m4(inv_posemat, pc_posemat);
/* get the new matrix */
- mul_m4_m4m4(outmat, inmat, inv_posemat);
+ mult_m4_m4m4(outmat, inv_posemat, inmat);
}
/* Convert Pose-Space Location to Bone-Space Location
@@ -1237,7 +1237,7 @@ void armature_mat_pose_to_delta(float delta_mat[][4], float pose_mat[][4], float
float imat[4][4];
invert_m4_m4(imat, arm_mat);
- mul_m4_m4m4(delta_mat, pose_mat, imat);
+ mult_m4_m4m4(delta_mat, imat, pose_mat);
}
/* **************** Rotation Mode Conversions ****************************** */
@@ -1410,7 +1410,7 @@ void where_is_armature_bone(Bone *bone, Bone *prevbone)
offs_bone[3][1]+= prevbone->length;
/* Compose the matrix for this bone */
- mul_m4_m4m4(bone->arm_mat, offs_bone, prevbone->arm_mat);
+ mult_m4_m4m4(bone->arm_mat, prevbone->arm_mat, offs_bone);
}
else {
copy_m4_m3(bone->arm_mat, bone->bone_mat);
@@ -2310,7 +2310,7 @@ void where_is_pose_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float cti
/* extract the scale of the parent matrix */
mat4_to_size(tscale, parchan->pose_mat);
size_to_mat4(tsmat, tscale);
- mul_m4_m4m4(tmat, tmat, tsmat);
+ mult_m4_m4m4(tmat, tsmat, tmat);
mul_serie_m4(pchan->pose_mat, tmat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL);
}
@@ -2344,7 +2344,7 @@ void where_is_pose_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float cti
}
}
else {
- mul_m4_m4m4(pchan->pose_mat, pchan->chan_mat, bone->arm_mat);
+ mult_m4_m4m4(pchan->pose_mat, bone->arm_mat, pchan->chan_mat);
/* optional location without arm_mat rotation */
if(bone->flag & BONE_NO_LOCAL_LOCATION)
@@ -2466,7 +2466,7 @@ void where_is_pose (Scene *scene, Object *ob)
for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
if(pchan->bone) {
invert_m4_m4(imat, pchan->bone->arm_mat);
- mul_m4_m4m4(pchan->chan_mat, imat, pchan->pose_mat);
+ mult_m4_m4m4(pchan->chan_mat, pchan->pose_mat, imat);
}
}
}
diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c
index 6656d06e72e..ec2e6b3c078 100644
--- a/source/blender/blenkernel/intern/boids.c
+++ b/source/blender/blenkernel/intern/boids.c
@@ -1514,7 +1514,8 @@ BoidState *boid_new_state(BoidSettings *boids)
return state;
}
-BoidState *boid_duplicate_state(BoidSettings *boids, BoidState *state) {
+BoidState *boid_duplicate_state(BoidSettings *boids, BoidState *state)
+{
BoidState *staten = MEM_dupallocN(state);
BLI_duplicatelist(&staten->rules, &state->rules);
diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c
index 2bd973d7799..f55ceab7de8 100644
--- a/source/blender/blenkernel/intern/camera.c
+++ b/source/blender/blenkernel/intern/camera.c
@@ -159,7 +159,7 @@ float object_camera_dof_distance(Object *ob)
copy_m4_m4(obmat, ob->obmat);
normalize_m4(obmat);
invert_m4_m4(imat, obmat);
- mul_m4_m4m4(mat, cam->dof_ob->obmat, imat);
+ mult_m4_m4m4(mat, imat, cam->dof_ob->obmat);
return fabsf(mat[3][2]);
}
return cam->YF_dofdist;
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index d4d83fec0eb..6f088b8abf7 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -657,7 +657,7 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
float *nors= dm->getFaceDataArray(dm, CD_NORMAL);
MTFace *tf = DM_get_face_data_layer(dm, CD_MTFACE);
int i, j, orig, *index = DM_get_face_data_layer(dm, CD_ORIGINDEX);
- int startFace = 0, lastFlag = 0xdeadbeef;
+ int startFace = 0 /*, lastFlag = 0xdeadbeef */ /* UNUSED */;
MCol *mcol = dm->getFaceDataArray(dm, CD_WEIGHT_MCOL);
if(!mcol)
mcol = dm->getFaceDataArray(dm, CD_MCOL);
@@ -776,7 +776,7 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
int next_actualFace= dm->drawObject->triangle_to_mface[0];
glShadeModel( GL_SMOOTH );
- lastFlag = 0;
+ /* lastFlag = 0; */ /* UNUSED */
for(i = 0; i < tottri; i++) {
int actualFace = next_actualFace;
int flag = 1;
@@ -1870,7 +1870,7 @@ void CDDM_apply_vert_coords(DerivedMesh *dm, float (*vertCoords)[3])
int i;
/* this will just return the pointer if it wasn't a referenced layer */
- vert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MVERT);
+ vert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MVERT, dm->numVertData);
cddm->mvert = vert;
for(i = 0; i < dm->numVertData; ++i, ++vert)
@@ -1884,7 +1884,7 @@ void CDDM_apply_vert_normals(DerivedMesh *dm, short (*vertNormals)[3])
int i;
/* this will just return the pointer if it wasn't a referenced layer */
- vert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MVERT);
+ vert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MVERT, dm->numVertData);
cddm->mvert = vert;
for(i = 0; i < dm->numVertData; ++i, ++vert)
@@ -1899,7 +1899,7 @@ void CDDM_calc_normals(DerivedMesh *dm)
if(dm->numVertData == 0) return;
/* we don't want to overwrite any referenced layers */
- cddm->mvert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MVERT);
+ cddm->mvert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MVERT, dm->numVertData);
/* make a face normal layer if not present */
face_nors = CustomData_get_layer(&dm->faceData, CD_NORMAL);
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 831d4d1bc07..820f6b9ef5a 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -153,7 +153,7 @@ bConstraintOb *constraints_make_evalob (Scene *scene, Object *ob, void *subdata,
}
/* matrix in world-space */
- mul_m4_m4m4(cob->matrix, cob->pchan->pose_mat, ob->obmat);
+ mult_m4_m4m4(cob->matrix, ob->obmat, cob->pchan->pose_mat);
}
else
unit_m4(cob->matrix);
@@ -182,7 +182,7 @@ void constraints_clear_evalob (bConstraintOb *cob)
/* calculate delta of constraints evaluation */
invert_m4_m4(imat, cob->startmat);
- mul_m4_m4m4(delta, imat, cob->matrix);
+ mult_m4_m4m4(delta, cob->matrix, imat);
/* copy matrices back to source */
switch (cob->type) {
@@ -203,7 +203,7 @@ void constraints_clear_evalob (bConstraintOb *cob)
/* cob->ob or cob->pchan might not exist */
if (cob->ob && cob->pchan) {
/* copy new pose-matrix back to owner */
- mul_m4_m4m4(cob->pchan->pose_mat, cob->matrix, cob->ob->imat);
+ mult_m4_m4m4(cob->pchan->pose_mat, cob->ob->imat, cob->matrix);
/* copy inverse of delta back to owner */
invert_m4_m4(cob->pchan->constinv, delta);
@@ -242,7 +242,7 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4
/* world to pose */
invert_m4_m4(imat, ob->obmat);
copy_m4_m4(tempmat, mat);
- mul_m4_m4m4(mat, tempmat, imat);
+ mult_m4_m4m4(mat, imat, tempmat);
/* use pose-space as stepping stone for other spaces... */
if (ELEM(to, CONSTRAINT_SPACE_LOCAL, CONSTRAINT_SPACE_PARLOCAL)) {
@@ -256,7 +256,7 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4
/* pose to world */
if (to == CONSTRAINT_SPACE_WORLD) {
copy_m4_m4(tempmat, mat);
- mul_m4_m4m4(mat, tempmat, ob->obmat);
+ mult_m4_m4m4(mat, ob->obmat, tempmat);
}
/* pose to local */
else if (to == CONSTRAINT_SPACE_LOCAL) {
@@ -281,12 +281,12 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4
offs_bone[3][0]= offs_bone[3][1]= offs_bone[3][2]= 0.0f;
mul_m4_v3(pchan->parent->pose_mat, tmat[3]);
- mul_m4_m4m4(diff_mat, offs_bone, tmat);
+ mult_m4_m4m4(diff_mat, tmat, offs_bone);
invert_m4_m4(imat, diff_mat);
}
else {
/* pose_mat = par_pose_mat * bone_mat * chan_mat */
- mul_m4_m4m4(diff_mat, offs_bone, pchan->parent->pose_mat);
+ mult_m4_m4m4(diff_mat, pchan->parent->pose_mat, offs_bone);
invert_m4_m4(imat, diff_mat);
}
}
@@ -296,7 +296,7 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4
}
copy_m4_m4(tempmat, mat);
- mul_m4_m4m4(mat, tempmat, imat);
+ mult_m4_m4m4(mat, imat, tempmat);
}
}
/* pose to local with parent */
@@ -304,7 +304,7 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4
if (pchan->bone) {
invert_m4_m4(imat, pchan->bone->arm_mat);
copy_m4_m4(tempmat, mat);
- mul_m4_m4m4(mat, tempmat, imat);
+ mult_m4_m4m4(mat, imat, tempmat);
}
}
}
@@ -334,22 +334,22 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4
zero_v3(offs_bone[3]);
mul_m4_v3(pchan->parent->pose_mat, tmat[3]);
- mul_m4_m4m4(diff_mat, offs_bone, tmat);
+ mult_m4_m4m4(diff_mat, tmat, offs_bone);
copy_m4_m4(tempmat, mat);
- mul_m4_m4m4(mat, tempmat, diff_mat);
+ mult_m4_m4m4(mat, diff_mat, tempmat);
}
else {
/* pose_mat = par_pose_mat * bone_mat * chan_mat */
- mul_m4_m4m4(diff_mat, offs_bone, pchan->parent->pose_mat);
+ mult_m4_m4m4(diff_mat, pchan->parent->pose_mat, offs_bone);
copy_m4_m4(tempmat, mat);
- mul_m4_m4m4(mat, tempmat, diff_mat);
+ mult_m4_m4m4(mat, diff_mat, tempmat);
}
}
else {
copy_m4_m4(diff_mat, pchan->bone->arm_mat);
copy_m4_m4(tempmat, mat);
- mul_m4_m4m4(mat, tempmat, diff_mat);
+ mult_m4_m4m4(mat, diff_mat, tempmat);
}
}
@@ -366,7 +366,7 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4
if (pchan->bone) {
copy_m4_m4(diff_mat, pchan->bone->arm_mat);
copy_m4_m4(tempmat, mat);
- mul_m4_m4m4(mat, diff_mat, tempmat);
+ mult_m4_m4m4(mat, tempmat, diff_mat);
}
/* use pose-space as stepping stone for other spaces */
@@ -384,10 +384,10 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4
/* check if object has a parent */
if (ob->parent) {
/* 'subtract' parent's effects from owner */
- mul_m4_m4m4(diff_mat, ob->parentinv, ob->parent->obmat);
+ mult_m4_m4m4(diff_mat, ob->parent->obmat, ob->parentinv);
invert_m4_m4(imat, diff_mat);
copy_m4_m4(tempmat, mat);
- mul_m4_m4m4(mat, tempmat, imat);
+ mult_m4_m4m4(mat, imat, tempmat);
}
else {
/* Local space in this case will have to be defined as local to the owner's
@@ -399,7 +399,7 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4
invert_m4_m4(imat, diff_mat);
copy_m4_m4(tempmat, mat);
- mul_m4_m4m4(mat, tempmat, imat);
+ mult_m4_m4m4(mat, imat, tempmat);
}
}
else if (from==CONSTRAINT_SPACE_LOCAL && to==CONSTRAINT_SPACE_WORLD) {
@@ -407,8 +407,8 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4
if (ob->parent) {
/* 'add' parent's effect back to owner */
copy_m4_m4(tempmat, mat);
- mul_m4_m4m4(diff_mat, ob->parentinv, ob->parent->obmat);
- mul_m4_m4m4(mat, tempmat, diff_mat);
+ mult_m4_m4m4(diff_mat, ob->parent->obmat, ob->parentinv);
+ mult_m4_m4m4(mat, diff_mat, tempmat);
}
else {
/* Local space in this case will have to be defined as local to the owner's
@@ -419,7 +419,7 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4
zero_v3(diff_mat[3]);
copy_m4_m4(tempmat, mat);
- mul_m4_m4m4(mat, tempmat, diff_mat);
+ mult_m4_m4m4(mat, diff_mat, tempmat);
}
}
}
@@ -612,7 +612,7 @@ static void constraint_target_to_mat4 (Object *ob, const char *substring, float
*/
if (headtail < 0.000001f) {
/* skip length interpolation if set to head */
- mul_m4_m4m4(mat, pchan->pose_mat, ob->obmat);
+ mult_m4_m4m4(mat, ob->obmat, pchan->pose_mat);
}
else {
float tempmat[4][4], loc[3];
@@ -624,7 +624,7 @@ static void constraint_target_to_mat4 (Object *ob, const char *substring, float
copy_m4_m4(tempmat, pchan->pose_mat);
copy_v3_v3(tempmat[3], loc);
- mul_m4_m4m4(mat, tempmat, ob->obmat);
+ mult_m4_m4m4(mat, ob->obmat, tempmat);
}
}
else
@@ -836,12 +836,12 @@ static void childof_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta
/* multiply target (parent matrix) by offset (parent inverse) to get
* the effect of the parent that will be exherted on the owner
*/
- mul_m4_m4m4(parmat, data->invmat, ct->matrix);
+ mult_m4_m4m4(parmat, ct->matrix, data->invmat);
/* now multiply the parent matrix by the owner matrix to get the
* the effect of this constraint (i.e. owner is 'parented' to parent)
*/
- mul_m4_m4m4(cob->matrix, cob->matrix, parmat);
+ mult_m4_m4m4(cob->matrix, parmat, cob->matrix);
}
else {
float invmat[4][4], tempmat[4][4];
@@ -878,13 +878,13 @@ static void childof_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta
/* multiply target (parent matrix) by offset (parent inverse) to get
* the effect of the parent that will be exherted on the owner
*/
- mul_m4_m4m4(parmat, invmat, ct->matrix);
+ mult_m4_m4m4(parmat, ct->matrix, invmat);
/* now multiply the parent matrix by the owner matrix to get the
* the effect of this constraint (i.e. owner is 'parented' to parent)
*/
copy_m4_m4(tempmat, cob->matrix);
- mul_m4_m4m4(cob->matrix, tempmat, parmat);
+ mult_m4_m4m4(cob->matrix, parmat, tempmat);
/* without this, changes to scale and rotation can change location
* of a parentless bone or a disconnected bone. Even though its set
@@ -1294,7 +1294,7 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
if (data->followflag & FOLLOWPATH_RADIUS) {
float tmat[4][4], rmat[4][4];
scale_m4_fl(tmat, radius);
- mul_m4_m4m4(rmat, totmat, tmat);
+ mult_m4_m4m4(rmat, tmat, totmat);
copy_m4_m4(totmat, rmat);
}
@@ -2237,7 +2237,7 @@ static void actcon_evaluate (bConstraint *UNUSED(con), bConstraintOb *cob, ListB
* function has already taken care of everything else.
*/
copy_m4_m4(temp, cob->matrix);
- mul_m4_m4m4(cob->matrix, ct->matrix, temp);
+ mult_m4_m4m4(cob->matrix, temp, ct->matrix);
}
}
@@ -2928,7 +2928,7 @@ static void minmax_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *tar
if (data->flag & MINMAX_USEROT) {
/* take rotation of target into account by doing the transaction in target's localspace */
invert_m4_m4(imat, tarmat);
- mul_m4_m4m4(tmat, obmat, imat);
+ mult_m4_m4m4(tmat, imat, obmat);
copy_m4_m4(obmat, tmat);
unit_m4(tarmat);
}
@@ -2981,7 +2981,7 @@ static void minmax_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *tar
}
if (data->flag & MINMAX_USEROT) {
/* get out of localspace */
- mul_m4_m4m4(tmat, obmat, ct->matrix);
+ mult_m4_m4m4(tmat, ct->matrix, obmat);
copy_m4_m4(cob->matrix, tmat);
}
else {
@@ -3992,7 +3992,7 @@ static void followtrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase
else {
BKE_get_tracking_mat(cob->scene, camob, mat);
- mul_m4_m4m4(cob->matrix, mat, obmat);
+ mult_m4_m4m4(cob->matrix, obmat, mat);
translate_m4(cob->matrix, track->bundle_pos[0], track->bundle_pos[1], track->bundle_pos[2]);
}
}
@@ -4043,7 +4043,7 @@ static void followtrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase
copy_m4_m4(rmat, camob->obmat);
zero_v3(rmat[3]);
- mul_m4_m4m4(cob->matrix, rmat, cob->matrix);
+ mult_m4_m4m4(cob->matrix, cob->matrix, rmat);
copy_v3_v3(cob->matrix[3], disp);
}
@@ -4062,7 +4062,7 @@ static void followtrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase
/* apply camera rotation so Z-axis would be co-linear */
copy_m4_m4(rmat, camob->obmat);
zero_v3(rmat[3]);
- mul_m4_m4m4(cob->matrix, rmat, cob->matrix);
+ mult_m4_m4m4(cob->matrix, cob->matrix, rmat);
copy_v3_v3(cob->matrix[3], disp);
}
@@ -4121,7 +4121,7 @@ static void camerasolver_evaluate (bConstraint *con, bConstraintOb *cob, ListBas
copy_m4_m4(obmat, cob->matrix);
- mul_m4_m4m4(cob->matrix, mat, obmat);
+ mult_m4_m4m4(cob->matrix, obmat, mat);
}
}
@@ -4187,7 +4187,7 @@ static void objectsolver_evaluate (bConstraint *con, bConstraintOb *cob, ListBas
BKE_tracking_get_interpolated_camera(tracking, object, scene->r.cfra, mat);
invert_m4_m4(camimat, cammat);
- mul_m4_m4m4(parmat, data->invmat, cammat);
+ mult_m4_m4m4(parmat, cammat, data->invmat);
copy_m4_m4(cammat, camob->obmat);
copy_m4_m4(obmat, cob->matrix);
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 6efd0a2727f..5305372402b 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -1404,7 +1404,7 @@ int CustomData_number_of_layers(const CustomData *data, int type)
return number;
}
-void *CustomData_duplicate_referenced_layer(struct CustomData *data, int type)
+void *CustomData_duplicate_referenced_layer(struct CustomData *data, const int type, const int totelem)
{
CustomDataLayer *layer;
int layer_index;
@@ -1416,7 +1416,20 @@ void *CustomData_duplicate_referenced_layer(struct CustomData *data, int type)
layer = &data->layers[layer_index];
if (layer->flag & CD_FLAG_NOFREE) {
- layer->data = MEM_dupallocN(layer->data);
+ /* MEM_dupallocN won’t work in case of complex layers, like e.g.
+ * CD_MDEFORMVERT, which has pointers to allocated data...
+ * So in case a custom copy function is defined, use it!
+ */
+ const LayerTypeInfo *typeInfo = layerType_getInfo(layer->type);
+
+ if(typeInfo->copy) {
+ char *dest_data = MEM_mallocN(typeInfo->size * totelem, "CD duplicate ref layer");
+ typeInfo->copy(layer->data, dest_data, totelem);
+ layer->data = dest_data;
+ }
+ else
+ layer->data = MEM_dupallocN(layer->data);
+
layer->flag &= ~CD_FLAG_NOFREE;
}
@@ -1424,7 +1437,7 @@ void *CustomData_duplicate_referenced_layer(struct CustomData *data, int type)
}
void *CustomData_duplicate_referenced_layer_named(struct CustomData *data,
- int type, const char *name)
+ const int type, const char *name, const int totelem)
{
CustomDataLayer *layer;
int layer_index;
@@ -1436,7 +1449,20 @@ void *CustomData_duplicate_referenced_layer_named(struct CustomData *data,
layer = &data->layers[layer_index];
if (layer->flag & CD_FLAG_NOFREE) {
- layer->data = MEM_dupallocN(layer->data);
+ /* MEM_dupallocN won’t work in case of complex layers, like e.g.
+ * CD_MDEFORMVERT, which has pointers to allocated data...
+ * So in case a custom copy function is defined, use it!
+ */
+ const LayerTypeInfo *typeInfo = layerType_getInfo(layer->type);
+
+ if(typeInfo->copy) {
+ char *dest_data = MEM_mallocN(typeInfo->size * totelem, "CD duplicate ref layer");
+ typeInfo->copy(layer->data, dest_data, totelem);
+ layer->data = dest_data;
+ }
+ else
+ layer->data = MEM_dupallocN(layer->data);
+
layer->flag &= ~CD_FLAG_NOFREE;
}
@@ -1995,7 +2021,8 @@ void CustomData_to_bmeshpoly(CustomData *fdata, CustomData *pdata, CustomData *l
CustomData_add_layer(ldata, CD_MLOOPCOL, CD_CALLOC, &(fdata->layers[i].name), 0);
}
}
-void CustomData_from_bmeshpoly(CustomData *fdata, CustomData *pdata, CustomData *ldata, int total){
+void CustomData_from_bmeshpoly(CustomData *fdata, CustomData *pdata, CustomData *ldata, int total)
+{
int i;
for(i=0; i < pdata->totlayer; i++){
if(pdata->layers[i].type == CD_MTEXPOLY)
@@ -2008,7 +2035,8 @@ void CustomData_from_bmeshpoly(CustomData *fdata, CustomData *pdata, CustomData
}
-void CustomData_bmesh_init_pool(CustomData *data, int allocsize){
+void CustomData_bmesh_init_pool(CustomData *data, int allocsize)
+{
if(data->totlayer)data->pool = BLI_mempool_create(data->totsize, allocsize, allocsize, FALSE, FALSE);
}
diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c
index f7f10276ee4..6fb4164d6c6 100644
--- a/source/blender/blenkernel/intern/deform.c
+++ b/source/blender/blenkernel/intern/deform.c
@@ -213,7 +213,7 @@ void defvert_normalize_lock(MDeformVert *dvert, const int def_nr_lock)
dvert->dw[0].weight= 1.0f;
}
else {
- MDeformWeight *dw_lock;
+ MDeformWeight *dw_lock = NULL;
MDeformWeight *dw;
unsigned int i;
float tot_weight= 0.0f;
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index b592e078db3..955e747eded 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -3220,7 +3220,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
/* hit data */
float hitCoord[3];
int hitFace = -1;
- short hitQuad;
+ short hitQuad = 0;
/* Supersampling factor */
if (samples > 1 && surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ)
@@ -4647,7 +4647,7 @@ static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, Scene *sc
#pragma omp parallel for schedule(static)
for (index=0; index<sData->total_points; index++)
{
- float prev_point[3];
+ 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);
}
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index d01e3de0796..b9947c506d1 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -1283,7 +1283,7 @@ static float dvar_eval_transChan (ChannelDriver *driver, DriverVar *dvar)
}
else {
/* worldspace matrix */
- mul_m4_m4m4(mat, pchan->pose_mat, ob->obmat);
+ mult_m4_m4m4(mat, ob->obmat, pchan->pose_mat);
}
}
else {
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index fb734ea4f3d..25ff7b5fa04 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -1508,10 +1508,7 @@ int BKE_write_ibuf(ImBuf *ibuf, const char *name, ImageFormatData *imf)
int ok;
- if(imtype == -1) {
- /* use whatever existing image type is set by 'ibuf' */
- }
- else if(imtype== R_IMF_IMTYPE_IRIS) {
+ if(imtype== R_IMF_IMTYPE_IRIS) {
ibuf->ftype= IMAGIC;
}
#ifdef WITH_HDR
@@ -2277,7 +2274,10 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_
ibuf->x= rres.rectx;
ibuf->y= rres.recty;
- if(ibuf->rect_float!=rectf || rect) /* ensure correct redraw */
+ /* free rect buffer if float buffer changes, so it can be recreated with
+ the updated result, and also in case we got byte buffer from sequencer,
+ so we don't keep reference to freed buffer */
+ if(ibuf->rect_float!=rectf || rect || !rectf)
imb_freerectImBuf(ibuf);
if(rect)
diff --git a/source/blender/blenkernel/intern/image_gen.c b/source/blender/blenkernel/intern/image_gen.c
index 751980f61e8..a93d0221cf0 100644
--- a/source/blender/blenkernel/intern/image_gen.c
+++ b/source/blender/blenkernel/intern/image_gen.c
@@ -30,6 +30,7 @@
#include "BKE_image.h"
#include "BLI_math_color.h"
+#include "BLI_math_base.h"
#include "BLF_api.h"
void BKE_image_buf_fill_color(unsigned char *rect, float *rect_float, int width, int height, float color[4])
@@ -161,21 +162,6 @@ void BKE_image_buf_fill_checker(unsigned char *rect, float *rect_float, int widt
#define BLEND_FLOAT(real, add) (real+add <= 1.0f) ? (real+add) : 1.0f
#define BLEND_CHAR(real, add) ((real + (char)(add * 255.0f)) <= 255) ? (real + (char)(add * 255.0f)) : 255
-static int is_pow2(int n)
-{
- return ((n)&(n-1))==0;
-}
-static int larger_pow2(int n)
-{
- if (is_pow2(n))
- return n;
-
- while(!is_pow2(n))
- n= n&(n-1);
-
- return n*2;
-}
-
static void checker_board_color_fill(unsigned char *rect, float *rect_float, int width, int height)
{
int hue_step, y, x;
@@ -183,7 +169,7 @@ static void checker_board_color_fill(unsigned char *rect, float *rect_float, int
sat= 1.0;
- hue_step= larger_pow2(width / 8);
+ hue_step= power_of_2_max_i(width / 8);
if(hue_step < 8) hue_step= 8;
for(y= 0; y < height; y++)
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index fe07662795e..4c30789db73 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -316,7 +316,7 @@ void init_latt_deform(Object *oblatt, Object *ob)
else {
/* in deformspace, calc matrix */
invert_m4_m4(imat, oblatt->obmat);
- mul_m4_m4m4(lt->latmat, ob->obmat, imat);
+ mult_m4_m4m4(lt->latmat, imat, ob->obmat);
/* back: put in deform array */
invert_m4_m4(imat, lt->latmat);
@@ -470,7 +470,7 @@ typedef struct {
static void init_curve_deform(Object *par, Object *ob, CurveDeform *cd, int dloc)
{
invert_m4_m4(ob->imat, ob->obmat);
- mul_m4_m4m4(cd->objectspace, par->obmat, ob->imat);
+ mult_m4_m4m4(cd->objectspace, ob->imat, par->obmat);
invert_m4_m4(cd->curvespace, cd->objectspace);
copy_m3_m4(cd->objectspace3, cd->objectspace);
diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c
index 0883ec121d6..57fc7473860 100644
--- a/source/blender/blenkernel/intern/mball.c
+++ b/source/blender/blenkernel/intern/mball.c
@@ -1679,7 +1679,7 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */
temp2[3][1]= ml->y;
temp2[3][2]= ml->z;
- mul_m4_m4m4(temp1, temp3, temp2);
+ mult_m4_m4m4(temp1, temp2, temp3);
/* make a copy because of duplicates */
mainb[a]= new_pgn_element(sizeof(MetaElem));
@@ -1691,9 +1691,9 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */
/* mat is the matrix to transform from mball into the basis-mball */
invert_m4_m4(obinv, obmat);
- mul_m4_m4m4(temp2, bob->obmat, obinv);
+ mult_m4_m4m4(temp2, obinv, bob->obmat);
/* MetaBall transformation */
- mul_m4_m4m4(mat, temp1, temp2);
+ mult_m4_m4m4(mat, temp2, temp1);
invert_m4_m4(imat,mat);
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 7be6ef9968d..cc49e8465b9 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -1899,6 +1899,7 @@ static void registerShaderNodes(bNodeTreeType *ttype)
register_node_type_sh_output(ttype);
register_node_type_sh_material(ttype);
register_node_type_sh_camera(ttype);
+ register_node_type_sh_gamma(ttype);
register_node_type_sh_value(ttype);
register_node_type_sh_rgb(ttype);
register_node_type_sh_mix_rgb(ttype);
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 13b6919683c..28c1aacdec5 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -1363,7 +1363,7 @@ void object_make_proxy(Object *ob, Object *target, Object *gob)
* this is closer to making a copy of the object - in-place. */
if(gob) {
ob->rotmode= target->rotmode;
- mul_m4_m4m4(ob->obmat, target->obmat, gob->obmat);
+ mult_m4_m4m4(ob->obmat, gob->obmat, target->obmat);
if(gob->dup_group) { /* should always be true */
float tvec[3];
copy_v3_v3(tvec, gob->dup_group->dupli_ofs);
@@ -1589,9 +1589,9 @@ void object_apply_mat4(Object *ob, float mat[][4], const short use_compat, const
if(use_parent && ob->parent) {
float rmat[4][4], diff_mat[4][4], imat[4][4];
- mul_m4_m4m4(diff_mat, ob->parentinv, ob->parent->obmat);
+ mult_m4_m4m4(diff_mat, ob->parent->obmat, ob->parentinv);
invert_m4_m4(imat, diff_mat);
- mul_m4_m4m4(rmat, mat, imat); /* get the parent relative matrix */
+ mult_m4_m4m4(rmat, imat, mat); /* get the parent relative matrix */
object_apply_mat4(ob, rmat, use_compat, FALSE);
/* same as below, use rmat rather than mat */
@@ -1715,7 +1715,7 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4])
if(cu->flag & CU_PATH_RADIUS) {
float tmat[4][4], rmat[4][4];
scale_m4_fl(tmat, radius);
- mul_m4_m4m4(rmat, mat, tmat);
+ mult_m4_m4m4(rmat, tmat, mat);
copy_m4_m4(mat, rmat);
}
@@ -2473,6 +2473,14 @@ void object_tfm_restore(Object *ob, void *obtfm_pt)
copy_m4_m4(ob->imat, obtfm->imat);
}
+int BKE_object_parent_loop_check(const Object *par, const Object *ob)
+{
+ /* test if 'ob' is a parent somewhere in par's parents */
+ if(par == NULL) return 0;
+ if(ob == par) return 1;
+ return BKE_object_parent_loop_check(par->parent, ob);
+}
+
/* proxy rule: lib_object->proxy_from == the one we borrow from, only set temporal and cleared here */
/* local_object->proxy == pointer to library object, saved in files and read */
@@ -2512,7 +2520,7 @@ void object_handle_update(Scene *scene, Object *ob)
if(ob->proxy_from->proxy_group) {/* transform proxy into group space */
Object *obg= ob->proxy_from->proxy_group;
invert_m4_m4(obg->imat, obg->obmat);
- mul_m4_m4m4(ob->obmat, ob->proxy_from->obmat, obg->imat);
+ mult_m4_m4m4(ob->obmat, obg->imat, ob->proxy_from->obmat);
if(obg->dup_group) { /* should always be true */
add_v3_v3(ob->obmat[3], obg->dup_group->dupli_ofs);
}
diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c
index ae622358fd2..15ce2e377b6 100644
--- a/source/blender/blenkernel/intern/ocean.c
+++ b/source/blender/blenkernel/intern/ocean.c
@@ -1343,7 +1343,8 @@ typedef struct Ocean {
} Ocean;
-float BKE_ocean_jminus_to_foam(float UNUSED(jminus), float UNUSED(coverage)) {
+float BKE_ocean_jminus_to_foam(float UNUSED(jminus), float UNUSED(coverage))
+{
return 0.0f;
}
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 000df5e721d..a3e13b48fe4 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -709,8 +709,8 @@ void psys_render_set(Object *ob, ParticleSystem *psys, float viewmat[][4], float
psys->childcachebufs.first = psys->childcachebufs.last = NULL;
copy_m4_m4(data->winmat, winmat);
- mul_m4_m4m4(data->viewmat, ob->obmat, viewmat);
- mul_m4_m4m4(data->mat, data->viewmat, winmat);
+ mult_m4_m4m4(data->viewmat, viewmat, ob->obmat);
+ mult_m4_m4m4(data->mat, winmat, data->viewmat);
data->winx= winx;
data->winy= winy;
@@ -3374,7 +3374,7 @@ void psys_mat_hair_to_global(Object *ob, DerivedMesh *dm, short from, ParticleDa
psys_mat_hair_to_object(ob, dm, from, pa, facemat);
- mul_m4_m4m4(hairmat, facemat, ob->obmat);
+ mult_m4_m4m4(hairmat, ob->obmat, facemat);
}
/************************************************/
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index 5445c990a9b..411e77de858 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -1491,7 +1491,7 @@ static int ptcache_old_elemsize(PTCacheID *pid)
static void ptcache_find_frames_around(PTCacheID *pid, unsigned int frame, int *fra1, int *fra2)
{
if(pid->cache->flag & PTCACHE_DISK_CACHE) {
- int cfra1=frame-1, cfra2=frame+1;
+ int cfra1=frame, cfra2=frame+1;
while(cfra1 >= pid->cache->startframe && !BKE_ptcache_id_exist(pid, cfra1))
cfra1--;
@@ -1518,7 +1518,7 @@ static void ptcache_find_frames_around(PTCacheID *pid, unsigned int frame, int *
PTCacheMem *pm = pid->cache->mem_cache.first;
PTCacheMem *pm2 = pid->cache->mem_cache.last;
- while(pm->next && pm->next->frame < frame)
+ while(pm->next && pm->next->frame <= frame)
pm= pm->next;
if(pm2->frame < frame) {
@@ -1841,7 +1841,7 @@ static int ptcache_interpolate(PTCacheID *pid, float cfra, int cfra1, int cfra2)
/* possible to get old or interpolated result */
int BKE_ptcache_read(PTCacheID *pid, float cfra)
{
- int cfrai = (int)cfra, cfra1=0, cfra2=0;
+ int cfrai = (int)floor(cfra), cfra1=0, cfra2=0;
int ret = 0;
/* nothing to read to */
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index f7cf0122269..374ef3512e8 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -225,6 +225,7 @@ static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm,
CCGVertHDL fverts[4];
EdgeHash *ehash;
float creaseFactor = (float)ccgSubSurf_getSubdivisionLevels(ss);
+ float uv[3]= {0.0f, 0.0f, 0.0f}; /* only first 2 values are written into */
limit[0]= limit[1]= STD_UV_CONNECT_LIMIT;
vmap= make_uv_vert_map(mface, tface, totface, totvert, 0, limit);
@@ -248,11 +249,8 @@ static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm,
if (v->separate) {
CCGVert *ssv;
CCGVertHDL vhdl = SET_INT_IN_POINTER(v->f*4 + v->tfindex);
- float uv[3];
- uv[0]= (tface+v->f)->uv[v->tfindex][0];
- uv[1]= (tface+v->f)->uv[v->tfindex][1];
- uv[2]= 0.0f;
+ copy_v2_v2(uv, (tface+v->f)->uv[v->tfindex]);
ccgSubSurf_syncVert(ss, vhdl, uv, seam, &ssv);
}
@@ -359,15 +357,10 @@ static void set_subsurf_uv(CCGSubSurf *ss, DerivedMesh *dm, DerivedMesh *result,
for(y = 0; y < gridFaces; y++) {
for(x = 0; x < gridFaces; x++) {
- float *a = faceGridData[(y + 0)*gridSize + x + 0].co;
- float *b = faceGridData[(y + 0)*gridSize + x + 1].co;
- float *c = faceGridData[(y + 1)*gridSize + x + 1].co;
- float *d = faceGridData[(y + 1)*gridSize + x + 0].co;
-
- tf->uv[0][0] = a[0]; tf->uv[0][1] = a[1];
- tf->uv[1][0] = d[0]; tf->uv[1][1] = d[1];
- tf->uv[2][0] = c[0]; tf->uv[2][1] = c[1];
- tf->uv[3][0] = b[0]; tf->uv[3][1] = b[1];
+ copy_v2_v2(tf->uv[0], faceGridData[(y + 0)*gridSize + x + 0].co);
+ copy_v2_v2(tf->uv[1], faceGridData[(y + 1)*gridSize + x + 0].co);
+ copy_v2_v2(tf->uv[2], faceGridData[(y + 1)*gridSize + x + 1].co);
+ copy_v2_v2(tf->uv[3], faceGridData[(y + 0)*gridSize + x + 1].co);
tf++;
}
diff --git a/source/blender/blenkernel/intern/suggestions.c b/source/blender/blenkernel/intern/suggestions.c
index 48bc4926a85..e1e872c42b6 100644
--- a/source/blender/blenkernel/intern/suggestions.c
+++ b/source/blender/blenkernel/intern/suggestions.c
@@ -47,7 +47,8 @@ static SuggList suggestions = {NULL, NULL, NULL, NULL, NULL};
static char *documentation = NULL;
//static int doc_lines = 0;
-static int txttl_cmp(const char *first, const char *second, int len) {
+static int txttl_cmp(const char *first, const char *second, int len)
+{
int cmp, i;
for (cmp=0, i=0; i<len; i++) {
if ( (cmp= toupper(first[i])-toupper(second[i])) ) {
@@ -57,7 +58,8 @@ static int txttl_cmp(const char *first, const char *second, int len) {
return cmp;
}
-static void txttl_free_suggest(void) {
+static void txttl_free_suggest(void)
+{
SuggItem *item, *prev;
for (item = suggestions.last; item; item=prev) {
prev = item->prev;
@@ -69,7 +71,8 @@ static void txttl_free_suggest(void) {
suggestions.top = 0;
}
-static void txttl_free_docs(void) {
+static void txttl_free_docs(void)
+{
if (documentation) {
MEM_freeN(documentation);
documentation = NULL;
@@ -80,23 +83,27 @@ static void txttl_free_docs(void) {
/* General tool functions */
/**************************/
-void free_texttools(void) {
+void free_texttools(void)
+{
txttl_free_suggest();
txttl_free_docs();
}
-void texttool_text_set_active(Text *text) {
+void texttool_text_set_active(Text *text)
+{
if (activeToolText == text) return;
texttool_text_clear();
activeToolText = text;
}
-void texttool_text_clear(void) {
+void texttool_text_clear(void)
+{
free_texttools();
activeToolText = NULL;
}
-short texttool_text_is_active(Text *text) {
+short texttool_text_is_active(Text *text)
+{
return activeToolText==text ? 1 : 0;
}
@@ -104,7 +111,8 @@ short texttool_text_is_active(Text *text) {
/* Suggestion list methods */
/***************************/
-void texttool_suggest_add(const char *name, char type) {
+void texttool_suggest_add(const char *name, char type)
+{
SuggItem *newitem, *item;
int len, cmp;
@@ -154,7 +162,8 @@ void texttool_suggest_add(const char *name, char type) {
suggestions.top= 0;
}
-void texttool_suggest_prefix(const char *prefix) {
+void texttool_suggest_prefix(const char *prefix)
+{
SuggItem *match, *first, *last;
int cmp, len = strlen(prefix), top = 0;
@@ -194,27 +203,33 @@ void texttool_suggest_prefix(const char *prefix) {
}
}
-void texttool_suggest_clear(void) {
+void texttool_suggest_clear(void)
+{
txttl_free_suggest();
}
-SuggItem *texttool_suggest_first(void) {
+SuggItem *texttool_suggest_first(void)
+{
return suggestions.firstmatch;
}
-SuggItem *texttool_suggest_last(void) {
+SuggItem *texttool_suggest_last(void)
+{
return suggestions.lastmatch;
}
-void texttool_suggest_select(SuggItem *sel) {
+void texttool_suggest_select(SuggItem *sel)
+{
suggestions.selected = sel;
}
-SuggItem *texttool_suggest_selected(void) {
+SuggItem *texttool_suggest_selected(void)
+{
return suggestions.selected;
}
-int *texttool_suggest_top(void) {
+int *texttool_suggest_top(void)
+{
return &suggestions.top;
}
@@ -222,7 +237,8 @@ int *texttool_suggest_top(void) {
/* Documentation methods */
/*************************/
-void texttool_docs_show(const char *docs) {
+void texttool_docs_show(const char *docs)
+{
int len;
if (!docs) return;
@@ -246,10 +262,12 @@ void texttool_docs_show(const char *docs) {
documentation[len] = '\0';
}
-char *texttool_docs_get(void) {
+char *texttool_docs_get(void)
+{
return documentation;
}
-void texttool_docs_clear(void) {
+void texttool_docs_clear(void)
+{
txttl_free_docs();
}
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index 60cc029bf6e..7e102bc9854 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -2851,7 +2851,8 @@ void txt_add_marker(Text *text, TextLine *line, int start, int end, const unsign
/* Returns the first matching marker on the specified line between two points.
If the group or flags fields are non-zero the returned flag must be in the
specified group and have at least the specified flags set. */
-TextMarker *txt_find_marker_region(Text *text, TextLine *line, int start, int end, int group, int flags) {
+TextMarker *txt_find_marker_region(Text *text, TextLine *line, int start, int end, int group, int flags)
+{
TextMarker *marker, *next;
int lineno= txt_get_span(text->lines.first, line);
@@ -2918,7 +2919,8 @@ short txt_clear_markers(Text *text, int group, int flags)
/* Finds the marker at the specified line and cursor position with at least the
specified flags set in the given group (if non-zero). */
-TextMarker *txt_find_marker(Text *text, TextLine *line, int curs, int group, int flags) {
+TextMarker *txt_find_marker(Text *text, TextLine *line, int curs, int group, int flags)
+{
TextMarker *marker;
int lineno= txt_get_span(text->lines.first, line);
@@ -2936,7 +2938,8 @@ TextMarker *txt_find_marker(Text *text, TextLine *line, int curs, int group, int
/* Finds the previous marker in the same group. If no other is found, the same
marker will be returned */
-TextMarker *txt_prev_marker(Text *text, TextMarker *marker) {
+TextMarker *txt_prev_marker(Text *text, TextMarker *marker)
+{
TextMarker *tmp= marker;
while (tmp) {
if (tmp->prev) tmp= tmp->prev;
@@ -2949,7 +2952,8 @@ TextMarker *txt_prev_marker(Text *text, TextMarker *marker) {
/* Finds the next marker in the same group. If no other is found, the same
marker will be returned */
-TextMarker *txt_next_marker(Text *text, TextMarker *marker) {
+TextMarker *txt_next_marker(Text *text, TextMarker *marker)
+{
TextMarker *tmp= marker;
while (tmp) {
if (tmp->next) tmp= tmp->next;
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c
index 262c0576186..06680dc9da4 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -1228,7 +1228,7 @@ int BKE_tracking_next(MovieTrackingContext *context)
#pragma omp parallel for private(a) shared(ibuf_new, ok) if(map_size>1)
for(a= 0; a<map_size; a++) {
- TrackContext *track_context;
+ TrackContext *track_context = NULL;
MovieTrackingTrack *track;
MovieTrackingMarker *marker;
@@ -1572,7 +1572,7 @@ static int retrieve_libmv_reconstruct_tracks(MovieReconstructContext *context, M
}
if(origin_set)
- mul_m4_m4m4(mat, mat, imat);
+ mult_m4_m4m4(mat, imat, mat);
copy_m4_m4(reconstructed[reconstruction->camnr].mat, mat);
reconstructed[reconstruction->camnr].framenr= a;
@@ -2036,7 +2036,7 @@ void BKE_tracking_projection_matrix(MovieTracking *tracking, MovieTrackingObject
float imat[4][4];
invert_m4_m4(imat, camera->mat);
- mul_m4_m4m4(mat, imat, winmat);
+ mult_m4_m4m4(mat, winmat, imat);
} else copy_m4_m4(mat, winmat);
}
diff --git a/source/blender/blenlib/BLI_ghash.h b/source/blender/blenlib/BLI_ghash.h
index 976519c281a..f2a7e73e5e0 100644
--- a/source/blender/blenlib/BLI_ghash.h
+++ b/source/blender/blenlib/BLI_ghash.h
@@ -142,6 +142,16 @@ int BLI_ghashutil_strcmp (const void *a, const void *b);
unsigned int BLI_ghashutil_inthash (const void *ptr);
int BLI_ghashutil_intcmp (const void *a, const void *b);
+typedef struct GHashPair {
+ const void *first;
+ int second;
+} GHashPair;
+
+GHashPair* BLI_ghashutil_pairalloc (const void *first, int second);
+unsigned int BLI_ghashutil_pairhash (const void *ptr);
+int BLI_ghashutil_paircmp (const void *a, const void *b);
+void BLI_ghashutil_pairfree (void *ptr);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenlib/BLI_math_base.h b/source/blender/blenlib/BLI_math_base.h
index 204ec9b5159..53db77dc203 100644
--- a/source/blender/blenlib/BLI_math_base.h
+++ b/source/blender/blenlib/BLI_math_base.h
@@ -167,6 +167,11 @@ MINLINE float signf(float f);
MINLINE float power_of_2(float f);
+/* these dont really fit anywhere but were being copied about a lot */
+MINLINE int is_power_of_2_i(int n);
+MINLINE int power_of_2_max_i(int n);
+MINLINE int power_of_2_min_i(int n);
+
MINLINE float shell_angle_to_dist(float angle);
#if (defined(WIN32) || defined(WIN64)) && !defined(FREE_WINDOWS)
diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h
index 008d2ad49ce..4d3a4dfe445 100644
--- a/source/blender/blenlib/BLI_math_matrix.h
+++ b/source/blender/blenlib/BLI_math_matrix.h
@@ -68,10 +68,12 @@ void sub_m3_m3m3(float R[3][3], float A[3][3], float B[3][3]);
void sub_m4_m4m4(float R[4][4], float A[4][4], float B[4][4]);
void mul_m3_m3m3(float R[3][3], float A[3][3], float B[3][3]);
-void mul_m4_m4m4(float R[4][4], float A[4][4], float B[4][4]);
void mul_m4_m3m4(float R[4][4], float A[3][3], float B[4][4]);
void mul_m4_m4m3(float R[4][4], float A[4][4], float B[3][3]);
-void mul_m3_m3m4(float R[3][3], float A[3][3], float B[4][4]);
+/* note: the A,B arguments are reversed compared to previous mul_m4_m4m4
+ function, for consistency with above functions & math notation. */
+void mult_m4_m4m4(float R[4][4], float A[4][4], float B[4][4]);
+void mult_m3_m3m4(float R[3][3], float A[4][4], float B[3][3]);
void mul_serie_m3(float R[3][3],
float M1[3][3], float M2[3][3], float M3[3][3], float M4[3][3],
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h
index d8e880a9dec..e9e44ed7b2c 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -198,6 +198,7 @@ double dot_vn_vn(const float *array_src_a, const float *array_src_b, const int s
float normalize_vn_vn(float *array_tar, const float *array_src, const int size);
float normalize_vn(float *array_tar, const int size);
void range_vn_i(int *array_tar, const int size, const int start);
+void range_vn_fl(float *array_tar, const int size, const float start, const float step);
void negate_vn(float *array_tar, const int size);
void negate_vn_vn(float *array_tar, const float *array_src, const int size);
void mul_vn_fl(float *array_tar, const int size, const float f);
diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h
index a6b4f2c9b92..94189af34fa 100644
--- a/source/blender/blenlib/BLI_utildefines.h
+++ b/source/blender/blenlib/BLI_utildefines.h
@@ -279,24 +279,22 @@
# endif
# if defined(__GNUC__) || defined(_MSC_VER) /* check __func__ is available */
# define BLI_assert(a) \
-do { \
- if (!(a)) { \
+ (void)((!(a)) ? ( \
+ ( \
fprintf(stderr, \
"BLI_assert failed: %s, %s(), %d at \'%s\'\n", \
- __FILE__, __func__, __LINE__, STRINGIFY(a)); \
- _dummy_abort(); \
- } \
-} while (0)
+ __FILE__, __func__, __LINE__, STRINGIFY(a)), \
+ _dummy_abort(), \
+ NULL)) : NULL)
# else
-# define BLI_assert(a) \
-do { \
- if (0 == (a)) { \
+# define BLI_assert(a) \
+ (void)((!(a)) ? ( \
+ ( \
fprintf(stderr, \
"BLI_assert failed: %s, %d at \'%s\'\n", \
- __FILE__, __LINE__, STRINGIFY(a)); \
- _dummy_abort(); \
- } \
-} while (0)
+ __FILE__, __LINE__, STRINGIFY(a)), \
+ _dummy_abort(), \
+ NULL)) : NULL)
# endif
#else
# define BLI_assert(a) (void)0
diff --git a/source/blender/blenlib/intern/BLI_dynstr.c b/source/blender/blenlib/intern/BLI_dynstr.c
index 5cdadce7c01..349bc3492e7 100644
--- a/source/blender/blenlib/intern/BLI_dynstr.c
+++ b/source/blender/blenlib/intern/BLI_dynstr.c
@@ -94,7 +94,8 @@ void BLI_dynstr_append(DynStr *ds, const char *cstr)
ds->curlen+= cstrlen;
}
-void BLI_dynstr_nappend(DynStr *ds, const char *cstr, int len) {
+void BLI_dynstr_nappend(DynStr *ds, const char *cstr, int len)
+{
DynStrElem *dse= malloc(sizeof(*dse));
int cstrlen= BLI_strnlen(cstr, len);
@@ -225,7 +226,8 @@ int BLI_dynstr_get_len(DynStr *ds)
return ds->curlen;
}
-char *BLI_dynstr_get_cstring(DynStr *ds) {
+char *BLI_dynstr_get_cstring(DynStr *ds)
+{
char *s, *rets= MEM_mallocN(ds->curlen+1, "dynstr_cstring");
DynStrElem *dse;
@@ -241,7 +243,8 @@ char *BLI_dynstr_get_cstring(DynStr *ds) {
return rets;
}
-void BLI_dynstr_free(DynStr *ds) {
+void BLI_dynstr_free(DynStr *ds)
+{
DynStrElem *dse;
for (dse= ds->elems; dse; ) {
diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c
index c1894088300..9f388b68c38 100644
--- a/source/blender/blenlib/intern/BLI_ghash.c
+++ b/source/blender/blenlib/intern/BLI_ghash.c
@@ -56,7 +56,8 @@ static unsigned int hashsizes[]= {
/***/
-GHash *BLI_ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info) {
+GHash *BLI_ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info)
+{
GHash *gh= MEM_mallocN(sizeof(*gh), info);
gh->hashfp= hashfp;
gh->cmpfp= cmpfp;
@@ -72,11 +73,13 @@ GHash *BLI_ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info) {
return gh;
}
-int BLI_ghash_size(GHash *gh) {
+int BLI_ghash_size(GHash *gh)
+{
return gh->nentries;
}
-void BLI_ghash_insert(GHash *gh, void *key, void *val) {
+void BLI_ghash_insert(GHash *gh, void *key, void *val)
+{
unsigned int hash= gh->hashfp(key)%gh->nbuckets;
Entry *e= (Entry*) BLI_mempool_alloc(gh->entrypool);
@@ -109,7 +112,8 @@ void BLI_ghash_insert(GHash *gh, void *key, void *val) {
}
}
-void *BLI_ghash_lookup(GHash *gh, const void *key) {
+void *BLI_ghash_lookup(GHash *gh, const void *key)
+{
if(gh) {
unsigned int hash= gh->hashfp(key)%gh->nbuckets;
Entry *e;
@@ -151,7 +155,8 @@ int BLI_ghash_remove (GHash *gh, void *key, GHashKeyFreeFP keyfreefp, GHashValFr
return 0;
}
-int BLI_ghash_haskey(GHash *gh, void *key) {
+int BLI_ghash_haskey(GHash *gh, void *key)
+{
unsigned int hash= gh->hashfp(key)%gh->nbuckets;
Entry *e;
@@ -162,7 +167,8 @@ int BLI_ghash_haskey(GHash *gh, void *key) {
return 0;
}
-void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp) {
+void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
+{
int i;
if (keyfreefp || valfreefp) {
@@ -190,7 +196,8 @@ void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreef
/***/
-GHashIterator *BLI_ghashIterator_new(GHash *gh) {
+GHashIterator *BLI_ghashIterator_new(GHash *gh)
+{
GHashIterator *ghi= MEM_mallocN(sizeof(*ghi), "ghash iterator");
ghi->gh= gh;
ghi->curEntry= NULL;
@@ -203,7 +210,8 @@ GHashIterator *BLI_ghashIterator_new(GHash *gh) {
}
return ghi;
}
-void BLI_ghashIterator_init(GHashIterator *ghi, GHash *gh) {
+void BLI_ghashIterator_init(GHashIterator *ghi, GHash *gh)
+{
ghi->gh= gh;
ghi->curEntry= NULL;
ghi->curBucket= -1;
@@ -214,18 +222,22 @@ void BLI_ghashIterator_init(GHashIterator *ghi, GHash *gh) {
ghi->curEntry= ghi->gh->buckets[ghi->curBucket];
}
}
-void BLI_ghashIterator_free(GHashIterator *ghi) {
+void BLI_ghashIterator_free(GHashIterator *ghi)
+{
MEM_freeN(ghi);
}
-void *BLI_ghashIterator_getKey(GHashIterator *ghi) {
+void *BLI_ghashIterator_getKey(GHashIterator *ghi)
+{
return ghi->curEntry?ghi->curEntry->key:NULL;
}
-void *BLI_ghashIterator_getValue(GHashIterator *ghi) {
+void *BLI_ghashIterator_getValue(GHashIterator *ghi)
+{
return ghi->curEntry?ghi->curEntry->val:NULL;
}
-void BLI_ghashIterator_step(GHashIterator *ghi) {
+void BLI_ghashIterator_step(GHashIterator *ghi)
+{
if (ghi->curEntry) {
ghi->curEntry= ghi->curEntry->next;
while (!ghi->curEntry) {
@@ -236,23 +248,27 @@ void BLI_ghashIterator_step(GHashIterator *ghi) {
}
}
}
-int BLI_ghashIterator_isDone(GHashIterator *ghi) {
+int BLI_ghashIterator_isDone(GHashIterator *ghi)
+{
return !ghi->curEntry;
}
/***/
-unsigned int BLI_ghashutil_ptrhash(const void *key) {
+unsigned int BLI_ghashutil_ptrhash(const void *key)
+{
return (unsigned int)(intptr_t)key;
}
-int BLI_ghashutil_ptrcmp(const void *a, const void *b) {
+int BLI_ghashutil_ptrcmp(const void *a, const void *b)
+{
if (a==b)
return 0;
else
return (a<b)?-1:1;
}
-unsigned int BLI_ghashutil_inthash(const void *ptr) {
+unsigned int BLI_ghashutil_inthash(const void *ptr)
+{
uintptr_t key = (uintptr_t)ptr;
key += ~(key << 16);
@@ -265,14 +281,16 @@ unsigned int BLI_ghashutil_inthash(const void *ptr) {
return (unsigned int)(key & 0xffffffff);
}
-int BLI_ghashutil_intcmp(const void *a, const void *b) {
+int BLI_ghashutil_intcmp(const void *a, const void *b)
+{
if (a==b)
return 0;
else
return (a<b)?-1:1;
}
-unsigned int BLI_ghashutil_strhash(const void *ptr) {
+unsigned int BLI_ghashutil_strhash(const void *ptr)
+{
const char *s= ptr;
unsigned int i= 0;
unsigned char c;
@@ -282,6 +300,39 @@ unsigned int BLI_ghashutil_strhash(const void *ptr) {
return i;
}
-int BLI_ghashutil_strcmp(const void *a, const void *b) {
+int BLI_ghashutil_strcmp(const void *a, const void *b)
+{
return strcmp(a, b);
}
+
+GHashPair *BLI_ghashutil_pairalloc(const void *first, int second)
+{
+ GHashPair *pair = MEM_mallocN(sizeof(GHashPair), "GHashPair");
+ pair->first = first;
+ pair->second = second;
+ return pair;
+}
+
+unsigned int BLI_ghashutil_pairhash(const void *ptr)
+{
+ const GHashPair *pair = ptr;
+ unsigned int hash = BLI_ghashutil_ptrhash(pair->first);
+ return hash ^ BLI_ghashutil_inthash(SET_INT_IN_POINTER(pair->second));
+}
+
+int BLI_ghashutil_paircmp(const void *a, const void *b)
+{
+ const GHashPair *A = a;
+ const GHashPair *B = b;
+
+ int cmp = BLI_ghashutil_ptrcmp(A->first, B->first);
+ if(cmp == 0)
+ return BLI_ghashutil_intcmp(SET_INT_IN_POINTER(A->second), SET_INT_IN_POINTER(B->second));
+ return cmp;
+}
+
+void BLI_ghashutil_pairfree(void *ptr)
+{
+ MEM_freeN((void*)ptr);
+}
+
diff --git a/source/blender/blenlib/intern/BLI_linklist.c b/source/blender/blenlib/intern/BLI_linklist.c
index a9b8cbb6467..6300817ec03 100644
--- a/source/blender/blenlib/intern/BLI_linklist.c
+++ b/source/blender/blenlib/intern/BLI_linklist.c
@@ -35,7 +35,8 @@
#include "BLI_linklist.h"
#include "BLI_memarena.h"
-int BLI_linklist_length(LinkNode *list) {
+int BLI_linklist_length(LinkNode *list)
+{
if (0) {
return list?(1+BLI_linklist_length(list->next)):0;
} else {
@@ -70,7 +71,8 @@ LinkNode *BLI_linklist_find(LinkNode *list, int index)
return NULL;
}
-void BLI_linklist_reverse(LinkNode **listp) {
+void BLI_linklist_reverse(LinkNode **listp)
+{
LinkNode *rhead= NULL, *cur= *listp;
while (cur) {
@@ -85,7 +87,8 @@ void BLI_linklist_reverse(LinkNode **listp) {
*listp= rhead;
}
-void BLI_linklist_prepend(LinkNode **listp, void *ptr) {
+void BLI_linklist_prepend(LinkNode **listp, void *ptr)
+{
LinkNode *nlink= MEM_mallocN(sizeof(*nlink), "nlink");
nlink->link= ptr;
@@ -93,7 +96,8 @@ void BLI_linklist_prepend(LinkNode **listp, void *ptr) {
*listp= nlink;
}
-void BLI_linklist_append(LinkNode **listp, void *ptr) {
+void BLI_linklist_append(LinkNode **listp, void *ptr)
+{
LinkNode *nlink= MEM_mallocN(sizeof(*nlink), "nlink");
LinkNode *node = *listp;
@@ -110,7 +114,8 @@ void BLI_linklist_append(LinkNode **listp, void *ptr) {
}
}
-void BLI_linklist_prepend_arena(LinkNode **listp, void *ptr, MemArena *ma) {
+void BLI_linklist_prepend_arena(LinkNode **listp, void *ptr, MemArena *ma)
+{
LinkNode *nlink= BLI_memarena_alloc(ma, sizeof(*nlink));
nlink->link= ptr;
@@ -118,7 +123,8 @@ void BLI_linklist_prepend_arena(LinkNode **listp, void *ptr, MemArena *ma) {
*listp= nlink;
}
-void BLI_linklist_insert_after(LinkNode **listp, void *ptr) {
+void BLI_linklist_insert_after(LinkNode **listp, void *ptr)
+{
LinkNode *nlink= MEM_mallocN(sizeof(*nlink), "nlink");
LinkNode *node = *listp;
@@ -134,7 +140,8 @@ void BLI_linklist_insert_after(LinkNode **listp, void *ptr) {
}
}
-void BLI_linklist_free(LinkNode *list, LinkNodeFreeFP freefunc) {
+void BLI_linklist_free(LinkNode *list, LinkNodeFreeFP freefunc)
+{
while (list) {
LinkNode *next= list->next;
@@ -146,7 +153,8 @@ void BLI_linklist_free(LinkNode *list, LinkNodeFreeFP freefunc) {
}
}
-void BLI_linklist_apply(LinkNode *list, LinkNodeApplyFP applyfunc, void *userdata) {
+void BLI_linklist_apply(LinkNode *list, LinkNodeApplyFP applyfunc, void *userdata)
+{
for (; list; list= list->next)
applyfunc(list->link, userdata);
}
diff --git a/source/blender/blenlib/intern/BLI_memarena.c b/source/blender/blenlib/intern/BLI_memarena.c
index 308fc6a61e6..4debe1a4b04 100644
--- a/source/blender/blenlib/intern/BLI_memarena.c
+++ b/source/blender/blenlib/intern/BLI_memarena.c
@@ -48,7 +48,8 @@ struct MemArena {
LinkNode *bufs;
};
-MemArena *BLI_memarena_new(int bufsize, const char *name) {
+MemArena *BLI_memarena_new(int bufsize, const char *name)
+{
MemArena *ma= MEM_callocN(sizeof(*ma), "memarena");
ma->bufsize= bufsize;
ma->align = 8;
@@ -57,20 +58,24 @@ MemArena *BLI_memarena_new(int bufsize, const char *name) {
return ma;
}
-void BLI_memarena_use_calloc(MemArena *ma) {
+void BLI_memarena_use_calloc(MemArena *ma)
+{
ma->use_calloc= 1;
}
-void BLI_memarena_use_malloc(MemArena *ma) {
+void BLI_memarena_use_malloc(MemArena *ma)
+{
ma->use_calloc= 0;
}
-void BLI_memarena_use_align(struct MemArena *ma, int align) {
+void BLI_memarena_use_align(struct MemArena *ma, int align)
+{
/* align should be a power of two */
ma->align = align;
}
-void BLI_memarena_free(MemArena *ma) {
+void BLI_memarena_free(MemArena *ma)
+{
BLI_linklist_free(ma->bufs, (void(*)(void*)) MEM_freeN);
MEM_freeN(ma);
}
@@ -78,7 +83,8 @@ void BLI_memarena_free(MemArena *ma) {
/* amt must be power of two */
#define PADUP(num, amt) ((num+(amt-1))&~(amt-1))
-void *BLI_memarena_alloc(MemArena *ma, int size) {
+void *BLI_memarena_alloc(MemArena *ma, int size)
+{
void *ptr;
/* ensure proper alignment by rounding
diff --git a/source/blender/blenlib/intern/bpath.c b/source/blender/blenlib/intern/bpath.c
index 140e1752648..861efcfe6c5 100644
--- a/source/blender/blenlib/intern/bpath.c
+++ b/source/blender/blenlib/intern/bpath.c
@@ -199,7 +199,11 @@ void makeFilesAbsolute(Main *bmain, const char *basedir, ReportList *reports)
- filesize: filesize for the file
*/
#define MAX_RECUR 16
-static int findFileRecursive(char *filename_new, const char *dirname, const char *filename, int *filesize, int *recur_depth)
+static int findFileRecursive(char *filename_new,
+ const char *dirname,
+ const char *filename,
+ int *filesize,
+ int *recur_depth)
{
/* file searching stuff */
DIR *dir;
@@ -314,7 +318,11 @@ static int rewrite_path_fixed(char *path, BPathVisitor visit_cb, const char *abs
}
}
-static int rewrite_path_fixed_dirfile(char path_dir[FILE_MAXDIR], char path_file[FILE_MAXFILE], BPathVisitor visit_cb, const char *absbase, void *userdata)
+static int rewrite_path_fixed_dirfile(char path_dir[FILE_MAXDIR],
+ char path_file[FILE_MAXFILE],
+ BPathVisitor visit_cb,
+ const char *absbase,
+ void *userdata)
{
char path_src[FILE_MAX];
char path_dst[FILE_MAX];
@@ -496,7 +504,8 @@ void bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int fla
SEQ_BEGIN(scene->ed, seq) {
if (SEQ_HAS_PATH(seq)) {
if (ELEM(seq->type, SEQ_MOVIE, SEQ_SOUND)) {
- rewrite_path_fixed_dirfile(seq->strip->dir, seq->strip->stripdata->name, visit_cb, absbase, bpath_user_data);
+ rewrite_path_fixed_dirfile(seq->strip->dir, seq->strip->stripdata->name,
+ visit_cb, absbase, bpath_user_data);
}
else if (seq->type == SEQ_IMAGE) {
/* might want an option not to loop over all strips */
@@ -510,7 +519,8 @@ void bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int fla
}
for(i= 0; i < len; i++, se++) {
- rewrite_path_fixed_dirfile(seq->strip->dir, se->name, visit_cb, absbase, bpath_user_data);
+ rewrite_path_fixed_dirfile(seq->strip->dir, se->name,
+ visit_cb, absbase, bpath_user_data);
}
}
else {
diff --git a/source/blender/blenlib/intern/edgehash.c b/source/blender/blenlib/intern/edgehash.c
index 0eda3e78824..7ae68101154 100644
--- a/source/blender/blenlib/intern/edgehash.c
+++ b/source/blender/blenlib/intern/edgehash.c
@@ -64,7 +64,8 @@ struct EdgeHash {
/***/
-EdgeHash *BLI_edgehash_new(void) {
+EdgeHash *BLI_edgehash_new(void)
+{
EdgeHash *eh= MEM_mallocN(sizeof(*eh), "EdgeHash");
eh->cursize= 0;
eh->nentries= 0;
@@ -76,7 +77,8 @@ EdgeHash *BLI_edgehash_new(void) {
return eh;
}
-void BLI_edgehash_insert(EdgeHash *eh, int v0, int v1, void *val) {
+void BLI_edgehash_insert(EdgeHash *eh, int v0, int v1, void *val)
+{
unsigned int hash;
Entry *e= malloc(sizeof(*e));
@@ -117,7 +119,8 @@ void BLI_edgehash_insert(EdgeHash *eh, int v0, int v1, void *val) {
}
}
-void** BLI_edgehash_lookup_p(EdgeHash *eh, int v0, int v1) {
+void** BLI_edgehash_lookup_p(EdgeHash *eh, int v0, int v1)
+{
unsigned int hash;
Entry *e;
@@ -134,21 +137,25 @@ void** BLI_edgehash_lookup_p(EdgeHash *eh, int v0, int v1) {
return NULL;
}
-void* BLI_edgehash_lookup(EdgeHash *eh, int v0, int v1) {
+void* BLI_edgehash_lookup(EdgeHash *eh, int v0, int v1)
+{
void **value_p = BLI_edgehash_lookup_p(eh,v0,v1);
return value_p?*value_p:NULL;
}
-int BLI_edgehash_haskey(EdgeHash *eh, int v0, int v1) {
+int BLI_edgehash_haskey(EdgeHash *eh, int v0, int v1)
+{
return BLI_edgehash_lookup_p(eh, v0, v1)!=NULL;
}
-int BLI_edgehash_size(EdgeHash *eh) {
+int BLI_edgehash_size(EdgeHash *eh)
+{
return eh->nentries;
}
-void BLI_edgehash_clear(EdgeHash *eh, EdgeHashFreeFP valfreefp) {
+void BLI_edgehash_clear(EdgeHash *eh, EdgeHashFreeFP valfreefp)
+{
int i;
for (i=0; i<eh->nbuckets; i++) {
@@ -168,7 +175,8 @@ void BLI_edgehash_clear(EdgeHash *eh, EdgeHashFreeFP valfreefp) {
eh->nentries= 0;
}
-void BLI_edgehash_free(EdgeHash *eh, EdgeHashFreeFP valfreefp) {
+void BLI_edgehash_free(EdgeHash *eh, EdgeHashFreeFP valfreefp)
+{
BLI_edgehash_clear(eh, valfreefp);
free(eh->buckets);
@@ -184,7 +192,8 @@ struct EdgeHashIterator {
Entry *curEntry;
};
-EdgeHashIterator *BLI_edgehashIterator_new(EdgeHash *eh) {
+EdgeHashIterator *BLI_edgehashIterator_new(EdgeHash *eh)
+{
EdgeHashIterator *ehi= malloc(sizeof(*ehi));
ehi->eh= eh;
ehi->curEntry= NULL;
@@ -197,26 +206,31 @@ EdgeHashIterator *BLI_edgehashIterator_new(EdgeHash *eh) {
}
return ehi;
}
-void BLI_edgehashIterator_free(EdgeHashIterator *ehi) {
+void BLI_edgehashIterator_free(EdgeHashIterator *ehi)
+{
free(ehi);
}
-void BLI_edgehashIterator_getKey(EdgeHashIterator *ehi, int *v0_r, int *v1_r) {
+void BLI_edgehashIterator_getKey(EdgeHashIterator *ehi, int *v0_r, int *v1_r)
+{
if (ehi->curEntry) {
*v0_r = ehi->curEntry->v0;
*v1_r = ehi->curEntry->v1;
}
}
-void *BLI_edgehashIterator_getValue(EdgeHashIterator *ehi) {
+void *BLI_edgehashIterator_getValue(EdgeHashIterator *ehi)
+{
return ehi->curEntry?ehi->curEntry->val:NULL;
}
-void BLI_edgehashIterator_setValue(EdgeHashIterator *ehi, void *val) {
+void BLI_edgehashIterator_setValue(EdgeHashIterator *ehi, void *val)
+{
if(ehi->curEntry)
ehi->curEntry->val= val;
}
-void BLI_edgehashIterator_step(EdgeHashIterator *ehi) {
+void BLI_edgehashIterator_step(EdgeHashIterator *ehi)
+{
if (ehi->curEntry) {
ehi->curEntry= ehi->curEntry->next;
while (!ehi->curEntry) {
@@ -227,7 +241,8 @@ void BLI_edgehashIterator_step(EdgeHashIterator *ehi) {
}
}
}
-int BLI_edgehashIterator_isDone(EdgeHashIterator *ehi) {
+int BLI_edgehashIterator_isDone(EdgeHashIterator *ehi)
+{
return !ehi->curEntry;
}
diff --git a/source/blender/blenlib/intern/math_base_inline.c b/source/blender/blenlib/intern/math_base_inline.c
index 0b2411af009..7e04e0ae566 100644
--- a/source/blender/blenlib/intern/math_base_inline.c
+++ b/source/blender/blenlib/intern/math_base_inline.c
@@ -115,6 +115,31 @@ MINLINE float power_of_2(float val)
return (float)pow(2.0, ceil(log((double)val) / M_LN2));
}
+MINLINE int is_power_of_2_i(int n)
+{
+ return (n & (n - 1)) == 0;
+}
+
+MINLINE int power_of_2_max_i(int n)
+{
+ if (is_power_of_2_i(n))
+ return n;
+
+ while(!is_power_of_2_i(n))
+ n = n & (n - 1);
+
+ return n * 2;
+}
+
+MINLINE int power_of_2_min_i(int n)
+{
+ while (!is_power_of_2_i(n))
+ n = n & (n - 1);
+
+ return n;
+}
+
+
MINLINE float minf(float a, float b)
{
return (a < b)? a: b;
@@ -130,5 +155,6 @@ MINLINE float signf(float f)
return (f < 0.f)? -1.f: 1.f;
}
+
#endif /* BLI_MATH_BASE_INLINE_H */
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c
index 19aa86ee941..cd54c944ba9 100644
--- a/source/blender/blenlib/intern/math_matrix.c
+++ b/source/blender/blenlib/intern/math_matrix.c
@@ -142,7 +142,7 @@ void swap_m4m4(float m1[][4], float m2[][4])
/******************************** Arithmetic *********************************/
-void mul_m4_m4m4(float m1[][4], float m2_[][4], float m3_[][4])
+void mult_m4_m4m4(float m1[][4], float m3_[][4], float m2_[][4])
{
float m2[4][4], m3[4][4];
@@ -215,7 +215,7 @@ void mul_m4_m4m3(float (*m1)[4], float (*m3_)[4], float (*m2_)[3])
}
/* m1 = m2 * m3, ignore the elements on the 4th row/column of m3*/
-void mul_m3_m3m4(float m1[][3], float m2[][3], float m3[][4])
+void mult_m3_m3m4(float m1[][3], float m3[][4], float m2[][3])
{
/* m1[i][j] = m2[i][k] * m3[k][j] */
m1[0][0] = m2[0][0] * m3[0][0] + m2[0][1] * m3[1][0] +m2[0][2] * m3[2][0];
@@ -286,19 +286,19 @@ void mul_serie_m4(float answ[][4], float m1[][4],
if(m1==NULL || m2==NULL) return;
- mul_m4_m4m4(answ, m2, m1);
+ mult_m4_m4m4(answ, m1, m2);
if(m3) {
- mul_m4_m4m4(temp, m3, answ);
+ mult_m4_m4m4(temp, answ, m3);
if(m4) {
- mul_m4_m4m4(answ, m4, temp);
+ mult_m4_m4m4(answ, temp, m4);
if(m5) {
- mul_m4_m4m4(temp, m5, answ);
+ mult_m4_m4m4(temp, answ, m5);
if(m6) {
- mul_m4_m4m4(answ, m6, temp);
+ mult_m4_m4m4(answ, temp, m6);
if(m7) {
- mul_m4_m4m4(temp, m7, answ);
+ mult_m4_m4m4(temp, answ, m7);
if(m8) {
- mul_m4_m4m4(answ, m8, temp);
+ mult_m4_m4m4(answ, temp, m8);
}
else copy_m4_m4(answ, temp);
}
diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c
index e4664798f5d..5596b6f9f22 100644
--- a/source/blender/blenlib/intern/math_rotation.c
+++ b/source/blender/blenlib/intern/math_rotation.c
@@ -1433,7 +1433,7 @@ void mat4_to_dquat(DualQuat *dq,float basemat[][4], float mat[][4])
/* split scaling and rotation, there is probably a faster way to do
this, it's done like this now to correctly get negative scaling */
- mul_m4_m4m4(baseRS, basemat, mat);
+ mult_m4_m4m4(baseRS, mat, basemat);
mat4_to_size(scale,baseRS);
copy_v3_v3(dscale, scale);
@@ -1452,10 +1452,10 @@ void mat4_to_dquat(DualQuat *dq,float basemat[][4], float mat[][4])
copy_v3_v3(baseR[3], baseRS[3]);
invert_m4_m4(baseinv, basemat);
- mul_m4_m4m4(R, baseinv, baseR);
+ mult_m4_m4m4(R, baseR, baseinv);
invert_m4_m4(baseRinv, baseR);
- mul_m4_m4m4(S, baseRS, baseRinv);
+ mult_m4_m4m4(S, baseRinv, baseRS);
/* set scaling part */
mul_serie_m4(dq->scale, basemat, S, baseinv, NULL, NULL, NULL, NULL, NULL);
diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c
index a9ea90ef555..590a48e8085 100644
--- a/source/blender/blenlib/intern/math_vector.c
+++ b/source/blender/blenlib/intern/math_vector.c
@@ -416,6 +416,15 @@ void range_vn_i(int *array_tar, const int size, const int start)
while(i--) { *(array_pt--) = j--; }
}
+void range_vn_fl(float *array_tar, const int size, const float start, const float step)
+{
+ float *array_pt= array_tar + (size-1);
+ int i= size;
+ while(i--) {
+ *(array_pt--) = start + step * (float)(i);
+ }
+}
+
void negate_vn(float *array_tar, const int size)
{
float *array_pt= array_tar + (size-1);
diff --git a/source/blender/blenlib/intern/rand.c b/source/blender/blenlib/intern/rand.c
index b1b7ebed18e..28dc5a696d5 100644
--- a/source/blender/blenlib/intern/rand.c
+++ b/source/blender/blenlib/intern/rand.c
@@ -78,11 +78,13 @@ void rng_free(RNG* rng)
MEM_freeN(rng);
}
-void rng_seed(RNG *rng, unsigned int seed) {
+void rng_seed(RNG *rng, unsigned int seed)
+{
rng->X= (((r_uint64) seed)<<16) | LOWSEED;
}
-void rng_srandom(RNG *rng, unsigned int seed) {
+void rng_srandom(RNG *rng, unsigned int seed)
+{
rng_seed(rng, seed + hash[seed & 255]);
seed= rng_getInt(rng);
rng_seed(rng, seed + hash[seed & 255]);
@@ -90,16 +92,19 @@ void rng_srandom(RNG *rng, unsigned int seed) {
rng_seed(rng, seed + hash[seed & 255]);
}
-int rng_getInt(RNG *rng) {
+int rng_getInt(RNG *rng)
+{
rng->X= (MULTIPLIER*rng->X + ADDEND)&MASK;
return (int) (rng->X>>17);
}
-double rng_getDouble(RNG *rng) {
+double rng_getDouble(RNG *rng)
+{
return (double) rng_getInt(rng)/0x80000000;
}
-float rng_getFloat(RNG *rng) {
+float rng_getFloat(RNG *rng)
+{
return (float) rng_getInt(rng)/0x80000000;
}
@@ -135,28 +140,34 @@ void rng_skip(RNG *rng, int n)
static RNG theBLI_rng = {0};
/* note, this one creates periodical patterns */
-void BLI_srand(unsigned int seed) {
+void BLI_srand(unsigned int seed)
+{
rng_seed(&theBLI_rng, seed);
}
/* using hash table to create better seed */
-void BLI_srandom(unsigned int seed) {
+void BLI_srandom(unsigned int seed)
+{
rng_srandom(&theBLI_rng, seed);
}
-int BLI_rand(void) {
+int BLI_rand(void)
+{
return rng_getInt(&theBLI_rng);
}
-double BLI_drand(void) {
+double BLI_drand(void)
+{
return rng_getDouble(&theBLI_rng);
}
-float BLI_frand(void) {
+float BLI_frand(void)
+{
return rng_getFloat(&theBLI_rng);
}
-void BLI_fillrand(void *addr, int len) {
+void BLI_fillrand(void *addr, int len)
+{
RNG rng;
unsigned char *p= addr;
@@ -188,11 +199,13 @@ void BLI_thread_srandom(int thread, unsigned int seed)
rng_seed(&rng_tab[thread], seed + hash[seed & 255]);
}
-int BLI_thread_rand(int thread) {
+int BLI_thread_rand(int thread)
+{
return rng_getInt(&rng_tab[thread]);
}
-float BLI_thread_frand(int thread) {
+float BLI_thread_frand(int thread)
+{
return rng_getFloat(&rng_tab[thread]);
}
diff --git a/source/blender/blenlib/intern/winstuff.c b/source/blender/blenlib/intern/winstuff.c
index 1b5bb607386..b2002b63a22 100644
--- a/source/blender/blenlib/intern/winstuff.c
+++ b/source/blender/blenlib/intern/winstuff.c
@@ -49,7 +49,8 @@
/* FILE_MAX */
-int BLI_getInstallationDir( char * str ) {
+int BLI_getInstallationDir( char * str )
+{
char dir[FILE_MAXDIR];
int a;
@@ -73,7 +74,8 @@ void RegisterBlendExtension_Fail(HKEY root)
TerminateProcess(GetCurrentProcess(),1);
}
-void RegisterBlendExtension(void) {
+void RegisterBlendExtension(void)
+{
LONG lresult;
HKEY hkey = 0;
HKEY root = 0;
@@ -167,7 +169,8 @@ void RegisterBlendExtension(void) {
TerminateProcess(GetCurrentProcess(),0);
}
-DIR *opendir (const char *path) {
+DIR *opendir (const char *path)
+{
if (GetFileAttributes(path) & FILE_ATTRIBUTE_DIRECTORY) {
DIR *newd= MEM_mallocN(sizeof(DIR), "opendir");
@@ -185,7 +188,8 @@ DIR *opendir (const char *path) {
}
}
-struct dirent *readdir(DIR *dp) {
+struct dirent *readdir(DIR *dp)
+{
if (dp->direntry.d_name) {
MEM_freeN(dp->direntry.d_name);
dp->direntry.d_name= NULL;
@@ -208,7 +212,8 @@ struct dirent *readdir(DIR *dp) {
}
}
-int closedir (DIR *dp) {
+int closedir (DIR *dp)
+{
if (dp->direntry.d_name) MEM_freeN(dp->direntry.d_name);
if (dp->handle!=INVALID_HANDLE_VALUE) FindClose(dp->handle);
@@ -217,7 +222,8 @@ int closedir (DIR *dp) {
return 0;
}
-void get_default_root(char* root) {
+void get_default_root(char* root)
+{
char str[MAX_PATH+1];
/* the default drive to resolve a directory without a specified drive
diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp
index 7bd70e9f289..7b57ed243a1 100644
--- a/source/blender/collada/AnimationExporter.cpp
+++ b/source/blender/collada/AnimationExporter.cpp
@@ -767,7 +767,7 @@ std::string AnimationExporter::create_4x4_source(std::vector<float> &frames , Ob
// compute bone local mat
if (bone->parent) {
invert_m4_m4(ipar, parchan->pose_mat);
- mul_m4_m4m4(mat, pchan->pose_mat, ipar);
+ mult_m4_m4m4(mat, ipar, pchan->pose_mat);
}
else
copy_m4_m4(mat, pchan->pose_mat);
@@ -1274,7 +1274,7 @@ void AnimationExporter::sample_animation(float *v, std::vector<float> &frames, i
// compute bone local mat
if (bone->parent) {
invert_m4_m4(ipar, parchan->pose_mat);
- mul_m4_m4m4(mat, pchan->pose_mat, ipar);
+ mult_m4_m4m4(mat, ipar, pchan->pose_mat);
}
else
copy_m4_m4(mat, pchan->pose_mat);
diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp
index 9b4e47615f7..c47e024aba4 100644
--- a/source/blender/collada/AnimationImporter.cpp
+++ b/source/blender/collada/AnimationImporter.cpp
@@ -723,7 +723,7 @@ void AnimationImporter::apply_matrix_curves( Object * ob, std::vector<FCurve*>&
// calc M
calc_joint_parent_mat_rest(par, NULL, root, node);
- mul_m4_m4m4(temp, matfra, par);
+ mult_m4_m4m4(temp, par, matfra);
// evaluate_joint_world_transform_at_frame(temp, NULL, , node, fra);
@@ -1276,7 +1276,7 @@ Object *AnimationImporter::translate_animation_OLD(COLLADAFW::Node *node,
// calc M
calc_joint_parent_mat_rest(par, NULL, root, node);
- mul_m4_m4m4(temp, matfra, par);
+ mult_m4_m4m4(temp, par, matfra);
// evaluate_joint_world_transform_at_frame(temp, NULL, , node, fra);
@@ -1434,7 +1434,7 @@ void AnimationImporter::evaluate_transform_at_frame(float mat[4][4], COLLADAFW::
float temp[4][4];
copy_m4_m4(temp, mat);
- mul_m4_m4m4(mat, m, temp);
+ mult_m4_m4m4(mat, temp, m);
}
}
@@ -1597,7 +1597,7 @@ void AnimationImporter::get_joint_rest_mat(float mat[4][4], COLLADAFW::Node *roo
calc_joint_parent_mat_rest(par, NULL, root, node);
get_node_mat(m, node, NULL, NULL);
- mul_m4_m4m4(mat, m, par);
+ mult_m4_m4m4(mat, par, m);
}
}
@@ -1616,7 +1616,7 @@ bool AnimationImporter::calc_joint_parent_mat_rest(float mat[4][4], float par[4]
if (par) {
float temp[4][4];
get_node_mat(temp, node, NULL, NULL);
- mul_m4_m4m4(m, temp, par);
+ mult_m4_m4m4(m, par, temp);
}
else {
get_node_mat(m, node, NULL, NULL);
@@ -1656,7 +1656,7 @@ Object *AnimationImporter::get_joint_object(COLLADAFW::Node *root, COLLADAFW::No
float temp[4][4], ipar[4][4];
invert_m4_m4(ipar, par_job->obmat);
copy_m4_m4(temp, mat);
- mul_m4_m4m4(mat, temp, ipar);
+ mult_m4_m4m4(mat, ipar, temp);
}
TransformBase::decompose(mat, job->loc, NULL, job->quat, job->size);
@@ -1689,7 +1689,7 @@ bool AnimationImporter::evaluate_joint_world_transform_at_frame(float mat[4][4],
if (par) {
float temp[4][4];
evaluate_transform_at_frame(temp, node, node == end ? fra : 0.0f);
- mul_m4_m4m4(m, temp, par);
+ mult_m4_m4m4(m, par, temp);
}
else {
evaluate_transform_at_frame(m, node, node == end ? fra : 0.0f);
diff --git a/source/blender/collada/ArmatureExporter.cpp b/source/blender/collada/ArmatureExporter.cpp
index df786c38c71..fcfc197ce80 100644
--- a/source/blender/collada/ArmatureExporter.cpp
+++ b/source/blender/collada/ArmatureExporter.cpp
@@ -218,11 +218,11 @@ void ArmatureExporter::add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW:
float invpar[4][4];
invert_m4_m4(invpar, parchan->pose_mat);
- mul_m4_m4m4(mat, pchan->pose_mat, invpar);
+ mult_m4_m4m4(mat, invpar, pchan->pose_mat);
}
else {
// get world-space from armature-space
- mul_m4_m4m4(mat, pchan->pose_mat, ob_arm->obmat);
+ mult_m4_m4m4(mat, ob_arm->obmat, pchan->pose_mat);
}
TransformWriter::add_node_transform(node, mat,NULL );
@@ -374,7 +374,7 @@ std::string ArmatureExporter::add_inv_bind_mats_source(Object *ob_arm, ListBase
float inv_bind_mat[4][4];
// make world-space matrix, arm_mat is armature-space
- mul_m4_m4m4(world, pchan->bone->arm_mat, ob_arm->obmat);
+ mult_m4_m4m4(world, ob_arm->obmat, pchan->bone->arm_mat);
invert_m4_m4(mat, world);
converter.mat4_to_dae(inv_bind_mat, mat);
diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp
index bababf880a6..4bc0c18551a 100644
--- a/source/blender/collada/ArmatureImporter.cpp
+++ b/source/blender/collada/ArmatureImporter.cpp
@@ -99,7 +99,7 @@ void ArmatureImporter::create_unskinned_bone( COLLADAFW::Node *node, EditBone *p
// get world-space
if (parent){
- mul_m4_m4m4(mat, obmat, parent_mat);
+ mult_m4_m4m4(mat, parent_mat, obmat);
}
else {
@@ -185,7 +185,7 @@ void ArmatureImporter::create_bone(SkinInfo& skin, COLLADAFW::Node *node, EditBo
// get world-space
if (parent)
- mul_m4_m4m4(mat, obmat, parent_mat);
+ mult_m4_m4m4(mat, parent_mat, obmat);
else
copy_m4_m4(mat, obmat);
@@ -584,17 +584,17 @@ void ArmatureImporter::set_pose ( Object * ob_arm , COLLADAFW::Node * root_node
// get world-space
if (parentname){
- mul_m4_m4m4(mat, obmat, parent_mat);
+ mult_m4_m4m4(mat, parent_mat, obmat);
bPoseChannel *parchan = get_pose_channel(ob_arm->pose, parentname);
- mul_m4_m4m4(pchan->pose_mat, mat , parchan->pose_mat);
+ mult_m4_m4m4(pchan->pose_mat, parchan->pose_mat, mat );
}
else {
copy_m4_m4(mat, obmat);
float invObmat[4][4];
invert_m4_m4(invObmat, ob_arm->obmat);
- mul_m4_m4m4(pchan->pose_mat, mat, invObmat);
+ mult_m4_m4m4(pchan->pose_mat, invObmat, mat);
}
mat4_to_axis_angle(ax,&angle,mat);
diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp
index 267aa925c74..05b2b3b738d 100644
--- a/source/blender/collada/DocumentImporter.cpp
+++ b/source/blender/collada/DocumentImporter.cpp
@@ -335,7 +335,7 @@ Object* DocumentImporter::create_instance_node(Object *source_ob, COLLADAFW::Nod
}
}
// calc new matrix and apply
- mul_m4_m4m4(obn->obmat, mat, obn->obmat);
+ mult_m4_m4m4(obn->obmat, obn->obmat, mat);
object_apply_mat4(obn, obn->obmat, 0, 0);
}
}
diff --git a/source/blender/collada/TransformReader.cpp b/source/blender/collada/TransformReader.cpp
index 26049398c26..a73d5243624 100644
--- a/source/blender/collada/TransformReader.cpp
+++ b/source/blender/collada/TransformReader.cpp
@@ -63,7 +63,7 @@ void TransformReader::get_node_mat(float mat[][4], COLLADAFW::Node *node, std::m
}
copy_m4_m4(copy, mat);
- mul_m4_m4m4(mat, cur, copy);
+ mult_m4_m4m4(mat, copy, cur);
if (animation_map) {
// AnimationList that drives this Transformation
diff --git a/source/blender/collada/TransformWriter.cpp b/source/blender/collada/TransformWriter.cpp
index 2b4864ec32b..379a0619040 100644
--- a/source/blender/collada/TransformWriter.cpp
+++ b/source/blender/collada/TransformWriter.cpp
@@ -40,7 +40,7 @@ void TransformWriter::add_node_transform(COLLADASW::Node& node, float mat[][4],
if (parent_mat) {
float invpar[4][4];
invert_m4_m4(invpar, parent_mat);
- mul_m4_m4m4(local, mat, invpar);
+ mult_m4_m4m4(local, invpar, mat);
}
else {
copy_m4_m4(local, mat);
@@ -77,7 +77,7 @@ void TransformWriter::add_node_transform_ob(COLLADASW::Node& node, Object *ob)
// calculate local mat
invert_m4_m4(imat, ob->parent->obmat);
- mul_m4_m4m4(mat, tmat, imat);
+ mult_m4_m4m4(mat, imat, tmat);
// done
diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp
index 6a82446f035..c3aa73510d1 100644
--- a/source/blender/collada/collada_utils.cpp
+++ b/source/blender/collada/collada_utils.cpp
@@ -89,7 +89,7 @@ int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space)
where_is_object(sce, par);
// move child obmat into world space
- mul_m4_m4m4(mat, ob->obmat, par->obmat);
+ mult_m4_m4m4(mat, par->obmat, ob->obmat);
copy_m4_m4(ob->obmat, mat);
}
diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c
index 682b40affc2..25432260387 100644
--- a/source/blender/editors/animation/keyingsets.c
+++ b/source/blender/editors/animation/keyingsets.c
@@ -776,7 +776,7 @@ void ANIM_keying_sets_menu_setup (bContext *C, const char title[], const char op
* - only include entry if it exists
*/
if (scene->active_keyingset) {
- uiItemIntO(layout, "Active Keying Set", ICON_NONE, op_name, "type", i++);
+ uiItemEnumO(layout, op_name, "Active Keying Set", ICON_NONE, "type", i++);
uiItemS(layout);
}
else
@@ -788,7 +788,7 @@ void ANIM_keying_sets_menu_setup (bContext *C, const char title[], const char op
if (scene->keyingsets.first) {
for (ks= scene->keyingsets.first; ks; ks=ks->next, i++) {
if (ANIM_keyingset_context_ok_poll(C, ks))
- uiItemIntO(layout, ks->name, ICON_NONE, op_name, "type", i);
+ uiItemEnumO(layout, op_name, ks->name, ICON_NONE, "type", i);
}
uiItemS(layout);
}
@@ -798,7 +798,7 @@ void ANIM_keying_sets_menu_setup (bContext *C, const char title[], const char op
for (ks= builtin_keyingsets.first; ks; ks=ks->next, i--) {
/* only show KeyingSet if context is suitable */
if (ANIM_keyingset_context_ok_poll(C, ks))
- uiItemIntO(layout, ks->name, ICON_NONE, op_name, "type", i);
+ uiItemEnumO(layout, op_name, ks->name, ICON_NONE, "type", i);
}
uiPupMenuEnd(C, pup);
diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c
index 6dbb08e115f..48f3f78b849 100644
--- a/source/blender/editors/armature/editarmature.c
+++ b/source/blender/editors/armature/editarmature.c
@@ -936,7 +936,7 @@ int join_armature_exec(bContext *C, wmOperator *UNUSED(op))
/* Find the difference matrix */
invert_m4_m4(oimat, ob->obmat);
- mul_m4_m4m4(mat, base->object->obmat, oimat);
+ mult_m4_m4m4(mat, oimat, base->object->obmat);
/* Copy bones and posechannels from the object to the edit armature */
for (pchan=opose->chanbase.first; pchan; pchan=pchann) {
@@ -972,7 +972,7 @@ int join_armature_exec(bContext *C, wmOperator *UNUSED(op))
/* Find the roll */
invert_m4_m4(imat, premat);
- mul_m4_m4m4(difmat, postmat, imat);
+ mult_m4_m4m4(difmat, imat, postmat);
curbone->roll -= (float)atan2(difmat[2][0], difmat[2][2]);
}
diff --git a/source/blender/editors/curve/curve_ops.c b/source/blender/editors/curve/curve_ops.c
index 8df54670bd4..8b2e1bba6cf 100644
--- a/source/blender/editors/curve/curve_ops.c
+++ b/source/blender/editors/curve/curve_ops.c
@@ -151,8 +151,7 @@ void ED_operatormacros_curve(void)
ot= WM_operatortype_append_macro("CURVE_OT_extrude_move", "Extrude Curve and Move", OPTYPE_UNDO|OPTYPE_REGISTER);
ot->description = "Extrude curve and move result";
- otmacro= WM_operatortype_macro_define(ot, "CURVE_OT_extrude");
- RNA_enum_set(otmacro->ptr, "type", 1);
+ WM_operatortype_macro_define(ot, "CURVE_OT_extrude");
otmacro= WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
RNA_enum_set(otmacro->ptr, "proportional", 0);
RNA_boolean_set(otmacro->ptr, "mirror", 0);
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index a679fa3e2bf..762564c1cc9 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -6056,7 +6056,7 @@ int join_curve_exec(bContext *C, wmOperator *UNUSED(op))
if(cu->nurb.first) {
/* watch it: switch order here really goes wrong */
- mul_m4_m4m4(cmat, base->object->obmat, imat);
+ mult_m4_m4m4(cmat, imat, base->object->obmat);
nu= cu->nurb.first;
while(nu) {
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h
index 2cd610e1fe4..f75f2921e51 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -87,8 +87,8 @@ struct rcti;
/* meshtools.c */
-intptr_t mesh_octree_table(struct Object *ob, struct EditMesh *em, float *co, char mode);
-long mesh_mirrtopo_table(struct Object *ob, char mode);
+intptr_t mesh_octree_table(struct Object *ob, struct EditMesh *em, float *co, char mode);
+int mesh_mirrtopo_table(struct Object *ob, char mode);
struct EditVert *editmesh_get_x_mirror_vert(struct Object *ob, struct EditMesh *em, struct EditVert *eve, float *co, int index);
int mesh_get_x_mirror_vert(struct Object *ob, int index);
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index a10de9a8a42..1bad61be324 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -2833,7 +2833,7 @@ uiBut *uiDefBut(uiBlock *block, int type, int retval, const char *str, int x1, i
*/
static int findBitIndex(unsigned int x)
{
- if (!x || (x&(x-1))!=0) { /* x&(x-1) strips lowest bit */
+ if (!x || !is_power_of_2_i(x)) { /* is_power_of_2_i(x) strips lowest bit */
return -1;
} else {
int idx= 0;
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index 06b7822ad05..6ebb67af67a 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -389,17 +389,7 @@ void uiRoundBox(float minx, float miny, float maxx, float maxy, float rad)
glEnable( GL_BLEND );
}
- /* solid part */
- uiDrawBox(GL_POLYGON, minx, miny, maxx, maxy, rad);
-
- /* set antialias line */
- glEnable( GL_LINE_SMOOTH );
- glEnable( GL_BLEND );
-
- uiDrawBox(GL_LINE_LOOP, minx, miny, maxx, maxy, rad);
-
- glDisable( GL_BLEND );
- glDisable( GL_LINE_SMOOTH );
+ ui_draw_anti_roundbox(GL_POLYGON, minx, miny, maxx, maxy, rad);
}
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index d6460f9046e..e4cc605e3f5 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -462,6 +462,7 @@ extern int ui_button_is_active(struct ARegion *ar);
/* interface_widgets.c */
void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3);
+void ui_draw_anti_roundbox(int mode, float minx, float miny, float maxx, float maxy, float rad);
void ui_draw_menu_back(struct uiStyle *style, uiBlock *block, rcti *rect);
void ui_draw_search_back(struct uiStyle *style, uiBlock *block, rcti *rect);
int ui_link_bezier_points(rcti *rect, float coord_array[][2], int resol);
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 1edfa2f4ea6..c21bc09ff27 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -330,7 +330,6 @@ static void uiPanelPop(uiBlock *UNUSED(block))
#endif
/* triangle 'icon' for panel header */
-/* NOTE - this seems to be only used for hiding nodes now */
void UI_DrawTriIcon(float x, float y, char dir)
{
if(dir=='h') {
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index b89a80bb0d7..c535f2c1ad0 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -1071,18 +1071,16 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but)
/* copy to int, gets projected if possible too */
x1= x1f; y1= y1f; x2= x2f; y2= y2f;
- if(butregion) {
- if(butregion->v2d.cur.xmin != butregion->v2d.cur.xmax) {
- UI_view2d_to_region_no_clip(&butregion->v2d, x1f, y1f, &x1, &y1);
- UI_view2d_to_region_no_clip(&butregion->v2d, x2f, y2f, &x2, &y2);
- }
-
- x1 += butregion->winrct.xmin;
- x2 += butregion->winrct.xmin;
- y1 += butregion->winrct.ymin;
- y2 += butregion->winrct.ymin;
+ if(butregion->v2d.cur.xmin != butregion->v2d.cur.xmax) {
+ UI_view2d_to_region_no_clip(&butregion->v2d, x1f, y1f, &x1, &y1);
+ UI_view2d_to_region_no_clip(&butregion->v2d, x2f, y2f, &x2, &y2);
}
-
+
+ x1 += butregion->winrct.xmin;
+ x2 += butregion->winrct.xmin;
+ y1 += butregion->winrct.ymin;
+ y2 += butregion->winrct.ymin;
+
wm_window_get_size(CTX_wm_window(C), &winx, &winy);
if(x2 > winx) {
@@ -1096,7 +1094,8 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but)
x2= winx;
}
}
- if(y1 < 0) { /* XXX butregion NULL check?, there is one above */
+
+ if(y1 < 0) {
int newy1;
UI_view2d_to_region_no_clip(&butregion->v2d, 0, but->y2 + ofsy, NULL, &newy1);
newy1 += butregion->winrct.ymin;
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 9a438070e1e..0da4d3895e0 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -200,7 +200,25 @@ void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y
glDisableClientState(GL_VERTEX_ARRAY);
glDisable(GL_BLEND);
+}
+
+void ui_draw_anti_roundbox(int mode, float minx, float miny, float maxx, float maxy, float rad)
+{
+ float color[4];
+ int j;
+
+ glEnable(GL_BLEND);
+ glGetFloatv(GL_CURRENT_COLOR, color);
+ color[3] *= 0.125f;
+ glColor4fv(color);
+ for(j=0; j<8; j++) {
+ glTranslatef(1.0f * jit[j][0], 1.0f * jit[j][1], 0.0f);
+ uiDrawBox(mode, minx, miny, maxx, maxy, rad);
+ glTranslatef(-1.0f * jit[j][0], -1.0f * jit[j][1], 0.0f);
+ }
+
+ glDisable(GL_BLEND);
}
static void widget_init(uiWidgetBase *wtb)
diff --git a/source/blender/editors/mesh/editmesh_lib.c b/source/blender/editors/mesh/editmesh_lib.c
index 845cc29c91b..5e8105d507a 100644
--- a/source/blender/editors/mesh/editmesh_lib.c
+++ b/source/blender/editors/mesh/editmesh_lib.c
@@ -1316,7 +1316,7 @@ static short extrudeflag_edge(Object *obedit, EditMesh *em, short UNUSED(flag),
if (mmd->mirror_ob) {
float imtx[4][4];
invert_m4_m4(imtx, mmd->mirror_ob->obmat);
- mul_m4_m4m4(mtx, obedit->obmat, imtx);
+ mult_m4_m4m4(mtx, imtx, obedit->obmat);
}
for (eed= em->edges.first; eed; eed= eed->next) {
@@ -1603,7 +1603,7 @@ short extrudeflag_vert(Object *obedit, EditMesh *em, short flag, float *nor, int
if (mmd->mirror_ob) {
float imtx[4][4];
invert_m4_m4(imtx, mmd->mirror_ob->obmat);
- mul_m4_m4m4(mtx, obedit->obmat, imtx);
+ mult_m4_m4m4(mtx, imtx, obedit->obmat);
}
for (eed= em->edges.first; eed; eed= eed->next) {
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 2e5fc515330..37d3d5b587c 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -7246,7 +7246,7 @@ static int sort_faces_exec(bContext *C, wmOperator *op)
float cur[3];
if (event == 1)
- mul_m4_m4m4(mat, OBACT->obmat, rv3d->viewmat); /* apply the view matrix to the object matrix */
+ mult_m4_m4m4(mat, rv3d->viewmat, OBACT->obmat); /* apply the view matrix to the object matrix */
else if (event == 2) { /* sort from cursor */
if( v3d && v3d->localvd ) {
VECCOPY(cur, v3d->cursor);
diff --git a/source/blender/editors/mesh/mesh_navmesh.c b/source/blender/editors/mesh/mesh_navmesh.c
index 48d2c629148..973659cbb35 100644
--- a/source/blender/editors/mesh/mesh_navmesh.c
+++ b/source/blender/editors/mesh/mesh_navmesh.c
@@ -534,7 +534,8 @@ void MESH_OT_navmesh_face_copy(struct wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
-static int compare(const void * a, const void * b){
+static int compare(const void * a, const void * b)
+{
return ( *(int*)a - *(int*)b );
}
diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c
index 707936351cf..dd82f055f14 100644
--- a/source/blender/editors/mesh/meshtools.c
+++ b/source/blender/editors/mesh/meshtools.c
@@ -327,7 +327,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
/* if this is the object we're merging into, no need to do anything */
if(base->object != ob) {
/* watch this: switch matmul order really goes wrong */
- mul_m4_m4m4(cmat, base->object->obmat, imat);
+ mult_m4_m4m4(cmat, imat, base->object->obmat);
/* transform vertex coordinates into new space */
for(a=0, mv=mvert; a < me->totvert; a++, mv++) {
@@ -671,17 +671,17 @@ static void mesh_octree_free_node(MocNode **bt)
/* temporal define, just to make nicer code below */
-#define MOC_ADDNODE(vx, vy, vz) mesh_octree_add_node(basetable + ((vx)*MOC_RES*MOC_RES) + (vy)*MOC_RES + (vz), index)
+#define MOC_INDEX(vx, vy, vz) (((vx)*MOC_RES*MOC_RES) + (vy)*MOC_RES + (vz))
static void mesh_octree_add_nodes(MocNode **basetable, float *co, float *offs, float *div, intptr_t index)
{
float fx, fy, fz;
int vx, vy, vz;
- if (!finite(co[0]) ||
- !finite(co[1]) ||
- !finite(co[2])
- ) {
+ if ( !finite(co[0]) ||
+ !finite(co[1]) ||
+ !finite(co[2]))
+ {
return;
}
@@ -692,33 +692,33 @@ static void mesh_octree_add_nodes(MocNode **basetable, float *co, float *offs, f
CLAMP(fy, 0.0f, MOC_RES-MOC_THRESH);
CLAMP(fz, 0.0f, MOC_RES-MOC_THRESH);
- vx= floor(fx);
- vy= floor(fy);
- vz= floor(fz);
-
- MOC_ADDNODE(vx, vy, vz);
-
- if( vx>0 )
- if( fx-((float)vx)-MOC_THRESH < 0.0f)
- MOC_ADDNODE(vx-1, vy, vz);
- if( vx<MOC_RES-2 )
- if( fx-((float)vx)+MOC_THRESH > 1.0f)
- MOC_ADDNODE(vx+1, vy, vz);
-
- if( vy>0 )
- if( fy-((float)vy)-MOC_THRESH < 0.0f)
- MOC_ADDNODE(vx, vy-1, vz);
- if( vy<MOC_RES-2 )
- if( fy-((float)vy)+MOC_THRESH > 1.0f)
- MOC_ADDNODE(vx, vy+1, vz);
-
- if( vz>0 )
- if( fz-((float)vz)-MOC_THRESH < 0.0f)
- MOC_ADDNODE(vx, vy, vz-1);
- if( vz<MOC_RES-2 )
- if( fz-((float)vz)+MOC_THRESH > 1.0f)
- MOC_ADDNODE(vx, vy, vz+1);
-
+ vx= (int)floorf(fx);
+ vy= (int)floorf(fy);
+ vz= (int)floorf(fz);
+
+ mesh_octree_add_node(basetable + MOC_INDEX(vx, vy, vz), index);
+
+ if (vx > 0)
+ if (fx-((float)vx)-MOC_THRESH < 0.0f)
+ mesh_octree_add_node(basetable + MOC_INDEX(vx - 1, vy, vz), index);
+ if (vx < MOC_RES - 2)
+ if (fx-((float)vx)+MOC_THRESH > 1.0f)
+ mesh_octree_add_node(basetable + MOC_INDEX(vx + 1, vy, vz), index);
+
+ if (vy > 0)
+ if (fy-((float)vy)-MOC_THRESH < 0.0f)
+ mesh_octree_add_node(basetable + MOC_INDEX(vx, vy - 1, vz), index);
+ if (vy < MOC_RES - 2)
+ if (fy-((float)vy)+MOC_THRESH > 1.0f)
+ mesh_octree_add_node(basetable + MOC_INDEX(vx, vy + 1, vz), index);
+
+ if (vz > 0)
+ if (fz-((float)vz)-MOC_THRESH < 0.0f)
+ mesh_octree_add_node(basetable + MOC_INDEX(vx, vy, vz - 1), index);
+ if (vz <MOC_RES - 2)
+ if (fz-((float)vz)+MOC_THRESH > 1.0f)
+ mesh_octree_add_node(basetable + MOC_INDEX(vx, vy, vz + 1), index);
+
}
static intptr_t mesh_octree_find_index(MocNode **bt, MVert *mvert, float *co)
@@ -851,41 +851,45 @@ intptr_t mesh_octree_table(Object *ob, EditMesh *em, float *co, char mode)
/* ********************* MESH VERTEX MIRR TOPO LOOKUP *************** */
-#define MIRRHASH_TYPE int
+typedef int MirrTopoHash_t;
-typedef struct MirrTopoPair {
- long hash;
- int vIndex;
-} MirrTopoPair;
+typedef struct MirrTopoPair_t {
+ MirrTopoHash_t hash;
+ int vIndex;
+} MirrTopoPair_t;
static int MirrTopo_long_sort(const void *l1, const void *l2)
{
- if( (MIRRHASH_TYPE)(intptr_t)l1 > (MIRRHASH_TYPE)(intptr_t)l2 ) return 1;
- else if( (MIRRHASH_TYPE)(intptr_t)l1 < (MIRRHASH_TYPE)(intptr_t)l2 ) return -1;
+ if ((MirrTopoHash_t)(intptr_t)l1 > (MirrTopoHash_t)(intptr_t)l2 ) return 1;
+ else if ((MirrTopoHash_t)(intptr_t)l1 < (MirrTopoHash_t)(intptr_t)l2 ) return -1;
return 0;
}
static int MirrTopo_item_sort(const void *v1, const void *v2)
{
- if( ((MirrTopoPair *)v1)->hash > ((MirrTopoPair *)v2)->hash ) return 1;
- else if( ((MirrTopoPair *)v1)->hash < ((MirrTopoPair *)v2)->hash ) return -1;
+ if (((MirrTopoPair_t *)v1)->hash > ((MirrTopoPair_t *)v2)->hash ) return 1;
+ else if (((MirrTopoPair_t *)v1)->hash < ((MirrTopoPair_t *)v2)->hash ) return -1;
return 0;
}
-static long *mesh_topo_lookup = NULL;
-static int mesh_topo_lookup_tot = -1;
-static int mesh_topo_lookup_mode = -1;
+static intptr_t *mesh_topo_lookup = NULL;
+static int mesh_topo_lookup_vert_tot = -1;
+static int mesh_topo_lookup_edge_tot = -1;
+static int mesh_topo_lookup_mode = -1;
/* mode is 's' start, or 'e' end, or 'u' use */
/* if end, ob can be NULL */
-long mesh_mirrtopo_table(Object *ob, char mode)
+/* note, is supposed return -1 on error, which callers are currently checking for, but is not used so far */
+int mesh_mirrtopo_table(Object *ob, char mode)
{
if(mode=='u') { /* use table */
Mesh *me= ob->data;
if( (mesh_topo_lookup==NULL) ||
(mesh_topo_lookup_mode != ob->mode) ||
- (me->edit_mesh && me->edit_mesh->totvert != mesh_topo_lookup_tot) ||
- (me->edit_mesh==NULL && me->totvert != mesh_topo_lookup_tot)
+ (me->edit_mesh && (me->edit_mesh->totvert != mesh_topo_lookup_vert_tot)) ||
+ (me->edit_mesh && (me->edit_mesh->totedge != mesh_topo_lookup_edge_tot)) ||
+ (me->edit_mesh==NULL && me->totvert != mesh_topo_lookup_vert_tot) ||
+ (me->edit_mesh==NULL && me->totedge != mesh_topo_lookup_edge_tot)
) {
mesh_mirrtopo_table(ob, 's');
}
@@ -899,12 +903,13 @@ long mesh_mirrtopo_table(Object *ob, char mode)
/* editmode*/
EditEdge *eed;
- int a, last, totvert;
+ int a, last;
+ int totvert, totedge;
int totUnique= -1, totUniqueOld= -1;
- MIRRHASH_TYPE *MirrTopoHash = NULL;
- MIRRHASH_TYPE *MirrTopoHash_Prev = NULL;
- MirrTopoPair *MirrTopoPairs;
+ MirrTopoHash_t *MirrTopoHash = NULL;
+ MirrTopoHash_t *MirrTopoHash_Prev = NULL;
+ MirrTopoPair_t *MirrTopoPairs;
mesh_topo_lookup_mode= ob->mode;
/* reallocate if needed */
@@ -926,16 +931,20 @@ long mesh_mirrtopo_table(Object *ob, char mode)
totvert = me->totvert;
}
- MirrTopoHash = MEM_callocN( totvert * sizeof(MIRRHASH_TYPE), "TopoMirr" );
+ MirrTopoHash = MEM_callocN( totvert * sizeof(MirrTopoHash_t), "TopoMirr" );
/* Initialize the vert-edge-user counts used to detect unique topology */
if(em) {
- for(eed=em->edges.first; eed; eed= eed->next) {
+ totedge= 0;
+
+ for(eed=em->edges.first; eed; eed= eed->next, totedge++) {
MirrTopoHash[eed->v1->tmp.l]++;
MirrTopoHash[eed->v2->tmp.l]++;
}
} else {
- for(a=0, medge=me->medge; a<me->totedge; a++, medge++) {
+ totedge= me->totedge;
+
+ for(a=0, medge=me->medge; a < me->totedge; a++, medge++) {
MirrTopoHash[medge->v1]++;
MirrTopoHash[medge->v2]++;
}
@@ -959,10 +968,10 @@ long mesh_mirrtopo_table(Object *ob, char mode)
MirrTopoHash[medge->v2] += MirrTopoHash_Prev[medge->v1];
}
}
- memcpy(MirrTopoHash_Prev, MirrTopoHash, sizeof(MIRRHASH_TYPE) * totvert);
+ memcpy(MirrTopoHash_Prev, MirrTopoHash, sizeof(MirrTopoHash_t) * totvert);
/* sort so we can count unique values */
- qsort(MirrTopoHash_Prev, totvert, sizeof(MIRRHASH_TYPE), MirrTopo_long_sort);
+ qsort(MirrTopoHash_Prev, totvert, sizeof(MirrTopoHash_t), MirrTopo_long_sort);
totUnique = 1; /* account for skiping the first value */
for(a=1; a<totvert; a++) {
@@ -979,7 +988,7 @@ long mesh_mirrtopo_table(Object *ob, char mode)
totUniqueOld = totUnique;
}
/* Copy the hash calculated this iter, so we can use them next time */
- memcpy(MirrTopoHash_Prev, MirrTopoHash, sizeof(MIRRHASH_TYPE) * totvert);
+ memcpy(MirrTopoHash_Prev, MirrTopoHash, sizeof(MirrTopoHash_t) * totvert);
}
/* restore eve->tmp.* */
@@ -996,7 +1005,7 @@ long mesh_mirrtopo_table(Object *ob, char mode)
/* Hash/Index pairs are needed for sorting to find index pairs */
- MirrTopoPairs= MEM_callocN( sizeof(MirrTopoPair) * totvert, "MirrTopoPairs");
+ MirrTopoPairs= MEM_callocN( sizeof(MirrTopoPair_t) * totvert, "MirrTopoPairs");
/* since we are looping through verts, initialize these values here too */
mesh_topo_lookup = MEM_mallocN( totvert * sizeof(long), "mesh_topo_lookup" );
@@ -1014,7 +1023,7 @@ long mesh_mirrtopo_table(Object *ob, char mode)
mesh_topo_lookup[a] = -1;
}
- qsort(MirrTopoPairs, totvert, sizeof(MirrTopoPair), MirrTopo_item_sort);
+ qsort(MirrTopoPairs, totvert, sizeof(MirrTopoPair_t), MirrTopo_item_sort);
/* Since the loop starts at 2, we must define the last index where the hash's differ */
last = ((totvert >= 2) && (MirrTopoPairs[0].hash == MirrTopoPairs[1].hash)) ? 0 : 1;
@@ -1026,8 +1035,8 @@ long mesh_mirrtopo_table(Object *ob, char mode)
if ((a==totvert) || (MirrTopoPairs[a-1].hash != MirrTopoPairs[a].hash)) {
if (a-last==2) {
if(em) {
- mesh_topo_lookup[MirrTopoPairs[a-1].vIndex] = (long)EM_get_vert_for_index(MirrTopoPairs[a-2].vIndex);
- mesh_topo_lookup[MirrTopoPairs[a-2].vIndex] = (long)EM_get_vert_for_index(MirrTopoPairs[a-1].vIndex);
+ mesh_topo_lookup[MirrTopoPairs[a-1].vIndex] = (intptr_t)EM_get_vert_for_index(MirrTopoPairs[a-2].vIndex);
+ mesh_topo_lookup[MirrTopoPairs[a-2].vIndex] = (intptr_t)EM_get_vert_for_index(MirrTopoPairs[a-1].vIndex);
} else {
mesh_topo_lookup[MirrTopoPairs[a-1].vIndex] = MirrTopoPairs[a-2].vIndex;
mesh_topo_lookup[MirrTopoPairs[a-2].vIndex] = MirrTopoPairs[a-1].vIndex;
@@ -1046,14 +1055,16 @@ long mesh_mirrtopo_table(Object *ob, char mode)
MEM_freeN( MirrTopoHash );
MEM_freeN( MirrTopoHash_Prev );
- mesh_topo_lookup_tot = totvert;
+ mesh_topo_lookup_vert_tot = totvert;
+ mesh_topo_lookup_edge_tot = totedge;
} else if(mode=='e') { /* end table */
if (mesh_topo_lookup) {
MEM_freeN(mesh_topo_lookup);
}
mesh_topo_lookup = NULL;
- mesh_topo_lookup_tot= -1;
+ mesh_topo_lookup_vert_tot= -1;
+ mesh_topo_lookup_edge_tot= -1;
}
return 0;
}
@@ -1113,7 +1124,7 @@ static EditVert *editmesh_get_x_mirror_vert_spacial(Object *ob, EditMesh *em, fl
static EditVert *editmesh_get_x_mirror_vert_topo(Object *ob, struct EditMesh *em, EditVert *eve, int index)
{
- long poinval;
+ intptr_t poinval;
if (mesh_mirrtopo_table(ob, 'u')==-1)
return NULL;
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 8c60a4d5868..1547c5daf54 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -47,9 +47,10 @@
#include "DNA_speaker_types.h"
#include "DNA_vfont_types.h"
+#include "BLI_ghash.h"
+#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_string.h"
-#include "BLI_listbase.h"
#include "BLI_utildefines.h"
#include "BKE_anim.h"
@@ -1050,11 +1051,17 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base,
{
ListBase *lb;
DupliObject *dob;
-
+ GHash *dupli_gh= NULL, *parent_gh= NULL;
+
if(!(base->object->transflag & OB_DUPLI))
return;
lb= object_duplilist(scene, base->object);
+
+ if(use_hierarchy || use_base_parent) {
+ dupli_gh= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "make_object_duplilist_real dupli_gh");
+ parent_gh= BLI_ghash_new(BLI_ghashutil_pairhash, BLI_ghashutil_paircmp, "make_object_duplilist_real parent_gh");
+ }
for(dob= lb->first; dob; dob= dob->next) {
Base *basen;
@@ -1083,6 +1090,11 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base,
copy_m4_m4(ob->obmat, dob->mat);
object_apply_mat4(ob, ob->obmat, FALSE, FALSE);
+
+ if(dupli_gh)
+ BLI_ghash_insert(dupli_gh, dob, ob);
+ if(parent_gh)
+ BLI_ghash_insert(parent_gh, BLI_ghashutil_pairalloc(dob->ob, dob->index), ob);
}
if (use_hierarchy) {
@@ -1091,12 +1103,17 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base,
Object *ob_src= dob->ob;
Object *ob_src_par= ob_src->parent;
- Object *ob_dst= (Object *)ob_src->id.newid;
+ Object *ob_dst= BLI_ghash_lookup(dupli_gh, dob);
+ Object *ob_dst_par= NULL;
- if (ob_src_par && ob_src_par->id.newid) {
- /* the parent was also made real, parent newly real duplis */
- Object *ob_dst_par= (Object *)ob_src_par->id.newid;
+ /* find parent that was also made real */
+ if(ob_src_par) {
+ GHashPair *pair = BLI_ghashutil_pairalloc(ob_src_par, dob->index);
+ ob_dst_par = BLI_ghash_lookup(parent_gh, pair);
+ BLI_ghashutil_pairfree(pair);
+ }
+ if (ob_dst_par) {
/* allow for all possible parent types */
ob_dst->partype= ob_src->partype;
BLI_strncpy(ob_dst->parsubstr, ob_src->parsubstr, sizeof(ob_dst->parsubstr));
@@ -1130,8 +1147,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base,
* base object */
for(dob= lb->first; dob; dob= dob->next) {
/* original parents */
- Object *ob_src= dob->ob;
- Object *ob_dst= (Object *)ob_src->id.newid;
+ Object *ob_dst= BLI_ghash_lookup(dupli_gh, dob);
ob_dst->parent= base->object;
ob_dst->partype= PAROBJECT;
@@ -1145,6 +1161,11 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base,
}
}
+ if(dupli_gh)
+ BLI_ghash_free(dupli_gh, NULL, NULL);
+ if(parent_gh)
+ BLI_ghash_free(parent_gh, BLI_ghashutil_pairfree, NULL);
+
copy_object_set_idnew(C, 0);
free_object_duplilist(lb);
diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c
index fa4f50e240f..8266f3501c5 100644
--- a/source/blender/editors/object/object_constraint.c
+++ b/source/blender/editors/object/object_constraint.c
@@ -754,7 +754,7 @@ static void child_get_inverse_matrix (Scene *scene, Object *ob, bConstraint *con
* the effect of the constraint
*/
invert_m4_m4(imat, pchan->pose_mat);
- mul_m4_m4m4(tmat, imat, pmat);
+ mult_m4_m4m4(tmat, pmat, imat);
invert_m4_m4(invmat, tmat);
/* 5. restore constraints */
diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c
index 773974d0cc0..7bb91c1fc4b 100644
--- a/source/blender/editors/object/object_hook.c
+++ b/source/blender/editors/object/object_hook.c
@@ -646,7 +646,7 @@ static int object_hook_reset_exec(bContext *C, wmOperator *op)
float imat[4][4], mat[4][4];
/* calculate the world-space matrix for the pose-channel target first, then carry on as usual */
- mul_m4_m4m4(mat, pchan->pose_mat, hmd->object->obmat);
+ mult_m4_m4m4(mat, hmd->object->obmat, pchan->pose_mat);
invert_m4_m4(imat, mat);
mul_serie_m4(hmd->parentinv, imat, ob->obmat, NULL, NULL, NULL, NULL, NULL, NULL);
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index 6b517b6eeb0..1ba0157e8d3 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -512,19 +512,9 @@ static EnumPropertyItem prop_make_parent_types[] = {
{0, NULL, 0, NULL, NULL}
};
-static int test_parent_loop(Object *par, Object *ob)
-{
- /* test if 'ob' is a parent somewhere in par's parents */
-
- if(par == NULL) return 0;
- if(ob == par) return 1;
-
- return test_parent_loop(par->parent, ob);
-}
-
void ED_object_parent(Object *ob, Object *par, int type, const char *substr)
{
- if(!par || test_parent_loop(par, ob)) {
+ if (!par || BKE_object_parent_loop_check(par, ob)) {
ob->parent= NULL;
ob->partype= PAROBJECT;
ob->parsubstr[0]= 0;
@@ -593,7 +583,7 @@ static int parent_set_exec(bContext *C, wmOperator *op)
if(ob!=par) {
- if( test_parent_loop(par, ob) ) {
+ if (BKE_object_parent_loop_check(par, ob)) {
BKE_report(op->reports, RPT_ERROR, "Loop in parents");
}
else {
@@ -766,7 +756,7 @@ static int parent_noinv_set_exec(bContext *C, wmOperator *op)
/* context iterator */
CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
if (ob != par) {
- if (test_parent_loop(par, ob)) {
+ if (BKE_object_parent_loop_check(par, ob)) {
BKE_report(op->reports, RPT_ERROR, "Loop in parents");
}
else {
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c
index 50fe9d26cf9..bfb5d166e6f 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -892,7 +892,7 @@ static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, in
int totweight = dvert->totweight;
float oldw = 0;
float oldPos[3] = {0};
- float vc, hc, dist;
+ float vc, hc, dist = 0.0f;
int i, k;
float (*changes)[2] = MEM_mallocN(sizeof(float *)*totweight*2, "vertHorzChange");
float *dists = MEM_mallocN(sizeof(float)*totweight, "distance");
@@ -2599,8 +2599,8 @@ static int set_active_group_exec(bContext *C, wmOperator *op)
Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
int nr= RNA_enum_get(op->ptr, "group");
+ BLI_assert(nr+1 >= 0);
ob->actdef= nr+1;
- BLI_assert(ob->actdef >= 0);
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob);
@@ -2733,8 +2733,8 @@ static int vgroup_do_remap(Object *ob, char *name_array, wmOperator *op)
sort_map_update[0]= 0;
vgroup_remap_update_users(ob, sort_map_update);
+ BLI_assert(sort_map_update[ob->actdef] >= 0);
ob->actdef= sort_map_update[ob->actdef];
- BLI_assert(ob->actdef >= 0);
MEM_freeN(sort_map_update);
diff --git a/source/blender/editors/physics/physics_pointcache.c b/source/blender/editors/physics/physics_pointcache.c
index 0cecfa05b49..62e0e5e201d 100644
--- a/source/blender/editors/physics/physics_pointcache.c
+++ b/source/blender/editors/physics/physics_pointcache.c
@@ -59,7 +59,8 @@
#include "physics_intern.h"
-static int cache_break_test(void *UNUSED(cbd)) {
+static int cache_break_test(void *UNUSED(cbd))
+{
return G.afbreek==1;
}
static int ptcache_bake_all_poll(bContext *C)
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 060cae48fa0..3aefe5f9ea3 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -3087,8 +3087,8 @@ static void project_paint_begin(ProjPaintState *ps)
}
/* same as view3d_get_object_project_mat */
- mul_m4_m4m4(vmat, ps->ob->obmat, viewmat);
- mul_m4_m4m4(ps->projectMat, vmat, winmat);
+ mult_m4_m4m4(vmat, viewmat, ps->ob->obmat);
+ mult_m4_m4m4(ps->projectMat, winmat, vmat);
}
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index 5706633d138..c0e3d00343b 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -1023,8 +1023,8 @@ static int weight_sample_group_exec(bContext *C, wmOperator *op)
ViewContext vc;
view3d_set_viewcontext(C, &vc);
+ BLI_assert(type + 1 >= 0);
vc.obact->actdef= type + 1;
- BLI_assert(vc.obact->actdef >= 0);
DAG_id_tag_update(&vc.obact->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, vc.obact);
@@ -1918,8 +1918,9 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *UNUSED
dg= ED_vgroup_add_name(ob, pchan->name); /* sets actdef */
}
else {
- ob->actdef= 1 + BLI_findindex(&ob->defbase, dg);
- BLI_assert(ob->actdef >= 0);
+ int actdef = 1 + BLI_findindex(&ob->defbase, dg);
+ BLI_assert(actdef >= 0);
+ ob->actdef= actdef;
}
}
}
@@ -1930,7 +1931,7 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *UNUSED
}
/* imat for normals */
- mul_m4_m4m4(mat, ob->obmat, wpd->vc.rv3d->viewmat);
+ mult_m4_m4m4(mat, wpd->vc.rv3d->viewmat, ob->obmat);
invert_m4_m4(imat, mat);
copy_m3_m4(wpd->wpimat, imat);
@@ -1980,7 +1981,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
view3d_operator_needs_opengl(C);
/* load projection matrix */
- mul_m4_m4m4(mat, ob->obmat, vc->rv3d->persmat);
+ mult_m4_m4m4(mat, vc->rv3d->persmat, ob->obmat);
pressure = RNA_float_get(itemptr, "pressure");
RNA_float_get_array(itemptr, "mouse", mval);
@@ -2361,7 +2362,7 @@ static int vpaint_stroke_test_start(bContext *C, struct wmOperator *op, wmEvent
copy_vpaint_prev(vp, (unsigned int *)me->mcol, me->totface);
/* some old cruft to sort out later */
- mul_m4_m4m4(mat, ob->obmat, vpd->vc.rv3d->viewmat);
+ mult_m4_m4m4(mat, vpd->vc.rv3d->viewmat, ob->obmat);
invert_m4_m4(imat, mat);
copy_m3_m4(vpd->vpimat, imat);
@@ -2423,7 +2424,7 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
view3d_operator_needs_opengl(C);
/* load projection matrix */
- mul_m4_m4m4(mat, ob->obmat, vc->rv3d->persmat);
+ mult_m4_m4m4(mat, vc->rv3d->persmat, ob->obmat);
mval[0]-= vc->ar->winrct.xmin;
mval[1]-= vc->ar->winrct.ymin;
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index b84fea29e62..272475194ee 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -1688,7 +1688,7 @@ static void calc_flatten_center(Sculpt *sd, Object *ob, PBVHNode **nodes, int to
if(ss->cache->original) {
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
if(sculpt_brush_test_fast(&test, unode->co[vd.i])) {
- add_v3_v3(private_fc, vd.co);
+ add_v3_v3(private_fc, unode->co[vd.i]);
private_count++;
}
}
@@ -1758,7 +1758,7 @@ static void calc_area_normal_and_flatten_center(Sculpt *sd, Object *ob, PBVHNode
add_norm_if(ss->cache->view_normal, private_an, private_out_flip, fno);
// fc
- add_v3_v3(private_fc, vd.co);
+ add_v3_v3(private_fc, unode->co[vd.i]);
private_count++;
}
}
@@ -2121,7 +2121,7 @@ static void do_clay_tubes_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int to
copy_v3_v3(mat[3], ss->cache->location); mat[3][3] = 1;
normalize_m4(mat);
scale_m4_fl(scale, ss->cache->radius);
- mul_m4_m4m4(tmat, scale, mat);
+ mult_m4_m4m4(tmat, mat, scale);
invert_m4_m4(mat, tmat);
#pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c
index dd7ea81d520..8eb1f08b5b0 100644
--- a/source/blender/editors/sound/sound_ops.c
+++ b/source/blender/editors/sound/sound_ops.c
@@ -212,6 +212,104 @@ static void SOUND_OT_open_mono(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "mono", TRUE, "Mono", "Mixdown the sound to mono");
}
+/* ******************************************************* */
+
+static int sound_update_animation_flags_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ Sequence* seq;
+ Scene* scene = CTX_data_scene(C);
+ struct FCurve* fcu;
+ char driven;
+
+ SEQ_BEGIN(scene->ed, seq) {
+ fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "volume", 0, &driven);
+ if(fcu || driven)
+ seq->flag |= SEQ_AUDIO_VOLUME_ANIMATED;
+ else
+ seq->flag &= ~SEQ_AUDIO_VOLUME_ANIMATED;
+
+ fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "pitch", 0, &driven);
+ if(fcu || driven)
+ seq->flag |= SEQ_AUDIO_PITCH_ANIMATED;
+ else
+ seq->flag &= ~SEQ_AUDIO_PITCH_ANIMATED;
+
+ fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "pan", 0, &driven);
+ if(fcu || driven)
+ seq->flag |= SEQ_AUDIO_PAN_ANIMATED;
+ else
+ seq->flag &= ~SEQ_AUDIO_PAN_ANIMATED;
+ }
+ SEQ_END
+
+ fcu = id_data_find_fcurve(&scene->id, scene, &RNA_Scene, "audio_volume", 0, &driven);
+ if(fcu || driven)
+ scene->audio.flag |= AUDIO_VOLUME_ANIMATED;
+ else
+ scene->audio.flag &= ~AUDIO_VOLUME_ANIMATED;
+
+ return OPERATOR_FINISHED;
+}
+
+static void SOUND_OT_update_animation_flags(wmOperatorType *ot)
+{
+ /*
+ This operator is needed to set a correct state of the sound animation
+ System. Unfortunately there's no really correct place to call the exec
+ function, that's why I made it an operator that's only visible in the
+ search menu. Apart from that the bake animation operator calls it too.
+ */
+
+ /* identifiers */
+ ot->name= "Update animation";
+ ot->description= "Update animation flags";
+ ot->idname= "SOUND_OT_update_animation_flags";
+
+ /* api callbacks */
+ ot->exec= sound_update_animation_flags_exec;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER;
+}
+
+/* ******************************************************* */
+
+static int sound_bake_animation_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ Main* bmain = CTX_data_main(C);
+ Scene* scene = CTX_data_scene(C);
+ int oldfra = scene->r.cfra;
+ int cfra;
+
+ sound_update_animation_flags_exec(C, NULL);
+
+ for(cfra = scene->r.sfra > 0 ? scene->r.sfra - 1 : 0; cfra <= scene->r.efra + 1; cfra++)
+ {
+ scene->r.cfra = cfra;
+ scene_update_for_newframe(bmain, scene, scene->lay);
+ }
+
+ scene->r.cfra = oldfra;
+ scene_update_for_newframe(bmain, scene, scene->lay);
+
+ return OPERATOR_FINISHED;
+}
+
+static void SOUND_OT_bake_animation(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Update animation cache";
+ ot->description= "Updates the audio animation cache so that it's up to date";
+ ot->idname= "SOUND_OT_bake_animation";
+
+ /* api callbacks */
+ ot->exec= sound_bake_animation_exec;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER;
+}
+
+
/******************** mixdown operator ********************/
static int sound_mixdown_exec(bContext *C, wmOperator *op)
@@ -228,6 +326,8 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op)
AUD_Codec codec;
const char* result;
+ sound_bake_animation_exec(C, op);
+
RNA_string_get(op->ptr, "filepath", path);
bitrate = RNA_int_get(op->ptr, "bitrate") * 1000;
accuracy = RNA_int_get(op->ptr, "accuracy");
@@ -615,104 +715,6 @@ static void SOUND_OT_unpack(wmOperatorType *ot)
/* ******************************************************* */
-static int sound_update_animation_flags_exec(bContext *C, wmOperator *UNUSED(op))
-{
- Sequence* seq;
- Scene* scene = CTX_data_scene(C);
- struct FCurve* fcu;
- char driven;
-
- SEQ_BEGIN(scene->ed, seq) {
- fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "volume", 0, &driven);
- if(fcu || driven)
- seq->flag |= SEQ_AUDIO_VOLUME_ANIMATED;
- else
- seq->flag &= ~SEQ_AUDIO_VOLUME_ANIMATED;
-
- fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "pitch", 0, &driven);
- if(fcu || driven)
- seq->flag |= SEQ_AUDIO_PITCH_ANIMATED;
- else
- seq->flag &= ~SEQ_AUDIO_PITCH_ANIMATED;
-
- fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "pan", 0, &driven);
- if(fcu || driven)
- seq->flag |= SEQ_AUDIO_PAN_ANIMATED;
- else
- seq->flag &= ~SEQ_AUDIO_PAN_ANIMATED;
- }
- SEQ_END
-
- fcu = id_data_find_fcurve(&scene->id, scene, &RNA_Scene, "audio_volume", 0, &driven);
- if(fcu || driven)
- scene->audio.flag |= AUDIO_VOLUME_ANIMATED;
- else
- scene->audio.flag &= ~AUDIO_VOLUME_ANIMATED;
-
- return OPERATOR_FINISHED;
-}
-
-static void SOUND_OT_update_animation_flags(wmOperatorType *ot)
-{
- /*
- This operator is needed to set a correct state of the sound animation
- System. Unfortunately there's no really correct place to call the exec
- function, that's why I made it an operator that's only visible in the
- search menu. Apart from that the bake animation operator calls it too.
- */
-
- /* identifiers */
- ot->name= "Update animation";
- ot->description= "Update animation flags";
- ot->idname= "SOUND_OT_update_animation_flags";
-
- /* api callbacks */
- ot->exec= sound_update_animation_flags_exec;
-
- /* flags */
- ot->flag= OPTYPE_REGISTER;
-}
-
-/* ******************************************************* */
-
-static int sound_bake_animation_exec(bContext *C, wmOperator *UNUSED(op))
-{
- Main* bmain = CTX_data_main(C);
- Scene* scene = CTX_data_scene(C);
- int oldfra = scene->r.cfra;
- int cfra;
-
- sound_update_animation_flags_exec(C, NULL);
-
- for(cfra = scene->r.sfra > 0 ? scene->r.sfra - 1 : 0; cfra <= scene->r.efra + 1; cfra++)
- {
- scene->r.cfra = cfra;
- scene_update_for_newframe(bmain, scene, scene->lay);
- }
-
- scene->r.cfra = oldfra;
- scene_update_for_newframe(bmain, scene, scene->lay);
-
- return OPERATOR_FINISHED;
-}
-
-static void SOUND_OT_bake_animation(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name= "Update animation cache";
- ot->description= "Updates the audio animation cache so that it's up to date";
- ot->idname= "SOUND_OT_bake_animation";
-
- /* api callbacks */
- ot->exec= sound_bake_animation_exec;
-
- /* flags */
- ot->flag= OPTYPE_REGISTER;
-}
-
-
-/* ******************************************************* */
-
void ED_operatortypes_sound(void)
{
WM_operatortype_append(SOUND_OT_open);
diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c
index 1382d58482d..414999b2f2b 100644
--- a/source/blender/editors/space_action/action_select.c
+++ b/source/blender/editors/space_action/action_select.c
@@ -360,6 +360,8 @@ static EnumPropertyItem prop_column_select_types[] = {
/* ------------------- */
/* Selects all visible keyframes between the specified markers */
+/* TODO, this is almost an _exact_ duplicate of a function of the same name in graph_select.c
+ * should de-duplicate - campbell */
static void markers_selectkeys_between (bAnimContext *ac)
{
ListBase anim_data = {NULL, NULL};
diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c
index ca854c7befe..c37113e924c 100644
--- a/source/blender/editors/space_clip/tracking_ops.c
+++ b/source/blender/editors/space_clip/tracking_ops.c
@@ -1952,7 +1952,7 @@ static void object_solver_inverted_matrix(Scene *scene, Object *ob, float invmat
if(cti->type==CONSTRAINT_TYPE_OBJECTSOLVER) {
bObjectSolverConstraint *data= (bObjectSolverConstraint *)con->data;
- mul_m4_m4m4(invmat, data->invmat, invmat);
+ mult_m4_m4m4(invmat, invmat, data->invmat);
}
}
@@ -2126,7 +2126,7 @@ static void set_axis(Scene *scene, Object *ob, MovieTrackingObject *tracking_ob
if(is_camera) {
invert_m4(mat);
- mul_m4_m4m4(mat, obmat, mat);
+ mult_m4_m4m4(mat, mat, obmat);
}
else {
if(!flip) {
@@ -2143,7 +2143,7 @@ static void set_axis(Scene *scene, Object *ob, MovieTrackingObject *tracking_ob
mul_serie_m4(mat, lmat, mat, ilmat, obmat, NULL, NULL, NULL, NULL);
}
else {
- mul_m4_m4m4(mat, mat, obmat);
+ mult_m4_m4m4(mat, obmat, mat);
}
}
@@ -2227,14 +2227,14 @@ static int set_floor_exec(bContext *C, wmOperator *op)
invert_m4(mat);
object_to_mat4(object, obmat);
- mul_m4_m4m4(mat, obmat, mat);
- mul_m4_m4m4(newmat, mat, rot);
+ mult_m4_m4m4(mat, mat, obmat);
+ mult_m4_m4m4(newmat, rot, mat);
object_apply_mat4(object, newmat, 0, 0);
/* make camera have positive z-coordinate */
if(object->loc[2]<0) {
invert_m4(rot);
- mul_m4_m4m4(newmat, mat, rot);
+ mult_m4_m4m4(newmat, rot, mat);
object_apply_mat4(object, newmat, 0, 0);
}
}
diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c
index 2ba79ee230a..c1268ec61f0 100644
--- a/source/blender/editors/space_graph/graph_select.c
+++ b/source/blender/editors/space_graph/graph_select.c
@@ -386,6 +386,8 @@ static EnumPropertyItem prop_column_select_types[] = {
/* ------------------- */
/* Selects all visible keyframes between the specified markers */
+/* TODO, this is almost an _exact_ duplicate of a function of the same name in action_select.c
+ * should de-duplicate - campbell */
static void markers_selectkeys_between (bAnimContext *ac)
{
ListBase anim_data = {NULL, NULL};
@@ -393,7 +395,7 @@ static void markers_selectkeys_between (bAnimContext *ac)
int filter;
KeyframeEditFunc ok_cb, select_cb;
- KeyframeEditData ked;
+ KeyframeEditData ked= {{NULL}};
float min, max;
/* get extreme markers */
@@ -404,9 +406,8 @@ static void markers_selectkeys_between (bAnimContext *ac)
/* get editing funcs + data */
ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE);
select_cb= ANIM_editkeyframes_select(SELECT_ADD);
-
- memset(&ked, 0, sizeof(KeyframeEditData));
- ked.f1= min;
+
+ ked.f1= min;
ked.f2= max;
/* filter data */
@@ -416,8 +417,8 @@ static void markers_selectkeys_between (bAnimContext *ac)
/* select keys in-between */
for (ale= anim_data.first; ale; ale= ale->next) {
AnimData *adt= ANIM_nla_mapping_get(ac, ale);
-
- if (adt) {
+
+ if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c
index 67b4c43343e..08e073494bb 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -562,6 +562,18 @@ static void node_draw_preview(bNodePreview *preview, rctf *prv)
}
+/* common handle function for operator buttons that need to select the node first */
+static void node_toggle_button_cb(struct bContext *C, void *node_argv, void *op_argv)
+{
+ bNode *node = (bNode*)node_argv;
+ const char *opname = (const char *)op_argv;
+
+ /* select & activate only the button's node */
+ node_select_single(C, node);
+
+ WM_operator_name_call(C, opname, WM_OP_INVOKE_DEFAULT, NULL);
+}
+
static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeTree *ntree, bNode *node)
{
bNodeSocket *sock;
@@ -601,39 +613,34 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT);
uiRoundBox(rct->xmin, rct->ymax-NODE_DY, rct->xmax, rct->ymax, BASIS_RAD);
- /* show/hide icons, note this sequence is copied in do_header_node() node_state.c */
+ /* show/hide icons */
iconofs= rct->xmax - 7.0f;
+ /* preview */
if(node->typeinfo->flag & NODE_PREVIEW) {
- float alpha = (node->flag & (NODE_ACTIVE_ID|NODE_DO_OUTPUT))? 1.0f: 0.5f;
-
+ uiBut *but;
iconofs-=iconbutw;
- uiDefIconBut(node->block, LABEL, B_REDR, ICON_MATERIAL, iconofs, rct->ymax-NODE_DY,
- iconbutw, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, alpha, "");
+ uiBlockSetEmboss(node->block, UI_EMBOSSN);
+ but = uiDefIconBut(node->block, TOGBUT, B_REDR, ICON_MATERIAL,
+ iconofs, rct->ymax-NODE_DY, iconbutw, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
+ uiButSetFunc(but, node_toggle_button_cb, node, (void*)"NODE_OT_preview_toggle");
+ /* XXX this does not work when node is activated and the operator called right afterwards,
+ * since active ID is not updated yet (needs to process the notifier).
+ * This can only work as visual indicator!
+ */
+// if (!(node->flag & (NODE_ACTIVE_ID|NODE_DO_OUTPUT)))
+// uiButSetFlag(but, UI_BUT_DISABLED);
+ uiBlockSetEmboss(node->block, UI_EMBOSS);
}
+ /* group edit */
if(node->type == NODE_GROUP) {
-
- iconofs-=iconbutw;
- uiDefIconBut(node->block, LABEL, B_REDR, ICON_NODETREE, iconofs, rct->ymax-NODE_DY,
- iconbutw, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, 0.5, "");
- }
- if(node->typeinfo->flag & NODE_OPTIONS) {
- iconofs-=iconbutw;
- uiDefIconBut(node->block, LABEL, B_REDR, ICON_BUTS, iconofs, rct->ymax-NODE_DY,
- iconbutw, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, 0.5, "");
- }
- { /* always hide/reveal unused sockets */
- // XXX re-enable
- /* int shade;
- if(node_has_hidden_sockets(node))
- shade= -40;
- else
- shade= -90; */
-
+ uiBut *but;
iconofs-=iconbutw;
-
- uiDefIconBut(node->block, LABEL, B_REDR, ICON_PLUS, iconofs, rct->ymax-NODE_DY,
- iconbutw, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, 0.5, "");
+ uiBlockSetEmboss(node->block, UI_EMBOSSN);
+ but = uiDefIconBut(node->block, TOGBUT, B_REDR, ICON_NODETREE,
+ iconofs, rct->ymax-NODE_DY, iconbutw, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
+ uiButSetFunc(but, node_toggle_button_cb, node, (void*)"NODE_OT_group_edit");
+ uiBlockSetEmboss(node->block, UI_EMBOSS);
}
/* title */
@@ -643,7 +650,19 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
UI_ThemeColorBlendShade(TH_TEXT, color_id, 0.4f, 10);
/* open/close entirely? */
- UI_DrawTriIcon(rct->xmin+10.0f, rct->ymax-NODE_DY/2.0f, 'v');
+ {
+ uiBut *but;
+ int but_size = UI_UNIT_X *0.6f;
+ /* XXX button uses a custom triangle draw below, so make it invisible without icon */
+ uiBlockSetEmboss(node->block, UI_EMBOSSN);
+ but = uiDefBut(node->block, TOGBUT, B_REDR, "",
+ rct->xmin+10.0f-but_size/2, rct->ymax-NODE_DY/2.0f-but_size/2, but_size, but_size, NULL, 0, 0, 0, 0, "");
+ uiButSetFunc(but, node_toggle_button_cb, node, (void*)"NODE_OT_hide_toggle");
+ uiBlockSetEmboss(node->block, UI_EMBOSS);
+
+ /* custom draw function for this button */
+ UI_DrawTriIcon(rct->xmin+10.0f, rct->ymax-NODE_DY/2.0f, 'v');
+ }
/* this isn't doing anything for the label, so commenting out
if(node->flag & SELECT)
@@ -789,7 +808,19 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
UI_ThemeColorBlendShade(TH_TEXT, color_id, 0.4f, 10);
/* open entirely icon */
- UI_DrawTriIcon(rct->xmin+10.0f, centy, 'h');
+ {
+ uiBut *but;
+ int but_size = UI_UNIT_X *0.6f;
+ /* XXX button uses a custom triangle draw below, so make it invisible without icon */
+ uiBlockSetEmboss(node->block, UI_EMBOSSN);
+ but = uiDefBut(node->block, TOGBUT, B_REDR, "",
+ rct->xmin+10.0f-but_size/2, centy-but_size/2, but_size, but_size, NULL, 0, 0, 0, 0, "");
+ uiButSetFunc(but, node_toggle_button_cb, node, (void*)"NODE_OT_hide_toggle");
+ uiBlockSetEmboss(node->block, UI_EMBOSS);
+
+ /* custom draw function for this button */
+ UI_DrawTriIcon(rct->xmin+10.0f, centy, 'h');
+ }
/* disable lines */
if(node->flag & NODE_MUTED)
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index e5a216d42b0..87a56274035 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -690,108 +690,6 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node)
}
}
-static int compare_nodes(bNode *a, bNode *b)
-{
- bNode *parent;
- /* These tell if either the node or any of the parent nodes is selected.
- * A selected parent means an unselected node is also in foreground!
- */
- int a_select=(a->flag & NODE_SELECT), b_select=(b->flag & NODE_SELECT);
- int a_active=(a->flag & NODE_ACTIVE), b_active=(b->flag & NODE_ACTIVE);
-
- /* if one is an ancestor of the other */
- /* XXX there might be a better sorting algorithm for stable topological sort, this is O(n^2) worst case */
- for (parent = a->parent; parent; parent=parent->parent) {
- /* if b is an ancestor, it is always behind a */
- if (parent==b)
- return 1;
- /* any selected ancestor moves the node forward */
- if (parent->flag & NODE_ACTIVE)
- a_active = 1;
- if (parent->flag & NODE_SELECT)
- a_select = 1;
- }
- for (parent = b->parent; parent; parent=parent->parent) {
- /* if a is an ancestor, it is always behind b */
- if (parent==a)
- return 0;
- /* any selected ancestor moves the node forward */
- if (parent->flag & NODE_ACTIVE)
- b_active = 1;
- if (parent->flag & NODE_SELECT)
- b_select = 1;
- }
-
- /* if one of the nodes is in the background and the other not */
- if ((a->flag & NODE_BACKGROUND) && !(b->flag & NODE_BACKGROUND))
- return 0;
- else if (!(a->flag & NODE_BACKGROUND) && (b->flag & NODE_BACKGROUND))
- return 1;
-
- /* if one has a higher selection state (active > selected > nothing) */
- if (!b_active && a_active)
- return 1;
- else if (!b_select && (a_active || a_select))
- return 1;
-
- return 0;
-}
-/* Sorts nodes by selection: unselected nodes first, then selected,
- * then the active node at the very end. Relative order is kept intact!
- */
-void node_sort(bNodeTree *ntree)
-{
- /* merge sort is the algorithm of choice here */
- bNode *first_a, *first_b, *node_a, *node_b, *tmp;
- int totnodes= BLI_countlist(&ntree->nodes);
- int k, a, b;
-
- k = 1;
- while (k < totnodes) {
- first_a = first_b = ntree->nodes.first;
-
- do {
- /* setup first_b pointer */
- for (b=0; b < k && first_b; ++b) {
- first_b = first_b->next;
- }
- /* all batches merged? */
- if (first_b==NULL)
- break;
-
- /* merge batches */
- node_a = first_a;
- node_b = first_b;
- a = b = 0;
- while (a < k && b < k && node_b) {
- if (compare_nodes(node_a, node_b)==0) {
- node_a = node_a->next;
- ++a;
- }
- else {
- tmp = node_b;
- node_b = node_b->next;
- ++b;
- BLI_remlink(&ntree->nodes, tmp);
- BLI_insertlinkbefore(&ntree->nodes, node_a, tmp);
- }
- }
-
- /* setup first pointers for next batch */
- first_b = node_b;
- for (; b < k; ++b) {
- /* all nodes sorted? */
- if (first_b==NULL)
- break;
- first_b = first_b->next;
- }
- first_a = first_b;
- } while (first_b);
-
- k = k << 1;
- }
-}
-
static int inside_rctf(rctf *bounds, rctf *rect)
{
return (bounds->xmin <= rect->xmin && bounds->xmax >= rect->xmax
@@ -940,7 +838,7 @@ static int node_group_edit_exec(bContext *C, wmOperator *UNUSED(op))
ED_preview_kill_jobs(C);
if (snode->nodetree==snode->edittree) {
- bNode *gnode= nodeGetActive(snode->nodetree);
+ bNode *gnode = nodeGetActive(snode->edittree);
snode_make_group_editable(snode, gnode);
}
else
@@ -955,8 +853,11 @@ static int node_group_edit_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(e
{
SpaceNode *snode = CTX_wm_space_node(C);
bNode *gnode;
-
- gnode= nodeGetActive(snode->edittree);
+
+ gnode = nodeGetActive(snode->edittree);
+ if (!gnode)
+ return OPERATOR_CANCELLED;
+
/* XXX callback? */
if(gnode && gnode->id && GS(gnode->id->name)==ID_NT && gnode->id->lib) {
uiPupMenuOkee(C, op->type->idname, "Make group local?");
@@ -1696,90 +1597,8 @@ void NODE_OT_resize(wmOperatorType *ot)
ot->flag= OPTYPE_BLOCKING;
}
-/* ********************** select ******************** */
-
-
-/* no undo here! */
-void node_deselectall(SpaceNode *snode)
-{
- bNode *node;
-
- for(node= snode->edittree->nodes.first; node; node= node->next)
- node->flag &= ~SELECT;
-}
-/* return 1 if we need redraw otherwise zero. */
-int node_select_same_type(SpaceNode *snode)
-{
- bNode *nac, *p;
- int redraw;
-
- /* search for the active node. */
- for (nac= snode->edittree->nodes.first; nac; nac= nac->next) {
- if (nac->flag & SELECT)
- break;
- }
-
- /* no active node, return. */
- if (!nac)
- return(0);
-
- redraw= 0;
- for (p= snode->edittree->nodes.first; p; p= p->next) {
- if (p->type != nac->type && p->flag & SELECT) {
- /* if it's selected but different type, unselect */
- redraw= 1;
- p->flag &= ~SELECT;
- }
- else if (p->type == nac->type && (!(p->flag & SELECT))) {
- /* if it's the same type and is not selected, select! */
- redraw= 1;
- p->flag |= SELECT;
- }
- }
- return(redraw);
-}
-
-/* return 1 if we need redraw, otherwise zero.
- * dir can be 0 == next or 0 != prev.
- */
-int node_select_same_type_np(SpaceNode *snode, int dir)
-{
- bNode *nac, *p;
-
- /* search the active one. */
- for (nac= snode->edittree->nodes.first; nac; nac= nac->next) {
- if (nac->flag & SELECT)
- break;
- }
-
- /* no active node, return. */
- if (!nac)
- return(0);
-
- if (dir == 0)
- p= nac->next;
- else
- p= nac->prev;
-
- while (p) {
- /* Now search the next with the same type. */
- if (p->type == nac->type)
- break;
-
- if (dir == 0)
- p= p->next;
- else
- p= p->prev;
- }
-
- if (p) {
- node_deselectall(snode);
- p->flag |= SELECT;
- return(1);
- }
- return(0);
-}
+/* ********************** hidden sockets ******************** */
int node_has_hidden_sockets(bNode *node)
{
@@ -1794,6 +1613,31 @@ int node_has_hidden_sockets(bNode *node)
return 0;
}
+/* note: call node_tree_verify_groups(snode->nodetree) after this
+ */
+void node_set_hidden_sockets(SpaceNode *snode, bNode *node, int set)
+{
+ bNodeSocket *sock;
+
+ if(set==0) {
+ for(sock= node->inputs.first; sock; sock= sock->next)
+ sock->flag &= ~SOCK_HIDDEN;
+ for(sock= node->outputs.first; sock; sock= sock->next)
+ sock->flag &= ~SOCK_HIDDEN;
+ }
+ else {
+ /* hide unused sockets */
+ for(sock= node->inputs.first; sock; sock= sock->next) {
+ if(sock->link==NULL)
+ sock->flag |= SOCK_HIDDEN;
+ }
+ for(sock= node->outputs.first; sock; sock= sock->next) {
+ if(nodeCountSocketLinks(snode->edittree, sock)==0)
+ sock->flag |= SOCK_HIDDEN;
+ }
+ }
+}
+
static void node_link_viewer(SpaceNode *snode, bNode *tonode)
{
bNode *node;
@@ -2232,7 +2076,7 @@ bNode *node_add_node(SpaceNode *snode, Main *bmain, Scene *scene, bNodeTemplate
{
bNode *node= NULL, *gnode;
- node_deselectall(snode);
+ node_deselect_all(snode);
node = nodeAddNode(snode->edittree, ntemp);
@@ -3130,15 +2974,21 @@ void NODE_OT_group_make(wmOperatorType *ot)
static void node_flag_toggle_exec(SpaceNode *snode, int toggle_flag)
{
- int tot_eq= 0, tot_neq= 0;
bNode *node;
+ int tot_eq= 0, tot_neq= 0;
+ /* Toggles the flag on all selected nodes.
+ * If the flag is set on all nodes it is unset.
+ * If the flag is not set on all nodes, it is set.
+ */
for(node= snode->edittree->nodes.first; node; node= node->next) {
if(node->flag & SELECT) {
-
+
if(toggle_flag== NODE_PREVIEW && (node->typeinfo->flag & NODE_PREVIEW)==0)
continue;
-
+ if(toggle_flag== NODE_OPTIONS && (node->typeinfo->flag & NODE_OPTIONS)==0)
+ continue;
+
if(node->flag & toggle_flag)
tot_eq++;
else
@@ -3147,10 +2997,12 @@ static void node_flag_toggle_exec(SpaceNode *snode, int toggle_flag)
}
for(node= snode->edittree->nodes.first; node; node= node->next) {
if(node->flag & SELECT) {
-
+
if(toggle_flag== NODE_PREVIEW && (node->typeinfo->flag & NODE_PREVIEW)==0)
continue;
-
+ if(toggle_flag== NODE_OPTIONS && (node->typeinfo->flag & NODE_OPTIONS)==0)
+ continue;
+
if( (tot_eq && tot_neq) || tot_eq==0)
node->flag |= toggle_flag;
else
@@ -3159,7 +3011,7 @@ static void node_flag_toggle_exec(SpaceNode *snode, int toggle_flag)
}
}
-static int node_hide_exec(bContext *C, wmOperator *UNUSED(op))
+static int node_hide_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceNode *snode= CTX_wm_space_node(C);
@@ -3182,14 +3034,14 @@ void NODE_OT_hide_toggle(wmOperatorType *ot)
ot->idname= "NODE_OT_hide_toggle";
/* callbacks */
- ot->exec= node_hide_exec;
+ ot->exec= node_hide_toggle_exec;
ot->poll= ED_operator_node_active;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
-static int node_preview_exec(bContext *C, wmOperator *UNUSED(op))
+static int node_preview_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceNode *snode= CTX_wm_space_node(C);
@@ -3214,7 +3066,37 @@ void NODE_OT_preview_toggle(wmOperatorType *ot)
ot->idname= "NODE_OT_preview_toggle";
/* callbacks */
- ot->exec= node_preview_exec;
+ ot->exec= node_preview_toggle_exec;
+ ot->poll= ED_operator_node_active;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+static int node_options_toggle_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ SpaceNode *snode= CTX_wm_space_node(C);
+
+ /* sanity checking (poll callback checks this already) */
+ if((snode == NULL) || (snode->edittree == NULL))
+ return OPERATOR_CANCELLED;
+
+ node_flag_toggle_exec(snode, NODE_OPTIONS);
+
+ snode_notify(C, snode);
+
+ return OPERATOR_FINISHED;
+}
+
+void NODE_OT_options_toggle(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Toggle Node Options";
+ ot->description= "Toggle option buttons display for selected nodes";
+ ot->idname= "NODE_OT_options_toggle";
+
+ /* callbacks */
+ ot->exec= node_options_toggle_exec;
ot->poll= ED_operator_node_active;
/* flags */
@@ -3225,7 +3107,7 @@ static int node_socket_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceNode *snode= CTX_wm_space_node(C);
bNode *node;
- int hidden= 0;
+ int hidden;
/* sanity checking (poll callback checks this already) */
if((snode == NULL) || (snode->edittree == NULL))
@@ -3233,6 +3115,8 @@ static int node_socket_toggle_exec(bContext *C, wmOperator *UNUSED(op))
ED_preview_kill_jobs(C);
+ /* Toggle for all selected nodes */
+ hidden = 0;
for(node= snode->edittree->nodes.first; node; node= node->next) {
if(node->flag & SELECT) {
if(node_has_hidden_sockets(node)) {
@@ -3241,7 +3125,7 @@ static int node_socket_toggle_exec(bContext *C, wmOperator *UNUSED(op))
}
}
}
-
+
for(node= snode->edittree->nodes.first; node; node= node->next) {
if(node->flag & SELECT) {
node_set_hidden_sockets(snode, node, !hidden);
@@ -3570,7 +3454,7 @@ static int node_add_file_exec(bContext *C, wmOperator *op)
}
}
- node_deselectall(snode);
+ node_deselect_all(snode);
if (snode->nodetree->type==NTREE_COMPOSIT)
ntemp.type = CMP_NODE_IMAGE;
diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h
index 88b81d0855c..9068493360e 100644
--- a/source/blender/editors/space_node/node_intern.h
+++ b/source/blender/editors/space_node/node_intern.h
@@ -82,17 +82,23 @@ void node_operatortypes(void);
void node_keymap(wmKeyConfig *keyconf);
/* node_select.c */
+void node_deselect_all(struct SpaceNode *snode);
+int node_select_same_type(struct SpaceNode *snode);
+int node_select_same_type_np(struct SpaceNode *snode, int dir);
+void node_select_single(struct bContext *C, struct bNode *node);
+
void NODE_OT_select(struct wmOperatorType *ot);
void NODE_OT_select_all(wmOperatorType *ot);
void NODE_OT_select_linked_to(wmOperatorType *ot);
void NODE_OT_select_linked_from(wmOperatorType *ot);
-void NODE_OT_visibility_toggle(struct wmOperatorType *ot);
-void NODE_OT_view_all(struct wmOperatorType *ot);
void NODE_OT_select_border(struct wmOperatorType *ot);
void NODE_OT_select_same_type(struct wmOperatorType *ot);
void NODE_OT_select_same_type_next(wmOperatorType *ot);
void NODE_OT_select_same_type_prev(wmOperatorType *ot);
+/* node_state.c */
+void NODE_OT_view_all(struct wmOperatorType *ot);
+
/* drawnode.c */
void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link);
void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, int th_col1, int do_shaded, int th_col2, int do_triple, int th_col3 );
@@ -108,10 +114,6 @@ void snode_dag_update(bContext *C, SpaceNode *snode);
bNode *node_add_node(struct SpaceNode *snode, struct Main *bmain, struct Scene *scene, struct bNodeTemplate *ntemp, float locx, float locy);
void snode_set_context(SpaceNode *snode, Scene *scene);
void snode_make_group_editable(SpaceNode *snode, bNode *gnode);
-void node_sort(struct bNodeTree *ntree);
-void node_deselectall(SpaceNode *snode);
-int node_select_same_type(SpaceNode *snode);
-int node_select_same_type_np(SpaceNode *snode, int dir);
void snode_composite_job(const struct bContext *C, ScrArea *sa);
bNode *node_tree_get_editgroup(bNodeTree *ntree);
void node_tree_verify_groups(bNodeTree *nodetree);
@@ -141,6 +143,7 @@ void NODE_OT_mute_toggle(struct wmOperatorType *ot);
void NODE_OT_hide_toggle(struct wmOperatorType *ot);
void NODE_OT_hide_socket_toggle(struct wmOperatorType *ot);
void NODE_OT_preview_toggle(struct wmOperatorType *ot);
+void NODE_OT_options_toggle(struct wmOperatorType *ot);
void NODE_OT_show_cyclic_dependencies(struct wmOperatorType *ot);
void NODE_OT_link_viewer(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_node/node_ops.c b/source/blender/editors/space_node/node_ops.c
index 8309181ddda..b5c435b50e8 100644
--- a/source/blender/editors/space_node/node_ops.c
+++ b/source/blender/editors/space_node/node_ops.c
@@ -59,10 +59,11 @@ void node_operatortypes(void)
WM_operatortype_append(NODE_OT_select_same_type_prev);
WM_operatortype_append(NODE_OT_view_all);
- WM_operatortype_append(NODE_OT_visibility_toggle);
+
WM_operatortype_append(NODE_OT_mute_toggle);
WM_operatortype_append(NODE_OT_hide_toggle);
WM_operatortype_append(NODE_OT_preview_toggle);
+ WM_operatortype_append(NODE_OT_options_toggle);
WM_operatortype_append(NODE_OT_hide_socket_toggle);
WM_operatortype_append(NODE_OT_show_cyclic_dependencies);
@@ -148,7 +149,6 @@ void node_keymap(struct wmKeyConfig *keyconf)
/* each of these falls through if not handled... */
WM_keymap_add_item(keymap, "NODE_OT_link", LEFTMOUSE, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "NODE_OT_resize", LEFTMOUSE, KM_PRESS, 0, 0);
- WM_keymap_add_item(keymap, "NODE_OT_visibility_toggle", LEFTMOUSE, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "NODE_OT_links_cut", LEFTMOUSE, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "NODE_OT_select_link_viewer", LEFTMOUSE, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c
index c863efada9f..15efd65450c 100644
--- a/source/blender/editors/space_node/node_select.c
+++ b/source/blender/editors/space_node/node_select.c
@@ -31,6 +31,8 @@
#include <stdio.h>
+#include "BLI_listbase.h"
+
#include "DNA_node_types.h"
#include "DNA_scene_types.h"
@@ -68,6 +70,206 @@ static bNode *node_under_mouse(bNodeTree *ntree, int mx, int my)
return NULL;
}
+static int compare_nodes(bNode *a, bNode *b)
+{
+ bNode *parent;
+ /* These tell if either the node or any of the parent nodes is selected.
+ * A selected parent means an unselected node is also in foreground!
+ */
+ int a_select=(a->flag & NODE_SELECT), b_select=(b->flag & NODE_SELECT);
+ int a_active=(a->flag & NODE_ACTIVE), b_active=(b->flag & NODE_ACTIVE);
+
+ /* if one is an ancestor of the other */
+ /* XXX there might be a better sorting algorithm for stable topological sort, this is O(n^2) worst case */
+ for (parent = a->parent; parent; parent=parent->parent) {
+ /* if b is an ancestor, it is always behind a */
+ if (parent==b)
+ return 1;
+ /* any selected ancestor moves the node forward */
+ if (parent->flag & NODE_ACTIVE)
+ a_active = 1;
+ if (parent->flag & NODE_SELECT)
+ a_select = 1;
+ }
+ for (parent = b->parent; parent; parent=parent->parent) {
+ /* if a is an ancestor, it is always behind b */
+ if (parent==a)
+ return 0;
+ /* any selected ancestor moves the node forward */
+ if (parent->flag & NODE_ACTIVE)
+ b_active = 1;
+ if (parent->flag & NODE_SELECT)
+ b_select = 1;
+ }
+
+ /* if one of the nodes is in the background and the other not */
+ if ((a->flag & NODE_BACKGROUND) && !(b->flag & NODE_BACKGROUND))
+ return 0;
+ else if (!(a->flag & NODE_BACKGROUND) && (b->flag & NODE_BACKGROUND))
+ return 1;
+
+ /* if one has a higher selection state (active > selected > nothing) */
+ if (!b_active && a_active)
+ return 1;
+ else if (!b_select && (a_active || a_select))
+ return 1;
+
+ return 0;
+}
+
+/* Sorts nodes by selection: unselected nodes first, then selected,
+ * then the active node at the very end. Relative order is kept intact!
+ */
+static void node_sort(bNodeTree *ntree)
+{
+ /* merge sort is the algorithm of choice here */
+ bNode *first_a, *first_b, *node_a, *node_b, *tmp;
+ int totnodes= BLI_countlist(&ntree->nodes);
+ int k, a, b;
+
+ k = 1;
+ while (k < totnodes) {
+ first_a = first_b = ntree->nodes.first;
+
+ do {
+ /* setup first_b pointer */
+ for (b=0; b < k && first_b; ++b) {
+ first_b = first_b->next;
+ }
+ /* all batches merged? */
+ if (first_b==NULL)
+ break;
+
+ /* merge batches */
+ node_a = first_a;
+ node_b = first_b;
+ a = b = 0;
+ while (a < k && b < k && node_b) {
+ if (compare_nodes(node_a, node_b)==0) {
+ node_a = node_a->next;
+ ++a;
+ }
+ else {
+ tmp = node_b;
+ node_b = node_b->next;
+ ++b;
+ BLI_remlink(&ntree->nodes, tmp);
+ BLI_insertlinkbefore(&ntree->nodes, node_a, tmp);
+ }
+ }
+
+ /* setup first pointers for next batch */
+ first_b = node_b;
+ for (; b < k; ++b) {
+ /* all nodes sorted? */
+ if (first_b==NULL)
+ break;
+ first_b = first_b->next;
+ }
+ first_a = first_b;
+ } while (first_b);
+
+ k = k << 1;
+ }
+}
+
+/* no undo here! */
+void node_deselect_all(SpaceNode *snode)
+{
+ bNode *node;
+
+ for(node= snode->edittree->nodes.first; node; node= node->next)
+ node->flag &= ~SELECT;
+}
+
+/* return 1 if we need redraw otherwise zero. */
+int node_select_same_type(SpaceNode *snode)
+{
+ bNode *nac, *p;
+ int redraw;
+
+ /* search for the active node. */
+ for (nac= snode->edittree->nodes.first; nac; nac= nac->next) {
+ if (nac->flag & SELECT)
+ break;
+ }
+
+ /* no active node, return. */
+ if (!nac)
+ return(0);
+
+ redraw= 0;
+ for (p= snode->edittree->nodes.first; p; p= p->next) {
+ if (p->type != nac->type && p->flag & SELECT) {
+ /* if it's selected but different type, unselect */
+ redraw= 1;
+ p->flag &= ~SELECT;
+ }
+ else if (p->type == nac->type && (!(p->flag & SELECT))) {
+ /* if it's the same type and is not selected, select! */
+ redraw= 1;
+ p->flag |= SELECT;
+ }
+ }
+ return(redraw);
+}
+
+/* return 1 if we need redraw, otherwise zero.
+ * dir can be 0 == next or 0 != prev.
+ */
+int node_select_same_type_np(SpaceNode *snode, int dir)
+{
+ bNode *nac, *p;
+
+ /* search the active one. */
+ for (nac= snode->edittree->nodes.first; nac; nac= nac->next) {
+ if (nac->flag & SELECT)
+ break;
+ }
+
+ /* no active node, return. */
+ if (!nac)
+ return(0);
+
+ if (dir == 0)
+ p= nac->next;
+ else
+ p= nac->prev;
+
+ while (p) {
+ /* Now search the next with the same type. */
+ if (p->type == nac->type)
+ break;
+
+ if (dir == 0)
+ p= p->next;
+ else
+ p= p->prev;
+ }
+
+ if (p) {
+ node_deselect_all(snode);
+ p->flag |= SELECT;
+ return(1);
+ }
+ return(0);
+}
+
+void node_select_single(bContext *C, bNode *node)
+{
+ Main *bmain= CTX_data_main(C);
+ SpaceNode *snode= CTX_wm_space_node(C);
+
+ node_deselect_all(snode);
+ node->flag |= SELECT;
+
+ ED_node_set_active(bmain, snode->edittree, node);
+
+ node_sort(snode->edittree);
+
+ WM_event_add_notifier(C, NC_NODE|NA_SELECTED, NULL);
+}
+
/* ****** Click Select ****** */
static bNode *node_mouse_select(Main *bmain, SpaceNode *snode, ARegion *ar, const int mval[2], short extend)
@@ -86,7 +288,7 @@ static bNode *node_mouse_select(Main *bmain, SpaceNode *snode, ARegion *ar, cons
if (node) {
if (extend == 0) {
- node_deselectall(snode);
+ node_deselect_all(snode);
node->flag |= SELECT;
}
else
diff --git a/source/blender/editors/space_node/node_state.c b/source/blender/editors/space_node/node_state.c
index bfebd087c3f..58623e17b10 100644
--- a/source/blender/editors/space_node/node_state.c
+++ b/source/blender/editors/space_node/node_state.c
@@ -52,160 +52,6 @@
#include "node_intern.h"
-/* **************** Node Header Buttons ************** */
-
-/* note: call node_tree_verify_groups(snode->nodetree) after this
- */
-void node_set_hidden_sockets(SpaceNode *snode, bNode *node, int set)
-{
- bNodeSocket *sock;
-
- if(set==0) {
- for(sock= node->inputs.first; sock; sock= sock->next)
- sock->flag &= ~SOCK_HIDDEN;
- for(sock= node->outputs.first; sock; sock= sock->next)
- sock->flag &= ~SOCK_HIDDEN;
- }
- else {
- /* hide unused sockets */
- for(sock= node->inputs.first; sock; sock= sock->next) {
- if(sock->link==NULL)
- sock->flag |= SOCK_HIDDEN;
- }
- for(sock= node->outputs.first; sock; sock= sock->next) {
- if(nodeCountSocketLinks(snode->edittree, sock)==0)
- sock->flag |= SOCK_HIDDEN;
- }
- }
-}
-
-static void node_hide_unhide_sockets(SpaceNode *snode, bNode *node)
-{
- node_set_hidden_sockets(snode, node, !node_has_hidden_sockets(node));
- ntreeUpdateTree(snode->edittree);
-}
-
-static int do_header_node(SpaceNode *snode, bNode *node, float mx, float my)
-{
- rctf totr= node->totr;
-
- totr.ymin= totr.ymax-20.0f;
-
- totr.xmax= totr.xmin+15.0f;
- if(BLI_in_rctf(&totr, mx, my)) {
- node->flag |= NODE_HIDDEN;
- return 1;
- }
-
- totr.xmax= node->totr.xmax;
- totr.xmin= totr.xmax-18.0f;
- if(node->typeinfo->flag & NODE_PREVIEW) {
- if(BLI_in_rctf(&totr, mx, my)) {
- node->flag ^= NODE_PREVIEW;
- return 1;
- }
- totr.xmin-=15.0f;
- }
- if(node->type == NODE_GROUP) {
- if(BLI_in_rctf(&totr, mx, my)) {
- snode_make_group_editable(snode, node);
- return 1;
- }
- totr.xmin-=15.0f;
- }
- if(node->typeinfo->flag & NODE_OPTIONS) {
- if(BLI_in_rctf(&totr, mx, my)) {
- node->flag ^= NODE_OPTIONS;
- return 1;
- }
- totr.xmin-=15.0f;
- }
- /* hide unused sockets */
- if(BLI_in_rctf(&totr, mx, my)) {
- node_hide_unhide_sockets(snode, node);
- }
-
- return 0;
-}
-
-static int do_header_hidden_node(bNode *node, float mx, float my)
-{
- rctf totr= node->totr;
-
- totr.xmax= totr.xmin+15.0f;
- if(BLI_in_rctf(&totr, mx, my)) {
- node->flag &= ~NODE_HIDDEN;
- return 1;
- }
- return 0;
-}
-
-static int node_toggle_visibility(SpaceNode *snode, ARegion *ar, const int mval[2])
-{
- bNode *node;
- float mx, my;
-
- mx= (float)mval[0];
- my= (float)mval[1];
-
- UI_view2d_region_to_view(&ar->v2d, mval[0], mval[1], &mx, &my);
-
- for(node=snode->edittree->nodes.last; node; node=node->prev) {
- if(node->flag & NODE_HIDDEN) {
- if(do_header_hidden_node(node, mx, my)) {
- ED_region_tag_redraw(ar);
- return 1;
- }
- }
- else {
- if(do_header_node(snode, node, mx, my)) {
- ED_region_tag_redraw(ar);
- return 1;
- }
- }
- }
- return 0;
-}
-
-static int node_toggle_visibility_exec(bContext *C, wmOperator *op)
-{
- SpaceNode *snode= CTX_wm_space_node(C);
- ARegion *ar= CTX_wm_region(C);
- int mval[2];
-
- mval[0] = RNA_int_get(op->ptr, "mouse_x");
- mval[1] = RNA_int_get(op->ptr, "mouse_y");
- if(node_toggle_visibility(snode, ar, mval))
- return OPERATOR_FINISHED;
- else
- return OPERATOR_CANCELLED|OPERATOR_PASS_THROUGH;
-}
-
-static int node_toggle_visibility_invoke(bContext *C, wmOperator *op, wmEvent *event)
-{
- RNA_int_set(op->ptr, "mouse_x", event->mval[0]);
- RNA_int_set(op->ptr, "mouse_y", event->mval[1]);
-
- return node_toggle_visibility_exec(C,op);
-}
-
-void NODE_OT_visibility_toggle(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name= "Toggle Visibility";
- ot->idname= "NODE_OT_visibility_toggle";
- ot->description= "Handle clicks on node header buttons";
-
- /* api callbacks */
- ot->invoke= node_toggle_visibility_invoke;
- ot->poll= ED_operator_node_active;
-
- /* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
-
- RNA_def_int(ot->srna, "mouse_x", 0, INT_MIN, INT_MAX, "Mouse X", "", INT_MIN, INT_MAX);
- RNA_def_int(ot->srna, "mouse_y", 0, INT_MIN, INT_MAX, "Mouse Y", "", INT_MIN, INT_MAX);
-}
/* **************** View All Operator ************** */
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index 89547edaafa..e728267f45f 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -396,8 +396,8 @@ static int tree_element_active_defgroup(bContext *C, Scene *scene, TreeElement *
/* id in tselem is object */
ob= (Object *)tselem->id;
if(set) {
+ BLI_assert(te->index+1 >= 0);
ob->actdef= te->index+1;
- BLI_assert(ob->actdef >= 0);
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob);
diff --git a/source/blender/editors/space_view3d/drawanimviz.c b/source/blender/editors/space_view3d/drawanimviz.c
index 30042433ef2..1784d949761 100644
--- a/source/blender/editors/space_view3d/drawanimviz.c
+++ b/source/blender/editors/space_view3d/drawanimviz.c
@@ -312,269 +312,3 @@ void draw_motion_paths_cleanup(View3D *v3d)
if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
glPopMatrix();
}
-
-#if 0 // XXX temp file guards
-
-/* ***************************** Onion Skinning (Ghosts) ******************************** */
-
-#if 0 // XXX only for bones
-/* helper function for ghost drawing - sets/removes flags for temporarily
- * hiding unselected bones while drawing ghosts
- */
-static void ghost_poses_tag_unselected(Object *ob, short unset)
-{
- bArmature *arm= ob->data;
- bPose *pose= ob->pose;
- bPoseChannel *pchan;
-
- /* don't do anything if no hiding any bones */
- if ((arm->flag & ARM_GHOST_ONLYSEL)==0)
- return;
-
- /* loop over all pchans, adding/removing tags as appropriate */
- for (pchan= pose->chanbase.first; pchan; pchan= pchan->next) {
- if ((pchan->bone) && (arm->layer & pchan->bone->layer)) {
- if (unset) {
- /* remove tags from all pchans if cleaning up */
- pchan->bone->flag &= ~BONE_HIDDEN_PG;
- }
- else {
- /* set tags on unselected pchans only */
- if ((pchan->bone->flag & BONE_SELECTED)==0)
- pchan->bone->flag |= BONE_HIDDEN_PG;
- }
- }
- }
-}
-#endif // XXX only for bones
-
-/* draw ghosts that occur within a frame range
- * note: object should be in posemode
- */
-static void draw_ghost_poses_range(Scene *scene, View3D *v3d, ARegion *ar, Base *base)
-{
- Object *ob= base->object;
- AnimData *adt= BKE_animdata_from_id(&ob->id);
- bArmature *arm= ob->data;
- bPose *posen, *poseo;
- float start, end, stepsize, range, colfac;
- int cfrao, flago, ipoflago;
-
- start = (float)arm->ghostsf;
- end = (float)arm->ghostef;
- if (end <= start)
- return;
-
- stepsize= (float)(arm->ghostsize);
- range= (float)(end - start);
-
- /* store values */
- ob->mode &= ~OB_MODE_POSE;
- cfrao= CFRA;
- flago= arm->flag;
- arm->flag &= ~(ARM_DRAWNAMES|ARM_DRAWAXES);
- ipoflago= ob->ipoflag;
- ob->ipoflag |= OB_DISABLE_PATH;
-
- /* copy the pose */
- poseo= ob->pose;
- copy_pose(&posen, ob->pose, 1);
- ob->pose= posen;
- armature_rebuild_pose(ob, ob->data); /* child pointers for IK */
- ghost_poses_tag_unselected(ob, 0); /* hide unselected bones if need be */
-
- glEnable(GL_BLEND);
- if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
-
- /* draw from first frame of range to last */
- for (CFRA= (int)start; CFRA < end; CFRA += (int)stepsize) {
- colfac = (end - (float)CFRA) / range;
- UI_ThemeColorShadeAlpha(TH_WIRE, 0, -128-(int)(120.0*sqrt(colfac)));
-
- BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL);
- where_is_pose(scene, ob);
- draw_pose_bones(scene, v3d, ar, base, OB_WIRE);
- }
- glDisable(GL_BLEND);
- if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
-
- ghost_poses_tag_unselected(ob, 1); /* unhide unselected bones if need be */
- free_pose(posen);
-
- /* restore */
- CFRA= cfrao;
- ob->pose= poseo;
- arm->flag= flago;
- armature_rebuild_pose(ob, ob->data);
- ob->mode |= OB_MODE_POSE;
- ob->ipoflag= ipoflago;
-}
-
-/* draw ghosts on keyframes in action within range
- * - object should be in posemode
- */
-static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, ARegion *ar, Base *base)
-{
- Object *ob= base->object;
- AnimData *adt= BKE_animdata_from_id(&ob->id);
- bAction *act= (adt) ? adt->action : NULL;
- bArmature *arm= ob->data;
- bPose *posen, *poseo;
- DLRBT_Tree keys;
- ActKeyColumn *ak, *akn;
- float start, end, range, colfac, i;
- int cfrao, flago;
-
- start = (float)arm->ghostsf;
- end = (float)arm->ghostef;
- if (end <= start)
- return;
-
- /* get keyframes - then clip to only within range */
- BLI_dlrbTree_init(&keys);
- action_to_keylist(adt, act, &keys, NULL);
- BLI_dlrbTree_linkedlist_sync(&keys);
-
- range= 0;
- for (ak= keys.first; ak; ak= akn) {
- akn= ak->next;
-
- if ((ak->cfra < start) || (ak->cfra > end))
- BLI_freelinkN((ListBase *)&keys, ak);
- else
- range++;
- }
- if (range == 0) return;
-
- /* store values */
- ob->mode &= ~OB_MODE_POSE;
- cfrao= CFRA;
- flago= arm->flag;
- arm->flag &= ~(ARM_DRAWNAMES|ARM_DRAWAXES);
- ob->ipoflag |= OB_DISABLE_PATH;
-
- /* copy the pose */
- poseo= ob->pose;
- copy_pose(&posen, ob->pose, 1);
- ob->pose= posen;
- armature_rebuild_pose(ob, ob->data); /* child pointers for IK */
- ghost_poses_tag_unselected(ob, 0); /* hide unselected bones if need be */
-
- glEnable(GL_BLEND);
- if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
-
- /* draw from first frame of range to last */
- for (ak=keys.first, i=0; ak; ak=ak->next, i++) {
- colfac = i/range;
- UI_ThemeColorShadeAlpha(TH_WIRE, 0, -128-(int)(120.0*sqrt(colfac)));
-
- CFRA= (int)ak->cfra;
-
- BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL);
- where_is_pose(scene, ob);
- draw_pose_bones(scene, v3d, ar, base, OB_WIRE);
- }
- glDisable(GL_BLEND);
- if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
-
- ghost_poses_tag_unselected(ob, 1); /* unhide unselected bones if need be */
- BLI_dlrbTree_free(&keys);
- free_pose(posen);
-
- /* restore */
- CFRA= cfrao;
- ob->pose= poseo;
- arm->flag= flago;
- armature_rebuild_pose(ob, ob->data);
- ob->mode |= OB_MODE_POSE;
-}
-
-/* draw ghosts around current frame
- * - object is supposed to be armature in posemode
- */
-static void draw_ghost_poses(Scene *scene, View3D *v3d, ARegion *ar, Base *base)
-{
- Object *ob= base->object;
- AnimData *adt= BKE_animdata_from_id(&ob->id);
- bArmature *arm= ob->data;
- bPose *posen, *poseo;
- float cur, start, end, stepsize, range, colfac, actframe, ctime;
- int cfrao, flago;
-
- /* pre conditions, get an action with sufficient frames */
- if ELEM(NULL, adt, adt->action)
- return;
-
- calc_action_range(adt->action, &start, &end, 0);
- if (start == end)
- return;
-
- stepsize= (float)(arm->ghostsize);
- range= (float)(arm->ghostep)*stepsize + 0.5f; /* plus half to make the for loop end correct */
-
- /* store values */
- ob->mode &= ~OB_MODE_POSE;
- cfrao= CFRA;
- actframe= BKE_nla_tweakedit_remap(adt, (float)CFRA, 0);
- flago= arm->flag;
- arm->flag &= ~(ARM_DRAWNAMES|ARM_DRAWAXES);
-
- /* copy the pose */
- poseo= ob->pose;
- copy_pose(&posen, ob->pose, 1);
- ob->pose= posen;
- armature_rebuild_pose(ob, ob->data); /* child pointers for IK */
- ghost_poses_tag_unselected(ob, 0); /* hide unselected bones if need be */
-
- glEnable(GL_BLEND);
- if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
-
- /* draw from darkest blend to lowest */
- for(cur= stepsize; cur<range; cur+=stepsize) {
- ctime= cur - (float)fmod(cfrao, stepsize); /* ensures consistent stepping */
- colfac= ctime/range;
- UI_ThemeColorShadeAlpha(TH_WIRE, 0, -128-(int)(120.0*sqrt(colfac)));
-
- /* only within action range */
- if (actframe+ctime >= start && actframe+ctime <= end) {
- CFRA= (int)BKE_nla_tweakedit_remap(adt, actframe+ctime, NLATIME_CONVERT_MAP);
-
- if (CFRA != cfrao) {
- BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL);
- where_is_pose(scene, ob);
- draw_pose_bones(scene, v3d, ar, base, OB_WIRE);
- }
- }
-
- ctime= cur + (float)fmod((float)cfrao, stepsize) - stepsize+1.0f; /* ensures consistent stepping */
- colfac= ctime/range;
- UI_ThemeColorShadeAlpha(TH_WIRE, 0, -128-(int)(120.0*sqrt(colfac)));
-
- /* only within action range */
- if ((actframe-ctime >= start) && (actframe-ctime <= end)) {
- CFRA= (int)BKE_nla_tweakedit_remap(adt, actframe-ctime, NLATIME_CONVERT_MAP);
-
- if (CFRA != cfrao) {
- BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL);
- where_is_pose(scene, ob);
- draw_pose_bones(scene, v3d, ar, base, OB_WIRE);
- }
- }
- }
- glDisable(GL_BLEND);
- if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
-
- ghost_poses_tag_unselected(ob, 1); /* unhide unselected bones if need be */
- free_pose(posen);
-
- /* restore */
- CFRA= cfrao;
- ob->pose= poseo;
- arm->flag= flago;
- armature_rebuild_pose(ob, ob->data);
- ob->mode |= OB_MODE_POSE;
-}
-
-
-
-#endif // XXX temp file guards
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 21ac4e1431f..e3e551d67ee 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -4050,7 +4050,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
if( (base->flag & OB_FROMDUPLI) && (ob->flag & OB_FROMGROUP) ) {
float mat[4][4];
- mul_m4_m4m4(mat, psys->imat, ob->obmat);
+ mult_m4_m4m4(mat, ob->obmat, psys->imat);
glMultMatrixf(mat);
}
diff --git a/source/blender/editors/space_view3d/drawvolume.c b/source/blender/editors/space_view3d/drawvolume.c
index 6605d488d36..8308a4a9ccf 100644
--- a/source/blender/editors/space_view3d/drawvolume.c
+++ b/source/blender/editors/space_view3d/drawvolume.c
@@ -158,23 +158,6 @@ static int convex(float *p0, float *up, float *a, float *b)
return dot_v3v3(up, tmp) >= 0;
}
-// copied from gpu_extension.c
-static int is_pow2(int n)
-{
- return ((n)&(n-1))==0;
-}
-
-static int larger_pow2(int n)
-{
- if (is_pow2(n))
- return n;
-
- while(!is_pow2(n))
- n= n&(n-1);
-
- return n*2;
-}
-
void draw_volume(ARegion *ar, GPUTexture *tex, float *min, float *max, int res[3], float dx, GPUTexture *tex_shadow)
{
RegionView3D *rv3d= ar->regiondata;
@@ -379,9 +362,9 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float *min, float *max, int res[3
printf("No volume shadow\n");
if (!GPU_non_power_of_two_support()) {
- cor[0] = (float)res[0]/(float)larger_pow2(res[0]);
- cor[1] = (float)res[1]/(float)larger_pow2(res[1]);
- cor[2] = (float)res[2]/(float)larger_pow2(res[2]);
+ cor[0] = (float)res[0]/(float)power_of_2_max_i(res[0]);
+ cor[1] = (float)res[1]/(float)power_of_2_max_i(res[1]);
+ cor[2] = (float)res[2]/(float)power_of_2_max_i(res[2]);
}
// our slices are defined by the plane equation a*x + b*y +c*z + d = 0
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index c493e4af944..cac5d856652 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -204,8 +204,8 @@ ARegion *ED_view3d_context_region_unlock(bContext *C)
void ED_view3d_init_mats_rv3d(struct Object *ob, struct RegionView3D *rv3d)
{
/* local viewmat and persmat, to calculate projections */
- mul_m4_m4m4(rv3d->viewmatob, ob->obmat, rv3d->viewmat);
- mul_m4_m4m4(rv3d->persmatob, ob->obmat, rv3d->persmat);
+ mult_m4_m4m4(rv3d->viewmatob, rv3d->viewmat, ob->obmat);
+ mult_m4_m4m4(rv3d->persmatob, rv3d->persmat, ob->obmat);
/* initializes object space clipping, speeds up clip tests */
ED_view3d_local_clipping(rv3d, ob->obmat);
diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c
index d2689fad8c2..1b923c7a0cd 100644
--- a/source/blender/editors/space_view3d/view3d_buttons.c
+++ b/source/blender/editors/space_view3d/view3d_buttons.c
@@ -59,6 +59,7 @@
#include "BKE_mesh.h"
#include "BKE_screen.h"
#include "BKE_deform.h"
+#include "BKE_object.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -1105,14 +1106,6 @@ static void v3d_editmetaball_buts(uiLayout *layout, Object *ob)
}
}
-/* test if 'ob' is a parent somewhere in par's parents */
-static int test_parent_loop(Object *par, Object *ob)
-{
- if(par == NULL) return 0;
- if(ob == par) return 1;
- return test_parent_loop(par->parent, ob);
-}
-
static void do_view3d_region_buttons(bContext *C, void *UNUSED(index), int event)
{
Main *bmain= CTX_data_main(C);
@@ -1144,7 +1137,7 @@ static void do_view3d_region_buttons(bContext *C, void *UNUSED(index), int event
/* note; this case also used for parbone */
case B_OBJECTPANELPARENT:
if(ob) {
- if(ob->id.lib || test_parent_loop(ob->parent, ob) )
+ if (ob->id.lib || BKE_object_parent_loop_check(ob->parent, ob))
ob->parent= NULL;
else {
DAG_scene_sort(bmain, scene);
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 3f979787a1f..80b7522d1a3 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -1993,7 +1993,7 @@ void draw_depth_gpencil(Scene *scene, ARegion *ar, View3D *v3d)
setwinmatrixview3d(ar, v3d, NULL); /* 0= no pick rect */
setviewmatrixview3d(scene, v3d, rv3d); /* note: calls where_is_object for camera... */
- mul_m4_m4m4(rv3d->persmat, rv3d->viewmat, rv3d->winmat);
+ mult_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat);
invert_m4_m4(rv3d->persinv, rv3d->persmat);
invert_m4_m4(rv3d->viewinv, rv3d->viewmat);
@@ -2028,7 +2028,7 @@ void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (* func)(void *))
setwinmatrixview3d(ar, v3d, NULL); /* 0= no pick rect */
setviewmatrixview3d(scene, v3d, rv3d); /* note: calls where_is_object for camera... */
- mul_m4_m4m4(rv3d->persmat, rv3d->viewmat, rv3d->winmat);
+ mult_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat);
invert_m4_m4(rv3d->persinv, rv3d->persmat);
invert_m4_m4(rv3d->viewinv, rv3d->viewmat);
@@ -2219,7 +2219,7 @@ static void gpu_update_lamps_shadows(Scene *scene, View3D *v3d)
copy_m4_m4(rv3d.winmat, winmat);
copy_m4_m4(rv3d.viewmat, viewmat);
invert_m4_m4(rv3d.viewinv, rv3d.viewmat);
- mul_m4_m4m4(rv3d.persmat, rv3d.viewmat, rv3d.winmat);
+ mult_m4_m4m4(rv3d.persmat, rv3d.winmat, rv3d.viewmat);
invert_m4_m4(rv3d.persinv, rv3d.viewinv);
ED_view3d_draw_offscreen(scene, v3d, &ar, winsize, winsize, viewmat, winmat);
@@ -2301,7 +2301,7 @@ static void view3d_main_area_setup_view(Scene *scene, View3D *v3d, ARegion *ar,
setviewmatrixview3d(scene, v3d, rv3d); /* note: calls where_is_object for camera... */
/* update utilitity matrices */
- mul_m4_m4m4(rv3d->persmat, rv3d->viewmat, rv3d->winmat);
+ mult_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat);
invert_m4_m4(rv3d->persinv, rv3d->persmat);
invert_m4_m4(rv3d->viewinv, rv3d->viewmat);
@@ -2555,7 +2555,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, Object *camera, int w
v3d.lens= params.lens;
}
- mul_m4_m4m4(rv3d.persmat, rv3d.viewmat, rv3d.winmat);
+ mult_m4_m4m4(rv3d.persmat, rv3d.winmat, rv3d.viewmat);
invert_m4_m4(rv3d.persinv, rv3d.viewinv);
return ED_view3d_draw_offscreen_imbuf(scene, &v3d, &ar, width, height, flag, err_out);
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 6d2a745fd67..fa970f7f9d8 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -116,9 +116,9 @@ int ED_view3d_camera_lock_sync(View3D *v3d, RegionView3D *rv3d)
ED_view3d_to_m4(view_mat, rv3d->ofs, rv3d->viewquat, rv3d->dist);
invert_m4_m4(v3d->camera->imat, v3d->camera->obmat);
- mul_m4_m4m4(diff_mat, v3d->camera->imat, view_mat);
+ mult_m4_m4m4(diff_mat, view_mat, v3d->camera->imat);
- mul_m4_m4m4(parent_mat, root_parent->obmat, diff_mat);
+ mult_m4_m4m4(parent_mat, diff_mat, root_parent->obmat);
object_tfm_protected_backup(root_parent, &obtfm);
object_apply_mat4(root_parent, parent_mat, TRUE, FALSE);
diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c
index 0cdb7a19995..981d46774dc 100644
--- a/source/blender/editors/space_view3d/view3d_fly.c
+++ b/source/blender/editors/space_view3d/view3d_fly.c
@@ -663,8 +663,8 @@ static void move_camera(bContext* C, RegionView3D* rv3d, FlyInfo* fly, int orien
ED_view3d_to_m4(prev_view_mat, fly->rv3d->ofs, fly->rv3d->viewquat, fly->rv3d->dist);
invert_m4_m4(prev_view_imat, prev_view_mat);
ED_view3d_to_m4(view_mat, rv3d->ofs, rv3d->viewquat, rv3d->dist);
- mul_m4_m4m4(diff_mat, prev_view_imat, view_mat);
- mul_m4_m4m4(parent_mat, fly->root_parent->obmat, diff_mat);
+ mult_m4_m4m4(diff_mat, view_mat, prev_view_imat);
+ mult_m4_m4m4(parent_mat, diff_mat, fly->root_parent->obmat);
object_apply_mat4(fly->root_parent, parent_mat, TRUE, FALSE);
// where_is_object(scene, fly->root_parent);
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index 7da07149490..fb309f6de25 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -141,7 +141,7 @@ void view3d_get_transformation(ARegion *ar, RegionView3D *rv3d, Object *ob, bglM
int i, j;
if (ob) {
- mul_m4_m4m4(cpy, ob->obmat, rv3d->viewmat);
+ mult_m4_m4m4(cpy, rv3d->viewmat, ob->obmat);
} else {
copy_m4_m4(cpy, rv3d->viewmat);
}
diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c
index db33426a804..a2173537c8c 100644
--- a/source/blender/editors/space_view3d/view3d_snap.c
+++ b/source/blender/editors/space_view3d/view3d_snap.c
@@ -792,7 +792,7 @@ static void bundle_midpoint(Scene *scene, Object *ob, float vec[3])
BKE_tracking_get_interpolated_camera(tracking, object, scene->r.cfra, imat);
invert_m4(imat);
- mul_m4_m4m4(obmat, imat, cammat);
+ mult_m4_m4m4(obmat, cammat, imat);
}
while(track) {
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index 89f859d0976..4d98afc4c10 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -740,8 +740,8 @@ void ED_view3d_ob_project_mat_get(RegionView3D *rv3d, Object *ob, float pmat[4][
{
float vmat[4][4];
- mul_m4_m4m4(vmat, ob->obmat, rv3d->viewmat);
- mul_m4_m4m4(pmat, vmat, rv3d->winmat);
+ mult_m4_m4m4(vmat, rv3d->viewmat, ob->obmat);
+ mult_m4_m4m4(pmat, rv3d->winmat, vmat);
}
#if 0
@@ -809,7 +809,7 @@ int ED_view3d_boundbox_clip(RegionView3D *rv3d, float obmat[][4], BoundBox *bb)
if(bb==NULL) return 1;
if(bb->flag & OB_BB_DISABLED) return 1;
- mul_m4_m4m4(mat, obmat, rv3d->persmat);
+ mult_m4_m4m4(mat, rv3d->persmat, obmat);
for(a=0; a<8; a++) {
copy_v3_v3(vec, bb->vec[a]);
@@ -1196,7 +1196,7 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b
}
setwinmatrixview3d(ar, v3d, &rect);
- mul_m4_m4m4(vc->rv3d->persmat, vc->rv3d->viewmat, vc->rv3d->winmat);
+ mult_m4_m4m4(vc->rv3d->persmat, vc->rv3d->winmat, vc->rv3d->viewmat);
if(v3d->drawtype > OB_WIRE) {
v3d->zbuf= TRUE;
@@ -1274,7 +1274,7 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b
G.f &= ~G_PICKSEL;
setwinmatrixview3d(ar, v3d, NULL);
- mul_m4_m4m4(vc->rv3d->persmat, vc->rv3d->viewmat, vc->rv3d->winmat);
+ mult_m4_m4m4(vc->rv3d->persmat, vc->rv3d->winmat, vc->rv3d->viewmat);
if(v3d->drawtype > OB_WIRE) {
v3d->zbuf= 0;
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index cee7b19470b..8e6e5d08266 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -376,7 +376,8 @@ static void viewRedrawPost(bContext *C, TransInfo *t)
/* ************************** TRANSFORMATIONS **************************** */
-void BIF_selectOrientation(void) {
+void BIF_selectOrientation(void)
+{
#if 0 // TRANSFORM_FIX_ME
short val;
char *str_menu = BIF_menustringTransformOrientation("Orientation");
@@ -2547,7 +2548,8 @@ void initResize(TransInfo *t)
t->num.increment = t->snap[1];
}
-static void headerResize(TransInfo *t, float vec[3], char *str) {
+static void headerResize(TransInfo *t, float vec[3], char *str)
+{
char tvec[60];
char *spos= str;
if (hasNumInput(&t->num)) {
@@ -2607,7 +2609,8 @@ static void TransMat3ToSize( float mat[][3], float smat[][3], float *size)
}
-static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) {
+static void ElementResize(TransInfo *t, TransData *td, float mat[3][3])
+{
float tmat[3][3], smat[3][3], center[3];
float vec[3];
@@ -2904,7 +2907,8 @@ void initRotation(TransInfo *t)
copy_v3_v3(t->axis_orig, t->axis);
}
-static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short around) {
+static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short around)
+{
float vec[3], totmat[3][3], smat[3][3];
float eul[3], fmat[3][3], quat[4];
float *center = t->center;
@@ -3344,7 +3348,8 @@ void initTranslation(TransInfo *t)
t->num.increment = t->snap[1];
}
-static void headerTranslation(TransInfo *t, float vec[3], char *str) {
+static void headerTranslation(TransInfo *t, float vec[3], char *str)
+{
char *spos= str;
char tvec[60];
char distvec[20];
@@ -3418,7 +3423,8 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str) {
(void)spos;
}
-static void applyTranslation(TransInfo *t, float vec[3]) {
+static void applyTranslation(TransInfo *t, float vec[3])
+{
TransData *td = t->data;
float tvec[3];
int i;
@@ -4099,7 +4105,8 @@ void initBoneSize(TransInfo *t)
t->num.increment = t->snap[1];
}
-static void headerBoneSize(TransInfo *t, float vec[3], char *str) {
+static void headerBoneSize(TransInfo *t, float vec[3], char *str)
+{
char tvec[60];
if (hasNumInput(&t->num)) {
outputNumInput(&(t->num), tvec);
@@ -5302,7 +5309,8 @@ static void headerSeqSlide(TransInfo *t, float val[2], char *str)
sprintf(str, "Sequence Slide: %s%s", &tvec[0], t->con.text);
}
-static void applySeqSlide(TransInfo *t, float val[2]) {
+static void applySeqSlide(TransInfo *t, float val[2])
+{
TransData *td = t->data;
int i;
@@ -5826,7 +5834,8 @@ void initTimeScale(TransInfo *t)
t->num.increment = t->snap[1];
}
-static void headerTimeScale(TransInfo *t, char *str) {
+static void headerTimeScale(TransInfo *t, char *str)
+{
char tvec[60];
if (hasNumInput(&t->num))
@@ -5837,7 +5846,8 @@ static void headerTimeScale(TransInfo *t, char *str) {
sprintf(str, "ScaleX: %s", &tvec[0]);
}
-static void applyTimeScale(TransInfo *t) {
+static void applyTimeScale(TransInfo *t)
+{
Scene *scene = t->scene;
TransData *td = t->data;
TransData2D *td2d = t->data2d;
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index bfb96149ed3..b88e57e1861 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -138,7 +138,8 @@ void constraintNumInput(TransInfo *t, float vec[3])
}
}
-static void postConstraintChecks(TransInfo *t, float vec[3], float pvec[3]) {
+static void postConstraintChecks(TransInfo *t, float vec[3], float pvec[3])
+{
int i = 0;
mul_m3_v3(t->con.imtx, vec);
@@ -209,7 +210,8 @@ static void viewAxisCorrectCenter(TransInfo *t, float t_con_center[3])
}
}
-static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3]) {
+static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3])
+{
float norm[3], vec[3], factor, angle;
float t_con_center[3];
@@ -284,7 +286,8 @@ static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3
}
}
-static void planeProjection(TransInfo *t, float in[3], float out[3]) {
+static void planeProjection(TransInfo *t, float in[3], float out[3])
+{
float vec[3], factor, norm[3];
add_v3_v3v3(vec, in, t->con.center);
@@ -547,7 +550,8 @@ static void applyObjectConstraintRot(TransInfo *t, TransData *td, float vec[3],
/*--------------------- INTERNAL SETUP CALLS ------------------*/
-void setConstraint(TransInfo *t, float space[3][3], int mode, const char text[]) {
+void setConstraint(TransInfo *t, float space[3][3], int mode, const char text[])
+{
strncpy(t->con.text + 1, text, 48);
copy_m3_m3(t->con.mtx, space);
t->con.mode = mode;
@@ -562,7 +566,8 @@ void setConstraint(TransInfo *t, float space[3][3], int mode, const char text[])
t->redraw = 1;
}
-void setLocalConstraint(TransInfo *t, int mode, const char text[]) {
+void setLocalConstraint(TransInfo *t, int mode, const char text[])
+{
if (t->flag & T_EDIT) {
float obmat[3][3];
copy_m3_m4(obmat, t->scene->obedit->obmat);
@@ -596,7 +601,8 @@ void setLocalConstraint(TransInfo *t, int mode, const char text[]) {
ftext is a format string passed to sprintf. It will add the name of
the orientation where %s is (logically).
*/
-void setUserConstraint(TransInfo *t, short orientation, int mode, const char ftext[]) {
+void setUserConstraint(TransInfo *t, short orientation, int mode, const char ftext[])
+{
char text[40];
switch(orientation) {
@@ -744,7 +750,8 @@ void drawPropCircle(const struct bContext *C, TransInfo *t)
}
}
-static void drawObjectConstraint(TransInfo *t) {
+static void drawObjectConstraint(TransInfo *t)
+{
int i;
TransData * td = t->data;
@@ -781,13 +788,15 @@ static void drawObjectConstraint(TransInfo *t) {
/*--------------------- START / STOP CONSTRAINTS ---------------------- */
-void startConstraint(TransInfo *t) {
+void startConstraint(TransInfo *t)
+{
t->con.mode |= CON_APPLY;
*t->con.text = ' ';
t->num.idx_max = MIN2(getConstraintSpaceDimension(t) - 1, t->idx_max);
}
-void stopConstraint(TransInfo *t) {
+void stopConstraint(TransInfo *t)
+{
t->con.mode &= ~(CON_APPLY|CON_SELECT);
*t->con.text = '\0';
t->num.idx_max = t->idx_max;
@@ -836,7 +845,8 @@ void initSelectConstraint(TransInfo *t, float mtx[3][3])
t->con.applyRot = applyAxisConstraintRot;
}
-void selectConstraint(TransInfo *t) {
+void selectConstraint(TransInfo *t)
+{
if (t->con.mode & CON_SELECT) {
setNearestAxis(t);
startConstraint(t);
@@ -970,7 +980,8 @@ void setNearestAxis(TransInfo *t)
/*-------------- HELPER FUNCTIONS ----------------*/
-char constraintModeToChar(TransInfo *t) {
+char constraintModeToChar(TransInfo *t)
+{
if ((t->con.mode & CON_APPLY)==0) {
return '\0';
}
@@ -990,7 +1001,8 @@ char constraintModeToChar(TransInfo *t) {
}
-int isLockConstraint(TransInfo *t) {
+int isLockConstraint(TransInfo *t)
+{
int mode = t->con.mode;
if ( (mode & (CON_AXIS0|CON_AXIS1)) == (CON_AXIS0|CON_AXIS1))
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index 98ad5363c39..5ff7053da33 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -118,7 +118,8 @@ static short constraints_list_needinv(TransInfo *t, ListBase *list);
/* ************************** Functions *************************** */
-static void qsort_trans_data(TransInfo *t, TransData *head, TransData *tail, TransData *temp) {
+static void qsort_trans_data(TransInfo *t, TransData *head, TransData *tail, TransData *temp)
+{
TransData *ihead = head;
TransData *itail = tail;
*temp = *head;
@@ -165,7 +166,8 @@ static void qsort_trans_data(TransInfo *t, TransData *head, TransData *tail, Tra
}
}
-void sort_trans_data_dist(TransInfo *t) {
+void sort_trans_data_dist(TransInfo *t)
+{
TransData temp;
TransData *start = t->data;
int i = 1;
@@ -441,14 +443,14 @@ static short apply_targetless_ik(Object *ob)
offs_bone[3][0]= offs_bone[3][1]= offs_bone[3][2]= 0.0f;
mul_m4_v3(parchan->parent->pose_mat, rmat[3]);
- mul_m4_m4m4(tmat, offs_bone, rmat);
+ mult_m4_m4m4(tmat, rmat, offs_bone);
}
else if(parchan->bone->flag & BONE_NO_SCALE) {
- mul_m4_m4m4(tmat, offs_bone, parchan->parent->pose_mat);
+ mult_m4_m4m4(tmat, parchan->parent->pose_mat, offs_bone);
normalize_m4(tmat);
}
else
- mul_m4_m4m4(tmat, offs_bone, parchan->parent->pose_mat);
+ mult_m4_m4m4(tmat, parchan->parent->pose_mat, offs_bone);
invert_m4_m4(imat, tmat);
}
@@ -459,7 +461,7 @@ static short apply_targetless_ik(Object *ob)
invert_m4_m4(imat, tmat);
}
/* result matrix */
- mul_m4_m4m4(rmat, parchan->pose_mat, imat);
+ mult_m4_m4m4(rmat, imat, parchan->pose_mat);
/* apply and decompose, doesn't work for constraints or non-uniform scale well */
{
@@ -1326,7 +1328,8 @@ static void createTransMBallVerts(TransInfo *t)
/* ********************* curve/surface ********* */
-static void calc_distanceCurveVerts(TransData *head, TransData *tail) {
+static void calc_distanceCurveVerts(TransData *head, TransData *tail)
+{
TransData *td, *td_near = NULL;
for (td = head; td<=tail; td++) {
if (td->flag & TD_SELECTED) {
@@ -1371,7 +1374,8 @@ static void calc_distanceCurveVerts(TransData *head, TransData *tail) {
}
/* Utility function for getting the handle data from bezier's */
-static TransDataCurveHandleFlags *initTransDataCurveHandles(TransData *td, struct BezTriple *bezt) {
+static TransDataCurveHandleFlags *initTransDataCurveHandles(TransData *td, struct BezTriple *bezt)
+{
TransDataCurveHandleFlags *hdata;
td->flag |= TD_BEZTRIPLE;
hdata = td->hdata = MEM_mallocN(sizeof(TransDataCurveHandleFlags), "CuHandle Data");
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 0b0a0eb2e2d..f6aca0336be 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -171,7 +171,7 @@ static void clipMirrorModifier(TransInfo *t, Object *ob)
float obinv[4][4];
invert_m4_m4(obinv, mmd->mirror_ob->obmat);
- mul_m4_m4m4(mtx, ob->obmat, obinv);
+ mult_m4_m4m4(mtx, obinv, ob->obmat);
invert_m4_m4(imtx, mtx);
}
diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c
index 63495d54cf1..5578ea754df 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -1564,7 +1564,7 @@ static int manipulator_selectbuf(ScrArea *sa, ARegion *ar, const int mval[2], fl
rect.ymax= mval[1]+hotspot;
setwinmatrixview3d(ar, v3d, &rect);
- mul_m4_m4m4(rv3d->persmat, rv3d->viewmat, rv3d->winmat);
+ mult_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat);
glSelectBuffer( 64, buffer);
glRenderMode(GL_SELECT);
@@ -1586,7 +1586,7 @@ static int manipulator_selectbuf(ScrArea *sa, ARegion *ar, const int mval[2], fl
G.f &= ~G_PICKSEL;
setwinmatrixview3d(ar, v3d, NULL);
- mul_m4_m4m4(rv3d->persmat, rv3d->viewmat, rv3d->winmat);
+ mult_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat);
if(hits==1) return buffer[3];
else if(hits>1) {
diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c
index 7951fe0ee02..90f95bea696 100644
--- a/source/blender/editors/transform/transform_ops.c
+++ b/source/blender/editors/transform/transform_ops.c
@@ -632,7 +632,7 @@ void TRANSFORM_OT_warp(struct wmOperatorType *ot)
ot->cancel = transform_cancel;
ot->poll = ED_operator_screenactive;
- RNA_def_float_rotation(ot->srna, "value", 1, NULL, -FLT_MAX, FLT_MAX, "Angle", "", 0, 1);
+ RNA_def_float_rotation(ot->srna, "value", 1, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI*2, M_PI*2);
Transform_Properties(ot, P_PROPORTIONAL|P_MIRROR|P_SNAP);
// XXX Warp axis?
diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c
index 442ad662813..3cb35c48f39 100644
--- a/source/blender/editors/transform/transform_orientations.c
+++ b/source/blender/editors/transform/transform_orientations.c
@@ -127,7 +127,8 @@ void BIF_createTransformOrientation(bContext *C, ReportList *reports, char *name
}
}
-TransformOrientation *createObjectSpace(bContext *C, ReportList *UNUSED(reports), char *name, int overwrite) {
+TransformOrientation *createObjectSpace(bContext *C, ReportList *UNUSED(reports), char *name, int overwrite)
+{
Base *base = CTX_data_active_base(C);
Object *ob;
float mat[3][3];
@@ -150,7 +151,8 @@ TransformOrientation *createObjectSpace(bContext *C, ReportList *UNUSED(reports)
return addMatrixSpace(C, mat, name, overwrite);
}
-TransformOrientation *createBoneSpace(bContext *C, ReportList *reports, char *name, int overwrite) {
+TransformOrientation *createBoneSpace(bContext *C, ReportList *reports, char *name, int overwrite)
+{
float mat[3][3];
float normal[3], plane[3];
@@ -169,7 +171,8 @@ TransformOrientation *createBoneSpace(bContext *C, ReportList *reports, char *na
return addMatrixSpace(C, mat, name, overwrite);
}
-TransformOrientation *createMeshSpace(bContext *C, ReportList *reports, char *name, int overwrite) {
+TransformOrientation *createMeshSpace(bContext *C, ReportList *reports, char *name, int overwrite)
+{
float mat[3][3];
float normal[3], plane[3];
int type;
@@ -267,7 +270,8 @@ int createSpaceNormalTangent(float mat[3][3], float normal[3], float tangent[3])
return 1;
}
-TransformOrientation* addMatrixSpace(bContext *C, float mat[3][3], char name[], int overwrite) {
+TransformOrientation* addMatrixSpace(bContext *C, float mat[3][3], char name[], int overwrite)
+{
ListBase *transform_spaces = &CTX_data_scene(C)->transform_spaces;
TransformOrientation *ts = NULL;
@@ -294,7 +298,8 @@ TransformOrientation* addMatrixSpace(bContext *C, float mat[3][3], char name[],
return ts;
}
-void BIF_removeTransformOrientation(bContext *C, TransformOrientation *target) {
+void BIF_removeTransformOrientation(bContext *C, TransformOrientation *target)
+{
ListBase *transform_spaces = &CTX_data_scene(C)->transform_spaces;
TransformOrientation *ts;
int i;
@@ -321,7 +326,8 @@ void BIF_removeTransformOrientation(bContext *C, TransformOrientation *target) {
}
}
-void BIF_removeTransformOrientationIndex(bContext *C, int index) {
+void BIF_removeTransformOrientationIndex(bContext *C, int index)
+{
ListBase *transform_spaces = &CTX_data_scene(C)->transform_spaces;
TransformOrientation *ts= BLI_findlink(transform_spaces, index);
@@ -344,7 +350,8 @@ void BIF_removeTransformOrientationIndex(bContext *C, int index) {
}
}
-void BIF_selectTransformOrientation(bContext *C, TransformOrientation *target) {
+void BIF_selectTransformOrientation(bContext *C, TransformOrientation *target)
+{
ListBase *transform_spaces = &CTX_data_scene(C)->transform_spaces;
View3D *v3d = CTX_wm_view3d(C);
TransformOrientation *ts;
@@ -358,7 +365,8 @@ void BIF_selectTransformOrientation(bContext *C, TransformOrientation *target) {
}
}
-void BIF_selectTransformOrientationValue(bContext *C, int orientation) {
+void BIF_selectTransformOrientationValue(bContext *C, int orientation)
+{
View3D *v3d = CTX_wm_view3d(C);
if(v3d) /* currently using generic poll */
v3d->twmode = orientation;
@@ -407,7 +415,8 @@ EnumPropertyItem *BIF_enumTransformOrientation(bContext *C)
return item;
}
-const char * BIF_menustringTransformOrientation(const bContext *C, const char *title) {
+const char * BIF_menustringTransformOrientation(const bContext *C, const char *title)
+{
const char* menu = IFACE_("%t|Global%x0|Local%x1|Gimbal%x4|Normal%x2|View%x3");
ListBase *transform_spaces = &CTX_data_scene(C)->transform_spaces;
TransformOrientation *ts;
@@ -429,7 +438,8 @@ const char * BIF_menustringTransformOrientation(const bContext *C, const char *t
return str_menu;
}
-int BIF_countTransformOrientation(const bContext *C) {
+int BIF_countTransformOrientation(const bContext *C)
+{
ListBase *transform_spaces = &CTX_data_scene(C)->transform_spaces;
TransformOrientation *ts;
int count = 0;
@@ -441,7 +451,8 @@ int BIF_countTransformOrientation(const bContext *C) {
return count;
}
-void applyTransformOrientation(const bContext *C, float mat[3][3], char *name) {
+void applyTransformOrientation(const bContext *C, float mat[3][3], char *name)
+{
TransformOrientation *ts;
View3D *v3d = CTX_wm_view3d(C);
int selected_index = (v3d->twmode - V3D_MANIP_CUSTOM);
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index 92bd74db68a..1f71cd8a4c6 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -590,8 +590,7 @@ static void find_nearest_uv_face(Scene *scene, Image *ima, EditMesh *em, float c
cent[0]= cent[1]= 0.0f;
for(i=0; i<nverts; i++) {
- cent[0] += tf->uv[i][0];
- cent[1] += tf->uv[i][1];
+ add_v2_v2(cent, tf->uv[i]);
}
cent[0] /= nverts;
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c
index cc4b092a071..33796b7c215 100644
--- a/source/blender/gpu/intern/gpu_codegen.c
+++ b/source/blender/gpu/intern/gpu_codegen.c
@@ -647,11 +647,13 @@ static char *code_generate_vertex(ListBase *nodes)
return code;
}
-int GPU_bicubic_bump_support(void){
+int GPU_bicubic_bump_support(void)
+{
return GLEW_ARB_texture_gather && GLEW_ARB_texture_query_lod && GLEW_VERSION_3_0;
}
-void GPU_code_generate_glsl_lib(void){
+void GPU_code_generate_glsl_lib(void)
+{
DynStr *ds;
/* only initialize the library once */
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index 4af0cceb4e0..2dcce996065 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -189,20 +189,6 @@ void GPU_render_text(MTFace *tface, int mode,
/* Checking powers of two for images since opengl 1.x requires it */
-static int is_pow2(int num)
-{
- /* (n&(n-1)) zeros the least significant bit of n */
- return ((num)&(num-1))==0;
-}
-
-static int smaller_pow2(int num)
-{
- while (!is_pow2(num))
- num= num&(num-1);
-
- return num;
-}
-
static int is_pow2_limit(int num)
{
/* take texture clamping into account */
@@ -214,7 +200,7 @@ static int is_pow2_limit(int num)
if (U.glreslimit != 0 && num > U.glreslimit)
return 0;
- return ((num)&(num-1))==0;
+ return is_power_of_2_i(num);
}
static int smaller_pow2_limit(int num)
@@ -227,7 +213,7 @@ static int smaller_pow2_limit(int num)
if (U.glreslimit != 0 && num > U.glreslimit)
return U.glreslimit;
- return smaller_pow2(num);
+ return power_of_2_min_i(num);
}
/* Current OpenGL state caching for GPU_set_tpage */
@@ -692,7 +678,7 @@ void GPU_paint_update_image(Image *ima, int x, int y, int w, int h, int mipmap)
ibuf = BKE_image_get_ibuf(ima, NULL);
if (ima->repbind || (gpu_get_mipmap() && mipmap) || !ima->bindcode || !ibuf ||
- (!is_pow2(ibuf->x) || !is_pow2(ibuf->y)) ||
+ (!is_power_of_2_i(ibuf->x) || !is_power_of_2_i(ibuf->y)) ||
(w == 0) || (h == 0)) {
/* these cases require full reload still */
GPU_free_image(ima);
diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c
index 79db125c21f..eaa661a9dcf 100644
--- a/source/blender/gpu/intern/gpu_extensions.c
+++ b/source/blender/gpu/intern/gpu_extensions.c
@@ -41,6 +41,7 @@
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
+#include "BLI_math_base.h"
#include "GPU_draw.h"
#include "GPU_extensions.h"
@@ -111,6 +112,8 @@ void GPU_extensions_init(void)
if (!GLEW_ARB_vertex_shader) GG.glslsupport = 0;
if (!GLEW_ARB_fragment_shader) GG.glslsupport = 0;
+ GPU_code_generate_glsl_lib();
+
glGetIntegerv(GL_RED_BITS, &r);
glGetIntegerv(GL_GREEN_BITS, &g);
glGetIntegerv(GL_BLUE_BITS, &b);
@@ -292,22 +295,6 @@ static unsigned char *GPU_texture_convert_pixels(int length, float *fpixels)
return pixels;
}
-static int is_pow2(int n)
-{
- return ((n)&(n-1))==0;
-}
-
-static int larger_pow2(int n)
-{
- if (is_pow2(n))
- return n;
-
- while(!is_pow2(n))
- n= n&(n-1);
-
- return n*2;
-}
-
static void GPU_glTexSubImageEmpty(GLenum target, GLenum format, int x, int y, int w, int h)
{
void *pixels = MEM_callocN(sizeof(char)*4*w*h, "GPUTextureEmptyPixels");
@@ -353,8 +340,8 @@ static GPUTexture *GPU_texture_create_nD(int w, int h, int n, float *fpixels, in
}
if (!GPU_non_power_of_two_support()) {
- tex->w = larger_pow2(tex->w);
- tex->h = larger_pow2(tex->h);
+ tex->w = power_of_2_max_i(tex->w);
+ tex->h = power_of_2_max_i(tex->h);
}
tex->number = 0;
@@ -462,9 +449,9 @@ GPUTexture *GPU_texture_create_3D(int w, int h, int depth, float *fpixels)
}
if (!GPU_non_power_of_two_support()) {
- tex->w = larger_pow2(tex->w);
- tex->h = larger_pow2(tex->h);
- tex->depth = larger_pow2(tex->depth);
+ tex->w = power_of_2_max_i(tex->w);
+ tex->h = power_of_2_max_i(tex->h);
+ tex->depth = power_of_2_max_i(tex->depth);
}
tex->number = 0;
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c
index 4b991a36626..250ea51f8c8 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -321,9 +321,9 @@ void GPU_material_bind_uniforms(GPUMaterial *material, float obmat[][4], float v
}
if(material->dynproperty & DYN_LAMP_IMAT)
- mul_m4_m4m4(lamp->dynimat, viewinv, lamp->imat);
+ mult_m4_m4m4(lamp->dynimat, lamp->imat, viewinv);
if(material->dynproperty & DYN_LAMP_PERSMAT)
- mul_m4_m4m4(lamp->dynpersmat, viewinv, lamp->persmat);
+ mult_m4_m4m4(lamp->dynpersmat, lamp->persmat, viewinv);
}
GPU_pass_update_uniforms(material->pass);
@@ -1671,7 +1671,7 @@ void GPU_lamp_shadow_buffer_bind(GPULamp *lamp, float viewmat[][4], int *winsize
normalize_v3(lamp->viewmat[2]);
/* makeshadowbuf */
- mul_m4_m4m4(persmat, lamp->viewmat, lamp->winmat);
+ mult_m4_m4m4(persmat, lamp->winmat, lamp->viewmat);
/* opengl depth buffer is range 0.0..1.0 instead of -1.0..1.0 in blender */
unit_m4(rangemat);
@@ -1682,7 +1682,7 @@ void GPU_lamp_shadow_buffer_bind(GPULamp *lamp, float viewmat[][4], int *winsize
rangemat[3][1] = 0.5f;
rangemat[3][2] = 0.5f;
- mul_m4_m4m4(lamp->persmat, persmat, rangemat);
+ mult_m4_m4m4(lamp->persmat, rangemat, persmat);
/* opengl */
glDisable(GL_SCISSOR_TEST);
diff --git a/source/blender/ikplugin/intern/iksolver_plugin.c b/source/blender/ikplugin/intern/iksolver_plugin.c
index eb3695ea217..34656daaa19 100644
--- a/source/blender/ikplugin/intern/iksolver_plugin.c
+++ b/source/blender/ikplugin/intern/iksolver_plugin.c
@@ -199,7 +199,7 @@ static void make_dmats(bPoseChannel *pchan)
if (pchan->parent) {
float iR_parmat[4][4];
invert_m4_m4(iR_parmat, pchan->parent->pose_mat);
- mul_m4_m4m4(pchan->chan_mat, pchan->pose_mat, iR_parmat); // delta mat
+ mult_m4_m4m4(pchan->chan_mat, iR_parmat, pchan->pose_mat); // delta mat
}
else copy_m4_m4(pchan->chan_mat, pchan->pose_mat);
}
@@ -216,7 +216,7 @@ static void where_is_ik_bone(bPoseChannel *pchan, float ik_mat[][3]) // nr = t
if (pchan->parent)
mul_serie_m4(pchan->pose_mat, pchan->parent->pose_mat, pchan->chan_mat, ikmat, NULL, NULL, NULL, NULL, NULL);
else
- mul_m4_m4m4(pchan->pose_mat, ikmat, pchan->chan_mat);
+ mult_m4_m4m4(pchan->pose_mat, pchan->chan_mat, ikmat);
/* calculate head */
copy_v3_v3(pchan->pose_head, pchan->pose_mat[3]);
@@ -356,7 +356,7 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree)
unit_m4(rootmat);
copy_v3_v3(rootmat[3], pchan->pose_head);
- mul_m4_m4m4(imat, rootmat, ob->obmat);
+ mult_m4_m4m4(imat, ob->obmat, rootmat);
invert_m4_m4(goalinv, imat);
for (target=tree->targets.first; target; target=target->next) {
@@ -371,7 +371,7 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree)
get_constraint_target_matrix(scene, target->con, 0, CONSTRAINT_OBTYPE_OBJECT, ob, rootmat, 1.0);
/* and set and transform goal */
- mul_m4_m4m4(goal, rootmat, goalinv);
+ mult_m4_m4m4(goal, goalinv, rootmat);
copy_v3_v3(goalpos, goal[3]);
copy_m3_m4(goalrot, goal);
@@ -385,7 +385,7 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree)
break;
}
else {
- mul_m4_m4m4(goal, rootmat, goalinv);
+ mult_m4_m4m4(goal, goalinv, rootmat);
copy_v3_v3(polepos, goal[3]);
poleconstrain= 1;
diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp
index f4720b7fc41..f605441282b 100644
--- a/source/blender/ikplugin/intern/itasc_plugin.cpp
+++ b/source/blender/ikplugin/intern/itasc_plugin.cpp
@@ -570,7 +570,7 @@ static bool target_callback(const iTaSC::Timestamp& timestamp, const iTaSC::Fram
mul_serie_m4(restmat, target->owner->obmat, chanmat, target->eeRest, NULL, NULL, NULL, NULL, NULL);
}
else {
- mul_m4_m4m4(restmat, target->eeRest, target->owner->obmat);
+ mult_m4_m4m4(restmat, target->owner->obmat, target->eeRest);
}
// blend the target
blend_m4_m4m4(tarmat, restmat, tarmat, constraint->enforce);
@@ -597,7 +597,7 @@ static bool base_callback(const iTaSC::Timestamp& timestamp, const iTaSC::Frame&
// save the base as a frame too so that we can compute deformation
// after simulation
ikscene->baseFrame.setValue(&chanmat[0][0]);
- mul_m4_m4m4(rootmat, chanmat, ikscene->blArmature->obmat);
+ mult_m4_m4m4(rootmat, ikscene->blArmature->obmat, chanmat);
}
else {
copy_m4_m4(rootmat, ikscene->blArmature->obmat);
@@ -622,11 +622,11 @@ static bool base_callback(const iTaSC::Timestamp& timestamp, const iTaSC::Frame&
// get polar target matrix in world space
get_constraint_target_matrix(ikscene->blscene, ikscene->polarConstraint, 1, CONSTRAINT_OBTYPE_OBJECT, ikscene->blArmature, mat, 1.0);
// convert to armature space
- mul_m4_m4m4(polemat, mat, imat);
+ mult_m4_m4m4(polemat, imat, mat);
// get the target in world space (was computed before as target object are defined before base object)
iktarget->target->getPose().getValue(mat[0]);
// convert to armature space
- mul_m4_m4m4(goalmat, mat, imat);
+ mult_m4_m4m4(goalmat, imat, mat);
// take position of target, polar target, end effector, in armature space
KDL::Vector goalpos(goalmat[3]);
KDL::Vector polepos(polemat[3]);
@@ -1003,7 +1003,7 @@ static void convert_pose(IK_Scene *ikscene)
copy_m4_m4(bmat, bone->arm_mat);
}
invert_m4_m4(rmat, bmat);
- mul_m4_m4m4(bmat, pchan->pose_mat, rmat);
+ mult_m4_m4m4(bmat, rmat, pchan->pose_mat);
normalize_m4(bmat);
boneRot.setValue(bmat[0]);
GetJointRotation(boneRot, ikchan->jointType, rot);
@@ -1419,7 +1419,7 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan)
copy_m4_m4(mat, pchan->bone->arm_mat);
copy_v3_v3(mat[3], pchan->bone->arm_tail);
// get the rest pose relative to the armature base
- mul_m4_m4m4(iktarget->eeRest, mat, invBaseFrame);
+ mult_m4_m4m4(iktarget->eeRest, invBaseFrame, mat);
iktarget->eeBlend = (!ikscene->polarConstraint && condata->type==CONSTRAINT_IK_COPYPOSE) ? true : false;
// use target_callback to make sure the initPose includes enforce coefficient
target_callback(iTaSC::Timestamp(), iTaSC::F_identity, initPose, iktarget);
diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c
index 8928774dcb4..45264fa862b 100644
--- a/source/blender/imbuf/intern/anim_movie.c
+++ b/source/blender/imbuf/intern/anim_movie.c
@@ -110,7 +110,8 @@
#endif
#endif
-int ismovie(const char *UNUSED(filepath)) {
+int ismovie(const char *UNUSED(filepath))
+{
return 0;
}
@@ -126,7 +127,8 @@ static void free_anim_movie(struct anim *UNUSED(anim)) { ; }
# define PATHSEPERATOR '/'
#endif
-static int an_stringdec(const char *string, char* head, char *tail, unsigned short *numlen) {
+static int an_stringdec(const char *string, char* head, char *tail, unsigned short *numlen)
+{
unsigned short len,nume,nums=0;
short i,found=FALSE;
@@ -161,11 +163,13 @@ static int an_stringdec(const char *string, char* head, char *tail, unsigned sho
}
-static void an_stringenc(char *string, const char *head, const char *tail, unsigned short numlen, int pic) {
+static void an_stringenc(char *string, const char *head, const char *tail, unsigned short numlen, int pic)
+{
BLI_stringenc(string, head, tail, numlen, pic);
}
-static void free_anim_avi (struct anim *anim) {
+static void free_anim_avi (struct anim *anim)
+{
#if defined(_WIN32) && !defined(FREE_WINDOWS)
int i;
#endif
@@ -206,7 +210,8 @@ static void free_anim_ffmpeg(struct anim * anim);
static void free_anim_redcode(struct anim * anim);
#endif
-void IMB_free_anim(struct anim * anim) {
+void IMB_free_anim(struct anim * anim)
+{
if (anim == NULL) {
printf("free anim, anim == NULL\n");
return;
@@ -229,14 +234,16 @@ void IMB_free_anim(struct anim * anim) {
MEM_freeN(anim);
}
-void IMB_close_anim(struct anim * anim) {
+void IMB_close_anim(struct anim * anim)
+{
if (anim == NULL) return;
IMB_free_anim(anim);
}
-struct anim * IMB_open_anim( const char * name, int ib_flags, int streamindex) {
+struct anim * IMB_open_anim( const char * name, int ib_flags, int streamindex)
+{
struct anim * anim;
anim = (struct anim*)MEM_callocN(sizeof(struct anim), "anim struct");
@@ -249,7 +256,8 @@ struct anim * IMB_open_anim( const char * name, int ib_flags, int streamindex) {
}
-static int startavi (struct anim *anim) {
+static int startavi (struct anim *anim)
+{
AviError avierror;
#if defined(_WIN32) && !defined(FREE_WINDOWS)
@@ -355,7 +363,8 @@ static int startavi (struct anim *anim) {
return 0;
}
-static ImBuf * avi_fetchibuf (struct anim *anim, int position) {
+static ImBuf * avi_fetchibuf (struct anim *anim, int position)
+{
ImBuf *ibuf = NULL;
int *tmp;
int y;
@@ -405,7 +414,8 @@ static ImBuf * avi_fetchibuf (struct anim *anim, int position) {
extern void do_init_ffmpeg(void);
-static int startffmpeg(struct anim * anim) {
+static int startffmpeg(struct anim * anim)
+{
int i, videoStream;
AVCodec *pCodec;
@@ -693,7 +703,6 @@ static void ffmpeg_postprocess(struct anim * anim)
int dstStride2[4] = { -dstStride[0], 0, 0, 0 };
uint8_t* dst2[4] = { dst[0] + (anim->y - 1)*dstStride[0],
0, 0, 0 };
- int i;
sws_scale(anim->img_convert_ctx,
(const uint8_t * const *)input->data,
@@ -1032,7 +1041,8 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position,
return anim->last_frame;
}
-static void free_anim_ffmpeg(struct anim * anim) {
+static void free_anim_ffmpeg(struct anim * anim)
+{
if (anim == NULL) return;
if (anim->pCodecCtx) {
@@ -1058,7 +1068,8 @@ static void free_anim_ffmpeg(struct anim * anim) {
#ifdef WITH_REDCODE
-static int startredcode(struct anim * anim) {
+static int startredcode(struct anim * anim)
+{
anim->redcodeCtx = redcode_open(anim->name);
if (!anim->redcodeCtx) {
return -1;
@@ -1068,7 +1079,8 @@ static int startredcode(struct anim * anim) {
return 0;
}
-static ImBuf * redcode_fetchibuf(struct anim * anim, int position) {
+static ImBuf * redcode_fetchibuf(struct anim * anim, int position)
+{
struct ImBuf * ibuf;
struct redcode_frame * frame;
struct redcode_frame_raw * raw_frame;
@@ -1099,7 +1111,8 @@ static ImBuf * redcode_fetchibuf(struct anim * anim, int position) {
return ibuf;
}
-static void free_anim_redcode(struct anim * anim) {
+static void free_anim_redcode(struct anim * anim)
+{
if (anim->redcodeCtx) {
redcode_close(anim->redcodeCtx);
anim->redcodeCtx = 0;
@@ -1113,7 +1126,8 @@ static void free_anim_redcode(struct anim * anim) {
/* Geen plaatje, probeer dan volgende animatie te openen */
/* gelukt, haal dan eerste plaatje van animatie */
-static struct ImBuf * anim_getnew(struct anim * anim) {
+static struct ImBuf * anim_getnew(struct anim * anim)
+{
struct ImBuf *ibuf = NULL;
if (anim == NULL) return(NULL);
@@ -1175,7 +1189,8 @@ static struct ImBuf * anim_getnew(struct anim * anim) {
return(ibuf);
}
-struct ImBuf * IMB_anim_previewframe(struct anim * anim) {
+struct ImBuf * IMB_anim_previewframe(struct anim * anim)
+{
struct ImBuf * ibuf = NULL;
int position = 0;
@@ -1282,7 +1297,8 @@ struct ImBuf * IMB_anim_absolute(struct anim * anim, int position,
/***/
-int IMB_anim_get_duration(struct anim *anim, IMB_Timecode_Type tc) {
+int IMB_anim_get_duration(struct anim *anim, IMB_Timecode_Type tc)
+{
struct anim_index * idx;
if (tc == IMB_TC_NONE) {
return anim->duration;
diff --git a/source/blender/imbuf/intern/bmp.c b/source/blender/imbuf/intern/bmp.c
index a9c2d72b188..77fc6bdf856 100644
--- a/source/blender/imbuf/intern/bmp.c
+++ b/source/blender/imbuf/intern/bmp.c
@@ -185,14 +185,16 @@ struct ImBuf *imb_bmp_decode(unsigned char *mem, size_t size, int flags)
}
/* Couple of helper functions for writing our data */
-static int putIntLSB(unsigned int ui,FILE *ofile) {
+static int putIntLSB(unsigned int ui,FILE *ofile)
+{
putc((ui>>0)&0xFF,ofile);
putc((ui>>8)&0xFF,ofile);
putc((ui>>16)&0xFF,ofile);
return putc((ui>>24)&0xFF,ofile);
}
-static int putShortLSB(unsigned short us,FILE *ofile) {
+static int putShortLSB(unsigned short us,FILE *ofile)
+{
putc((us>>0)&0xFF,ofile);
return putc((us>>8)&0xFF,ofile);
}
diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c
index 568dd7a9fb7..f8082c95f84 100644
--- a/source/blender/imbuf/intern/jp2.c
+++ b/source/blender/imbuf/intern/jp2.c
@@ -70,21 +70,24 @@ int imb_is_a_jp2(unsigned char *buf)
/**
sample error callback expecting a FILE* client object
*/
-static void error_callback(const char *msg, void *client_data) {
+static void error_callback(const char *msg, void *client_data)
+{
FILE *stream = (FILE*)client_data;
fprintf(stream, "[ERROR] %s", msg);
}
/**
sample warning callback expecting a FILE* client object
*/
-static void warning_callback(const char *msg, void *client_data) {
+static void warning_callback(const char *msg, void *client_data)
+{
FILE *stream = (FILE*)client_data;
fprintf(stream, "[WARNING] %s", msg);
}
/**
sample debug callback expecting no client object
*/
-static void info_callback(const char *msg, void *client_data) {
+static void info_callback(const char *msg, void *client_data)
+{
(void)client_data;
fprintf(stdout, "[INFO] %s", msg);
}
@@ -305,7 +308,8 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags)
#define COMP_48_CS 520833 /*Maximum size per color component for 2K @ 48fps*/
-static int initialise_4K_poc(opj_poc_t *POC, int numres){
+static int initialise_4K_poc(opj_poc_t *POC, int numres)
+{
POC[0].tile = 1;
POC[0].resno0 = 0;
POC[0].compno0 = 0;
@@ -323,7 +327,8 @@ static int initialise_4K_poc(opj_poc_t *POC, int numres){
return 2;
}
-static void cinema_parameters(opj_cparameters_t *parameters){
+static void cinema_parameters(opj_cparameters_t *parameters)
+{
parameters->tile_size_on = false;
parameters->cp_tdx=1;
parameters->cp_tdy=1;
@@ -356,7 +361,8 @@ static void cinema_parameters(opj_cparameters_t *parameters){
}
-static void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *image, img_fol_t *img_fol){
+static void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *image, img_fol_t *img_fol)
+{
int i;
float temp_rate;
@@ -442,8 +448,8 @@ static void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *imag
}
-static opj_image_t* ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters) {
-
+static opj_image_t* ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters)
+{
unsigned char *rect;
float *rect_float;
@@ -662,8 +668,8 @@ static opj_image_t* ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters) {
/* Found write info at http://users.ece.gatech.edu/~slabaugh/personal/c/bitmapUnix.c */
-int imb_savejp2(struct ImBuf *ibuf, const char *name, int flags) {
-
+int imb_savejp2(struct ImBuf *ibuf, const char *name, int flags)
+{
int quality = ibuf->ftype & 0xff;
int bSuccess;
diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c
index 872b78743be..47dad378eb7 100644
--- a/source/blender/imbuf/intern/util.c
+++ b/source/blender/imbuf/intern/util.c
@@ -199,12 +199,14 @@ int IMB_ispic(const char *filename)
-static int isavi (const char *name) {
+static int isavi (const char *name)
+{
return AVI_is_avi (name);
}
#ifdef WITH_QUICKTIME
-static int isqtime (const char *name) {
+static int isqtime (const char *name)
+{
return anim_is_quicktime (name);
}
#endif
@@ -240,7 +242,8 @@ void do_init_ffmpeg(void)
}
}
-static int isffmpeg (const char *filename) {
+static int isffmpeg (const char *filename)
+{
AVFormatContext *pFormatCtx;
unsigned int i;
int videoStream;
@@ -323,7 +326,8 @@ static int isredcode(const char * filename)
#endif
-int imb_get_anim_type(const char * name) {
+int imb_get_anim_type(const char * name)
+{
int type;
struct stat st;
@@ -364,7 +368,8 @@ int imb_get_anim_type(const char * name) {
return(0);
}
-int IMB_isanim(const char *filename) {
+int IMB_isanim(const char *filename)
+{
int type;
if(U.uiflag & USER_FILTERFILEEXTS) {
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index c588dc9c8ac..c15758eed1f 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -64,9 +64,13 @@ EnumPropertyItem nodetree_type_items[] = {
EnumPropertyItem node_socket_type_items[] = {
- {SOCK_FLOAT, "VALUE", 0, "Value", ""},
- {SOCK_VECTOR, "VECTOR", 0, "Vector", ""},
- {SOCK_RGBA, "RGBA", 0, "RGBA", ""},
+ {SOCK_FLOAT, "VALUE", 0, "Value", ""},
+ {SOCK_VECTOR, "VECTOR", 0, "Vector", ""},
+ {SOCK_RGBA, "RGBA", 0, "RGBA", ""},
+ {SOCK_SHADER, "SHADER", 0, "Shader", ""},
+ {SOCK_BOOLEAN, "BOOLEAN", 0, "Boolean", ""},
+ {SOCK_MESH, "MESH", 0, "Mesh", ""},
+ {SOCK_INT, "INT", 0, "Int", ""},
{0, NULL, 0, NULL, NULL}};
EnumPropertyItem node_math_items[] = {
diff --git a/source/blender/makesrna/intern/rna_nodetree_types.h b/source/blender/makesrna/intern/rna_nodetree_types.h
index d8fabad824e..19082ea4689 100644
--- a/source/blender/makesrna/intern/rna_nodetree_types.h
+++ b/source/blender/makesrna/intern/rna_nodetree_types.h
@@ -40,6 +40,7 @@ DefNode( ShaderNode, SH_NODE_VALTORGB, def_colorramp, "VALTO
DefNode( ShaderNode, SH_NODE_RGBTOBW, 0, "RGBTOBW", RGBToBW, "RGB to BW", "" )
DefNode( ShaderNode, SH_NODE_TEXTURE, def_texture, "TEXTURE", Texture, "Texture", "" )
DefNode( ShaderNode, SH_NODE_NORMAL, 0, "NORMAL", Normal, "Normal", "" )
+DefNode( ShaderNode, SH_NODE_GAMMA, 0, "GAMMA", Gamma, "Gamma", "" )
DefNode( ShaderNode, SH_NODE_GEOMETRY, def_sh_geometry, "GEOMETRY", Geometry, "Geometry", "" )
DefNode( ShaderNode, SH_NODE_MAPPING, def_sh_mapping, "MAPPING", Mapping, "Mapping", "" )
DefNode( ShaderNode, SH_NODE_CURVE_VEC, def_vector_curve, "CURVE_VEC", VectorCurve, "Vector Curve", "" )
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index f920cfb5aec..f9bb0b36a3f 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -174,7 +174,7 @@ static void rna_Object_matrix_local_get(PointerRNA *ptr, float values[16])
if(ob->parent) {
float invmat[4][4]; /* for inverse of parent's matrix */
invert_m4_m4(invmat, ob->parent->obmat);
- mul_m4_m4m4((float(*)[4])values, ob->obmat, invmat);
+ mult_m4_m4m4((float(*)[4])values, invmat, ob->obmat);
}
else {
copy_m4_m4((float(*)[4])values, ob->obmat);
@@ -191,7 +191,7 @@ static void rna_Object_matrix_local_set(PointerRNA *ptr, const float values[16])
if(ob->parent) {
float invmat[4][4];
invert_m4_m4(invmat, ob->parentinv);
- mul_m4_m4m4(ob->obmat, (float(*)[4])values, invmat);
+ mult_m4_m4m4(ob->obmat, invmat, (float(*)[4])values);
}
else {
copy_m4_m4(ob->obmat, (float(*)[4])values);
@@ -809,11 +809,11 @@ static void rna_MaterialSlot_link_set(PointerRNA *ptr, int value)
if(value) {
ob->matbits[index]= 1;
- ob->colbits |= (1<<index);
+ /* ob->colbits |= (1<<index); */ /* DEPRECATED */
}
else {
ob->matbits[index]= 0;
- ob->colbits &= ~(1<<index);
+ /* ob->colbits &= ~(1<<index); */ /* DEPRECATED */
}
}
diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c
index e06bc206807..877da130357 100644
--- a/source/blender/makesrna/intern/rna_object_api.c
+++ b/source/blender/makesrna/intern/rna_object_api.c
@@ -191,13 +191,12 @@ Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int apply_
if( tmpcu->mat ) {
for( i = tmpcu->totcol; i-- > 0; ) {
/* are we an object material or data based? */
- if (ob->colbits & 1<<i)
- tmpmesh->mat[i] = ob->mat[i];
- else
- tmpmesh->mat[i] = tmpcu->mat[i];
- if (tmpmesh->mat[i])
+ tmpmesh->mat[i] = ob->matbits[i] ? ob->mat[i] : tmpcu->mat[i];
+
+ if (tmpmesh->mat[i]) {
tmpmesh->mat[i]->id.us++;
+ }
}
}
break;
@@ -230,12 +229,11 @@ Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int apply_
if( origmesh->mat ) {
for( i = origmesh->totcol; i-- > 0; ) {
/* are we an object material or data based? */
- if (ob->colbits & 1<<i)
- tmpmesh->mat[i] = ob->mat[i];
- else
- tmpmesh->mat[i] = origmesh->mat[i];
- if (tmpmesh->mat[i])
+ tmpmesh->mat[i] = ob->matbits[i] ? ob->mat[i] : origmesh->mat[i];
+
+ if (tmpmesh->mat[i]) {
tmpmesh->mat[i]->id.us++;
+ }
}
}
}
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index f0a008b4939..a7f45d867dd 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -2000,23 +2000,6 @@ static void rna_def_space_sequencer(BlenderRNA *brna)
RNA_def_property_enum_items(prop, proxy_render_size_items);
RNA_def_property_ui_text(prop, "Proxy render size", "Draw preview using full resolution or different proxy resolutions");
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_SEQUENCER, NULL);
-
-
- /* not sure we need rna access to these but adding anyway */
- prop= RNA_def_property(srna, "offset_x", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "xof");
- RNA_def_property_ui_text(prop, "X Offset", "Offset image horizontally from the view center");
- RNA_def_property_update(prop, NC_SPACE|ND_SPACE_SEQUENCER, NULL);
-
- prop= RNA_def_property(srna, "offset_y", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "yof");
- RNA_def_property_ui_text(prop, "Y Offset", "Offset image vertically from the view center");
- RNA_def_property_update(prop, NC_SPACE|ND_SPACE_SEQUENCER, NULL);
-
- prop= RNA_def_property(srna, "zoom", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "zoom");
- RNA_def_property_ui_text(prop, "Zoom", "Display zoom level");
- RNA_def_property_update(prop, NC_SPACE|ND_SPACE_SEQUENCER, NULL);
}
static void rna_def_space_text(BlenderRNA *brna)
diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c
index ce052b2c1bd..4602600889c 100644
--- a/source/blender/modifiers/intern/MOD_array.c
+++ b/source/blender/modifiers/intern/MOD_array.c
@@ -338,7 +338,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
unit_m4(final_offset);
for(j=0; j < count - 1; j++) {
- mul_m4_m4m4(tmp_mat, final_offset, offset);
+ mult_m4_m4m4(tmp_mat, offset, final_offset);
copy_m4_m4(final_offset, tmp_mat);
}
@@ -679,7 +679,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
cap_medge = end_cap->getEdgeArray(end_cap);
cap_mface = end_cap->getFaceArray(end_cap);
- mul_m4_m4m4(endoffset, final_offset, offset);
+ mult_m4_m4m4(endoffset, offset, final_offset);
vert_map = MEM_callocN(sizeof(*vert_map) * capVerts,
"arrayModifier_doArray vert_map");
diff --git a/source/blender/modifiers/intern/MOD_boolean_util.c b/source/blender/modifiers/intern/MOD_boolean_util.c
index 843501133c5..afd16b41131 100644
--- a/source/blender/modifiers/intern/MOD_boolean_util.c
+++ b/source/blender/modifiers/intern/MOD_boolean_util.c
@@ -474,7 +474,7 @@ static DerivedMesh *NewBooleanDerivedMesh_intern(
// we need to compute the inverse transform from global to ob (inv_mat),
// and the transform from ob to ob_select for use in interpolation (map_mat)
invert_m4_m4(inv_mat, ob->obmat);
- mul_m4_m4m4(map_mat, ob_select->obmat, inv_mat);
+ mult_m4_m4m4(map_mat, inv_mat, ob_select->obmat);
invert_m4_m4(inv_mat, ob_select->obmat);
{
diff --git a/source/blender/modifiers/intern/MOD_cast.c b/source/blender/modifiers/intern/MOD_cast.c
index e481f691a6e..16d57a2400f 100644
--- a/source/blender/modifiers/intern/MOD_cast.c
+++ b/source/blender/modifiers/intern/MOD_cast.c
@@ -159,7 +159,7 @@ static void sphere_do(
if (ctrl_ob) {
if(flag & MOD_CAST_USE_OB_TRANSFORM) {
invert_m4_m4(ctrl_ob->imat, ctrl_ob->obmat);
- mul_m4_m4m4(mat, ob->obmat, ctrl_ob->imat);
+ mult_m4_m4m4(mat, ctrl_ob->imat, ob->obmat);
invert_m4_m4(imat, mat);
}
@@ -331,7 +331,7 @@ static void cuboid_do(
if (ctrl_ob) {
if(flag & MOD_CAST_USE_OB_TRANSFORM) {
invert_m4_m4(ctrl_ob->imat, ctrl_ob->obmat);
- mul_m4_m4m4(mat, ob->obmat, ctrl_ob->imat);
+ mult_m4_m4m4(mat, ctrl_ob->imat, ob->obmat);
invert_m4_m4(imat, mat);
}
diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c
index 9948a1a462d..f5e4ebfd449 100644
--- a/source/blender/modifiers/intern/MOD_hook.c
+++ b/source/blender/modifiers/intern/MOD_hook.c
@@ -157,7 +157,7 @@ static void deformVerts_do(HookModifierData *hmd, Object *ob, DerivedMesh *dm,
/* get world-space matrix of target, corrected for the space the verts are in */
if (hmd->subtarget[0] && pchan) {
/* bone target if there's a matching pose-channel */
- mul_m4_m4m4(dmat, pchan->pose_mat, hmd->object->obmat);
+ mult_m4_m4m4(dmat, hmd->object->obmat, pchan->pose_mat);
}
else {
/* just object target */
diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c
index bcbb6c630a6..e6e2c0fd621 100644
--- a/source/blender/modifiers/intern/MOD_meshdeform.c
+++ b/source/blender/modifiers/intern/MOD_meshdeform.c
@@ -223,8 +223,8 @@ static void meshdeformModifier_do(
/* compute matrices to go in and out of cage object space */
invert_m4_m4(imat, mmd->object->obmat);
- mul_m4_m4m4(cagemat, ob->obmat, imat);
- mul_m4_m4m4(cmat, cagemat, mmd->bindmat);
+ mult_m4_m4m4(cagemat, imat, ob->obmat);
+ mult_m4_m4m4(cmat, mmd->bindmat, cagemat);
invert_m4_m4(iobmat, cmat);
copy_m3_m4(icagemat, iobmat);
diff --git a/source/blender/modifiers/intern/MOD_mirror.c b/source/blender/modifiers/intern/MOD_mirror.c
index 5336cb03efa..c72a76f0101 100644
--- a/source/blender/modifiers/intern/MOD_mirror.c
+++ b/source/blender/modifiers/intern/MOD_mirror.c
@@ -129,7 +129,7 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd,
float obinv[4][4];
invert_m4_m4(obinv, mmd->mirror_ob->obmat);
- mul_m4_m4m4(mtx, ob->obmat, obinv);
+ mult_m4_m4m4(mtx, obinv, ob->obmat);
invert_m4_m4(imtx, mtx);
}
diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c
index 5dc233c78b1..0867a4b2a7b 100644
--- a/source/blender/modifiers/intern/MOD_screw.c
+++ b/source/blender/modifiers/intern/MOD_screw.c
@@ -197,7 +197,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
/* calc the matrix relative to the axis object */
invert_m4_m4(mtx_tmp_a, ob->obmat);
copy_m4_m4(mtx_tx_inv, ltmd->ob_axis->obmat);
- mul_m4_m4m4(mtx_tx, mtx_tx_inv, mtx_tmp_a);
+ mult_m4_m4m4(mtx_tx, mtx_tmp_a, mtx_tx_inv);
/* calc the axis vec */
mul_mat3_m4_v3(mtx_tx, axis_vec); /* only rotation component */
diff --git a/source/blender/modifiers/intern/MOD_solidify.c b/source/blender/modifiers/intern/MOD_solidify.c
index 347af0066c6..067d66fc82c 100644
--- a/source/blender/modifiers/intern/MOD_solidify.c
+++ b/source/blender/modifiers/intern/MOD_solidify.c
@@ -75,8 +75,8 @@ static void dm_calc_normal(DerivedMesh *dm, float (*temp_nors)[3])
/* we don't want to overwrite any referenced layers */
/*
- Dosnt work here!
- mv = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MVERT);
+ Doesn't work here!
+ mv = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MVERT, numVerts);
cddm->mvert = mv;
*/
diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c
index 584aa6dc206..3146d1c9d5d 100644
--- a/source/blender/modifiers/intern/MOD_uvproject.c
+++ b/source/blender/modifiers/intern/MOD_uvproject.c
@@ -222,11 +222,11 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
if(cam->type == CAM_PERSP) {
float perspmat[4][4];
perspective_m4( perspmat,xmin, xmax, ymin, ymax, cam->clipsta, cam->clipend);
- mul_m4_m4m4(tmpmat, projectors[i].projmat, perspmat);
+ mult_m4_m4m4(tmpmat, perspmat, projectors[i].projmat);
} else { /* if(cam->type == CAM_ORTHO) */
float orthomat[4][4];
orthographic_m4( orthomat,xmin, xmax, ymin, ymax, cam->clipsta, cam->clipend);
- mul_m4_m4m4(tmpmat, projectors[i].projmat, orthomat);
+ mult_m4_m4m4(tmpmat, orthomat, projectors[i].projmat);
}
}
} else {
@@ -250,7 +250,7 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
}
}
- mul_m4_m4m4(projectors[i].projmat, tmpmat, offsetmat);
+ mult_m4_m4m4(projectors[i].projmat, offsetmat, tmpmat);
/* calculate worldspace projector normal (for best projector test) */
projectors[i].normal[0] = 0;
@@ -259,11 +259,12 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
mul_mat3_m4_v3(projectors[i].ob->obmat, projectors[i].normal);
}
+ numFaces = dm->getNumFaces(dm);
+
/* make sure we are not modifying the original UV map */
tface = CustomData_duplicate_referenced_layer_named(&dm->faceData,
- CD_MTFACE, uvname);
+ CD_MTFACE, uvname, numFaces);
-
numVerts = dm->getNumVerts(dm);
coords = MEM_callocN(sizeof(*coords) * numVerts,
@@ -280,7 +281,6 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
mul_project_m4_v3(projectors[0].projmat, *co);
mface = dm->getFaceArray(dm);
- numFaces = dm->getNumFaces(dm);
/* apply coords as UVs, and apply image if tfaces are new */
for(i = 0, mf = mface; i < numFaces; ++i, ++mf, ++tface) {
@@ -295,15 +295,11 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
}
else {
/* apply transformed coords as UVs */
- tface->uv[0][0] = coords[mf->v1][0];
- tface->uv[0][1] = coords[mf->v1][1];
- tface->uv[1][0] = coords[mf->v2][0];
- tface->uv[1][1] = coords[mf->v2][1];
- tface->uv[2][0] = coords[mf->v3][0];
- tface->uv[2][1] = coords[mf->v3][1];
- if(mf->v4) {
- tface->uv[3][0] = coords[mf->v4][0];
- tface->uv[3][1] = coords[mf->v4][1];
+ copy_v2_v2(tface->uv[0], coords[mf->v1]);
+ copy_v2_v2(tface->uv[1], coords[mf->v2]);
+ copy_v2_v2(tface->uv[2], coords[mf->v3]);
+ if (mf->v4) {
+ copy_v2_v2(tface->uv[3], coords[mf->v4]);
}
}
} else {
@@ -358,15 +354,11 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
mul_project_m4_v3(best_projector->projmat, co4);
/* apply transformed coords as UVs */
- tface->uv[0][0] = co1[0];
- tface->uv[0][1] = co1[1];
- tface->uv[1][0] = co2[0];
- tface->uv[1][1] = co2[1];
- tface->uv[2][0] = co3[0];
- tface->uv[2][1] = co3[1];
- if(mf->v4) {
- tface->uv[3][0] = co4[0];
- tface->uv[3][1] = co4[1];
+ copy_v2_v2(tface->uv[0], co1);
+ copy_v2_v2(tface->uv[1], co2);
+ copy_v2_v2(tface->uv[2], co3);
+ if (mf->v4) {
+ copy_v2_v2(tface->uv[3], co4);
}
}
}
diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c
index 8422916e450..41702a74cc1 100644
--- a/source/blender/modifiers/intern/MOD_warp.c
+++ b/source/blender/modifiers/intern/MOD_warp.c
@@ -197,11 +197,11 @@ static void warpModifier_do(WarpModifierData *wmd, Object *ob,
invert_m4_m4(obinv, ob->obmat);
- mul_m4_m4m4(mat_from, wmd->object_from->obmat, obinv);
- mul_m4_m4m4(mat_to, wmd->object_to->obmat, obinv);
+ mult_m4_m4m4(mat_from, obinv, wmd->object_from->obmat);
+ mult_m4_m4m4(mat_to, obinv, wmd->object_to->obmat);
invert_m4_m4(tmat, mat_from); // swap?
- mul_m4_m4m4(mat_final, mat_to, tmat);
+ mult_m4_m4m4(mat_final, tmat, mat_to);
invert_m4_m4(mat_from_inv, mat_from);
diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c
index 80dd0c0a720..398a078bf38 100644
--- a/source/blender/modifiers/intern/MOD_wave.c
+++ b/source/blender/modifiers/intern/MOD_wave.c
@@ -279,7 +279,7 @@ static void waveModifier_do(WaveModifierData *md,
float mat[4][4];
/* get the control object's location in local coordinates */
invert_m4_m4(ob->imat, ob->obmat);
- mul_m4_m4m4(mat, wmd->objectcenter->obmat, ob->imat);
+ mult_m4_m4m4(mat, ob->imat, wmd->objectcenter->obmat);
wmd->startx = mat[3][0];
wmd->starty = mat[3][1];
diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c
index a30c5da07c8..af180b8a688 100644
--- a/source/blender/modifiers/intern/MOD_weightvgproximity.c
+++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c
@@ -449,9 +449,17 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
MEM_freeN(tdw);
/* Get our vertex coordinates. */
- v_cos = MEM_mallocN(sizeof(float[3]) * numIdx, "WeightVGProximity Modifier, v_cos");
- for (i = 0; i < numIdx; i++)
- ret->getVertCo(ret, indices[i], v_cos[i]);
+ {
+ /* XXX In some situations, this code can be up to about 50 times more performant
+ * than simply using getVertCo for each affected vertex...
+ */
+ float (*tv_cos)[3] = MEM_mallocN(sizeof(float[3]) * numVerts, "WeightVGProximity Modifier, tv_cos");
+ v_cos = MEM_mallocN(sizeof(float[3]) * numIdx, "WeightVGProximity Modifier, v_cos");
+ ret->getVertCos(ret, tv_cos);
+ for (i = 0; i < numIdx; i++)
+ copy_v3_v3(v_cos[i], tv_cos[indices[i]]);
+ MEM_freeN(tv_cos);
+ }
/* Compute wanted distances. */
if (wmd->proximity_mode == MOD_WVG_PROXIMITY_OBJECT) {
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt
index 1b327edbc9f..a09aa7a52a3 100644
--- a/source/blender/nodes/CMakeLists.txt
+++ b/source/blender/nodes/CMakeLists.txt
@@ -113,6 +113,7 @@ set(SRC
shader/nodes/node_shader_common.c
shader/nodes/node_shader_curves.c
shader/nodes/node_shader_dynamic.c
+ shader/nodes/node_shader_gamma.c
shader/nodes/node_shader_geom.c
shader/nodes/node_shader_hueSatVal.c
shader/nodes/node_shader_invert.c
diff --git a/source/blender/nodes/NOD_shader.h b/source/blender/nodes/NOD_shader.h
index ae255517733..2cabdd33971 100644
--- a/source/blender/nodes/NOD_shader.h
+++ b/source/blender/nodes/NOD_shader.h
@@ -54,6 +54,7 @@ void register_node_type_sh_valtorgb(struct bNodeTreeType *ttype);
void register_node_type_sh_rgbtobw(struct bNodeTreeType *ttype);
void register_node_type_sh_texture(struct bNodeTreeType *ttype);
void register_node_type_sh_normal(struct bNodeTreeType *ttype);
+void register_node_type_sh_gamma(struct bNodeTreeType *ttype);
void register_node_type_sh_geom(struct bNodeTreeType *ttype);
void register_node_type_sh_mapping(struct bNodeTreeType *ttype);
void register_node_type_sh_curve_vec(struct bNodeTreeType *ttype);
diff --git a/source/blender/nodes/shader/nodes/node_shader_gamma.c b/source/blender/nodes/shader/nodes/node_shader_gamma.c
new file mode 100644
index 00000000000..1d525d71698
--- /dev/null
+++ b/source/blender/nodes/shader/nodes/node_shader_gamma.c
@@ -0,0 +1,63 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2006 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+
+*/
+
+/** \file blender/nodes/composite/nodes/node_composite_gamma.c
+ * \ingroup cmpnodes
+ */
+
+
+#include "node_shader_util.h"
+
+/* **************** Gamma Tools ******************** */
+
+static bNodeSocketTemplate sh_node_gamma_in[]= {
+ { SOCK_RGBA, 1, "Color", 1.0f, 1.0f, 1.0f, 1.0f},
+ { SOCK_FLOAT, 1, "Gamma", 1.0f, 0.0f, 0.0f, 0.0f, 0.001f, 10.0f, PROP_UNSIGNED},
+ { -1, 0, "" }
+};
+
+static bNodeSocketTemplate sh_node_gamma_out[]= {
+ { SOCK_RGBA, 0, "Color"},
+ { -1, 0, "" }
+};
+
+void register_node_type_sh_gamma(bNodeTreeType *ttype)
+{
+ static bNodeType ntype;
+
+ node_type_base(ttype, &ntype, SH_NODE_GAMMA, "Gamma", NODE_CLASS_OP_COLOR, NODE_OPTIONS);
+ node_type_compatibility(&ntype, NODE_NEW_SHADING);
+ node_type_socket_templates(&ntype, sh_node_gamma_in, sh_node_gamma_out);
+ node_type_size(&ntype, 140, 100, 320);
+ node_type_init(&ntype, NULL);
+ node_type_storage(&ntype, "", NULL, NULL);
+ node_type_exec(&ntype, NULL);
+ node_type_gpu(&ntype, NULL);
+
+ nodeRegisterType(ttype, &ntype);
+}
diff --git a/source/blender/nodes/shader/nodes/node_shader_normal.c b/source/blender/nodes/shader/nodes/node_shader_normal.c
index f699268e939..8515c99ba81 100644
--- a/source/blender/nodes/shader/nodes/node_shader_normal.c
+++ b/source/blender/nodes/shader/nodes/node_shader_normal.c
@@ -84,7 +84,7 @@ void register_node_type_sh_normal(bNodeTreeType *ttype)
static bNodeType ntype;
node_type_base(ttype, &ntype, SH_NODE_NORMAL, "Normal", NODE_CLASS_OP_VECTOR, NODE_OPTIONS);
- node_type_compatibility(&ntype, NODE_OLD_SHADING);
+ node_type_compatibility(&ntype, NODE_OLD_SHADING|NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_normal_in, sh_node_normal_out);
node_type_init(&ntype, node_shader_init_normal);
node_type_exec(&ntype, node_shader_exec_normal);
diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c
index 03d66e918d5..c2fd6036414 100644
--- a/source/blender/python/generic/bgl.c
+++ b/source/blender/python/generic/bgl.c
@@ -453,7 +453,7 @@ static int Buffer_ass_item(Buffer *self, int i, PyObject *v)
}
}
- switch(self->type) {
+ switch (self->type) {
case GL_BYTE:
return PyArg_Parse(v, "b:Expected ints", &self->buf.asbyte[i]) ? 0:-1;
case GL_SHORT:
@@ -595,7 +595,7 @@ static PyObject *Buffer_repr(Buffer *self)
PyObject *repr;
const char *typestr= "UNKNOWN";
- switch(self->type) {
+ switch (self->type) {
case GL_BYTE: typestr= "GL_BYTE"; break;
case GL_SHORT: typestr= "GL_SHORT"; break;
case GL_INT: typestr= "GL_BYTE"; break;
diff --git a/source/blender/python/generic/idprop_py_api.c b/source/blender/python/generic/idprop_py_api.c
index c31dadff3e1..c058ee1d4f0 100644
--- a/source/blender/python/generic/idprop_py_api.c
+++ b/source/blender/python/generic/idprop_py_api.c
@@ -405,7 +405,7 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty
val.array.len = PySequence_Size(ob);
- switch(val.array.type) {
+ switch (val.array.type) {
case IDP_DOUBLE:
prop = IDP_New(IDP_ARRAY, &val, name);
for (i=0; i<val.array.len; i++) {
@@ -565,7 +565,7 @@ static PyObject *BPy_IDGroup_MapDataToPy(IDProperty *prop)
return NULL;
}
- switch(prop->subtype) {
+ switch (prop->subtype) {
case IDP_FLOAT:
{
float *array= (float*)IDP_Array(prop);
@@ -976,7 +976,7 @@ static PyObject *BPy_IDArray_repr(BPy_IDArray *self)
static PyObject *BPy_IDArray_GetType(BPy_IDArray *self)
{
- switch(self->prop->subtype) {
+ switch (self->prop->subtype) {
case IDP_FLOAT:
return PyUnicode_FromString("f");
case IDP_DOUBLE:
diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c
index 8d68a407e62..43b8dc21300 100644
--- a/source/blender/python/generic/py_capi_utils.c
+++ b/source/blender/python/generic/py_capi_utils.c
@@ -191,7 +191,7 @@ void PyC_FileAndNum(const char **filename, int *lineno)
void PyC_FileAndNum_Safe(const char **filename, int *lineno)
{
- if(!PYC_INTERPRETER_ACTIVE) {
+ if (!PYC_INTERPRETER_ACTIVE) {
return;
}
diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c
index 1f99503202a..a10be098a61 100644
--- a/source/blender/python/intern/bpy_app.c
+++ b/source/blender/python/intern/bpy_app.c
@@ -260,6 +260,7 @@ PyObject *BPY_app_struct(void)
/* prevent user from creating new instances */
BlenderAppType.tp_init= NULL;
BlenderAppType.tp_new= NULL;
+ BlenderAppType.tp_hash= (hashfunc)_Py_HashPointer; /* without this we can't do set(sys.modules) [#29635] */
/* kindof a hack ontop of PyStructSequence */
py_struct_seq_getset_init();
diff --git a/source/blender/python/intern/bpy_app_handlers.c b/source/blender/python/intern/bpy_app_handlers.c
index edab92b295b..dc9ef9ee8e8 100644
--- a/source/blender/python/intern/bpy_app_handlers.c
+++ b/source/blender/python/intern/bpy_app_handlers.c
@@ -82,7 +82,7 @@ static PyObject *bpy_app_handlers_persistent_new(PyTypeObject *UNUSED(type), PyO
{
PyObject *value;
- if(!PyArg_ParseTuple(args, "O:bpy.app.handlers.persistent", &value))
+ if (!PyArg_ParseTuple(args, "O:bpy.app.handlers.persistent", &value))
return NULL;
if (PyFunction_Check(value)) {
@@ -210,6 +210,7 @@ PyObject *BPY_app_handlers_struct(void)
/* prevent user from creating new instances */
BlenderAppCbType.tp_init= NULL;
BlenderAppCbType.tp_new= NULL;
+ BlenderAppCbType.tp_hash= (hashfunc)_Py_HashPointer; /* without this we can't do set(sys.modules) [#29635] */
/* assign the C callbacks */
if (ret) {
@@ -251,12 +252,12 @@ void BPY_app_handlers_reset(const short do_all)
PyObject *item;
PyObject **dict_ptr;
- for(i= PyList_GET_SIZE(ls) - 1; i >= 0; i--) {
+ for (i= PyList_GET_SIZE(ls) - 1; i >= 0; i--) {
- if ( (PyFunction_Check((item= PyList_GET_ITEM(ls, i)))) &&
- (dict_ptr= _PyObject_GetDictPtr(item)) &&
- (*dict_ptr) &&
- (PyDict_GetItem(*dict_ptr, perm_id_str) != NULL))
+ if ( (PyFunction_Check((item= PyList_GET_ITEM(ls, i)))) &&
+ (dict_ptr= _PyObject_GetDictPtr(item)) &&
+ (*dict_ptr) &&
+ (PyDict_GetItem(*dict_ptr, perm_id_str) != NULL))
{
/* keep */
}
diff --git a/source/blender/python/intern/bpy_driver.c b/source/blender/python/intern/bpy_driver.c
index db408374b7f..e628cb891d8 100644
--- a/source/blender/python/intern/bpy_driver.c
+++ b/source/blender/python/intern/bpy_driver.c
@@ -94,13 +94,12 @@ int bpy_pydriver_create_dict(void)
/* note, this function should do nothing most runs, only when changing frame */
static PyObject *bpy_pydriver_InternStr__frame= NULL;
+/* not thread safe but neither is python */
+static float bpy_pydriver_evaltime_prev= FLT_MAX;
static void bpy_pydriver_update_dict(const float evaltime)
{
- /* not thread safe but neither is python */
- static float evaltime_prev= FLT_MAX;
-
- if (evaltime_prev != evaltime) {
+ if (bpy_pydriver_evaltime_prev != evaltime) {
/* currently only update the frame */
if (bpy_pydriver_InternStr__frame == NULL) {
@@ -111,7 +110,7 @@ static void bpy_pydriver_update_dict(const float evaltime)
bpy_pydriver_InternStr__frame,
PyFloat_FromDouble(evaltime));
- evaltime_prev= evaltime;
+ bpy_pydriver_evaltime_prev= evaltime;
}
}
@@ -137,6 +136,7 @@ void BPY_driver_reset(void)
if (bpy_pydriver_InternStr__frame) {
Py_DECREF(bpy_pydriver_InternStr__frame);
bpy_pydriver_InternStr__frame= NULL;
+ bpy_pydriver_evaltime_prev= FLT_MAX;
}
if (use_gil)
diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c
index c0d796669d6..d1408015089 100644
--- a/source/blender/python/intern/bpy_props.c
+++ b/source/blender/python/intern/bpy_props.c
@@ -971,14 +971,14 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i
item= PySequence_Fast_GET_ITEM(seq_fast, i);
- if ( (PyTuple_CheckExact(item)) &&
- (item_size= PyTuple_GET_SIZE(item)) &&
- (item_size == 3 || item_size == 4) &&
- (tmp.identifier= _PyUnicode_AsStringAndSize(PyTuple_GET_ITEM(item, 0), &id_str_size)) &&
- (tmp.name= _PyUnicode_AsStringAndSize(PyTuple_GET_ITEM(item, 1), &name_str_size)) &&
- (tmp.description= _PyUnicode_AsStringAndSize(PyTuple_GET_ITEM(item, 2), &desc_str_size)) &&
- (item_size < 4 || py_long_as_int(PyTuple_GET_ITEM(item, 3), &tmp.value) != -1) /* TODO, number isnt ensured to be unique from the script author */
- ) {
+ if ( (PyTuple_CheckExact(item)) &&
+ (item_size= PyTuple_GET_SIZE(item)) &&
+ (item_size == 3 || item_size == 4) &&
+ (tmp.identifier= _PyUnicode_AsStringAndSize(PyTuple_GET_ITEM(item, 0), &id_str_size)) &&
+ (tmp.name= _PyUnicode_AsStringAndSize(PyTuple_GET_ITEM(item, 1), &name_str_size)) &&
+ (tmp.description= _PyUnicode_AsStringAndSize(PyTuple_GET_ITEM(item, 2), &desc_str_size)) &&
+ (item_size < 4 || py_long_as_int(PyTuple_GET_ITEM(item, 3), &tmp.value) != -1)) /* TODO, number isnt ensured to be unique from the script author */
+ {
if (is_enum_flag) {
if (item_size < 4) {
tmp.value= 1<<i;
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index f099994fc57..69a5fb39b67 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -624,7 +624,7 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
if (!is_thick)
ret= pyrna_prop_CreatePyObject(ptr, prop); /* owned by the mathutils PyObject */
- switch(subtype) {
+ switch (subtype) {
case PROP_ALL_VECTOR_SUBTYPES:
if (len>=2 && len <= 4) {
if (is_thick) {
@@ -3441,7 +3441,7 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname)
int done= CTX_data_get(C, name, &newptr, &newlb, &newtype);
if (done==1) { /* found */
- switch(newtype) {
+ switch (newtype) {
case CTX_DATA_TYPE_POINTER:
if (newptr.data == NULL) {
ret= Py_None;
@@ -4201,7 +4201,7 @@ static int foreach_compat_buffer(RawPropertyType raw_type, int attr_signed, cons
{
char f= format ? *format:'B'; /* B is assumed when not set */
- switch(raw_type) {
+ switch (raw_type) {
case PROP_RAW_CHAR:
if (attr_signed) return (f=='b') ? 1:0;
else return (f=='B') ? 1:0;
@@ -4265,7 +4265,7 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set)
for ( ; i<tot; i++) {
item= PySequence_GetItem(seq, i);
- switch(raw_type) {
+ switch (raw_type) {
case PROP_RAW_CHAR:
((char *)array)[i]= (char)PyLong_AsLong(item);
break;
@@ -4320,7 +4320,7 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set)
for ( ; i<tot; i++) {
- switch(raw_type) {
+ switch (raw_type) {
case PROP_RAW_CHAR:
item= PyLong_FromSsize_t((Py_ssize_t) ((char *)array)[i]);
break;
@@ -4616,7 +4616,7 @@ static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *dat
PyTuple_SET_ITEM(ret, a, PyLong_FromSsize_t((Py_ssize_t)((int*)data)[a]));
break;
case PROP_FLOAT:
- switch(RNA_property_subtype(prop)) {
+ switch (RNA_property_subtype(prop)) {
#ifdef USE_MATHUTILS
case PROP_ALL_VECTOR_SUBTYPES:
ret= Vector_CreatePyObject(data, len, Py_NEW, NULL);
@@ -6969,10 +6969,10 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
if (err != 0) {
ReportList *reports;
/* alert the user, else they wont know unless they see the console. */
- if ( (!is_static) &&
- (ptr->data) &&
- (RNA_struct_is_a(ptr->type, &RNA_Operator)) &&
- (is_valid_wm == (CTX_wm_manager(C) != NULL)))
+ if ( (!is_static) &&
+ (ptr->data) &&
+ (RNA_struct_is_a(ptr->type, &RNA_Operator)) &&
+ (is_valid_wm == (CTX_wm_manager(C) != NULL)))
{
wmOperator *op= ptr->data;
reports= op->reports;
diff --git a/source/blender/python/intern/bpy_rna_anim.c b/source/blender/python/intern/bpy_rna_anim.c
index 8f88814b3e4..3006e2a6b90 100644
--- a/source/blender/python/intern/bpy_rna_anim.c
+++ b/source/blender/python/intern/bpy_rna_anim.c
@@ -148,8 +148,8 @@ static int pyrna_struct_anim_args_parse(
/* internal use for insert and delete */
static int pyrna_struct_keyframe_parse(
- PointerRNA *ptr, PyObject *args, PyObject *kw, const char *parse_str, const char *error_prefix,
- const char **path_full, int *index, float *cfra, const char **group_name) /* return values */
+ PointerRNA *ptr, PyObject *args, PyObject *kw, const char *parse_str, const char *error_prefix,
+ const char **path_full, int *index, float *cfra, const char **group_name) /* return values */
{
static const char *kwlist[]= {"data_path", "index", "frame", "group", NULL};
const char *path;
diff --git a/source/blender/python/intern/bpy_rna_callback.c b/source/blender/python/intern/bpy_rna_callback.c
index 85f950947a7..134cbfda71f 100644
--- a/source/blender/python/intern/bpy_rna_callback.c
+++ b/source/blender/python/intern/bpy_rna_callback.c
@@ -60,7 +60,7 @@ static void cb_region_draw(const bContext *C, ARegion *UNUSED(ar), void *customd
cb_args= PyTuple_GET_ITEM((PyObject *)customdata, 1);
result= PyObject_CallObject(cb_func, cb_args);
- if(result) {
+ if (result) {
Py_DECREF(result);
}
else {
@@ -82,21 +82,22 @@ PyObject *pyrna_callback_add(BPy_StructRNA *self, PyObject *args)
if (!PyArg_ParseTuple(args, "OO!|s:bpy_struct.callback_add", &cb_func, &PyTuple_Type, &cb_args, &cb_event_str))
return NULL;
- if(!PyCallable_Check(cb_func)) {
+ if (!PyCallable_Check(cb_func)) {
PyErr_SetString(PyExc_TypeError, "callback_add(): first argument isn't callable");
return NULL;
}
- if(RNA_struct_is_a(self->ptr.type, &RNA_Region)) {
- if(cb_event_str) {
+ if (RNA_struct_is_a(self->ptr.type, &RNA_Region)) {
+ if (cb_event_str) {
static EnumPropertyItem region_draw_mode_items[]= {
{REGION_DRAW_POST_PIXEL, "POST_PIXEL", 0, "Post Pixel", ""},
{REGION_DRAW_POST_VIEW, "POST_VIEW", 0, "Post View", ""},
{REGION_DRAW_PRE_VIEW, "PRE_VIEW", 0, "Pre View", ""},
{0, NULL, 0, NULL, NULL}};
- if(pyrna_enum_value_from_id(region_draw_mode_items, cb_event_str, &cb_event, "bpy_struct.callback_add()") < 0)
+ if (pyrna_enum_value_from_id(region_draw_mode_items, cb_event_str, &cb_event, "bpy_struct.callback_add()") < 0) {
return NULL;
+ }
}
else {
cb_event= REGION_DRAW_POST_PIXEL;
@@ -124,12 +125,12 @@ PyObject *pyrna_callback_remove(BPy_StructRNA *self, PyObject *args)
handle= PyCapsule_GetPointer(py_handle, RNA_CAPSULE_ID);
- if(handle==NULL) {
+ if (handle==NULL) {
PyErr_SetString(PyExc_ValueError, "callback_remove(handle): NULL handle given, invalid or already removed");
return NULL;
}
- if(RNA_struct_is_a(self->ptr.type, &RNA_Region)) {
+ if (RNA_struct_is_a(self->ptr.type, &RNA_Region)) {
customdata= ED_region_draw_cb_customdata(handle);
Py_DECREF((PyObject *)customdata);
diff --git a/source/blender/python/intern/gpu.c b/source/blender/python/intern/gpu.c
index 0da63297077..a155a7ec3d9 100644
--- a/source/blender/python/intern/gpu.c
+++ b/source/blender/python/intern/gpu.c
@@ -184,7 +184,8 @@ static PyObject* GPU_export_shader(PyObject* UNUSED(self), PyObject *args, PyObj
PyErr_SetString(PyExc_SystemError, "scene.as_pointer() failed");
return NULL;
}
- } else {
+ }
+ else {
PyErr_SetString(PyExc_TypeError, "gpu.export_shader() first argument should be of Scene type");
return NULL;
}
@@ -204,7 +205,8 @@ static PyObject* GPU_export_shader(PyObject* UNUSED(self), PyObject *args, PyObj
PyErr_SetString(PyExc_SystemError, "scene.as_pointer() failed");
return NULL;
}
- } else {
+ }
+ else {
PyErr_SetString(PyExc_TypeError, "gpu.export_shader() second argument should be of Material type");
return NULL;
}
@@ -260,7 +262,8 @@ static PyObject* GPU_export_shader(PyObject* UNUSED(self), PyObject *args, PyObj
if (attribute->name) {
if (attribute->name[0] != 0) {
PY_DICT_ADD_STRING(dict,attribute,name);
- } else {
+ }
+ else {
val = PyLong_FromLong(0);
PyDict_SetItemString(dict, "name", val);
Py_DECREF(val);
diff --git a/source/blender/python/mathutils/mathutils.c b/source/blender/python/mathutils/mathutils.c
index 121c5e26e73..5587028d812 100644
--- a/source/blender/python/mathutils/mathutils.c
+++ b/source/blender/python/mathutils/mathutils.c
@@ -40,36 +40,13 @@ PyDoc_STRVAR(M_Mathutils_doc,
"This module provides access to matrices, eulers, quaternions and vectors."
);
static int mathutils_array_parse_fast(float *array,
- int array_min, int array_max,
- PyObject *value, const char *error_prefix)
+ int size,
+ PyObject *value_fast,
+ const char *error_prefix)
{
- PyObject *value_fast= NULL;
PyObject *item;
- int i, size;
-
- /* non list/tuple cases */
- if (!(value_fast=PySequence_Fast(value, error_prefix))) {
- /* PySequence_Fast sets the error */
- return -1;
- }
-
- size= PySequence_Fast_GET_SIZE(value_fast);
-
- if (size > array_max || size < array_min) {
- if (array_max == array_min) {
- PyErr_Format(PyExc_ValueError,
- "%.200s: sequence size is %d, expected %d",
- error_prefix, size, array_max);
- }
- else {
- PyErr_Format(PyExc_ValueError,
- "%.200s: sequence size is %d, expected [%d - %d]",
- error_prefix, size, array_min, array_max);
- }
- Py_DECREF(value_fast);
- return -1;
- }
+ int i;
i= size;
do {
@@ -93,13 +70,14 @@ static int mathutils_array_parse_fast(float *array,
/* helper functionm returns length of the 'value', -1 on error */
int mathutils_array_parse(float *array, int array_min, int array_max, PyObject *value, const char *error_prefix)
{
-#if 1 /* approx 6x speedup for mathutils types */
int size;
- if ( (size= VectorObject_Check(value) ? ((VectorObject *)value)->size : 0) ||
- (size= EulerObject_Check(value) ? 3 : 0) ||
- (size= QuaternionObject_Check(value) ? 4 : 0) ||
- (size= ColorObject_Check(value) ? 3 : 0))
+#if 1 /* approx 6x speedup for mathutils types */
+
+ if ( (size= VectorObject_Check(value) ? ((VectorObject *)value)->size : 0) ||
+ (size= EulerObject_Check(value) ? 3 : 0) ||
+ (size= QuaternionObject_Check(value) ? 4 : 0) ||
+ (size= ColorObject_Check(value) ? 3 : 0))
{
if (BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
return -1;
@@ -125,7 +103,85 @@ int mathutils_array_parse(float *array, int array_min, int array_max, PyObject *
else
#endif
{
- return mathutils_array_parse_fast(array, array_min, array_max, value, error_prefix);
+ PyObject *value_fast= NULL;
+
+ /* non list/tuple cases */
+ if (!(value_fast=PySequence_Fast(value, error_prefix))) {
+ /* PySequence_Fast sets the error */
+ return -1;
+ }
+
+ size= PySequence_Fast_GET_SIZE(value_fast);
+
+ if (size > array_max || size < array_min) {
+ if (array_max == array_min) {
+ PyErr_Format(PyExc_ValueError,
+ "%.200s: sequence size is %d, expected %d",
+ error_prefix, size, array_max);
+ }
+ else {
+ PyErr_Format(PyExc_ValueError,
+ "%.200s: sequence size is %d, expected [%d - %d]",
+ error_prefix, size, array_min, array_max);
+ }
+ Py_DECREF(value_fast);
+ return -1;
+ }
+
+ return mathutils_array_parse_fast(array, size, value_fast, error_prefix);
+ }
+}
+
+int mathutils_array_parse_alloc(float **array, int array_min, PyObject *value, const char *error_prefix)
+{
+ int size;
+
+#if 1 /* approx 6x speedup for mathutils types */
+
+ if ( (size= VectorObject_Check(value) ? ((VectorObject *)value)->size : 0) ||
+ (size= EulerObject_Check(value) ? 3 : 0) ||
+ (size= QuaternionObject_Check(value) ? 4 : 0) ||
+ (size= ColorObject_Check(value) ? 3 : 0))
+ {
+ if (BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
+ return -1;
+ }
+
+ if (size < array_min) {
+ PyErr_Format(PyExc_ValueError,
+ "%.200s: sequence size is %d, expected > %d",
+ error_prefix, size, array_min);
+ return -1;
+ }
+
+ *array= PyMem_Malloc(size * sizeof(float));
+ memcpy(*array, ((BaseMathObject *)value)->data, size * sizeof(float));
+ return size;
+ }
+ else
+#endif
+ {
+ PyObject *value_fast= NULL;
+ //*array= NULL;
+
+ /* non list/tuple cases */
+ if (!(value_fast=PySequence_Fast(value, error_prefix))) {
+ /* PySequence_Fast sets the error */
+ return -1;
+ }
+
+ size= PySequence_Fast_GET_SIZE(value_fast);
+
+ if (size < array_min) {
+ PyErr_Format(PyExc_ValueError,
+ "%.200s: sequence size is %d, expected > %d",
+ error_prefix, size, array_min);
+ return -1;
+ }
+
+ *array= PyMem_Malloc(size * sizeof(float));
+
+ return mathutils_array_parse_fast(*array, size, value_fast, error_prefix);
}
}
diff --git a/source/blender/python/mathutils/mathutils.h b/source/blender/python/mathutils/mathutils.h
index a8170b8145c..cd3548b9b82 100644
--- a/source/blender/python/mathutils/mathutils.h
+++ b/source/blender/python/mathutils/mathutils.h
@@ -115,6 +115,7 @@ int _BaseMathObject_WriteIndexCallback(BaseMathObject *self, int index);
/* utility func */
int mathutils_array_parse(float *array, int array_min, int array_max, PyObject *value, const char *error_prefix);
+int mathutils_array_parse_alloc(float **array, int array_min, PyObject *value, const char *error_prefix);
int mathutils_any_to_rotmat(float rmat[3][3], PyObject *value, const char *error_prefix);
int column_vector_multiplication(float rvec[4], VectorObject *vec, MatrixObject *mat);
diff --git a/source/blender/python/mathutils/mathutils_Color.c b/source/blender/python/mathutils/mathutils_Color.c
index 8409344a9fe..e46dda7560f 100644
--- a/source/blender/python/mathutils/mathutils_Color.c
+++ b/source/blender/python/mathutils/mathutils_Color.c
@@ -48,7 +48,7 @@ static PyObject *Color_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return NULL;
}
- switch(PyTuple_GET_SIZE(args)) {
+ switch (PyTuple_GET_SIZE(args)) {
case 0:
break;
case 1:
diff --git a/source/blender/python/mathutils/mathutils_Euler.c b/source/blender/python/mathutils/mathutils_Euler.c
index 7e769da14cb..f44c0b82a2d 100644
--- a/source/blender/python/mathutils/mathutils_Euler.c
+++ b/source/blender/python/mathutils/mathutils_Euler.c
@@ -59,7 +59,7 @@ static PyObject *Euler_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (!PyArg_ParseTuple(args, "|Os:mathutils.Euler", &seq, &order_str))
return NULL;
- switch(PyTuple_GET_SIZE(args)) {
+ switch (PyTuple_GET_SIZE(args)) {
case 0:
break;
case 2:
@@ -84,7 +84,7 @@ static const char *euler_order_str(EulerObject *self)
short euler_order_from_string(const char *str, const char *error_prefix)
{
if ((str[0] && str[1] && str[2] && str[3]=='\0')) {
- switch(*((PY_INT32_T *)str)) {
+ switch (*((PY_INT32_T *)str)) {
case 'X'|'Y'<<8|'Z'<<16: return EULER_ORDER_XYZ;
case 'X'|'Z'<<8|'Y'<<16: return EULER_ORDER_XZY;
case 'Y'|'X'<<8|'Z'<<16: return EULER_ORDER_YXZ;
diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c
index ea636ef52fb..44799bb7943 100644
--- a/source/blender/python/mathutils/mathutils_Matrix.c
+++ b/source/blender/python/mathutils/mathutils_Matrix.c
@@ -52,13 +52,14 @@ static int mathutils_matrix_vector_check(BaseMathObject *bmo)
static int mathutils_matrix_vector_get(BaseMathObject *bmo, int subtype)
{
MatrixObject *self= (MatrixObject *)bmo->cb_user;
- int i;
+ int index;
if (BaseMath_ReadCallback(self) == -1)
return -1;
- for (i=0; i < self->col_size; i++)
- bmo->data[i]= self->matrix[subtype][i];
+ for (index=0; index < self->col_size; index++) {
+ bmo->data[index] = MATRIX_ITEM(self, subtype, index);
+ }
return 0;
}
@@ -66,13 +67,14 @@ static int mathutils_matrix_vector_get(BaseMathObject *bmo, int subtype)
static int mathutils_matrix_vector_set(BaseMathObject *bmo, int subtype)
{
MatrixObject *self= (MatrixObject *)bmo->cb_user;
- int i;
+ int index;
if (BaseMath_ReadCallback(self) == -1)
return -1;
- for (i=0; i < self->col_size; i++)
- self->matrix[subtype][i]= bmo->data[i];
+ for (index=0; index < self->col_size; index++) {
+ MATRIX_ITEM(self, subtype, index) = bmo->data[index];
+ }
(void)BaseMath_WriteCallback(self);
return 0;
@@ -85,7 +87,7 @@ static int mathutils_matrix_vector_get_index(BaseMathObject *bmo, int subtype, i
if (BaseMath_ReadCallback(self) == -1)
return -1;
- bmo->data[index]= self->matrix[subtype][index];
+ bmo->data[index]= MATRIX_ITEM(self, subtype, index);
return 0;
}
@@ -96,7 +98,7 @@ static int mathutils_matrix_vector_set_index(BaseMathObject *bmo, int subtype, i
if (BaseMath_ReadCallback(self) == -1)
return -1;
- self->matrix[subtype][index]= bmo->data[index];
+ MATRIX_ITEM(self, subtype, index) = bmo->data[index];
(void)BaseMath_WriteCallback(self);
return 0;
@@ -123,7 +125,7 @@ static PyObject *Matrix_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return NULL;
}
- switch(PyTuple_GET_SIZE(args)) {
+ switch (PyTuple_GET_SIZE(args)) {
case 0:
return Matrix_CreatePyObject(NULL, 4, 4, Py_NEW, type);
case 1:
@@ -620,24 +622,22 @@ static PyObject *C_Matrix_Shear(PyObject *cls, PyObject *args)
void matrix_as_3x3(float mat[3][3], MatrixObject *self)
{
- copy_v3_v3(mat[0], self->matrix[0]);
- copy_v3_v3(mat[1], self->matrix[1]);
- copy_v3_v3(mat[2], self->matrix[2]);
+ copy_v3_v3(mat[0], MATRIX_ROW_PTR(self, 0));
+ copy_v3_v3(mat[1], MATRIX_ROW_PTR(self, 1));
+ copy_v3_v3(mat[2], MATRIX_ROW_PTR(self, 2));
}
/* assumes rowsize == colsize is checked and the read callback has run */
static float matrix_determinant_internal(MatrixObject *self)
{
if (self->row_size == 2) {
- return determinant_m2(self->matrix[0][0], self->matrix[0][1],
- self->matrix[1][0], self->matrix[1][1]);
+ return determinant_m2(MATRIX_ITEM(self, 0, 0), MATRIX_ITEM(self, 0, 1),
+ MATRIX_ITEM(self, 1, 0), MATRIX_ITEM(self, 1, 1));
}
else if (self->row_size == 3) {
- return determinant_m3(self->matrix[0][0], self->matrix[0][1],
- self->matrix[0][2], self->matrix[1][0],
- self->matrix[1][1], self->matrix[1][2],
- self->matrix[2][0], self->matrix[2][1],
- self->matrix[2][2]);
+ return determinant_m3(MATRIX_ITEM(self, 0, 0), MATRIX_ITEM(self, 0, 1), MATRIX_ITEM(self, 0, 2),
+ MATRIX_ITEM(self, 1, 0), MATRIX_ITEM(self, 1, 1), MATRIX_ITEM(self, 1, 2),
+ MATRIX_ITEM(self, 2, 0), MATRIX_ITEM(self, 2, 1), MATRIX_ITEM(self, 2, 2));
}
else {
return determinant_m4((float (*)[4])self->contigPtr);
@@ -781,10 +781,7 @@ static PyObject *Matrix_resize_4x4(MatrixObject *self)
"problem allocating pointer space");
return NULL;
}
- /*set row pointers*/
- for (x = 0; x < 4; x++) {
- self->matrix[x] = self->contigPtr + (x * 4);
- }
+
/*move data to new spot in array + clean*/
for (blank_rows = (4 - self->row_size); blank_rows > 0; blank_rows--) {
for (x = 0; x < 4; x++) {
@@ -890,7 +887,7 @@ static PyObject *Matrix_to_translation(MatrixObject *self)
return NULL;
}
- return Vector_CreatePyObject(self->matrix[3], 3, Py_NEW, NULL);
+ return Vector_CreatePyObject(MATRIX_ROW_PTR(self, 3), 3, Py_NEW, NULL);
}
PyDoc_STRVAR(Matrix_to_scale_doc,
@@ -964,10 +961,10 @@ static PyObject *Matrix_invert(MatrixObject *self)
if (det != 0) {
/*calculate the classical adjoint*/
if (self->row_size == 2) {
- mat[0] = self->matrix[1][1];
- mat[1] = -self->matrix[0][1];
- mat[2] = -self->matrix[1][0];
- mat[3] = self->matrix[0][0];
+ mat[0] = MATRIX_ITEM(self, 1, 1);
+ mat[1] = -MATRIX_ITEM(self, 0, 1);
+ mat[2] = -MATRIX_ITEM(self, 1, 0);
+ mat[3] = MATRIX_ITEM(self, 0, 0);
}
else if (self->row_size == 3) {
adjoint_m3_m3((float (*)[3]) mat,(float (*)[3])self->contigPtr);
@@ -982,7 +979,7 @@ static PyObject *Matrix_invert(MatrixObject *self)
/*set values*/
for (x = 0; x < self->row_size; x++) {
for (y = 0; y < self->col_size; y++) {
- self->matrix[x][y] = mat[z];
+ MATRIX_ITEM(self, x, y) = mat[z];
z++;
}
}
@@ -1173,8 +1170,6 @@ PyDoc_STRVAR(Matrix_transpose_doc,
);
static PyObject *Matrix_transpose(MatrixObject *self)
{
- float t = 0.0f;
-
if (BaseMath_ReadCallback(self) == -1)
return NULL;
@@ -1186,9 +1181,9 @@ static PyObject *Matrix_transpose(MatrixObject *self)
}
if (self->row_size == 2) {
- t = self->matrix[1][0];
- self->matrix[1][0] = self->matrix[0][1];
- self->matrix[0][1] = t;
+ const float t = MATRIX_ITEM(self, 1, 0);
+ MATRIX_ITEM(self, 1, 0) = MATRIX_ITEM(self, 0, 1);
+ MATRIX_ITEM(self, 0, 1) = t;
}
else if (self->row_size == 3) {
transpose_m3((float (*)[3])self->contigPtr);
@@ -1256,10 +1251,10 @@ static PyObject *Matrix_identity(MatrixObject *self)
}
if (self->row_size == 2) {
- self->matrix[0][0] = 1.0f;
- self->matrix[0][1] = 0.0f;
- self->matrix[1][0] = 0.0f;
- self->matrix[1][1] = 1.0f;
+ MATRIX_ITEM(self, 0, 0) = 1.0f;
+ MATRIX_ITEM(self, 0, 1) = 0.0f;
+ MATRIX_ITEM(self, 1, 0) = 0.0f;
+ MATRIX_ITEM(self, 1, 1) = 1.0f;
}
else if (self->row_size == 3) {
unit_m3((float (*)[3])self->contigPtr);
@@ -1304,10 +1299,10 @@ static PyObject *Matrix_repr(MatrixObject *self)
for (x = 0; x < self->row_size; x++) {
rows[x]= PyTuple_New(self->col_size);
for (y = 0; y < self->col_size; y++) {
- PyTuple_SET_ITEM(rows[x], y, PyFloat_FromDouble(self->matrix[x][y]));
+ PyTuple_SET_ITEM(rows[x], y, PyFloat_FromDouble(MATRIX_ITEM(self, x, y)));
}
}
- switch(self->row_size) {
+ switch (self->row_size) {
case 2: return PyUnicode_FromFormat("Matrix((%R,\n"
" %R))", rows[0], rows[1]);
@@ -1406,7 +1401,7 @@ static int Matrix_ass_item(MatrixObject *self, int i, PyObject *value)
return -1;
}
- memcpy(self->matrix[i], vec, self->col_size *sizeof(float));
+ memcpy(MATRIX_ROW_PTR(self, i), vec, self->col_size * sizeof(float));
(void)BaseMath_WriteCallback(self);
return 0;
@@ -1591,7 +1586,7 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2)
for (x = 0; x < mat2->row_size; x++) {
for (y = 0; y < mat1->col_size; y++) {
for (z = 0; z < mat1->row_size; z++) {
- dot += (mat1->matrix[z][y] * mat2->matrix[x][z]);
+ dot += MATRIX_ITEM(mat1, z, y) * MATRIX_ITEM(mat2, x, z);
}
mat[((x * mat1->col_size) + y)] = (float)dot;
dot = 0.0f;
@@ -1944,31 +1939,18 @@ PyTypeObject matrix_Type = {
NULL /*tp_del*/
};
-/*------------------------Matrix_CreatePyObject (internal)-------------
-creates a new matrix object
-self->matrix self->contiguous_ptr (reference to data.xxx)
- [0]------------->[0]
- [1]
- [2]
- [1]------------->[3]
- [4]
- [5]
-
-self->matrix[1][1] = self->contigPtr[4] */
-
-/*pass Py_WRAP - if vector is a WRAPPER for data allocated by BLENDER
- (i.e. it was allocated elsewhere by MEM_mallocN())
- pass Py_NEW - if vector is not a WRAPPER and managed by PYTHON
- (i.e. it must be created here with PyMEM_malloc())*/
+/* pass Py_WRAP - if vector is a WRAPPER for data allocated by BLENDER
+ * (i.e. it was allocated elsewhere by MEM_mallocN())
+ * pass Py_NEW - if vector is not a WRAPPER and managed by PYTHON
+ * (i.e. it must be created here with PyMEM_malloc()) */
PyObject *Matrix_CreatePyObject(float *mat,
- const unsigned short rowSize, const unsigned short colSize,
+ const unsigned short row_size, const unsigned short col_size,
int type, PyTypeObject *base_type)
{
MatrixObject *self;
- int x, row, col;
- /*matrix objects can be any 2-4row x 2-4col matrix*/
- if (rowSize < 2 || rowSize > 4 || colSize < 2 || colSize > 4) {
+ /* matrix objects can be any 2-4row x 2-4col matrix */
+ if (row_size < 2 || row_size > 4 || col_size < 2 || col_size > 4) {
PyErr_SetString(PyExc_RuntimeError,
"Matrix(): "
"row and column sizes must be between 2 and 4");
@@ -1979,8 +1961,8 @@ PyObject *Matrix_CreatePyObject(float *mat,
(MatrixObject *)PyObject_GC_New(MatrixObject, &matrix_Type);
if (self) {
- self->row_size = rowSize;
- self->col_size = colSize;
+ self->row_size = row_size;
+ self->col_size = col_size;
/* init callbacks as NULL */
self->cb_user= NULL;
@@ -1988,36 +1970,29 @@ PyObject *Matrix_CreatePyObject(float *mat,
if (type == Py_WRAP) {
self->contigPtr = mat;
- /*pointer array points to contigous memory*/
- for (x = 0; x < rowSize; x++) {
- self->matrix[x] = self->contigPtr + (x * colSize);
- }
self->wrapped = Py_WRAP;
}
else if (type == Py_NEW) {
- self->contigPtr = PyMem_Malloc(rowSize * colSize * sizeof(float));
+ self->contigPtr = PyMem_Malloc(row_size * col_size * sizeof(float));
if (self->contigPtr == NULL) { /*allocation failure*/
PyErr_SetString(PyExc_MemoryError,
"Matrix(): "
"problem allocating pointer space");
return NULL;
}
- /*pointer array points to contigous memory*/
- for (x = 0; x < rowSize; x++) {
- self->matrix[x] = self->contigPtr + (x * colSize);
- }
- /*parse*/
+
if (mat) { /*if a float array passed*/
- for (row = 0; row < rowSize; row++) {
- for (col = 0; col < colSize; col++) {
- self->matrix[row][col] = mat[(row * colSize) + col];
- }
- }
+ memcpy(self->contigPtr, mat, row_size * col_size * sizeof(float));
}
- else if (rowSize == colSize) { /*or if no arguments are passed return identity matrix for square matrices */
+ else if (row_size == col_size) {
+ /* or if no arguments are passed return identity matrix for square matrices */
PyObject *ret_dummy= Matrix_identity(self);
Py_DECREF(ret_dummy);
}
+ else {
+ /* otherwise zero everything */
+ memset(self->contigPtr, 0, row_size * col_size * sizeof(float));
+ }
self->wrapped = Py_NEW;
}
else {
diff --git a/source/blender/python/mathutils/mathutils_Matrix.h b/source/blender/python/mathutils/mathutils_Matrix.h
index 6dfcbb1faf9..95768febca0 100644
--- a/source/blender/python/mathutils/mathutils_Matrix.h
+++ b/source/blender/python/mathutils/mathutils_Matrix.h
@@ -38,19 +38,33 @@ extern PyTypeObject matrix_Type;
#define MatrixObject_Check(_v) PyObject_TypeCheck((_v), &matrix_Type)
#define MATRIX_MAX_DIM 4
+/* matrix[row][col] == MATRIX_ITEM_INDEX(matrix, row, col) */
+
+#ifdef DEBUG
+# define MATRIX_ITEM_ASSERT(_mat, _row, _col) (BLI_assert(_row < (_mat)->row_size && _col < (_mat)->col_size))
+#else
+# define MATRIX_ITEM_ASSERT(_mat, _row, _col) (void)0
+#endif
+
+#define MATRIX_ITEM_INDEX(_mat, _row, _col) (MATRIX_ITEM_ASSERT(_mat, _row, _col),(((_mat)->col_size * (_row)) + (_col)))
+#define MATRIX_ITEM_PTR( _mat, _row, _col) ((_mat)->contigPtr + MATRIX_ITEM_INDEX(_mat, _row, _col))
+#define MATRIX_ITEM( _mat, _row, _col) ((_mat)->contigPtr [MATRIX_ITEM_INDEX(_mat, _row, _col)])
+
+#define MATRIX_ROW_INDEX(_mat, _row) (MATRIX_ITEM_INDEX(_mat, _row, 0))
+#define MATRIX_ROW_PTR( _mat, _row) ((_mat)->contigPtr + MATRIX_ROW_INDEX(_mat, _row))
+
typedef struct {
BASE_MATH_MEMBERS(contigPtr);
- float *matrix[MATRIX_MAX_DIM]; /* ptr to the contigPtr (accessor) */
unsigned short row_size;
unsigned short col_size;
} MatrixObject;
-/*struct data contains a pointer to the actual data that the
-object uses. It can use either PyMem allocated data (which will
-be stored in py_data) or be a wrapper for data allocated through
-blender (stored in blend_data). This is an either/or struct not both*/
+/* struct data contains a pointer to the actual data that the
+ * object uses. It can use either PyMem allocated data (which will
+ * be stored in py_data) or be a wrapper for data allocated through
+ * blender (stored in blend_data). This is an either/or struct not both */
-/*prototypes*/
+/* prototypes */
PyObject *Matrix_CreatePyObject(float *mat,
const unsigned short row_size, const unsigned short col_size,
int type, PyTypeObject *base_type);
diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c b/source/blender/python/mathutils/mathutils_Quaternion.c
index cf817003a98..7ab9b7b0713 100644
--- a/source/blender/python/mathutils/mathutils_Quaternion.c
+++ b/source/blender/python/mathutils/mathutils_Quaternion.c
@@ -1039,7 +1039,7 @@ static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kw
if (!PyArg_ParseTuple(args, "|Od:mathutils.Quaternion", &seq, &angle))
return NULL;
- switch(PyTuple_GET_SIZE(args)) {
+ switch (PyTuple_GET_SIZE(args)) {
case 0:
break;
case 1:
@@ -1075,18 +1075,18 @@ static PyObject *quat__apply_to_copy(PyNoArgsFunction quat_func, QuaternionObjec
static void quat__axis_angle_sanitize(float axis[3], float *angle)
{
if (axis) {
- if ( !finite(axis[0]) ||
- !finite(axis[1]) ||
- !finite(axis[2]))
+ if ( !finite(axis[0]) ||
+ !finite(axis[1]) ||
+ !finite(axis[2]))
{
axis[0]= 1.0f;
axis[1]= 0.0f;
axis[2]= 0.0f;
}
- else if ( EXPP_FloatsAreEqual(axis[0], 0.0f, 10) &&
- EXPP_FloatsAreEqual(axis[1], 0.0f, 10) &&
- EXPP_FloatsAreEqual(axis[2], 0.0f, 10)
- ) {
+ else if ( EXPP_FloatsAreEqual(axis[0], 0.0f, 10) &&
+ EXPP_FloatsAreEqual(axis[1], 0.0f, 10) &&
+ EXPP_FloatsAreEqual(axis[2], 0.0f, 10))
+ {
axis[0] = 1.0f;
}
}
diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c
index 9d1a22adb12..aedf60e7191 100644
--- a/source/blender/python/mathutils/mathutils_Vector.c
+++ b/source/blender/python/mathutils/mathutils_Vector.c
@@ -54,15 +54,29 @@ static int row_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject *v
*/
static PyObject *Vector_new(PyTypeObject *type, PyObject *args, PyObject *UNUSED(kwds))
{
- float vec[4]= {0.0f, 0.0f, 0.0f, 0.0f};
+ float *vec= NULL;
int size= 3; /* default to a 3D vector */
- switch(PyTuple_GET_SIZE(args)) {
+ switch (PyTuple_GET_SIZE(args)) {
case 0:
+ vec= PyMem_Malloc(size * sizeof(float));
+
+ if (vec == NULL) {
+ PyErr_SetString(PyExc_MemoryError,
+ "Vector(): "
+ "problem allocating pointer space");
+ return NULL;
+ }
+
+ fill_vn_fl(vec, size, 0.0f);
break;
case 1:
- if ((size=mathutils_array_parse(vec, 2, 4, PyTuple_GET_ITEM(args, 0), "mathutils.Vector()")) == -1)
+ if ((size=mathutils_array_parse_alloc(&vec, 2, PyTuple_GET_ITEM(args, 0), "mathutils.Vector()")) == -1) {
+ if (vec) {
+ PyMem_Free(vec);
+ }
return NULL;
+ }
break;
default:
PyErr_SetString(PyExc_TypeError,
@@ -87,6 +101,215 @@ static PyObject *vec__apply_to_copy(PyNoArgsFunction vec_func, VectorObject *sel
}
}
+/*-----------------------CLASS-METHODS----------------------------*/
+PyDoc_STRVAR(C_Vector_Fill_doc,
+".. classmethod:: Fill(size, fill=0.0)\n"
+"\n"
+" Create a vector of length size with all values set to fill.\n"
+"\n"
+" :arg size: The length of the vector to be created.\n"
+" :type size: int\n"
+" :arg fill: The value used to fill the vector.\n"
+" :type fill: float\n"
+);
+static PyObject *C_Vector_Fill(PyObject *cls, PyObject *args)
+{
+ float *vec;
+ int size;
+ float fill= 0.0f;
+
+ if (!PyArg_ParseTuple(args, "i|f:Vector.Fill", &size, &fill)) {
+ return NULL;
+ }
+
+ if (size < 2) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "Vector(): invalid size");
+ return NULL;
+ }
+
+ vec= PyMem_Malloc(size * sizeof(float));
+
+ if (vec == NULL) {
+ PyErr_SetString(PyExc_MemoryError,
+ "Vector.Fill(): "
+ "problem allocating pointer space");
+ return NULL;
+ }
+
+ fill_vn_fl(vec, size, fill);
+
+ return Vector_CreatePyObject_alloc(vec, size, (PyTypeObject *)cls);
+}
+
+PyDoc_STRVAR(C_Vector_Range_doc,
+".. classmethod:: Range(start=0, stop, step=1)\n"
+"\n"
+" Create a filled with a range of values.\n"
+"\n"
+" :arg start: The start of the range used to fill the vector.\n"
+" :type start: int\n"
+" :arg stop: The end of the range used to fill the vector.\n"
+" :type stop: int\n"
+" :arg step: The step between successive values in the vector.\n"
+" :type step: int\n"
+);
+static PyObject *C_Vector_Range(PyObject *cls, PyObject *args)
+{
+ float *vec;
+ int stop, size;
+ int start= 0;
+ int step= 1;
+
+ if (!PyArg_ParseTuple(args, "i|ii:Vector.Range", &start, &stop, &step)) {
+ return NULL;
+ }
+
+ switch (PyTuple_GET_SIZE(args)) {
+ case 1:
+ size = start;
+ start= 0;
+ break;
+ case 2:
+ if (start >= stop) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "Start value is larger"
+ "than the stop value");
+ return NULL;
+ }
+
+ size= stop - start;
+ break;
+ default:
+ if (start >= stop) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "Start value is larger"
+ "than the stop value");
+ return NULL;
+ }
+ size= (stop - start)/step;
+ if (size%step)
+ size++;
+ break;
+ }
+
+ vec= PyMem_Malloc(size * sizeof(float));
+
+ if (vec == NULL) {
+ PyErr_SetString(PyExc_MemoryError,
+ "Vector.Range(): "
+ "problem allocating pointer space");
+ return NULL;
+ }
+
+ range_vn_fl(vec, size, (float)start, (float)step);
+
+ return Vector_CreatePyObject_alloc(vec, size, (PyTypeObject *)cls);
+}
+
+PyDoc_STRVAR(C_Vector_Linspace_doc,
+".. classmethod:: Linspace(start, stop, size)\n"
+"\n"
+" Create a vector of the specified size which is filled with linearly spaced values between start and stop values.\n"
+"\n"
+" :arg start: The start of the range used to fill the vector.\n"
+" :type start: int\n"
+" :arg stop: The end of the range used to fill the vector.\n"
+" :type stop: int\n"
+" :arg size: The size of the vector to be created.\n"
+" :type size: int\n"
+);
+static PyObject *C_Vector_Linspace(PyObject *cls, PyObject *args)
+{
+ float *vec;
+ int size;
+ float start, end, step;
+
+ if (!PyArg_ParseTuple(args, "ffi:Vector.Linspace", &start, &end, &size)) {
+ return NULL;
+ }
+
+ if (size < 2) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "Vector.Linspace(): invalid size");
+ return NULL;
+ }
+
+ step= (end - start)/(float)(size-1);
+
+ vec= PyMem_Malloc(size * sizeof(float));
+
+ if (vec == NULL) {
+ PyErr_SetString(PyExc_MemoryError,
+ "Vector.Linspace(): "
+ "problem allocating pointer space");
+ return NULL;
+ }
+
+ range_vn_fl(vec, size, start, step);
+
+ return Vector_CreatePyObject_alloc(vec, size, (PyTypeObject *)cls);
+}
+
+PyDoc_STRVAR(C_Vector_Repeat_doc,
+".. classmethod:: Repeat(vector, size)\n"
+"\n"
+" Create a vector by repeating the values in vector until the required size is reached.\n"
+"\n"
+" :arg tuple: The vector to draw values from.\n"
+" :type tuple: :class:`mathutils.Vector`\n"
+" :arg size: The size of the vector to be created.\n"
+" :type size: int\n"
+);
+static PyObject *C_Vector_Repeat(PyObject *cls, PyObject *args)
+{
+ float *vec;
+ float *iter_vec= NULL;
+ int i, size, value_size;
+ PyObject *value;
+
+ if (!PyArg_ParseTuple(args, "Oi:Vector.Repeat", &value, &size)) {
+ return NULL;
+ }
+
+ if (size < 2) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "Vector.Repeat(): invalid size");
+ return NULL;
+ }
+
+ if ((value_size=mathutils_array_parse_alloc(&iter_vec, 2, value, "Vector.Repeat(vector, size), invalid 'vector' arg")) == -1) {
+ PyMem_Free(iter_vec);
+ return NULL;
+ }
+
+ if (iter_vec == NULL) {
+ PyErr_SetString(PyExc_MemoryError,
+ "Vector.Repeat(): "
+ "problem allocating pointer space");
+ return NULL;
+ }
+
+ vec= PyMem_Malloc(size * sizeof(float));
+
+ if (vec == NULL) {
+ PyErr_SetString(PyExc_MemoryError,
+ "Vector.Repeat(): "
+ "problem allocating pointer space");
+ return NULL;
+ }
+
+ i= 0;
+ while (i < size) {
+ vec[i]= iter_vec[i % value_size];
+ i++;
+ }
+
+ PyMem_Free(iter_vec);
+
+ return Vector_CreatePyObject_alloc(vec, size, (PyTypeObject *)cls);
+}
+
/*-----------------------------METHODS---------------------------- */
PyDoc_STRVAR(Vector_zero_doc,
".. method:: zero()\n"
@@ -137,6 +360,101 @@ static PyObject *Vector_normalized(VectorObject *self)
return vec__apply_to_copy((PyNoArgsFunction)Vector_normalize, self);
}
+PyDoc_STRVAR(Vector_resize_doc,
+".. method:: resize(size=3)\n"
+"\n"
+" Resize the vector to have size number of elements.\n"
+"\n"
+" :return: an instance of itself\n"
+" :rtype: :class:`Vector`\n"
+);
+static PyObject *Vector_resize(VectorObject *self, PyObject *value)
+{
+ int size;
+
+ if (self->wrapped==Py_WRAP) {
+ PyErr_SetString(PyExc_TypeError,
+ "Vector.resize(): "
+ "cannot resize wrapped data - only python vectors");
+ return NULL;
+ }
+ if (self->cb_user) {
+ PyErr_SetString(PyExc_TypeError,
+ "Vector.resize(): "
+ "cannot resize a vector that has an owner");
+ return NULL;
+ }
+
+ if ((size = PyLong_AsLong(value)) == -1) {
+ PyErr_SetString(PyExc_TypeError,
+ "Vector.resize(size): "
+ "expected size argument to be an integer");
+ return NULL;
+ }
+
+ if (size < 2) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "Vector.resize(): invalid size");
+ return NULL;
+ }
+
+ self->vec = PyMem_Realloc(self->vec, (size * sizeof(float)));
+ if (self->vec == NULL) {
+ PyErr_SetString(PyExc_MemoryError,
+ "Vector.resize(): "
+ "problem allocating pointer space");
+ return NULL;
+ }
+
+ /* If the vector has increased in length, set all new elements to 0.0f */
+ if (size > self->size) {
+ fill_vn_fl(self->vec + self->size, size - self->size, 0.0f);
+ }
+
+ self->size = size;
+ Py_RETURN_NONE;
+}
+
+PyDoc_STRVAR(Vector_resized_doc,
+".. method:: resized(size=3)\n"
+"\n"
+" Return a resized copy of the vector with size number of elements.\n"
+"\n"
+" :return: a new vector\n"
+" :rtype: :class:`Vector`\n"
+);
+static PyObject *Vector_resized(VectorObject *self, PyObject *value)
+{
+ int size;
+ float *vec;
+
+ /*if (!PyArg_ParseTuple(args, "i:resize", &size))
+ return NULL;*/
+ if ((size = PyLong_AsLong(value)) == -1) {
+ return NULL;
+ }
+
+ if (size < 2) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "Vector.resized(): invalid size");
+ return NULL;
+ }
+
+ vec= PyMem_Malloc(size * sizeof(float));
+
+ if (vec == NULL) {
+ PyErr_SetString(PyExc_MemoryError,
+ "Vector.resized(): "
+ "problem allocating pointer space");
+ return NULL;
+ }
+
+ fill_vn_fl(vec, size, 0.0f);
+ memcpy(vec, self->vec, self->size * sizeof(float));
+
+ return Vector_CreatePyObject_alloc(vec, size, NULL);
+}
+
PyDoc_STRVAR(Vector_resize_2d_doc,
".. method:: resize_2d()\n"
"\n"
@@ -394,7 +712,7 @@ static PyObject *Vector_to_track_quat(VectorObject *self, PyObject *args)
if (strlen(strack) == 2) {
if (strack[0] == '-') {
- switch(strack[1]) {
+ switch (strack[1]) {
case 'X':
track = 3;
break;
@@ -415,7 +733,7 @@ static PyObject *Vector_to_track_quat(VectorObject *self, PyObject *args)
}
}
else if (strlen(strack) == 1) {
- switch(strack[0]) {
+ switch (strack[0]) {
case '-':
case 'X':
track = 0;
@@ -440,7 +758,7 @@ static PyObject *Vector_to_track_quat(VectorObject *self, PyObject *args)
if (sup) {
const char *axis_err_msg= "only X, Y or Z for up axis";
if (strlen(sup) == 1) {
- switch(*sup) {
+ switch (*sup) {
case 'X':
up = 0;
break;
@@ -505,6 +823,12 @@ static PyObject *Vector_reflect(VectorObject *self, PyObject *value)
if ((value_size= mathutils_array_parse(tvec, 2, 4, value, "Vector.reflect(other), invalid 'other' arg")) == -1)
return NULL;
+ if (self->size < 2 || self->size > 4) {
+ PyErr_SetString(PyExc_ValueError,
+ "Vector must be 2D, 3D or 4D");
+ return NULL;
+ }
+
mirror[0] = tvec[0];
mirror[1] = tvec[1];
if (value_size > 2) mirror[2] = tvec[2];
@@ -544,6 +868,12 @@ static PyObject *Vector_cross(VectorObject *self, PyObject *value)
if (mathutils_array_parse(tvec, self->size, self->size, value, "Vector.cross(other), invalid 'other' arg") == -1)
return NULL;
+ if (self->size != 3) {
+ PyErr_SetString(PyExc_ValueError,
+ "Vector must be 3D");
+ return NULL;
+ }
+
ret= (VectorObject *)Vector_CreatePyObject(NULL, 3, Py_NEW, Py_TYPE(self));
cross_v3_v3v3(ret->vec, self->vec, tvec);
return (PyObject *)ret;
@@ -561,15 +891,20 @@ PyDoc_STRVAR(Vector_dot_doc,
);
static PyObject *Vector_dot(VectorObject *self, PyObject *value)
{
- float tvec[MAX_DIMENSIONS];
+ float *tvec;
if (BaseMath_ReadCallback(self) == -1)
return NULL;
- if (mathutils_array_parse(tvec, self->size, self->size, value, "Vector.dot(other), invalid 'other' arg") == -1)
- return NULL;
+ if (mathutils_array_parse_alloc(&tvec, self->size, value, "Vector.dot(other), invalid 'other' arg") == -1) {
+ goto cleanup;
+ }
return PyFloat_FromDouble(dot_vn_vn(self->vec, tvec, self->size));
+
+cleanup:
+ PyMem_Free(tvec);
+ return NULL;
}
PyDoc_STRVAR(Vector_angle_doc,
@@ -607,6 +942,12 @@ static PyObject *Vector_angle(VectorObject *self, PyObject *args)
if (mathutils_array_parse(tvec, self->size, self->size, value, "Vector.angle(other), invalid 'other' arg") == -1)
return NULL;
+ if (self->size > 4) {
+ PyErr_SetString(PyExc_ValueError,
+ "Vector must be 2D, 3D or 4D");
+ return NULL;
+ }
+
for (x = 0; x < size; x++) {
dot_self += (double)self->vec[x] * (double)self->vec[x];
dot_other += (double)tvec[x] * (double)tvec[x];
@@ -647,7 +988,7 @@ static PyObject *Vector_rotation_difference(VectorObject *self, PyObject *value)
{
float quat[4], vec_a[3], vec_b[3];
- if (self->size < 3) {
+ if (self->size < 3 || self->size > 4) {
PyErr_SetString(PyExc_ValueError,
"vec.difference(value): "
"expects both vectors to be size 3 or 4");
@@ -692,6 +1033,12 @@ static PyObject *Vector_project(VectorObject *self, PyObject *value)
if (mathutils_array_parse(tvec, size, size, value, "Vector.project(other), invalid 'other' arg") == -1)
return NULL;
+ if (self->size > 4) {
+ PyErr_SetString(PyExc_ValueError,
+ "Vector must be 2D, 3D or 4D");
+ return NULL;
+ }
+
if (BaseMath_ReadCallback(self) == -1)
return NULL;
@@ -725,24 +1072,41 @@ static PyObject *Vector_lerp(VectorObject *self, PyObject *args)
const int size= self->size;
PyObject *value= NULL;
float fac, ifac;
- float tvec[MAX_DIMENSIONS], vec[MAX_DIMENSIONS];
+ float *tvec, *vec;
int x;
if (!PyArg_ParseTuple(args, "Of:lerp", &value, &fac))
return NULL;
- if (mathutils_array_parse(tvec, size, size, value, "Vector.lerp(other), invalid 'other' arg") == -1)
- return NULL;
+ if (mathutils_array_parse_alloc(&tvec, size, value, "Vector.lerp(other), invalid 'other' arg") == -1) {
+ goto cleanup;
+ }
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
+ goto cleanup;
+ }
+
+ vec= PyMem_Malloc(size * sizeof(float));
+ if (vec == NULL) {
+ PyErr_SetString(PyExc_MemoryError,
+ "Vector.lerp(): "
+ "problem allocating pointer space");
return NULL;
+ }
ifac= 1.0f - fac;
for (x = 0; x < size; x++) {
vec[x] = (ifac * self->vec[x]) + (fac * tvec[x]);
}
- return Vector_CreatePyObject(vec, size, Py_NEW, Py_TYPE(self));
+
+ PyMem_Free(tvec);
+
+ return Vector_CreatePyObject_alloc(vec, size, Py_TYPE(self));
+
+cleanup:
+ PyMem_Free(tvec);
+ return NULL;
}
PyDoc_STRVAR(Vector_rotate_doc,
@@ -763,7 +1127,7 @@ static PyObject *Vector_rotate(VectorObject *self, PyObject *value)
if (mathutils_any_to_rotmat(other_rmat, value, "Vector.rotate(value)") == -1)
return NULL;
- if (self->size < 3) {
+ if (self->size < 3 || self->size > 4) {
PyErr_SetString(PyExc_ValueError,
"Vector must be 3D or 4D");
return NULL;
@@ -903,8 +1267,8 @@ static PyObject *Vector_slice(VectorObject *self, int begin, int end)
/* sequence slice (set): vector[a:b] = value */
static int Vector_ass_slice(VectorObject *self, int begin, int end, PyObject *seq)
{
- int y, size = 0;
- float vec[MAX_DIMENSIONS];
+ int size = 0;
+ float *vec= NULL;
if (BaseMath_ReadCallback(self) == -1)
return -1;
@@ -914,18 +1278,30 @@ static int Vector_ass_slice(VectorObject *self, int begin, int end, PyObject *se
begin = MIN2(begin, end);
size = (end - begin);
- if (mathutils_array_parse(vec, size, size, seq, "vector[begin:end] = [...]") == -1)
+ if (mathutils_array_parse_alloc(&vec, size, seq, "vector[begin:end] = [...]") == -1) {
+ goto cleanup;
+ }
+
+ if (vec == NULL) {
+ PyErr_SetString(PyExc_MemoryError,
+ "vec[:] = seq: "
+ "problem allocating pointer space");
return -1;
+ }
/*parsed well - now set in vector*/
- for (y = 0; y < size; y++) {
- self->vec[begin + y] = vec[y];
- }
+ memcpy(self->vec + begin, vec, size * sizeof(float));
if (BaseMath_WriteCallback(self) == -1)
return -1;
+ PyMem_Free(vec);
+
return 0;
+
+cleanup:
+ PyMem_Free(vec);
+ return -1;
}
/* Numeric Protocols */
@@ -933,7 +1309,7 @@ static int Vector_ass_slice(VectorObject *self, int begin, int end, PyObject *se
static PyObject *Vector_add(PyObject *v1, PyObject *v2)
{
VectorObject *vec1 = NULL, *vec2 = NULL;
- float vec[MAX_DIMENSIONS];
+ float *vec= NULL;
if (!VectorObject_Check(v1) || !VectorObject_Check(v2)) {
PyErr_Format(PyExc_AttributeError,
@@ -956,9 +1332,18 @@ static PyObject *Vector_add(PyObject *v1, PyObject *v2)
return NULL;
}
+ vec= PyMem_Malloc(vec1->size * sizeof(float));
+
+ if (vec == NULL) { /*allocation failure*/
+ PyErr_SetString(PyExc_MemoryError,
+ "Vector(): "
+ "problem allocating pointer space");
+ return NULL;
+ }
+
add_vn_vnvn(vec, vec1->vec, vec2->vec, vec1->size);
- return Vector_CreatePyObject(vec, vec1->size, Py_NEW, Py_TYPE(v1));
+ return Vector_CreatePyObject_alloc(vec, vec1->size, Py_TYPE(v1));
}
/* addition in-place: obj += obj */
@@ -997,7 +1382,7 @@ static PyObject *Vector_iadd(PyObject *v1, PyObject *v2)
static PyObject *Vector_sub(PyObject *v1, PyObject *v2)
{
VectorObject *vec1 = NULL, *vec2 = NULL;
- float vec[MAX_DIMENSIONS];
+ float *vec;
if (!VectorObject_Check(v1) || !VectorObject_Check(v2)) {
PyErr_Format(PyExc_AttributeError,
@@ -1019,9 +1404,18 @@ static PyObject *Vector_sub(PyObject *v1, PyObject *v2)
return NULL;
}
+ vec= PyMem_Malloc(vec1->size * sizeof(float));
+
+ if (vec == NULL) { /*allocation failure*/
+ PyErr_SetString(PyExc_MemoryError,
+ "Vector(): "
+ "problem allocating pointer space");
+ return NULL;
+ }
+
sub_vn_vnvn(vec, vec1->vec, vec2->vec, vec1->size);
- return Vector_CreatePyObject(vec, vec1->size, Py_NEW, Py_TYPE(v1));
+ return Vector_CreatePyObject_alloc(vec, vec1->size, Py_TYPE(v1));
}
/* subtraction in-place: obj -= obj */
@@ -1093,7 +1487,7 @@ int column_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject* vec,
for (x = 0; x < mat->col_size; x++) {
for (y = 0; y < mat->row_size; y++) {
- dot += (double)(mat->matrix[y][x] * vec_cpy[y]);
+ dot += (double)(MATRIX_ITEM(mat, y, x) * vec_cpy[y]);
}
rvec[z++] = (float)dot;
dot = 0.0f;
@@ -1104,9 +1498,18 @@ int column_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject* vec,
static PyObject *vector_mul_float(VectorObject *vec, const float scalar)
{
- float tvec[MAX_DIMENSIONS];
+ float *tvec= NULL;
+ tvec= PyMem_Malloc(vec->size * sizeof(float));
+
+ if (tvec == NULL) { /*allocation failure*/
+ PyErr_SetString(PyExc_MemoryError,
+ "vec * float: "
+ "problem allocating pointer space");
+ return NULL;
+ }
+
mul_vn_vn_fl(tvec, vec->vec, vec->size, scalar);
- return Vector_CreatePyObject(tvec, vec->size, Py_NEW, Py_TYPE(vec));
+ return Vector_CreatePyObject_alloc(tvec, vec->size, Py_TYPE(vec));
}
static PyObject *Vector_mul(PyObject *v1, PyObject *v2)
@@ -1277,8 +1680,7 @@ static PyObject *Vector_imul(PyObject *v1, PyObject *v2)
/* divid: obj / obj */
static PyObject *Vector_div(PyObject *v1, PyObject *v2)
{
- int i;
- float vec[4], scalar;
+ float *vec= NULL, scalar;
VectorObject *vec1 = NULL;
if (!VectorObject_Check(v1)) { /* not a vector */
@@ -1287,7 +1689,7 @@ static PyObject *Vector_div(PyObject *v1, PyObject *v2)
"Vector must be divided by a float");
return NULL;
}
- vec1 = (VectorObject*)v1; /* vector */
+ vec1 = (VectorObject *)v1; /* vector */
if (BaseMath_ReadCallback(vec1) == -1)
return NULL;
@@ -1306,16 +1708,23 @@ static PyObject *Vector_div(PyObject *v1, PyObject *v2)
return NULL;
}
- for (i = 0; i < vec1->size; i++) {
- vec[i] = vec1->vec[i] / scalar;
+ vec= PyMem_Malloc(vec1->size * sizeof(float));
+
+ if (vec == NULL) { /*allocation failure*/
+ PyErr_SetString(PyExc_MemoryError,
+ "vec / value: "
+ "problem allocating pointer space");
+ return NULL;
}
- return Vector_CreatePyObject(vec, vec1->size, Py_NEW, Py_TYPE(v1));
+
+ mul_vn_vn_fl(vec, vec1->vec, vec1->size, 1.0f/scalar);
+
+ return Vector_CreatePyObject_alloc(vec, vec1->size, Py_TYPE(v1));
}
/* divide in-place: obj /= obj */
static PyObject *Vector_idiv(PyObject *v1, PyObject *v2)
{
- int i;
float scalar;
VectorObject *vec1 = (VectorObject*)v1;
@@ -1335,9 +1744,8 @@ static PyObject *Vector_idiv(PyObject *v1, PyObject *v2)
"divide by zero error");
return NULL;
}
- for (i = 0; i < vec1->size; i++) {
- vec1->vec[i] /= scalar;
- }
+
+ mul_vn_fl(vec1->vec, vec1->size, 1.0f/scalar);
(void)BaseMath_WriteCallback(vec1);
@@ -1349,29 +1757,24 @@ static PyObject *Vector_idiv(PyObject *v1, PyObject *v2)
returns the negative of this object*/
static PyObject *Vector_neg(VectorObject *self)
{
- float tvec[MAX_DIMENSIONS];
+ float *tvec;
if (BaseMath_ReadCallback(self) == -1)
return NULL;
+ tvec= PyMem_Malloc(self->size * sizeof(float));
negate_vn_vn(tvec, self->vec, self->size);
- return Vector_CreatePyObject(tvec, self->size, Py_NEW, Py_TYPE(self));
+ return Vector_CreatePyObject_alloc(tvec, self->size, Py_TYPE(self));
}
/*------------------------vec_magnitude_nosqrt (internal) - for comparing only */
static double vec_magnitude_nosqrt(float *data, int size)
{
- double dot = 0.0f;
- int i;
-
- for (i=0; i<size; i++) {
- dot += (double)data[i];
- }
/*return (double)sqrt(dot);*/
/* warning, line above removed because we are not using the length,
rather the comparing the sizes and for this we do not need the sqrt
for the actual length, the dot must be sqrt'd */
- return dot;
+ return dot_vn_vn(data, data, size);
}
@@ -1606,16 +2009,10 @@ static int Vector_setAxis(VectorObject *self, PyObject *value, void *type)
/* vector.length */
static PyObject *Vector_getLength(VectorObject *self, void *UNUSED(closure))
{
- double dot = 0.0f;
- int i;
-
if (BaseMath_ReadCallback(self) == -1)
return NULL;
- for (i = 0; i < self->size; i++) {
- dot += (double)(self->vec[i] * self->vec[i]);
- }
- return PyFloat_FromDouble(sqrt(dot));
+ return PyFloat_FromDouble(sqrt(dot_vn_vn(self->vec, self->vec, self->size)));
}
static int Vector_setLength(VectorObject *self, PyObject *value)
@@ -2213,7 +2610,7 @@ static int row_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject *v
//muliplication
for (x = 0; x < mat->row_size; x++) {
for (y = 0; y < mat->col_size; y++) {
- dot += mat->matrix[x][y] * vec_cpy[y];
+ dot += MATRIX_ITEM(mat, x, y) * vec_cpy[y];
}
rvec[z++] = (float)dot;
dot = 0.0f;
@@ -2242,6 +2639,12 @@ static PyObject *Vector_negate(VectorObject *self)
}
static struct PyMethodDef Vector_methods[] = {
+ /* Class Methods */
+ {"Fill", (PyCFunction) C_Vector_Fill, METH_VARARGS | METH_CLASS, C_Vector_Fill_doc},
+ {"Range", (PyCFunction) C_Vector_Range, METH_VARARGS | METH_CLASS, C_Vector_Range_doc},
+ {"Linspace", (PyCFunction) C_Vector_Linspace, METH_VARARGS | METH_CLASS, C_Vector_Linspace_doc},
+ {"Repeat", (PyCFunction) C_Vector_Repeat, METH_VARARGS | METH_CLASS, C_Vector_Repeat_doc},
+
/* in place only */
{"zero", (PyCFunction) Vector_zero, METH_NOARGS, Vector_zero_doc},
{"negate", (PyCFunction) Vector_negate, METH_NOARGS, Vector_negate_doc},
@@ -2250,6 +2653,8 @@ static struct PyMethodDef Vector_methods[] = {
{"normalize", (PyCFunction) Vector_normalize, METH_NOARGS, Vector_normalize_doc},
{"normalized", (PyCFunction) Vector_normalized, METH_NOARGS, Vector_normalized_doc},
+ {"resize", (PyCFunction) Vector_resize, METH_O, Vector_resize_doc},
+ {"resized", (PyCFunction) Vector_resized, METH_O, Vector_resized_doc},
{"to_2d", (PyCFunction) Vector_to_2d, METH_NOARGS, Vector_to_2d_doc},
{"resize_2d", (PyCFunction) Vector_resize_2d, METH_NOARGS, Vector_resize_2d_doc},
{"to_3d", (PyCFunction) Vector_to_3d, METH_NOARGS, Vector_to_3d_doc},
@@ -2375,7 +2780,7 @@ PyObject *Vector_CreatePyObject(float *vec, const int size, const int type, PyTy
{
VectorObject *self;
- if (size > 4 || size < 2) {
+ if (size < 2) {
PyErr_SetString(PyExc_RuntimeError,
"Vector(): invalid size");
return NULL;
@@ -2429,3 +2834,12 @@ PyObject *Vector_CreatePyObject_cb(PyObject *cb_user, int size, int cb_type, int
return (PyObject *)self;
}
+
+PyObject *Vector_CreatePyObject_alloc(float *vec, const int size, PyTypeObject *base_type)
+{
+ VectorObject *vect_ob;
+ vect_ob= (VectorObject *)Vector_CreatePyObject(vec, size, Py_WRAP, base_type);
+ vect_ob->wrapped= Py_NEW;
+
+ return (PyObject *)vect_ob;
+}
diff --git a/source/blender/python/mathutils/mathutils_Vector.h b/source/blender/python/mathutils/mathutils_Vector.h
index 0f7fa174d18..4e10e795602 100644
--- a/source/blender/python/mathutils/mathutils_Vector.h
+++ b/source/blender/python/mathutils/mathutils_Vector.h
@@ -41,11 +41,12 @@ extern PyTypeObject vector_Type;
typedef struct {
BASE_MATH_MEMBERS(vec);
- unsigned char size; /* vec size 2,3 or 4 */
+ int size; /* vec size 2,3 or 4 */
} VectorObject;
/*prototypes*/
PyObject *Vector_CreatePyObject(float *vec, const int size, const int type, PyTypeObject *base_type);
PyObject *Vector_CreatePyObject_cb(PyObject *user, int size, int callback_type, int subtype);
+PyObject *Vector_CreatePyObject_alloc(float *vec, const int size, PyTypeObject *base_type);
#endif /* MATHUTILS_VECTOR_H */
diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c
index c5e0d2ab95d..f3a843baf66 100644
--- a/source/blender/python/mathutils/mathutils_geometry.c
+++ b/source/blender/python/mathutils/mathutils_geometry.c
@@ -99,11 +99,11 @@ static PyObject *M_Geometry_intersect_ray_tri(PyObject *UNUSED(self), PyObject*
return NULL;
}
- if ( BaseMath_ReadCallback(vec1) == -1 ||
- BaseMath_ReadCallback(vec2) == -1 ||
- BaseMath_ReadCallback(vec3) == -1 ||
- BaseMath_ReadCallback(ray) == -1 ||
- BaseMath_ReadCallback(ray_off) == -1)
+ if ( BaseMath_ReadCallback(vec1) == -1 ||
+ BaseMath_ReadCallback(vec2) == -1 ||
+ BaseMath_ReadCallback(vec3) == -1 ||
+ BaseMath_ReadCallback(ray) == -1 ||
+ BaseMath_ReadCallback(ray_off) == -1)
{
return NULL;
}
@@ -199,10 +199,10 @@ static PyObject *M_Geometry_intersect_line_line(PyObject *UNUSED(self), PyObject
return NULL;
}
- if ( BaseMath_ReadCallback(vec1) == -1 ||
- BaseMath_ReadCallback(vec2) == -1 ||
- BaseMath_ReadCallback(vec3) == -1 ||
- BaseMath_ReadCallback(vec4) == -1)
+ if ( BaseMath_ReadCallback(vec1) == -1 ||
+ BaseMath_ReadCallback(vec2) == -1 ||
+ BaseMath_ReadCallback(vec3) == -1 ||
+ BaseMath_ReadCallback(vec4) == -1)
{
return NULL;
}
@@ -298,9 +298,9 @@ static PyObject *M_Geometry_normal(PyObject *UNUSED(self), PyObject* args)
return NULL;
}
- if ( BaseMath_ReadCallback(vec1) == -1 ||
- BaseMath_ReadCallback(vec2) == -1 ||
- BaseMath_ReadCallback(vec3) == -1)
+ if ( BaseMath_ReadCallback(vec1) == -1 ||
+ BaseMath_ReadCallback(vec2) == -1 ||
+ BaseMath_ReadCallback(vec3) == -1)
{
return NULL;
}
@@ -327,10 +327,10 @@ static PyObject *M_Geometry_normal(PyObject *UNUSED(self), PyObject* args)
return NULL;
}
- if ( BaseMath_ReadCallback(vec1) == -1 ||
- BaseMath_ReadCallback(vec2) == -1 ||
- BaseMath_ReadCallback(vec3) == -1 ||
- BaseMath_ReadCallback(vec4) == -1)
+ if ( BaseMath_ReadCallback(vec1) == -1 ||
+ BaseMath_ReadCallback(vec2) == -1 ||
+ BaseMath_ReadCallback(vec3) == -1 ||
+ BaseMath_ReadCallback(vec4) == -1)
{
return NULL;
}
@@ -374,9 +374,9 @@ static PyObject *M_Geometry_area_tri(PyObject *UNUSED(self), PyObject* args)
return NULL;
}
- if ( BaseMath_ReadCallback(vec1) == -1 ||
- BaseMath_ReadCallback(vec2) == -1 ||
- BaseMath_ReadCallback(vec3) == -1)
+ if ( BaseMath_ReadCallback(vec1) == -1 ||
+ BaseMath_ReadCallback(vec2) == -1 ||
+ BaseMath_ReadCallback(vec3) == -1)
{
return NULL;
}
@@ -424,10 +424,10 @@ static PyObject *M_Geometry_intersect_line_line_2d(PyObject *UNUSED(self), PyObj
return NULL;
}
- if ( BaseMath_ReadCallback(line_a1) == -1 ||
- BaseMath_ReadCallback(line_a2) == -1 ||
- BaseMath_ReadCallback(line_b1) == -1 ||
- BaseMath_ReadCallback(line_b2) == -1)
+ if ( BaseMath_ReadCallback(line_a1) == -1 ||
+ BaseMath_ReadCallback(line_a2) == -1 ||
+ BaseMath_ReadCallback(line_b1) == -1 ||
+ BaseMath_ReadCallback(line_b2) == -1)
{
return NULL;
}
@@ -474,10 +474,10 @@ static PyObject *M_Geometry_intersect_line_plane(PyObject *UNUSED(self), PyObjec
return NULL;
}
- if ( BaseMath_ReadCallback(line_a) == -1 ||
- BaseMath_ReadCallback(line_b) == -1 ||
- BaseMath_ReadCallback(plane_co) == -1 ||
- BaseMath_ReadCallback(plane_no) == -1)
+ if ( BaseMath_ReadCallback(line_a) == -1 ||
+ BaseMath_ReadCallback(line_b) == -1 ||
+ BaseMath_ReadCallback(plane_co) == -1 ||
+ BaseMath_ReadCallback(plane_no) == -1)
{
return NULL;
}
@@ -530,10 +530,10 @@ static PyObject *M_Geometry_intersect_plane_plane(PyObject *UNUSED(self), PyObje
return NULL;
}
- if ( BaseMath_ReadCallback(plane_a_co) == -1 ||
- BaseMath_ReadCallback(plane_a_no) == -1 ||
- BaseMath_ReadCallback(plane_b_co) == -1 ||
- BaseMath_ReadCallback(plane_b_no) == -1)
+ if ( BaseMath_ReadCallback(plane_a_co) == -1 ||
+ BaseMath_ReadCallback(plane_a_no) == -1 ||
+ BaseMath_ReadCallback(plane_b_co) == -1 ||
+ BaseMath_ReadCallback(plane_b_no) == -1)
{
return NULL;
}
@@ -592,9 +592,9 @@ static PyObject *M_Geometry_intersect_line_sphere(PyObject *UNUSED(self), PyObje
return NULL;
}
- if ( BaseMath_ReadCallback(line_a) == -1 ||
- BaseMath_ReadCallback(line_b) == -1 ||
- BaseMath_ReadCallback(sphere_co) == -1)
+ if ( BaseMath_ReadCallback(line_a) == -1 ||
+ BaseMath_ReadCallback(line_b) == -1 ||
+ BaseMath_ReadCallback(sphere_co) == -1)
{
return NULL;
}
@@ -612,7 +612,7 @@ static PyObject *M_Geometry_intersect_line_sphere(PyObject *UNUSED(self), PyObje
PyObject *ret= PyTuple_New(2);
- switch(isect_line_sphere_v3(line_a->vec, line_b->vec, sphere_co->vec, sphere_radius, isect_a, isect_b)) {
+ switch (isect_line_sphere_v3(line_a->vec, line_b->vec, sphere_co->vec, sphere_radius, isect_a, isect_b)) {
case 1:
if (!(!clip || (((lambda= line_point_factor_v3(isect_a, line_a->vec, line_b->vec)) >= 0.0f) && (lambda <= 1.0f)))) use_a= FALSE;
use_b= FALSE;
@@ -672,9 +672,9 @@ static PyObject *M_Geometry_intersect_line_sphere_2d(PyObject *UNUSED(self), PyO
return NULL;
}
- if ( BaseMath_ReadCallback(line_a) == -1 ||
- BaseMath_ReadCallback(line_b) == -1 ||
- BaseMath_ReadCallback(sphere_co) == -1)
+ if ( BaseMath_ReadCallback(line_a) == -1 ||
+ BaseMath_ReadCallback(line_b) == -1 ||
+ BaseMath_ReadCallback(sphere_co) == -1)
{
return NULL;
}
@@ -685,7 +685,7 @@ static PyObject *M_Geometry_intersect_line_sphere_2d(PyObject *UNUSED(self), PyO
PyObject *ret= PyTuple_New(2);
- switch(isect_line_sphere_v2(line_a->vec, line_b->vec, sphere_co->vec, sphere_radius, isect_a, isect_b)) {
+ switch (isect_line_sphere_v2(line_a->vec, line_b->vec, sphere_co->vec, sphere_radius, isect_a, isect_b)) {
case 1:
if (!(!clip || (((lambda= line_point_factor_v2(isect_a, line_a->vec, line_b->vec)) >= 0.0f) && (lambda <= 1.0f)))) use_a= FALSE;
use_b= FALSE;
@@ -737,9 +737,9 @@ static PyObject *M_Geometry_intersect_point_line(PyObject *UNUSED(self), PyObjec
return NULL;
}
- if ( BaseMath_ReadCallback(pt) == -1 ||
- BaseMath_ReadCallback(line_1) == -1 ||
- BaseMath_ReadCallback(line_2) == -1)
+ if ( BaseMath_ReadCallback(pt) == -1 ||
+ BaseMath_ReadCallback(line_1) == -1 ||
+ BaseMath_ReadCallback(line_2) == -1)
{
return NULL;
}
@@ -791,10 +791,10 @@ static PyObject *M_Geometry_intersect_point_tri_2d(PyObject *UNUSED(self), PyObj
return NULL;
}
- if ( BaseMath_ReadCallback(pt_vec) == -1 ||
- BaseMath_ReadCallback(tri_p1) == -1 ||
- BaseMath_ReadCallback(tri_p2) == -1 ||
- BaseMath_ReadCallback(tri_p3) == -1)
+ if ( BaseMath_ReadCallback(pt_vec) == -1 ||
+ BaseMath_ReadCallback(tri_p1) == -1 ||
+ BaseMath_ReadCallback(tri_p2) == -1 ||
+ BaseMath_ReadCallback(tri_p3) == -1)
{
return NULL;
}
@@ -805,7 +805,8 @@ static PyObject *M_Geometry_intersect_point_tri_2d(PyObject *UNUSED(self), PyObj
PyDoc_STRVAR(M_Geometry_intersect_point_quad_2d_doc,
".. function:: intersect_point_quad_2d(pt, quad_p1, quad_p2, quad_p3, quad_p4)\n"
"\n"
-" Takes 5 vectors (using only the x and y coordinates): one is the point and the next 4 define the quad, only the x and y are used from the vectors. Returns 1 if the point is within the quad, otherwise 0.\n"
+" Takes 5 vectors (using only the x and y coordinates): one is the point and the next 4 define the quad, \n"
+" only the x and y are used from the vectors. Returns 1 if the point is within the quad, otherwise 0.\n"
"\n"
" :arg pt: Point\n"
" :type pt: :class:`mathutils.Vector`\n"
@@ -833,11 +834,11 @@ static PyObject *M_Geometry_intersect_point_quad_2d(PyObject *UNUSED(self), PyOb
return NULL;
}
- if ( BaseMath_ReadCallback(pt_vec) == -1 ||
- BaseMath_ReadCallback(quad_p1) == -1 ||
- BaseMath_ReadCallback(quad_p2) == -1 ||
- BaseMath_ReadCallback(quad_p3) == -1 ||
- BaseMath_ReadCallback(quad_p4) == -1)
+ if ( BaseMath_ReadCallback(pt_vec) == -1 ||
+ BaseMath_ReadCallback(quad_p1) == -1 ||
+ BaseMath_ReadCallback(quad_p2) == -1 ||
+ BaseMath_ReadCallback(quad_p3) == -1 ||
+ BaseMath_ReadCallback(quad_p4) == -1)
{
return NULL;
}
@@ -871,9 +872,9 @@ static PyObject *M_Geometry_distance_point_to_plane(PyObject *UNUSED(self), PyOb
return NULL;
}
- if ( BaseMath_ReadCallback(pt) == -1 ||
- BaseMath_ReadCallback(plene_co) == -1 ||
- BaseMath_ReadCallback(plane_no) == -1)
+ if ( BaseMath_ReadCallback(pt) == -1 ||
+ BaseMath_ReadCallback(plene_co) == -1 ||
+ BaseMath_ReadCallback(plane_no) == -1)
{
return NULL;
}
@@ -992,10 +993,10 @@ static PyObject *M_Geometry_interpolate_bezier(PyObject *UNUSED(self), PyObject*
return NULL;
}
- if ( BaseMath_ReadCallback(vec_k1) == -1 ||
- BaseMath_ReadCallback(vec_h1) == -1 ||
- BaseMath_ReadCallback(vec_k2) == -1 ||
- BaseMath_ReadCallback(vec_h2) == -1)
+ if ( BaseMath_ReadCallback(vec_k1) == -1 ||
+ BaseMath_ReadCallback(vec_h1) == -1 ||
+ BaseMath_ReadCallback(vec_k2) == -1 ||
+ BaseMath_ReadCallback(vec_h2) == -1)
{
return NULL;
}
diff --git a/source/blender/python/mathutils/mathutils_noise.c b/source/blender/python/mathutils/mathutils_noise.c
index 09337d9a23b..c0e8ac24baa 100644
--- a/source/blender/python/mathutils/mathutils_noise.c
+++ b/source/blender/python/mathutils/mathutils_noise.c
@@ -201,7 +201,7 @@ static void rand_vn(float *array_tar, const int size)
{
float *array_pt= array_tar + (size-1);
int i= size;
- while(i--) { *(array_pt--) = 2.0f * frand() - 1.0f; }
+ while (i--) { *(array_pt--) = 2.0f * frand() - 1.0f; }
}
/* Fills an array of length 3 with noise values */
diff --git a/source/blender/quicktime/apple/qtkit_export.m b/source/blender/quicktime/apple/qtkit_export.m
index c2e364b6080..75c7d890ddd 100644
--- a/source/blender/quicktime/apple/qtkit_export.m
+++ b/source/blender/quicktime/apple/qtkit_export.m
@@ -658,7 +658,7 @@ int append_qt(struct RenderData *rd, int frame, int *pixels, int rectx, int rect
}
else {
//Error getting audio packets
- BKE_reportf(reports, RPT_ERROR, "Unable to get further audio packets from frame %i, error = 0x%x",qtexport->audioTotalExportedFrames,err);
+ BKE_reportf(reports, RPT_ERROR, "Unable to get further audio packets from frame %i, error = 0x%x",(int)qtexport->audioTotalExportedFrames,err);
break;
}
@@ -779,7 +779,7 @@ void free_qtcomponentdata(void) {
void quicktime_verify_image_type(RenderData *rd)
{
- if (rd->imtype == R_IMF_IMTYPE_QUICKTIME) {
+ if (rd->im_format.imtype == R_IMF_IMTYPE_QUICKTIME) {
if ((rd->qtcodecsettings.codecType<= 0) ||
(rd->qtcodecsettings.codecSpatialQuality <0) ||
(rd->qtcodecsettings.codecSpatialQuality > 100)) {
diff --git a/source/blender/quicktime/apple/quicktime_export.c b/source/blender/quicktime/apple/quicktime_export.c
index 18c1ed23f8a..937e1b6be46 100644
--- a/source/blender/quicktime/apple/quicktime_export.c
+++ b/source/blender/quicktime/apple/quicktime_export.c
@@ -689,7 +689,7 @@ static void check_renderbutton_framerate(RenderData *rd, ReportList *reports)
void quicktime_verify_image_type(RenderData *rd)
{
- if (rd->imtype == R_IMF_IMTYPE_QUICKTIME) {
+ if (rd->im_format.imtype == R_IMF_IMTYPE_QUICKTIME) {
if ((rd->qtcodecsettings.codecType== 0) ||
(rd->qtcodecsettings.codecSpatialQuality <0) ||
(rd->qtcodecsettings.codecSpatialQuality > 100)) {
diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c
index d396522b8d0..78f2fe6171b 100644
--- a/source/blender/render/intern/source/convertblender.c
+++ b/source/blender/render/intern/source/convertblender.c
@@ -1690,14 +1690,14 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
}
/* 2.5 setup matrices */
- mul_m4_m4m4(mat, ob->obmat, re->viewmat);
+ mult_m4_m4m4(mat, re->viewmat, ob->obmat);
invert_m4_m4(ob->imat, mat); /* need to be that way, for imat texture */
copy_m3_m4(nmat, ob->imat);
transpose_m3(nmat);
if(psys->flag & PSYS_USE_IMAT) {
/* psys->imat is the original emitter's inverse matrix, ob->obmat is the duplicated object's matrix */
- mul_m4_m4m4(duplimat, psys->imat, ob->obmat);
+ mult_m4_m4m4(duplimat, ob->obmat, psys->imat);
use_duplimat = 1;
}
@@ -2134,7 +2134,7 @@ static void make_render_halos(Render *re, ObjectRen *obr, Mesh *UNUSED(me), int
float vec[3], hasize, mat[4][4], imat[3][3];
int a, ok, seed= ma->seed1;
- mul_m4_m4m4(mat, ob->obmat, re->viewmat);
+ mult_m4_m4m4(mat, re->viewmat, ob->obmat);
copy_m3_m4(imat, ob->imat);
re->flag |= R_HALO;
@@ -2429,7 +2429,7 @@ static void init_render_mball(Render *re, ObjectRen *obr)
if (ob!=find_basis_mball(re->scene, ob))
return;
- mul_m4_m4m4(mat, ob->obmat, re->viewmat);
+ mult_m4_m4m4(mat, re->viewmat, ob->obmat);
invert_m4_m4(ob->imat, mat);
copy_m3_m4(imat, ob->imat);
@@ -2802,7 +2802,7 @@ static void init_render_surf(Render *re, ObjectRen *obr, int timeoffset)
nu= cu->nurb.first;
if(nu==0) return;
- mul_m4_m4m4(mat, ob->obmat, re->viewmat);
+ mult_m4_m4m4(mat, re->viewmat, ob->obmat);
invert_m4_m4(ob->imat, mat);
/* material array */
@@ -2871,7 +2871,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset)
dl= disp.first;
if(dl==NULL) return;
- mul_m4_m4m4(mat, ob->obmat, re->viewmat);
+ mult_m4_m4m4(mat, re->viewmat, ob->obmat);
invert_m4_m4(ob->imat, mat);
/* material array */
@@ -3256,7 +3256,7 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset)
me= ob->data;
- mul_m4_m4m4(mat, ob->obmat, re->viewmat);
+ mult_m4_m4m4(mat, re->viewmat, ob->obmat);
invert_m4_m4(ob->imat, mat);
copy_m3_m4(imat, ob->imat);
negative_scale= is_negative_m4(mat);
@@ -3599,7 +3599,7 @@ static void initshadowbuf(Render *re, LampRen *lar, float mat[][4])
/* matrix: combination of inverse view and lampmat */
/* calculate again: the ortho-render has no correct viewinv */
invert_m4_m4(viewinv, re->viewmat);
- mul_m4_m4m4(shb->viewmat, viewinv, shb->winmat);
+ mult_m4_m4m4(shb->viewmat, shb->winmat, viewinv);
/* projection */
shb->d= lar->clipsta;
@@ -3677,7 +3677,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob)
BLI_addtail(&re->lampren, lar);
go->lampren= lar;
- mul_m4_m4m4(mat, ob->obmat, re->viewmat);
+ mult_m4_m4m4(mat, re->viewmat, ob->obmat);
invert_m4_m4(ob->imat, mat);
copy_m3_m4(lar->mat, mat);
@@ -4372,7 +4372,7 @@ static void find_dupli_instances(Render *re, ObjectRen *obr)
float imat[4][4], obmat[4][4], obimat[4][4], nmat[3][3];
int first = 1;
- mul_m4_m4m4(obmat, obr->obmat, re->viewmat);
+ mult_m4_m4m4(obmat, re->viewmat, obr->obmat);
invert_m4_m4(imat, obmat);
/* for objects instanced by dupliverts/faces/particles, we go over the
@@ -4385,7 +4385,7 @@ static void find_dupli_instances(Render *re, ObjectRen *obr)
/* compute difference between object matrix and
* object matrix with dupli transform, in viewspace */
copy_m4_m4(obimat, obi->mat);
- mul_m4_m4m4(obi->mat, imat, obimat);
+ mult_m4_m4m4(obi->mat, obimat, imat);
copy_m3_m4(nmat, obi->mat);
invert_m3_m3(obi->nmat, nmat);
@@ -4407,7 +4407,7 @@ static void assign_dupligroup_dupli(Render *re, ObjectInstanceRen *obi, ObjectRe
{
float imat[4][4], obmat[4][4], obimat[4][4], nmat[3][3];
- mul_m4_m4m4(obmat, obr->obmat, re->viewmat);
+ mult_m4_m4m4(obmat, re->viewmat, obr->obmat);
invert_m4_m4(imat, obmat);
obi->obr= obr;
@@ -4415,7 +4415,7 @@ static void assign_dupligroup_dupli(Render *re, ObjectInstanceRen *obi, ObjectRe
/* compute difference between object matrix and
* object matrix with dupli transform, in viewspace */
copy_m4_m4(obimat, obi->mat);
- mul_m4_m4m4(obi->mat, imat, obimat);
+ mult_m4_m4m4(obi->mat, obimat, imat);
copy_m3_m4(nmat, obi->mat);
invert_m3_m3(obi->nmat, nmat);
@@ -4612,7 +4612,7 @@ static void init_render_object(Render *re, Object *ob, Object *par, DupliObject
else if(render_object_type(ob->type))
add_render_object(re, ob, par, dob, timeoffset);
else {
- mul_m4_m4m4(mat, ob->obmat, re->viewmat);
+ mult_m4_m4m4(mat, re->viewmat, ob->obmat);
invert_m4_m4(ob->imat, mat);
}
@@ -4858,7 +4858,7 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp
* See bug: [#28744] - campbell */
for(ob= re->main->object.first; ob; ob= ob->id.next) {
/* imat objects has to be done here, since displace can have texture using Object map-input */
- mul_m4_m4m4(mat, ob->obmat, re->viewmat);
+ mult_m4_m4m4(mat, re->viewmat, ob->obmat);
invert_m4_m4(ob->imat_ren, mat);
copy_m4_m4(ob->imat, ob->imat_ren);
/* each object should only be rendered once */
@@ -4930,7 +4930,7 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp
* this is a duplivert/face/particle, or it is a non-animated object in
* a dupligroup that has already been created before */
if(dob->type != OB_DUPLIGROUP || (obr=find_dupligroup_dupli(re, obd, 0))) {
- mul_m4_m4m4(mat, dob->mat, re->viewmat);
+ mult_m4_m4m4(mat, re->viewmat, dob->mat);
obi= RE_addRenderInstance(re, NULL, obd, ob, dob->index, 0, mat, obd->lay);
/* fill in instance variables for texturing */
@@ -4957,7 +4957,7 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp
for(psys=obd->particlesystem.first; psys; psys=psys->next) {
if(dob->type != OB_DUPLIGROUP || (obr=find_dupligroup_dupli(re, obd, psysindex))) {
if(obi == NULL)
- mul_m4_m4m4(mat, dob->mat, re->viewmat);
+ mult_m4_m4m4(mat, re->viewmat, dob->mat);
obi= RE_addRenderInstance(re, NULL, obd, ob, dob->index, psysindex++, mat, obd->lay);
set_dupli_tex_mat(re, obi, dob);
@@ -5312,7 +5312,7 @@ static float *calculate_strandsurface_speedvectors(Render *re, ObjectInstanceRen
int a;
if(obi->flag & R_TRANSFORMED)
- mul_m4_m4m4(winmat, obi->mat, re->winmat);
+ mult_m4_m4m4(winmat, re->winmat, obi->mat);
else
copy_m4_m4(winmat, re->winmat);
@@ -5349,7 +5349,7 @@ static void calculate_speedvectors(Render *re, ObjectInstanceRen *obi, float *ve
int a, *face, *index;
if(obi->flag & R_TRANSFORMED)
- mul_m4_m4m4(winmat, obi->mat, re->winmat);
+ mult_m4_m4m4(winmat, re->winmat, obi->mat);
else
copy_m4_m4(winmat, re->winmat);
@@ -5443,7 +5443,7 @@ static int load_fluidsimspeedvectors(Render *re, ObjectInstanceRen *obi, float *
velarray = fss->meshVelocities;
if(obi->flag & R_TRANSFORMED)
- mul_m4_m4m4(winmat, obi->mat, re->winmat);
+ mult_m4_m4m4(winmat, re->winmat, obi->mat);
else
copy_m4_m4(winmat, re->winmat);
@@ -5533,7 +5533,7 @@ static void copy_dbase_object_vectors(Render *re, ListBase *lb)
vec= obilb->vectors= MEM_mallocN(2*sizeof(float)*totvector, "vector array");
if(obi->flag & R_TRANSFORMED)
- mul_m4_m4m4(winmat, obi->mat, re->winmat);
+ mult_m4_m4m4(winmat, re->winmat, obi->mat);
else
copy_m4_m4(winmat, re->winmat);
@@ -5861,7 +5861,7 @@ void RE_make_sticky(Scene *scene, View3D *v3d)
CD_CALLOC, NULL, me->totvert);
where_is_object(scene, ob);
- mul_m4_m4m4(mat, ob->obmat, re->viewmat);
+ mult_m4_m4m4(mat, re->viewmat, ob->obmat);
ms= me->msticky;
for(a=0; a<me->totvert; a++, ms++, mvert++) {
diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c
index 3512ffa865b..a45bb63ff06 100644
--- a/source/blender/render/intern/source/envmap.c
+++ b/source/blender/render/intern/source/envmap.c
@@ -263,7 +263,7 @@ static void env_rotate_scene(Render *re, float mat[][4], int mode)
/* append or set matrix depending on dupli */
if(obi->flag & R_DUPLI_TRANSFORMED) {
copy_m4_m4(tmpmat, obi->mat);
- mul_m4_m4m4(obi->mat, tmpmat, tmat);
+ mult_m4_m4m4(obi->mat, tmat, tmpmat);
}
else if(mode==1)
copy_m4_m4(obi->mat, tmat);
@@ -312,10 +312,10 @@ static void env_rotate_scene(Render *re, float mat[][4], int mode)
if(lar->shb) {
if(mode==1) {
invert_m4_m4(pmat, mat);
- mul_m4_m4m4(smat, pmat, lar->shb->viewmat);
- mul_m4_m4m4(lar->shb->persmat, smat, lar->shb->winmat);
+ mult_m4_m4m4(smat, lar->shb->viewmat, pmat);
+ mult_m4_m4m4(lar->shb->persmat, lar->shb->winmat, smat);
}
- else mul_m4_m4m4(lar->shb->persmat, lar->shb->viewmat, lar->shb->winmat);
+ else mult_m4_m4m4(lar->shb->persmat, lar->shb->winmat, lar->shb->viewmat);
}
}
@@ -393,7 +393,7 @@ static void env_set_imats(Render *re)
base= re->scene->base.first;
while(base) {
- mul_m4_m4m4(mat, base->object->obmat, re->viewmat);
+ mult_m4_m4m4(mat, re->viewmat, base->object->obmat);
invert_m4_m4(base->object->imat, mat);
base= base->next;
@@ -422,7 +422,7 @@ static void render_envmap(Render *re, EnvMap *env)
normalize_m4(orthmat);
/* need imat later for texture imat */
- mul_m4_m4m4(mat, orthmat, re->viewmat);
+ mult_m4_m4m4(mat, re->viewmat, orthmat);
invert_m4_m4(tmat, mat);
copy_m3_m4(env->obimat, tmat);
@@ -441,7 +441,7 @@ static void render_envmap(Render *re, EnvMap *env)
copy_m4_m4(envre->viewinv, tmat);
/* we have to correct for the already rotated vertexcoords */
- mul_m4_m4m4(tmat, oldviewinv, envre->viewmat);
+ mult_m4_m4m4(tmat, envre->viewmat, oldviewinv);
invert_m4_m4(env->imat, tmat);
env_rotate_scene(envre, tmat, 1);
@@ -528,7 +528,7 @@ void make_envmaps(Render *re)
normalize_m4(orthmat);
/* need imat later for texture imat */
- mul_m4_m4m4(mat, orthmat, re->viewmat);
+ mult_m4_m4m4(mat, re->viewmat, orthmat);
invert_m4_m4(tmat, mat);
copy_m3_m4(env->obimat, tmat);
}
diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c
index 5b81ea85914..ae3748755ff 100644
--- a/source/blender/render/intern/source/pointdensity.c
+++ b/source/blender/render/intern/source/pointdensity.c
@@ -116,7 +116,7 @@ static void pointdensity_cache_psys(Render *re, PointDensity *pd, Object *ob, Pa
/* init everything */
if (!psys || !ob || !pd) return;
- mul_m4_m4m4(obview, re->viewinv, ob->obmat);
+ mult_m4_m4m4(obview, ob->obmat, re->viewinv);
/* Just to create a valid rendering context for particles */
psys_render_set(ob, psys, re->viewmat, re->winmat, re->winx, re->winy, 0);
diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c
index 07e2cc3a701..883684c3483 100644
--- a/source/blender/render/intern/source/render_texture.c
+++ b/source/blender/render/intern/source/render_texture.c
@@ -1968,8 +1968,8 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T
if(shi->obr->ob->derivedFinal)
{
auto_bump = shi->obr->ob->derivedFinal->auto_bump_scale;
- auto_bump /= sqrtf((float) (dimx*dimy));
}
+ auto_bump /= sqrtf((float) (dimx*dimy));
// this variant using a derivative map is described here
// http://mmikkelsen3d.blogspot.com/2011/07/derivative-maps.html
@@ -2087,7 +2087,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T
if( mtex->texflag & MTEX_BUMP_OBJECTSPACE ) {
// TODO: these calculations happen for every pixel!
// -> move to shi->obi
- mul_m4_m4m4(tmp, shi->obr->ob->obmat, R.viewmat);
+ mult_m4_m4m4(tmp, R.viewmat, shi->obr->ob->obmat);
copy_m3_m4(obj2view, tmp); // use only upper left 3x3 matrix
invert_m3_m3(view2obj, obj2view);
diff --git a/source/blender/render/intern/source/shadbuf.c b/source/blender/render/intern/source/shadbuf.c
index 8cb7009f756..c14a768d1ce 100644
--- a/source/blender/render/intern/source/shadbuf.c
+++ b/source/blender/render/intern/source/shadbuf.c
@@ -640,7 +640,7 @@ static void shadowbuf_autoclip(Render *re, LampRen *lar)
obr= obi->obr;
if(obi->flag & R_TRANSFORMED)
- mul_m4_m4m4(obviewmat, obi->mat, viewmat);
+ mult_m4_m4m4(obviewmat, viewmat, obi->mat);
else
copy_m4_m4(obviewmat, viewmat);
@@ -777,7 +777,7 @@ void makeshadowbuf(Render *re, LampRen *lar)
wsize= shb->pixsize*(shb->size/2.0f);
perspective_m4( shb->winmat,-wsize, wsize, -wsize, wsize, shb->d, shb->clipend);
- mul_m4_m4m4(shb->persmat, shb->viewmat, shb->winmat);
+ mult_m4_m4m4(shb->persmat, shb->winmat, shb->viewmat);
if(ELEM3(lar->buftype, LA_SHADBUF_REGULAR, LA_SHADBUF_HALFWAY, LA_SHADBUF_DEEP)) {
shb->totbuf= lar->buffers;
@@ -1987,7 +1987,7 @@ static void isb_bsp_fillfaces(Render *re, LampRen *lar, ISBBranch *root)
obr= obi->obr;
if(obi->flag & R_TRANSFORMED)
- mul_m4_m4m4(winmat, obi->mat, shb->persmat);
+ mult_m4_m4m4(winmat, shb->persmat, obi->mat);
else
copy_m4_m4(winmat, shb->persmat);
diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c
index dd026740c33..580a09d5050 100644
--- a/source/blender/render/intern/source/shadeinput.c
+++ b/source/blender/render/intern/source/shadeinput.c
@@ -1268,7 +1268,7 @@ void shade_input_set_shade_texco(ShadeInput *shi)
zbuf_make_winmat(&R, winmat);
if(shi->obi->flag & R_TRANSFORMED)
- mul_m4_m4m4(obwinmat, obi->mat, winmat);
+ mult_m4_m4m4(obwinmat, winmat, obi->mat);
else
copy_m4_m4(obwinmat, winmat);
diff --git a/source/blender/render/intern/source/strand.c b/source/blender/render/intern/source/strand.c
index 633c7ca1847..4fc3bb7c5da 100644
--- a/source/blender/render/intern/source/strand.c
+++ b/source/blender/render/intern/source/strand.c
@@ -848,7 +848,7 @@ int zbuffer_strands_abuf(Render *re, RenderPart *pa, APixstrand *apixbuf, ListBa
/* compute matrix and try clipping whole object */
if(obi->flag & R_TRANSFORMED)
- mul_m4_m4m4(obwinmat, obi->mat, winmat);
+ mult_m4_m4m4(obwinmat, winmat, obi->mat);
else
copy_m4_m4(obwinmat, winmat);
diff --git a/source/blender/render/intern/source/volumetric.c b/source/blender/render/intern/source/volumetric.c
index 4b1894236fc..a46ef3888d8 100644
--- a/source/blender/render/intern/source/volumetric.c
+++ b/source/blender/render/intern/source/volumetric.c
@@ -245,7 +245,7 @@ static float metadensity(Object* ob, const float co[3])
/* transform co to meta-element */
float tco[3] = {co[0], co[1], co[2]};
- mul_m4_m4m4(mat, ob->obmat, R.viewmat);
+ mult_m4_m4m4(mat, R.viewmat, ob->obmat);
invert_m4_m4(imat, mat);
mul_m4_v3(imat, tco);
diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c
index 8b383992e65..8efe23c38f9 100644
--- a/source/blender/render/intern/source/zbuf.c
+++ b/source/blender/render/intern/source/zbuf.c
@@ -1819,7 +1819,7 @@ void zbuf_make_winmat(Render *re, float winmat[][4])
panomat[2][0]= -re->panosi;
panomat[2][2]= re->panoco;
- mul_m4_m4m4(winmat, panomat, re->winmat);
+ mult_m4_m4m4(winmat, re->winmat, panomat);
}
else
copy_m4_m4(winmat, re->winmat);
@@ -2138,7 +2138,7 @@ void zbuffer_solid(RenderPart *pa, RenderLayer *rl, void(*fillfunc)(RenderPart*,
continue;
if(obi->flag & R_TRANSFORMED)
- mul_m4_m4m4(obwinmat, obi->mat, winmat);
+ mult_m4_m4m4(obwinmat, winmat, obi->mat);
else
copy_m4_m4(obwinmat, winmat);
@@ -2318,7 +2318,7 @@ void zbuffer_shadow(Render *re, float winmat[][4], LampRen *lar, int *rectz, int
continue;
if(obi->flag & R_TRANSFORMED)
- mul_m4_m4m4(obwinmat, obi->mat, winmat);
+ mult_m4_m4m4(obwinmat, winmat, obi->mat);
else
copy_m4_m4(obwinmat, winmat);
@@ -2557,7 +2557,7 @@ void zbuffer_sss(RenderPart *pa, unsigned int lay, void *handle, void (*func)(vo
continue;
if(obi->flag & R_TRANSFORMED)
- mul_m4_m4m4(obwinmat, obi->mat, winmat);
+ mult_m4_m4m4(obwinmat, winmat, obi->mat);
else
copy_m4_m4(obwinmat, winmat);
@@ -3300,7 +3300,7 @@ static int zbuffer_abuf(Render *re, RenderPart *pa, APixstr *APixbuf, ListBase *
continue;
if(obi->flag & R_TRANSFORMED)
- mul_m4_m4m4(obwinmat, obi->mat, winmat);
+ mult_m4_m4m4(obwinmat, winmat, obi->mat);
else
copy_m4_m4(obwinmat, winmat);
diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c
index f03680852ea..4fe11044d30 100644
--- a/source/blender/windowmanager/intern/wm_draw.c
+++ b/source/blender/windowmanager/intern/wm_draw.c
@@ -43,6 +43,7 @@
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
+#include "BLI_math_base.h"
#include "BKE_context.h"
#include "BKE_global.h"
@@ -355,36 +356,12 @@ typedef struct wmDrawTriple {
GLenum target;
} wmDrawTriple;
-static int is_pow2(int n)
-{
- return ((n)&(n-1))==0;
-}
-
-static int smaller_pow2(int n)
-{
- while (!is_pow2(n))
- n= n&(n-1);
-
- return n;
-}
-
-static int larger_pow2(int n)
-{
- if (is_pow2(n))
- return n;
-
- while(!is_pow2(n))
- n= n&(n-1);
-
- return n*2;
-}
-
static void split_width(int x, int n, int *splitx, int *nx)
{
int a, newnx, waste;
/* if already power of two just use it */
- if(is_pow2(x)) {
+ if(is_power_of_2_i(x)) {
splitx[0]= x;
(*nx)++;
return;
@@ -392,12 +369,12 @@ static void split_width(int x, int n, int *splitx, int *nx)
if(n == 1) {
/* last part, we have to go larger */
- splitx[0]= larger_pow2(x);
+ splitx[0]= power_of_2_max_i(x);
(*nx)++;
}
else {
/* two or more parts to go, use smaller part */
- splitx[0]= smaller_pow2(x);
+ splitx[0]= power_of_2_min_i(x);
newnx= ++(*nx);
split_width(x-splitx[0], n-1, splitx+1, &newnx);
@@ -406,8 +383,8 @@ static void split_width(int x, int n, int *splitx, int *nx)
/* if we waste more space or use the same amount,
* revert deeper splits and just use larger */
- if(waste >= larger_pow2(x)) {
- splitx[0]= larger_pow2(x);
+ if(waste >= power_of_2_max_i(x)) {
+ splitx[0]= power_of_2_max_i(x);
memset(splitx+1, 0, sizeof(int)*(n-1));
}
else
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index 7026323bf97..2695f3d680d 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -176,7 +176,6 @@ void WM_init(bContext *C, int argc, const char **argv)
GPU_extensions_init();
GPU_set_mipmap(!(U.gameflags & USER_DISABLE_MIPMAP));
GPU_set_anisotropic(U.anisotropic_filter);
- GPU_code_generate_glsl_lib();
UI_init();
}
diff --git a/source/gameengine/Converter/BL_ArmatureChannel.cpp b/source/gameengine/Converter/BL_ArmatureChannel.cpp
index c463068d52c..80a9db4db83 100644
--- a/source/gameengine/Converter/BL_ArmatureChannel.cpp
+++ b/source/gameengine/Converter/BL_ArmatureChannel.cpp
@@ -215,7 +215,7 @@ PyObject* BL_ArmatureChannel::py_attr_get_joint_rotation(void *self_v, const str
normalize_m3(pose_mat);
if (pchan->parent) {
// bone has a parent, compute the rest pose of the bone taking actual pose of parent
- mul_m3_m3m4(rest_mat, pchan->bone->bone_mat, pchan->parent->pose_mat);
+ mult_m3_m3m4(rest_mat, pchan->parent->pose_mat, pchan->bone->bone_mat);
normalize_m3(rest_mat);
} else {
// otherwise, the bone matrix in armature space is the rest pose
diff --git a/source/gameengine/Ketsji/BL_Texture.cpp b/source/gameengine/Ketsji/BL_Texture.cpp
index a306e059442..6c57776cb60 100644
--- a/source/gameengine/Ketsji/BL_Texture.cpp
+++ b/source/gameengine/Ketsji/BL_Texture.cpp
@@ -38,11 +38,11 @@ extern "C" {
}
// (n&(n-1)) zeros the least significant bit of n
-static int is_pow2(int num) {
+static int is_power_of_2_i(int num) {
return ((num)&(num-1))==0;
}
-static int smaller_pow2(int num) {
- while (!is_pow2(num))
+static int power_of_2_min_i(int num) {
+ while (!is_power_of_2_i(num))
num= num&(num-1);
return num;
}
@@ -159,7 +159,7 @@ bool BL_Texture::InitFromImage(int unit, Image *img, bool mipmap)
void BL_Texture::InitGLTex(unsigned int *pix,int x,int y,bool mipmap)
{
- if (!is_pow2(x) || !is_pow2(y) ) {
+ if (!is_power_of_2_i(x) || !is_power_of_2_i(y) ) {
InitNonPow2Tex(pix, x,y,mipmap);
return;
}
@@ -184,8 +184,8 @@ void BL_Texture::InitGLTex(unsigned int *pix,int x,int y,bool mipmap)
void BL_Texture::InitNonPow2Tex(unsigned int *pix,int x,int y,bool mipmap)
{
- int nx= smaller_pow2(x);
- int ny= smaller_pow2(y);
+ int nx= power_of_2_min_i(x);
+ int ny= power_of_2_min_i(y);
unsigned int *newPixels = (unsigned int *)malloc(nx*ny*sizeof(unsigned int));
@@ -274,7 +274,7 @@ bool BL_Texture::InitCubeMap(int unit, EnvMap *cubemap)
my_envmap_split_ima(cubemap, ibuf);
- if (!is_pow2(cubemap->cube[0]->x) || !is_pow2(cubemap->cube[0]->y))
+ if (!is_power_of_2_i(cubemap->cube[0]->x) || !is_power_of_2_i(cubemap->cube[0]->y))
{
spit("invalid envmap size please render with CubeRes @ power of two");
@@ -610,8 +610,8 @@ void BL_Texture::setTexEnv(BL_Material *mat, bool modulate)
int BL_Texture::GetPow2(int n)
{
- if(!is_pow2(n))
- n = smaller_pow2(n);
+ if(!is_power_of_2_i(n))
+ n = power_of_2_min_i(n);
return n;
}
diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp
index d9822d131eb..29871c2b3cd 100644
--- a/source/gameengine/Ketsji/KX_PythonInit.cpp
+++ b/source/gameengine/Ketsji/KX_PythonInit.cpp
@@ -1950,7 +1950,15 @@ void setupGamePython(KX_KetsjiEngine* ketsjiengine, KX_Scene* startscene, Main *
initVideoTexture();
/* could be done a lot more nicely, but for now a quick way to get bge.* working */
- PyRun_SimpleString("sys = __import__('sys');mod = sys.modules['bge'] = type(sys)('bge');mod.__dict__.update({'logic':__import__('GameLogic'), 'render':__import__('Rasterizer'), 'events':__import__('GameKeys'), 'constraints':__import__('PhysicsConstraints'), 'types':__import__('GameTypes'), 'texture':__import__('VideoTexture')});");
+ PyRun_SimpleString("sys = __import__('sys');"
+ "mod = sys.modules['bge'] = type(sys)('bge');"
+ "mod.__dict__.update({'logic':__import__('GameLogic'), "
+ "'render':__import__('Rasterizer'), "
+ "'events':__import__('GameKeys'), "
+ "'constraints':__import__('PhysicsConstraints'), "
+ "'types':__import__('GameTypes'), "
+ "'texture':__import__('VideoTexture')});"
+ );
}
static struct PyModuleDef Rasterizer_module_def = {
diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp
index 4eadf8e3e66..30344ce3a10 100644
--- a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp
+++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp
@@ -431,6 +431,8 @@ void RAS_2DFilterManager::RenderFilters(RAS_ICanvas* canvas)
glViewport(0,0, texturewidth, textureheight);
glDisable(GL_DEPTH_TEST);
+ // in case the previous material was wire
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
// if the last rendered face had alpha add it would messes with the color of the plane we apply 2DFilter to
glDisable(GL_BLEND);
glPushMatrix(); //GL_MODELVIEW