Merge various small changes from render branch:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Thu, 15 Apr 2010 10:28:32 +0000 (10:28 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Thu, 15 Apr 2010 10:28:32 +0000 (10:28 +0000)
* Division by zero fix for TNT SVD code.
* Sound fix, in case ffmpeg decode fails, don't use the samples.
* Fix for incorrect bounds of transformed objects in new raytracing code.
* Gave memory arena's a name used for allocations for easier memory
  usage debugging.
* Dupligroup no_draw option was using layers but not restrict view/render
  setting. (not a bugfix exactly but would do display list context switching
  while drawing for no reason).
* Fix objects instanced on hair particles not giving consistent results
  when the object is transformed.
* New math functions: madd_v4_v4fl, len_squared_v3v3, interp_v4_v4v4v4,
  mul_v4_m4v4, SH and form factor functions, box_minmax_bounds_m4.
* mul_m4_m4m4 and mul_m3_m3m3 now accept the same pointers for multiple
  arguments.
* endjob callback for WM jobs system.
* Geometry node uv/color layer now has search list/autocomplete.
* Various small buildsystem tweaks, not strictly needed yet in trunk.

67 files changed:
intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp
intern/iksolver/intern/TNT/svd.h
source/blender/blenkernel/BKE_group.h
source/blender/blenkernel/intern/BME_tools.c
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/anim.c
source/blender/blenkernel/intern/depsgraph.c
source/blender/blenkernel/intern/image.c
source/blender/blenkernel/intern/particle.c
source/blender/blenkernel/intern/subsurf_ccg.c
source/blender/blenlib/BLI_kdopbvh.h
source/blender/blenlib/BLI_math.h
source/blender/blenlib/BLI_math_geom.h
source/blender/blenlib/BLI_math_matrix.h
source/blender/blenlib/BLI_math_vector.h
source/blender/blenlib/BLI_memarena.h
source/blender/blenlib/BLI_rand.h
source/blender/blenlib/BLI_threads.h
source/blender/blenlib/intern/BLI_heap.c
source/blender/blenlib/intern/BLI_memarena.c
source/blender/blenlib/intern/math_geom.c
source/blender/blenlib/intern/math_geom_inline.c [new file with mode: 0644]
source/blender/blenlib/intern/math_matrix.c
source/blender/blenlib/intern/math_vector.c
source/blender/blenlib/intern/math_vector_inline.c
source/blender/blenlib/intern/threads.c
source/blender/editors/armature/meshlaplacian.c
source/blender/editors/interface/interface_icons.c
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/object/object_bake.c
source/blender/editors/physics/physics_fluid.c
source/blender/editors/render/render_internal.c
source/blender/editors/render/render_preview.c
source/blender/editors/screen/screendump.c
source/blender/editors/sculpt_paint/paint_image.c
source/blender/editors/space_buttons/space_buttons.c
source/blender/editors/space_file/filelist.c
source/blender/editors/space_node/drawnode.c
source/blender/editors/space_node/node_edit.c
source/blender/editors/space_outliner/outliner.c
source/blender/editors/space_view3d/SConscript
source/blender/editors/uvedit/uvedit_draw.c
source/blender/editors/uvedit/uvedit_parametrizer.c
source/blender/gpu/CMakeLists.txt
source/blender/imbuf/intern/allocimbuf.c
source/blender/makesrna/RNA_types.h
source/blender/makesrna/intern/makesrna.c
source/blender/makesrna/intern/rna_object.c
source/blender/makesrna/intern/rna_object_force.c
source/blender/makesrna/intern/rna_scene.c
source/blender/modifiers/SConscript
source/blender/modifiers/intern/MOD_edgesplit.c
source/blender/render/intern/raytrace/Makefile
source/blender/render/intern/raytrace/rayobject.cpp
source/blender/render/intern/raytrace/rayobject_qbvh.cpp
source/blender/render/intern/raytrace/rayobject_svbvh.cpp
source/blender/render/intern/raytrace/rayobject_vbvh.cpp
source/blender/render/intern/source/Makefile
source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/occlusion.c
source/blender/render/intern/source/shadbuf.c
source/blender/render/intern/source/sss.c
source/blender/render/intern/source/strand.c
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/intern/wm_jobs.c
source/creator/CMakeLists.txt
source/creator/SConscript

index 027ac015eb5ac50369c53eb069e2727e0698a9f9..313ea52e892a284a8590fbf33efc5a78b3e80b0e 100644 (file)
@@ -67,12 +67,12 @@ int AUD_FFMPEGReader::decode(AVPacket* packet, AUD_Buffer* buffer)
                        audio_pkg_data,
                        audio_pkg_size);
 
-               buf_pos += data_size;
-
                // read error, next packet!
                if(read_length < 0)
                        break;
 
+               buf_pos += data_size;
+
                // move packet parameters
                audio_pkg_data += read_length;
                audio_pkg_size -= read_length;
index 9ca51fa265092cf3c78124aca7e9195789881e17..9ae289474a962bd225298df9b690bd82d29076ea 100644 (file)
@@ -349,8 +349,9 @@ void SVD(MaTRiX &A, MaTRiX &U, VecToR &s, MaTRiX &V, VecToR &work1, VecToR &work
 
                                for (j = k; j < p-1; j++) {
                                        typename MaTRiX::value_type t = hypot(f,g);
-                                       typename MaTRiX::value_type cs = f/t;
-                                       typename MaTRiX::value_type sn = g/t;
+                                       /* division by zero checks added to avoid NaN (brecht) */
+                                       typename MaTRiX::value_type cs = (t == 0.0f)? 0.0f: f/t;
+                                       typename MaTRiX::value_type sn = (t == 0.0f)? 0.0f: g/t;
                                        if (j != k) {
                                                e[j-1] = t;
                                        }
@@ -366,8 +367,9 @@ void SVD(MaTRiX &A, MaTRiX &U, VecToR &s, MaTRiX &V, VecToR &work1, VecToR &work
                                        }
 
                                        t = hypot(f,g);
-                                       cs = f/t;
-                                       sn = g/t;
+                                       /* division by zero checks added to avoid NaN (brecht) */
+                                       cs = (t == 0.0f)? 0.0f: f/t;
+                                       sn = (t == 0.0f)? 0.0f: g/t;
                                        s[j] = t;
                                        f = cs*e[j] + sn*s[j+1];
                                        s[j+1] = -sn*e[j] + cs*s[j+1];
index d1491cc161693de723cf69f294052d402c280ece..e63e3c93f1ebe7c0e74bcca5b93f9e08f0a22d80 100644 (file)
@@ -31,6 +31,7 @@
 #ifndef BKE_GROUP_H
 #define BKE_GROUP_H
 
+struct Base;
 struct Group;
 struct GroupObject;
 struct Object;
index 9753ad47488a2829638f3318616fc9697f68a8c0..b4919dd8cf3e807a8d554b1a807855ff8cc1cf79 100644 (file)
@@ -50,7 +50,7 @@ BME_TransData_Head *BME_init_transdata(int bufsize) {
 
        td = MEM_callocN(sizeof(BME_TransData_Head), "BMesh transdata header");
        td->gh = BLI_ghash_new(BLI_ghashutil_ptrhash,BLI_ghashutil_ptrcmp);
-       td->ma = BLI_memarena_new(bufsize);
+       td->ma = BLI_memarena_new(bufsize, "BME_TransData arena");
        BLI_memarena_use_calloc(td->ma);
 
        return td;
index 44757a09d4245b176530f16626427f2196953a4d..aa9974a7e205ad0c5f95fa536335d82dae522646 100644 (file)
@@ -2489,7 +2489,7 @@ void DM_add_tangent_layer(DerivedMesh *dm)
        tangent= DM_get_face_data_layer(dm, CD_TANGENT);
        
        /* allocate some space */
-       arena= BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE);
+       arena= BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "tangent layer arena");
        BLI_memarena_use_calloc(arena);
        vtangents= MEM_callocN(sizeof(VertexTangent*)*totvert, "VertexTangent");
        
index b687062fe15ab46364e058e56b71ad20c82569c3..77b6f5b481f024f7507f570a88b79f16d07357e4 100644 (file)
@@ -646,8 +646,18 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, i
                        }
                        
                        dob= new_dupli_object(lb, go->ob, mat, ob->lay, 0, OB_DUPLIGROUP, animated);
-                       dob->no_draw= (dob->origlay & group->layer)==0;
-                       
+
+                       /* check the group instance and object layers match, also that the object visible flags are ok. */
+                       if(     (dob->origlay & group->layer)==0 ||
+                               (G.rendering==0 && dob->ob->restrictflag & OB_RESTRICT_VIEW) ||
+                               (G.rendering && dob->ob->restrictflag & OB_RESTRICT_RENDER)
+                       ) {
+                               dob->no_draw= 1;
+                       }
+                       else {
+                               dob->no_draw= 0;
+                       }
+
                        if(go->ob->transflag & OB_DUPLI) {
                                copy_m4_m4(dob->ob->obmat, dob->mat);
                                object_duplilist_recursive((ID *)group, scene, go->ob, lb, ob->obmat, level+1, animated);
@@ -1003,7 +1013,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
                                                copy_m4_m4(tmat, obmat);
                                                mul_m4_m4m3(obmat, tmat, mat);
                                                
-                                               dob= new_dupli_object(lb, ob, obmat, lay, a, OB_DUPLIFACES, animated);
+                                               dob= new_dupli_object(lb, ob, obmat, par->lay, a, OB_DUPLIFACES, animated);
                                                if(G.rendering) {
                                                        w= (mv4)? 0.25f: 1.0f/3.0f;
 
index 86cafa733ffa2af58b5e01e9aa56b32e3da6b54f..f63e28fb46491d1f1351f80bd16181b24da665cf 100644 (file)
@@ -2237,6 +2237,8 @@ void DAG_on_load_update(void)
                                for(go= group->gobject.first; go; go= go->next) {
                                        if(ELEM5(go->ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL))
                                                go->ob->recalc |= OB_RECALC_DATA;
+                                       if(go->ob->proxy_from)
+                                               go->ob->recalc |= OB_RECALC_OB;
                                }
                                
                                group->id.flag &= ~LIB_DOIT;
index 55dcc38ebcf4e4329be7dd2bcf71b06ba748c288..7d194461c7823d975abf260c2d1619393834cccd 100644 (file)
@@ -1,4 +1,4 @@
-/*  image.c        
+/*  image.c
  * 
  * $Id$
  *
index 7ad65820bbed43f2dd788cd2f867c391f15d9b39..d41ede220060c904560bf23a06dad2698dfa0cfc 100644 (file)
@@ -4215,18 +4215,11 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa
        ParticleSystem *psys = sim->psys;
        ParticleSystemModifierData *psmd = sim->psmd;
        float loc[3], nor[3], vec[3], side[3], len, obrotmat[4][4], qmat[4][4];
-       float xvec[3] = {-1.0, 0.0, 0.0}, q[4];
+       float xvec[3] = {-1.0, 0.0, 0.0}, q[4], nmat[3][3];
 
        sub_v3_v3v3(vec, (cache+cache->steps-1)->co, cache->co);
        len= normalize_v3(vec);
 
-       if(pa)
-               psys_particle_on_emitter(psmd,sim->psys->part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,loc,nor,0,0,0,0);
-       else
-               psys_particle_on_emitter(psmd,
-                       (psys->part->childtype == PART_CHILD_FACES)? PART_FROM_FACE: PART_FROM_PARTICLE,
-                       cpa->num,DMCACHE_ISCHILD,cpa->fuv,cpa->foffset,loc,nor,0,0,0,0);
-       
        if(psys->part->rotmode) {
                if(!pa)
                        pa= psys->particles+cpa->pa[0];
@@ -4239,6 +4232,17 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa
                mul_m4_m4m4(mat, obrotmat, qmat);
        }
        else {
+               if(pa)
+                       psys_particle_on_emitter(psmd,sim->psys->part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,loc,nor,0,0,0,0);
+               else
+                       psys_particle_on_emitter(psmd,
+                               (psys->part->childtype == PART_CHILD_FACES)? PART_FROM_FACE: PART_FROM_PARTICLE,
+                               cpa->num,DMCACHE_ISCHILD,cpa->fuv,cpa->foffset,loc,nor,0,0,0,0);
+               
+               copy_m3_m4(nmat, ob->imat);
+               transpose_m3(nmat);
+               mul_m3_v3(nmat, nor);
+
                /* make sure that we get a proper side vector */
                if(fabs(dot_v3v3(nor,vec))>0.999999) {
                        if(fabs(dot_v3v3(nor,xvec))>0.999999) {
index 3972355d302686824b65253e085be2608ebca7bd..16cb671f2d083dc9f51a7c709a3e93f66bce5afe 100644 (file)
@@ -117,7 +117,7 @@ static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, int useAgin
 
        if (useArena) {
                CCGAllocatorIFC allocatorIFC;
-               CCGAllocatorHDL allocator = BLI_memarena_new((1<<16));
+               CCGAllocatorHDL allocator = BLI_memarena_new((1<<16), "subsurf arena");
 
                allocatorIFC.alloc = arena_alloc;
                allocatorIFC.realloc = arena_realloc;
index fc5469df23af126c173c9674c608a696c5b34421..d9e3d7e42c6fe820e61b949c3f48d2dfdc754e3e 100644 (file)
 #ifndef BLI_KDOPBVH_H
 #define BLI_KDOPBVH_H
 
+#ifdef __cplusplus
+extern "C" { 
+#endif
+
 #include <float.h>
 
 struct BVHTree;
@@ -100,6 +104,9 @@ float BLI_bvhtree_bb_raycast(float *bv, float *light_start, float *light_end, fl
 /* range query */
 int BLI_bvhtree_range_query(BVHTree *tree, const float *co, float radius, BVHTree_RangeQuery callback, void *userdata);
 
+#ifdef __cplusplus
+}
+#endif
 
 #endif // BLI_KDOPBVH_H
 
index 341a3a329344545ae42a154065fcc501427f8cee..d0fb530e34977c602319e48136369bf25429da1f 100644 (file)
 
 #include "BLI_math_base.h"
 #include "BLI_math_color.h"
-#include "BLI_math_geom.h"
 #include "BLI_math_matrix.h"
 #include "BLI_math_rotation.h"
 #include "BLI_math_vector.h"
+#include "BLI_math_geom.h"
 
 #endif /* BLI_MATH */
 
index 560a5b1abc9abfc1bec3223deec33a559d50820b..5d84de7531aa06c505d2f7a2f22a5f38457414c9 100644 (file)
 extern "C" {
 #endif
 
+#include "BLI_math_inline.h"
+
+#ifdef BLI_MATH_INLINE
+#include "intern/math_geom_inline.c"
+#endif
+
 /********************************** Polygons *********************************/
 
 void cent_tri_v3(float r[3], float a[3], float b[3], float c[3]);
@@ -146,6 +152,8 @@ void orthographic_m4(float mat[4][4], float left, float right,
 
 int box_clip_bounds_m4(float boundbox[2][3],
        float bounds[4], float winmat[4][4]);
+void box_minmax_bounds_m4(float min[3], float max[3],
+       float boundbox[2][3], float mat[4][4]);
 
 /********************************** Mapping **********************************/
 
@@ -165,11 +173,33 @@ void sum_or_add_vertex_tangent(void *arena, VertexTangent **vtang,
 void tangent_from_uv(float *uv1, float *uv2, float *uv3,
        float *co1, float *co2, float *co3, float *n, float *tang);
 
-/********************************* vector clouds******************************/
+/******************************** Vector Clouds ******************************/
+
+void vcloud_estimate_transform(int list_size, float (*pos)[3], float *weight,
+       float (*rpos)[3], float *rweight,
+       float lloc[3],float rloc[3],float lrot[3][3],float lscale[3][3]);
+
+/****************************** Spherical Harmonics *************************/
+
+/* Uses 2nd order SH => 9 coefficients, stored in this order:
+   0 = (0,0),
+   1 = (1,-1), 2 = (1,0), 3 = (1,1),
+   4 = (2,-2), 5 = (2,-1), 6 = (2,0), 7 = (2,1), 8 = (2,2) */
+
+MINLINE void zero_sh(float r[9]);
+MINLINE void copy_sh_sh(float r[9], float a[9]);
+MINLINE void mul_sh_fl(float r[9], float f);
+MINLINE void add_sh_shsh(float r[9], float a[9], float b[9]);
+
+MINLINE float eval_shv3(float r[9], float v[3]);
+MINLINE float diffuse_shv3(float r[9], float v[3]);
+MINLINE void vec_fac_to_sh(float r[9], float v[3], float f);
+MINLINE void madd_sh_shfl(float r[9], float sh[3], float f);
 
+/********************************* Form Factor *******************************/
 
-void vcloud_estimate_transform(int list_size, float (*pos)[3], float *weight,float (*rpos)[3], float *rweight,
-                                                       float lloc[3],float rloc[3],float lrot[3][3],float lscale[3][3]);
+float form_factor_hemi_poly(float p[3], float n[3],
+       float v1[3], float v2[3], float v3[3], float v4[3]);
 
 #ifdef __cplusplus
 }
index 8f897fdd5d6f2ebf0dd5b427ffe94976a9083302..31cefb21e7ac6b371871956c7007c9224691b0b4 100644 (file)
@@ -78,7 +78,8 @@ void mul_serie_m4(float R[4][4],
 void mul_m4_v3(float M[4][4], float r[3]);
 void mul_v3_m4v3(float r[3], float M[4][4], float v[3]);
 void mul_mat3_m4_v3(float M[4][4], float r[3]);
-void mul_m4_v4(float M[4][4], float r[3]);
+void mul_m4_v4(float M[4][4], float r[4]);
+void mul_v4_m4v4(float r[4], float M[4][4], float v[4]);
 void mul_project_m4_v4(float M[4][4], float r[3]);
 
 void mul_m3_v3(float M[3][3], float r[3]);
index 3ed8169f260fa9831dd447e4b32772dda1b4fac0..91e743271d2aee671ae5afedced14d5a37bc25bc 100644 (file)
@@ -32,6 +32,8 @@
 extern "C" {
 #endif
 
+#include "BLI_math_inline.h"
+
 #ifdef BLI_MATH_INLINE
 #include "intern/math_vector_inline.c"
 #endif
@@ -75,6 +77,7 @@ MINLINE void madd_v3_v3v3(float r[3], const float a[3], const float b[3]);
 MINLINE void madd_v2_v2v2fl(float r[2], const float a[2], const float b[2], float f);
 MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f);
 MINLINE void madd_v3_v3v3v3(float r[3], const float a[3], const float b[3], const float c[3]);
+MINLINE void madd_v4_v4fl(float r[4], const float a[4], float f);
 
 MINLINE void negate_v3(float r[3]);
 MINLINE void negate_v3_v3(float r[3], const float a[3]);
@@ -93,6 +96,7 @@ MINLINE float len_v2(const float a[2]);
 MINLINE float len_v2v2(const float a[2], const float b[2]);
 MINLINE float len_v3(const float a[3]);
 MINLINE float len_v3v3(const float a[3], const float b[3]);
+MINLINE float len_squared_v3v3(const float a[3], const float b[3]);
 
 MINLINE float normalize_v2(float r[2]);
 MINLINE float normalize_v2_v2(float r[2], const float a[2]);
@@ -107,6 +111,7 @@ void interp_v3_v3v3(float r[3], const float a[3], const float b[3], const float
 void interp_v3_v3v3v3(float p[3], const float v1[3], const float v2[3], const float v3[3], const float w[3]);
 void interp_v3_v3v3v3v3(float p[3], const float v1[3], const float v2[3], const float v3[3], const float v4[3], const float w[4]);
 void interp_v4_v4v4(float r[4], const float a[4], const float b[4], const float t);
+void interp_v4_v4v4v4(float p[4], const float v1[4], const float v2[4], const float v3[4], const float w[3]);
 
 void mid_v3_v3v3(float r[3], float a[3], float b[3]);
 
index 2383b2ed13946a6870c09ce3ff805e2b87ece833..a17c88b70df889eb8353ef2217217fb97bbbc282 100644 (file)
@@ -51,7 +51,7 @@ struct MemArena;
 typedef struct MemArena MemArena;
 
 
-struct MemArena*       BLI_memarena_new        (int bufsize);
+struct MemArena*       BLI_memarena_new        (int bufsize, const char *name);
 void                           BLI_memarena_free       (struct MemArena *ma);
 
 void                           BLI_memarena_use_malloc (struct MemArena *ma);
index b089d7e052f6963d5eb38d9f95c26b9342bfadb3..eab9f92d7e8b14946aaef98dc8af3680913e0104 100644 (file)
@@ -83,15 +83,15 @@ void        BLI_array_randomize     (void *data, int elemSize, int numElems, unsigned int s
 
 
        /** Better seed for the random number generator, using noise.c hash[] */
-       /** Allows up to 16 threads to address */
+       /** Allows up to BLENDER_MAX_THREADS threads to address */
 void   BLI_thread_srandom      (int thread, unsigned int seed);
 
        /** Return a pseudo-random number N where 0<=N<(2^31) */
-       /** Allows up to 16 threads to address */
+       /** Allows up to BLENDER_MAX_THREADS threads to address */
 int            BLI_thread_rand         (int thread);
 
        /** Return a pseudo-random number N where 0.0f<=N<1.0f */
-       /** Allows up to 16 threads to address */
+       /** Allows up to BLENDER_MAX_THREADS threads to address */
 float  BLI_thread_frand        (int thread);
 
 
index cf21707cd397c272be3dc50d75a60516f8c97697..a1e44f65200982394207670c89b3175d4f0f512e 100644 (file)
@@ -65,6 +65,7 @@ int           BLI_system_thread_count(void); /* gets the number of threads the system can
 #define LOCK_PREVIEW   1
 #define LOCK_VIEWER            2
 #define LOCK_CUSTOM1   3
+#define LOCK_RCACHE            2
 
 void   BLI_lock_thread(int type);
 void   BLI_unlock_thread(int type);
index 6c4e568c380b0dbd921c8093752004acba35a525..f6616ecb06bb05edf2ec446241a6c61fb1973c69 100644 (file)
@@ -69,7 +69,7 @@ Heap *BLI_heap_new()
        Heap *heap = (Heap*)MEM_callocN(sizeof(Heap), "BLIHeap");
        heap->bufsize = 1;
        heap->tree = (HeapNode**)MEM_mallocN(sizeof(HeapNode*), "BLIHeapTree");
-       heap->arena = BLI_memarena_new(1<<16);
+       heap->arena = BLI_memarena_new(1<<16, "heap arena");
 
        return heap;
 }
index 07e22b30fcc5e44687bef74227820857f7a7d065..cdb88e91cadcb45fab13b87ba646a088c847c117 100644 (file)
@@ -41,6 +41,7 @@
 struct MemArena {
        unsigned char *curbuf;
        int bufsize, cursize;
+       const char *name;
        
        int use_calloc; 
        int align;
@@ -48,10 +49,11 @@ struct MemArena {
        LinkNode *bufs;
 };
 
-MemArena *BLI_memarena_new(int bufsize) {
+MemArena *BLI_memarena_new(int bufsize, const char *name) {
        MemArena *ma= MEM_callocN(sizeof(*ma), "memarena");
        ma->bufsize= bufsize;
        ma->align = 8;
+       ma->name= name;
        
        return ma;
 }
@@ -94,9 +96,9 @@ void *BLI_memarena_alloc(MemArena *ma, int size) {
                else ma->cursize = ma->bufsize;
 
                if(ma->use_calloc)
-                       ma->curbuf= MEM_callocN(ma->cursize, "memarena calloc");
+                       ma->curbuf= MEM_callocN(ma->cursize, ma->name);
                else
-                       ma->curbuf= MEM_mallocN(ma->cursize, "memarena malloc");
+                       ma->curbuf= MEM_mallocN(ma->cursize, ma->name);
                
                BLI_linklist_prepend(&ma->bufs, ma->curbuf);
 
index 27f36752f80eb4856e719994cf71ec7b918b3d2f..af408e6bcc9dde62c195e66bea439208189b220e 100644 (file)
  * */
 
 
+#include "MEM_guardedalloc.h"
+
 #include "BLI_math.h"
 #include "BLI_memarena.h"
-#include "MEM_guardedalloc.h"
+
+#include "BKE_utildefines.h"
 
 /********************************** Polygons *********************************/
 
@@ -121,10 +124,6 @@ float area_tri_v3(const float v1[3], const float v2[3], const float v3[3])  /* T
        return (len/2.0f);
 }
 
-#define MAX2(x,y)              ((x)>(y) ? (x) : (y))
-#define MAX3(x,y,z)            MAX2(MAX2((x),(y)) , (z))
-
-
 float area_poly_v3(int nr, float verts[][3], float *normal)
 {
        float x, y, z, area, max;
@@ -1763,6 +1762,27 @@ int box_clip_bounds_m4(float boundbox[2][3], float bounds[4], float winmat[4][4]
        return flag;
 }
 
+void box_minmax_bounds_m4(float min[3], float max[3], float boundbox[2][3], float mat[4][4])
+{
+       float mn[3], mx[3], vec[3];
+       int a;
+
+       copy_v3_v3(mn, min);
+       copy_v3_v3(mx, max);
+
+       for(a=0; a<8; a++) {
+               vec[0]= (a & 1)? boundbox[0][0]: boundbox[1][0];
+               vec[1]= (a & 2)? boundbox[0][1]: boundbox[1][1];
+               vec[2]= (a & 4)? boundbox[0][2]: boundbox[1][2];
+
+               mul_m4_v3(mat, vec);
+               DO_MINMAX(vec, mn, mx);
+       }
+
+       copy_v3_v3(min, mn);
+       copy_v3_v3(max, mx);
+}
+
 /********************************** Mapping **********************************/
 
 void map_to_tube(float *u, float *v,float x, float y, float z)
@@ -1794,9 +1814,7 @@ void map_to_sphere(float *u, float *v,float x, float y, float z)
        }
 }
 
-/********************************************************/
-
-/* Tangents */
+/********************************* Tangents **********************************/
 
 /* For normal map tangents we need to detect uv boundaries, and only average
  * tangents in case the uvs are connected. Alternative would be to store 1 
@@ -1875,7 +1893,7 @@ void tangent_from_uv(float *uv1, float *uv2, float *uv3, float *co1, float *co2,
        }
 }
 
-/********************************************************/
+/****************************** Vector Clouds ********************************/
 
 /* vector clouds */
 /* void vcloud_estimate_transform(int list_size, float (*pos)[3], float *weight,float (*rpos)[3], float *rweight,
@@ -2034,3 +2052,422 @@ void vcloud_estimate_transform(int list_size, float (*pos)[3], float *weight,flo
        }
 }
 
+/******************************* Form Factor *********************************/
+
+static void vec_add_dir(float r[3], float v1[3], float v2[3], float fac)
+{
+       r[0]= v1[0] + fac*(v2[0] - v1[0]);
+       r[1]= v1[1] + fac*(v2[1] - v1[1]);
+       r[2]= v1[2] + fac*(v2[2] - v1[2]);
+}
+
+static int ff_visible_quad(float p[3], float n[3], float v0[3], float v1[3], float v2[3], float q0[3], float q1[3], float q2[3], float q3[3])
+{
+       static const float epsilon = 1e-6f;
+       float c, sd[3];
+       
+       c= dot_v3v3(n, p);
+
+       /* signed distances from the vertices to the plane. */
+       sd[0]= dot_v3v3(n, v0) - c;
+       sd[1]= dot_v3v3(n, v1) - c;
+       sd[2]= dot_v3v3(n, v2) - c;
+
+       if(fabsf(sd[0]) < epsilon) sd[0] = 0.0f;
+       if(fabsf(sd[1]) < epsilon) sd[1] = 0.0f;
+       if(fabsf(sd[2]) < epsilon) sd[2] = 0.0f;
+
+       if(sd[0] > 0) {
+               if(sd[1] > 0) {
+                       if(sd[2] > 0) {
+                               // +++
+                               copy_v3_v3(q0, v0);
+                               copy_v3_v3(q1, v1);
+                               copy_v3_v3(q2, v2);
+                               copy_v3_v3(q3, q2);
+                       }
+                       else if(sd[2] < 0) {
+                               // ++-
+                               copy_v3_v3(q0, v0);
+                               copy_v3_v3(q1, v1);
+                               vec_add_dir(q2, v1, v2, (sd[1]/(sd[1]-sd[2])));
+                               vec_add_dir(q3, v0, v2, (sd[0]/(sd[0]-sd[2])));
+                       }
+                       else {
+                               // ++0
+                               copy_v3_v3(q0, v0);
+                               copy_v3_v3(q1, v1);
+                               copy_v3_v3(q2, v2);
+                               copy_v3_v3(q3, q2);
+                       }
+               }
+               else if(sd[1] < 0) {
+                       if(sd[2] > 0) {
+                               // +-+
+                               copy_v3_v3(q0, v0);
+                               vec_add_dir(q1, v0, v1, (sd[0]/(sd[0]-sd[1])));
+                               vec_add_dir(q2, v1, v2, (sd[1]/(sd[1]-sd[2])));
+                               copy_v3_v3(q3, v2);
+                       }
+                       else if(sd[2] < 0) {
+                               // +--
+                               copy_v3_v3(q0, v0);
+                               vec_add_dir(q1, v0, v1, (sd[0]/(sd[0]-sd[1])));
+                               vec_add_dir(q2, v0, v2, (sd[0]/(sd[0]-sd[2])));
+                               copy_v3_v3(q3, q2);
+                       }
+                       else {
+                               // +-0
+                               copy_v3_v3(q0, v0);
+                               vec_add_dir(q1, v0, v1, (sd[0]/(sd[0]-sd[1])));
+                               copy_v3_v3(q2, v2);
+                               copy_v3_v3(q3, q2);
+                       }
+               }
+               else {
+                       if(sd[2] > 0) {
+                               // +0+
+                               copy_v3_v3(q0, v0);
+                               copy_v3_v3(q1, v1);
+                               copy_v3_v3(q2, v2);
+                               copy_v3_v3(q3, q2);
+                       }
+                       else if(sd[2] < 0) {
+                               // +0-
+                               copy_v3_v3(q0, v0);
+                               copy_v3_v3(q1, v1);
+                               vec_add_dir(q2, v0, v2, (sd[0]/(sd[0]-sd[2])));
+                               copy_v3_v3(q3, q2);
+                       }
+                       else {
+                               // +00
+                               copy_v3_v3(q0, v0);
+                               copy_v3_v3(q1, v1);
+                               copy_v3_v3(q2, v2);
+                               copy_v3_v3(q3, q2);
+                       }
+               }
+       }
+       else if(sd[0] < 0) {
+               if(sd[1] > 0) {
+                       if(sd[2] > 0) {
+                               // -++
+                               vec_add_dir(q0, v0, v1, (sd[0]/(sd[0]-sd[1])));
+                               copy_v3_v3(q1, v1);
+                               copy_v3_v3(q2, v2);
+                               vec_add_dir(q3, v0, v2, (sd[0]/(sd[0]-sd[2])));
+                       }
+                       else if(sd[2] < 0) {
+                               // -+-
+                               vec_add_dir(q0, v0, v1, (sd[0]/(sd[0]-sd[1])));
+                               copy_v3_v3(q1, v1);
+                               vec_add_dir(q2, v1, v2, (sd[1]/(sd[1]-sd[2])));
+                               copy_v3_v3(q3, q2);
+                       }
+                       else {
+                               // -+0
+                               vec_add_dir(q0, v0, v1, (sd[0]/(sd[0]-sd[1])));
+                               copy_v3_v3(q1, v1);
+                               copy_v3_v3(q2, v2);
+                               copy_v3_v3(q3, q2);
+                       }
+               }
+               else if(sd[1] < 0) {
+                       if(sd[2] > 0) {
+                               // --+
+                               vec_add_dir(q0, v0, v2, (sd[0]/(sd[0]-sd[2])));
+                               vec_add_dir(q1, v1, v2, (sd[1]/(sd[1]-sd[2])));
+                               copy_v3_v3(q2, v2);
+                               copy_v3_v3(q3, q2);
+                       }
+                       else if(sd[2] < 0) {
+                               // ---
+                               return 0;
+                       }
+                       else {
+                               // --0
+                               return 0;
+                       }
+               }
+               else {
+                       if(sd[2] > 0) {
+                               // -0+
+                               vec_add_dir(q0, v0, v2, (sd[0]/(sd[0]-sd[2])));
+                               copy_v3_v3(q1, v1);
+                               copy_v3_v3(q2, v2);
+                               copy_v3_v3(q3, q2);
+                       }
+                       else if(sd[2] < 0) {
+                               // -0-
+                               return 0;
+                       }
+                       else {
+                               // -00
+                               return 0;
+                       }
+               }
+       }
+       else {
+               if(sd[1] > 0) {
+                       if(sd[2] > 0) {
+                               // 0++
+                               copy_v3_v3(q0, v0);
+                               copy_v3_v3(q1, v1);
+                               copy_v3_v3(q2, v2);
+                               copy_v3_v3(q3, q2);
+                       }
+                       else if(sd[2] < 0) {
+                               // 0+-
+                               copy_v3_v3(q0, v0);
+                               copy_v3_v3(q1, v1);
+                               vec_add_dir(q2, v1, v2, (sd[1]/(sd[1]-sd[2])));
+                               copy_v3_v3(q3, q2);
+                       }
+                       else {
+                               // 0+0
+                               copy_v3_v3(q0, v0);
+                               copy_v3_v3(q1, v1);
+                               copy_v3_v3(q2, v2);
+                               copy_v3_v3(q3, q2);
+                       }
+               }
+               else if(sd[1] < 0) {
+                       if(sd[2] > 0) {
+                               // 0-+
+                               copy_v3_v3(q0, v0);
+                               vec_add_dir(q1, v1, v2, (sd[1]/(sd[1]-sd[2])));
+                               copy_v3_v3(q2, v2);
+                               copy_v3_v3(q3, q2);
+                       }
+                       else if(sd[2] < 0) {
+                               // 0--
+                               return 0;
+                       }
+                       else {
+                               // 0-0
+                               return 0;
+                       }
+               }
+               else {
+                       if(sd[2] > 0) {
+                               // 00+
+                               copy_v3_v3(q0, v0);
+                               copy_v3_v3(q1, v1);
+                               copy_v3_v3(q2, v2);
+                               copy_v3_v3(q3, q2);
+                       }
+                       else if(sd[2] < 0) {
+                               // 00-
+                               return 0;
+                       }
+                       else {
+                               // 000
+                               return 0;
+                       }
+               }
+       }
+
+       return 1;
+}
+
+/* altivec optimization, this works, but is unused */
+
+#if 0
+#include <Accelerate/Accelerate.h>
+
+typedef union {
+       vFloat v;
+       float f[4];
+} vFloatResult;
+
+static vFloat vec_splat_float(float val)
+{
+       return (vFloat){val, val, val, val};
+}
+
+static float ff_quad_form_factor(float *p, float *n, float *q0, float *q1, float *q2, float *q3)
+{
+       vFloat vcos, rlen, vrx, vry, vrz, vsrx, vsry, vsrz, gx, gy, gz, vangle;
+       vUInt8 rotate = (vUInt8){4,5,6,7,8,9,10,11,12,13,14,15,0,1,2,3};
+       vFloatResult vresult;
+       float result;
+
+       /* compute r* */
+       vrx = (vFloat){q0[0], q1[0], q2[0], q3[0]} - vec_splat_float(p[0]);
+       vry = (vFloat){q0[1], q1[1], q2[1], q3[1]} - vec_splat_float(p[1]);
+       vrz = (vFloat){q0[2], q1[2], q2[2], q3[2]} - vec_splat_float(p[2]);
+
+       /* normalize r* */
+       rlen = vec_rsqrte(vrx*vrx + vry*vry + vrz*vrz + vec_splat_float(1e-16f));
+       vrx = vrx*rlen;
+       vry = vry*rlen;
+       vrz = vrz*rlen;
+
+       /* rotate r* for cross and dot */
+       vsrx= vec_perm(vrx, vrx, rotate);
+       vsry= vec_perm(vry, vry, rotate);
+       vsrz= vec_perm(vrz, vrz, rotate);
+
+       /* cross product */
+       gx = vsry*vrz - vsrz*vry;
+       gy = vsrz*vrx - vsrx*vrz;
+       gz = vsrx*vry - vsry*vrx;
+
+       /* normalize */
+       rlen = vec_rsqrte(gx*gx + gy*gy + gz*gz + vec_splat_float(1e-16f));
+       gx = gx*rlen;
+       gy = gy*rlen;
+       gz = gz*rlen;
+
+       /* angle */
+       vcos = vrx*vsrx + vry*vsry + vrz*vsrz;
+       vcos= vec_max(vec_min(vcos, vec_splat_float(1.0f)), vec_splat_float(-1.0f));
+       vangle= vacosf(vcos);
+
+       /* dot */
+       vresult.v = (vec_splat_float(n[0])*gx +
+                    vec_splat_float(n[1])*gy +
+                    vec_splat_float(n[2])*gz)*vangle;
+
+       result= (vresult.f[0] + vresult.f[1] + vresult.f[2] + vresult.f[3])*(0.5f/(float)M_PI);
+       result= MAX2(result, 0.0f);
+
+       return result;
+}
+
+#endif
+
+/* SSE optimization, acos code doesn't work */
+
+#if 0
+
+#include <xmmintrin.h>
+
+static __m128 sse_approx_acos(__m128 x)
+{
+       /* needs a better approximation than taylor expansion of acos, since that
+        * gives big erros for near 1.0 values, sqrt(2*x)*acos(1-x) should work
+        * better, see http://www.tom.womack.net/projects/sse-fast-arctrig.html */
+
+       return _mm_set_ps1(1.0f);
+}
+
+static float ff_quad_form_factor(float *p, float *n, float *q0, float *q1, float *q2, float *q3)
+{
+       float r0[3], r1[3], r2[3], r3[3], g0[3], g1[3], g2[3], g3[3];
+       float a1, a2, a3, a4, dot1, dot2, dot3, dot4, result;
+       float fresult[4] __attribute__((aligned(16)));
+       __m128 qx, qy, qz, rx, ry, rz, rlen, srx, sry, srz, gx, gy, gz, glen, rcos, angle, aresult;
+
+       /* compute r */
+       qx = _mm_set_ps(q3[0], q2[0], q1[0], q0[0]);
+       qy = _mm_set_ps(q3[1], q2[1], q1[1], q0[1]);
+       qz = _mm_set_ps(q3[2], q2[2], q1[2], q0[2]);
+
+       rx = qx - _mm_set_ps1(p[0]);
+       ry = qy - _mm_set_ps1(p[1]);
+       rz = qz - _mm_set_ps1(p[2]);
+
+       /* normalize r */
+       rlen = _mm_rsqrt_ps(rx*rx + ry*ry + rz*rz + _mm_set_ps1(1e-16f));
+       rx = rx*rlen;
+       ry = ry*rlen;
+       rz = rz*rlen;
+
+       /* cross product */
+       srx = _mm_shuffle_ps(rx, rx, _MM_SHUFFLE(0,3,2,1));
+       sry = _mm_shuffle_ps(ry, ry, _MM_SHUFFLE(0,3,2,1));
+       srz = _mm_shuffle_ps(rz, rz, _MM_SHUFFLE(0,3,2,1));
+
+       gx = sry*rz - srz*ry;
+       gy = srz*rx - srx*rz;
+       gz = srx*ry - sry*rx;
+
+       /* normalize g */
+       glen = _mm_rsqrt_ps(gx*gx + gy*gy + gz*gz + _mm_set_ps1(1e-16f));
+       gx = gx*glen;
+       gy = gy*glen;
+       gz = gz*glen;
+
+       /* compute angle */
+       rcos = rx*srx + ry*sry + rz*srz;
+       rcos= _mm_max_ps(_mm_min_ps(rcos, _mm_set_ps1(1.0f)), _mm_set_ps1(-1.0f));
+
+       angle = sse_approx_cos(rcos);
+       aresult = (_mm_set_ps1(n[0])*gx + _mm_set_ps1(n[1])*gy + _mm_set_ps1(n[2])*gz)*angle;
+
+       /* sum together */
+    result= (fresult[0] + fresult[1] + fresult[2] + fresult[3])*(0.5f/(float)M_PI);
+       result= MAX2(result, 0.0f);
+
+       return result;
+}
+
+#endif
+
+static void ff_normalize(float n[3])
+{
+       float d;
+       
+       d= dot_v3v3(n, n);
+
+       if(d > 1.0e-35F) {
+               d= 1.0f/sqrtf(d);
+
+               n[0] *= d; 
+               n[1] *= d; 
+               n[2] *= d;
+       } 
+}
+
+static float ff_quad_form_factor(float *p, float *n, float *q0, float *q1, float *q2, float *q3)
+{
+       float r0[3], r1[3], r2[3], r3[3], g0[3], g1[3], g2[3], g3[3];
+       float a1, a2, a3, a4, dot1, dot2, dot3, dot4, result;
+
+       sub_v3_v3v3(r0, q0, p);
+       sub_v3_v3v3(r1, q1, p);
+       sub_v3_v3v3(r2, q2, p);
+       sub_v3_v3v3(r3, q3, p);
+
+       ff_normalize(r0);
+       ff_normalize(r1);
+       ff_normalize(r2);
+       ff_normalize(r3);
+
+       cross_v3_v3v3(g0, r1, r0); ff_normalize(g0);
+       cross_v3_v3v3(g1, r2, r1); ff_normalize(g1);
+       cross_v3_v3v3(g2, r3, r2); ff_normalize(g2);
+       cross_v3_v3v3(g3, r0, r3); ff_normalize(g3);
+
+       a1= saacosf(dot_v3v3(r0, r1));
+       a2= saacosf(dot_v3v3(r1, r2));
+       a3= saacosf(dot_v3v3(r2, r3));
+       a4= saacosf(dot_v3v3(r3, r0));
+
+       dot1= dot_v3v3(n, g0);
+       dot2= dot_v3v3(n, g1);
+       dot3= dot_v3v3(n, g2);
+       dot4= dot_v3v3(n, g3);
+
+       result= (a1*dot1 + a2*dot2 + a3*dot3 + a4*dot4)*0.5f/(float)M_PI;
+       result= MAX2(result, 0.0f);
+
+       return result;
+}
+
+float form_factor_hemi_poly(float p[3], float n[3], float v1[3], float v2[3], float v3[3], float v4[3])
+{
+       /* computes how much hemisphere defined by point and normal is
+          covered by a quad or triangle, cosine weighted */
+       float q0[3], q1[3], q2[3], q3[3], contrib= 0.0f;
+
+       if(ff_visible_quad(p, n, v1, v2, v3, q0, q1, q2, q3))
+               contrib += ff_quad_form_factor(p, n, q0, q1, q2, q3);
+       
+       if(v4 && ff_visible_quad(p, n, v1, v3, v4, q0, q1, q2, q3))
+               contrib += ff_quad_form_factor(p, n, q0, q1, q2, q3);
+
+       return contrib;
+}
+
diff --git a/source/blender/blenlib/intern/math_geom_inline.c b/source/blender/blenlib/intern/math_geom_inline.c
new file mode 100644 (file)
index 0000000..8b04b2a
--- /dev/null
@@ -0,0 +1,138 @@
+/**
+ * $Id: math_base_inline.c 26367 2010-01-28 16:02:26Z blendix $
+ *
+ * ***** 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: some of this file.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ * */
+
+#include "BLI_math.h"
+
+#ifndef BLI_MATH_GEOM_INLINE
+#define BLI_MATH_GEOM_INLINE
+
+/****************************** Spherical Harmonics **************************/
+
+MINLINE void zero_sh(float r[9])
+{
+       memset(r, 0, sizeof(float)*9);
+}
+
+MINLINE void copy_sh_sh(float r[9], float a[9])
+{
+       memcpy(r, a, sizeof(float)*9);
+}
+
+MINLINE void mul_sh_fl(float r[9], float f)
+{
+       int i;
+
+       for(i=0; i<9; i++)
+               r[i] *= f;
+}
+
+MINLINE void add_sh_shsh(float r[9], float a[9], float b[9])
+{
+       int i;
+
+       for(i=0; i<9; i++)
+               r[i]= a[i] + b[i];
+}
+
+MINLINE float dot_shsh(float a[9], float b[9])
+{
+       float r= 0.0f;
+       int i;
+
+       for(i=0; i<9; i++)
+               r += a[i]*b[i];
+       
+       return r;
+}
+
+MINLINE float diffuse_shv3(float sh[9], float v[3])
+{
+       /* See formula (13) in:
+          "An Efficient Representation for Irradiance Environment Maps" */
+       static const float c1 = 0.429043f, c2 = 0.511664f, c3 = 0.743125f;
+       static const float c4 = 0.886227f, c5 = 0.247708f;
+       float x, y, z, sum;
+
+       x= v[0];
+       y= v[1];
+       z= v[2];
+
+       sum= c1*sh[8]*(x*x - y*y);
+       sum += c3*sh[6]*z*z;
+       sum += c4*sh[0];
+       sum += -c5*sh[6];
+       sum += 2.0f*c1*(sh[4]*x*y + sh[7]*x*z + sh[5]*y*z);
+       sum += 2.0f*c2*(sh[3]*x + sh[1]*y + sh[2]*z);
+
+       return sum;
+}
+
+MINLINE void vec_fac_to_sh(float r[9], float v[3], float f)
+{
+       /* See formula (3) in:
+          "An Efficient Representation for Irradiance Environment Maps" */
+       float sh[9], x, y, z;
+
+       x= v[0];
+       y= v[1];
+       z= v[2];
+
+       sh[0]= 0.282095f;
+
+       sh[1]= 0.488603f*y;
+       sh[2]= 0.488603f*z;
+       sh[3]= 0.488603f*x;
+       
+       sh[4]= 1.092548f*x*y;
+       sh[5]= 1.092548f*y*z;
+       sh[6]= 0.315392f*(3.0f*z*z - 1.0f);
+       sh[7]= 1.092548f*x*z;
+       sh[8]= 0.546274f*(x*x - y*y);
+
+       mul_sh_fl(sh, f);
+       copy_sh_sh(r, sh);
+}
+
+MINLINE float eval_shv3(float sh[9], float v[3])
+{
+       float tmp[9];
+
+       vec_fac_to_sh(tmp, v, 1.0f);
+       return dot_shsh(tmp, sh);
+}
+
+MINLINE void madd_sh_shfl(float r[9], float sh[3], float f)
+{
+       float tmp[9];
+
+       copy_sh_sh(tmp, sh);
+       mul_sh_fl(tmp, f);
+       add_sh_shsh(r, r, tmp);
+}
+
+#endif /* BLI_MATH_GEOM_INLINE */
+
index fca8cf445d18281c2c2586e6671960d567590b71..396ae7ca5eeac30ffb93729f6695ff255fbbaa9b 100644 (file)
@@ -125,10 +125,15 @@ void swap_m4m4(float m1[][4], float m2[][4])
 
 /******************************** Arithmetic *********************************/
 
-void mul_m4_m4m4(float m1[][4], float m2[][4], float m3[][4])
+void mul_m4_m4m4(float m1[][4], float m2_[][4], float m3_[][4])
 {
-  /* matrix product: m1[j][k] = m2[j][i].m3[i][k] */
+       float m2[4][4], m3[4][4];
 
+       /* copy so it works when m1 is the same pointer as m2 or m3 */
+       copy_m4_m4(m2, m2_);
+       copy_m4_m4(m3, m3_);
+
+       /* matrix product: m1[j][k] = m2[j][i].m3[i][k] */
        m1[0][0] = m2[0][0]*m3[0][0] + m2[0][1]*m3[1][0] + m2[0][2]*m3[2][0] + m2[0][3]*m3[3][0];
        m1[0][1] = m2[0][0]*m3[0][1] + m2[0][1]*m3[1][1] + m2[0][2]*m3[2][1] + m2[0][3]*m3[3][1];
        m1[0][2] = m2[0][0]*m3[0][2] + m2[0][1]*m3[1][2] + m2[0][2]*m3[2][2] + m2[0][3]*m3[3][2];
@@ -151,20 +156,26 @@ void mul_m4_m4m4(float m1[][4], float m2[][4], float m3[][4])
 
 }
 
-void mul_m3_m3m3(float m1[][3], float m3[][3], float m2[][3])
+void mul_m3_m3m3(float m1[][3], float m3_[][3], float m2_[][3])
 {
-   /*  m1[i][j] = m2[i][k]*m3[k][j], args are flipped!  */
-         m1[0][0]= m2[0][0]*m3[0][0] + m2[0][1]*m3[1][0] + m2[0][2]*m3[2][0]; 
-         m1[0][1]= m2[0][0]*m3[0][1] + m2[0][1]*m3[1][1] + m2[0][2]*m3[2][1]; 
-         m1[0][2]= m2[0][0]*m3[0][2] + m2[0][1]*m3[1][2] + m2[0][2]*m3[2][2]; 
+       float m2[3][3], m3[3][3];
+
+       /* copy so it works when m1 is the same pointer as m2 or m3 */
+       copy_m3_m3(m2, m2_);
+       copy_m3_m3(m3, m3_);
 
-         m1[1][0]= m2[1][0]*m3[0][0] + m2[1][1]*m3[1][0] + m2[1][2]*m3[2][0]; 
-         m1[1][1]= m2[1][0]*m3[0][1] + m2[1][1]*m3[1][1] + m2[1][2]*m3[2][1]; 
-         m1[1][2]= m2[1][0]*m3[0][2] + m2[1][1]*m3[1][2] + m2[1][2]*m3[2][2]; 
+       /* m1[i][j] = m2[i][k]*m3[k][j], args are flipped!  */
+       m1[0][0]= m2[0][0]*m3[0][0] + m2[0][1]*m3[1][0] + m2[0][2]*m3[2][0]; 
+       m1[0][1]= m2[0][0]*m3[0][1] + m2[0][1]*m3[1][1] + m2[0][2]*m3[2][1]; 
+       m1[0][2]= m2[0][0]*m3[0][2] + m2[0][1]*m3[1][2] + m2[0][2]*m3[2][2]; 
 
-         m1[2][0]= m2[2][0]*m3[0][0] + m2[2][1]*m3[1][0] + m2[2][2]*m3[2][0]; 
-         m1[2][1]= m2[2][0]*m3[0][1] + m2[2][1]*m3[1][1] + m2[2][2]*m3[2][1]; 
-         m1[2][2]= m2[2][0]*m3[0][2] + m2[2][1]*m3[1][2] + m2[2][2]*m3[2][2]; 
+       m1[1][0]= m2[1][0]*m3[0][0] + m2[1][1]*m3[1][0] + m2[1][2]*m3[2][0]; 
+       m1[1][1]= m2[1][0]*m3[0][1] + m2[1][1]*m3[1][1] + m2[1][2]*m3[2][1]; 
+       m1[1][2]= m2[1][0]*m3[0][2] + m2[1][1]*m3[1][2] + m2[1][2]*m3[2][2]; 
+
+       m1[2][0]= m2[2][0]*m3[0][0] + m2[2][1]*m3[1][0] + m2[2][2]*m3[2][0]; 
+       m1[2][1]= m2[2][0]*m3[0][1] + m2[2][1]*m3[1][1] + m2[2][2]*m3[2][1]; 
+       m1[2][2]= m2[2][0]*m3[0][2] + m2[2][1]*m3[1][2] + m2[2][2]*m3[2][2]; 
 }
 
 void mul_m4_m4m3(float (*m1)[4], float (*m3)[4], float (*m2)[3])
@@ -321,17 +332,23 @@ void mul_project_m4_v4(float mat[][4], float *vec)
        vec[2] /= w;
 }
 
-void mul_m4_v4(float mat[][4], float *vec)
+void mul_v4_m4v4(float r[4], float mat[4][4], float v[4])
 {
-       float x,y,z;
+       float x, y, z;
 
-       x=vec[0]; 
-       y=vec[1]; 
-       z= vec[2];
-       vec[0]=x*mat[0][0] + y*mat[1][0] + z*mat[2][0] + mat[3][0]*vec[3];
-       vec[1]=x*mat[0][1] + y*mat[1][1] + z*mat[2][1] + mat[3][1]*vec[3];
-       vec[2]=x*mat[0][2] + y*mat[1][2] + z*mat[2][2] + mat[3][2]*vec[3];
-       vec[3]=x*mat[0][3] + y*mat[1][3] + z*mat[2][3] + mat[3][3]*vec[3];
+       x= v[0]; 
+       y= v[1]; 
+       z= v[2];
+
+       r[0]= x*mat[0][0] + y*mat[1][0] + z*mat[2][0] + mat[3][0]*v[3];
+       r[1]= x*mat[0][1] + y*mat[1][1] + z*mat[2][1] + mat[3][1]*v[3];
+       r[2]= x*mat[0][2] + y*mat[1][2] + z*mat[2][2] + mat[3][2]*v[3];
+       r[3]= x*mat[0][3] + y*mat[1][3] + z*mat[2][3] + mat[3][3]*v[3];
+}
+
+void mul_m4_v4(float mat[4][4], float r[4])
+{
+       mul_v4_m4v4(r, mat, r);
 }
 
 void mul_v3_m3v3(float r[3], float M[3][3], float a[3])
index 8032cd64de5984c82981b570d8f000ebcb3dd6d3..9baf897c8309eb083345b9fe7e159df735b61534 100644 (file)
@@ -83,6 +83,14 @@ void interp_v3_v3v3v3v3(float p[3], const float v1[3], const float v2[3], const
        p[2] = v1[2]*w[0] + v2[2]*w[1] + v3[2]*w[2] + v4[2]*w[3];
 }
 
+void interp_v4_v4v4v4(float p[4], const float v1[4], const float v2[4], const float v3[4], const float w[3])
+{
+       p[0] = v1[0]*w[0] + v2[0]*w[1] + v3[0]*w[2];
+       p[1] = v1[1]*w[0] + v2[1]*w[1] + v3[1]*w[2];
+       p[2] = v1[2]*w[0] + v2[2]*w[1] + v3[2]*w[2];
+       p[3] = v1[3]*w[0] + v2[3]*w[1] + v3[3]*w[2];
+}
+
 void mid_v3_v3v3(float *v, float *v1, float *v2)
 {
        v[0]= 0.5f*(v1[0] + v2[0]);
index f82daaa8af642f0fbe50d18aacf6aff456fcaa6d..974832051aff48b495ec7e2666e6b6d839459fc6 100644 (file)
@@ -188,6 +188,12 @@ MINLINE void mul_v3_v3(float r[3], const float a[3])
        r[2] *= a[2];
 }
 
+MINLINE void madd_v2_v2fl(float r[2], const float a[2], float f)
+{
+       r[0] += a[0]*f;
+       r[1] += a[1]*f;
+}
+
 MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
 {
        r[0] += a[0]*f;
@@ -222,6 +228,14 @@ MINLINE void madd_v3_v3v3v3(float r[3], const float a[3], const float b[3], cons
        r[2] = a[2] + b[2]*c[2];
 }
 
+MINLINE void madd_v4_v4fl(float r[4], const float a[4], float f)
+{
+       r[0] += a[0]*f;
+       r[1] += a[1]*f;
+       r[2] += a[2]*f;
+       r[3] += a[3]*f;
+}
+
 MINLINE void mul_v3_v3v3(float *v, const float *v1, const float *v2)
 {
        v[0] = v1[0] * v2[0];
@@ -305,6 +319,14 @@ MINLINE float len_v3v3(const float a[3], const float b[3])
        return len_v3(d);
 }
 
+MINLINE float len_squared_v3v3(const float a[3], const float b[3])
+{
+       float d[3];
+
+       sub_v3_v3v3(d, b, a);
+       return dot_v3v3(d, d);
+}
+
 MINLINE float normalize_v2_v2(float r[2], const float a[2])
 {
        float d= dot_v2v2(a, a);
index 6e2eff6f97a5fe9150cc4c57ebd624ed79deb046..aa87a56a60c7455cbd1eed0371b159d6534f7f51 100644 (file)
@@ -106,6 +106,7 @@ static pthread_mutex_t _image_lock = PTHREAD_MUTEX_INITIALIZER;
 static pthread_mutex_t _preview_lock = PTHREAD_MUTEX_INITIALIZER;
 static pthread_mutex_t _viewer_lock = PTHREAD_MUTEX_INITIALIZER;
 static pthread_mutex_t _custom1_lock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t _rcache_lock = PTHREAD_MUTEX_INITIALIZER;
 static pthread_t mainid;
 static int thread_levels= 0;   /* threads can be invoked inside threads */
 
@@ -340,6 +341,8 @@ void BLI_lock_thread(int type)
                pthread_mutex_lock(&_viewer_lock);
        else if (type==LOCK_CUSTOM1)
                pthread_mutex_lock(&_custom1_lock);
+       else if (type==LOCK_RCACHE)
+               pthread_mutex_lock(&_rcache_lock);
 }
 
 void BLI_unlock_thread(int type)
@@ -352,6 +355,8 @@ void BLI_unlock_thread(int type)
                pthread_mutex_unlock(&_viewer_lock);
        else if(type==LOCK_CUSTOM1)
                pthread_mutex_unlock(&_custom1_lock);
+       else if(type==LOCK_RCACHE)
+               pthread_mutex_unlock(&_rcache_lock);
 }
 
 /* Mutex Locks */
index bc50befa2a904046edbab586f69908612c2c22bb..4f0805cd0d649827b2409d1a62d9a648bc62dd6d 100644 (file)
@@ -1764,7 +1764,7 @@ static void harmonic_coordinates_bind(Scene *scene, MeshDeformModifierData *mmd,
        else
                mdb->weights= MEM_callocN(sizeof(float)*mdb->totvert*mdb->totcagevert, "MDefWeights");
 
-       mdb->memarena= BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE);
+       mdb->memarena= BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "harmonic coords arena");
        BLI_memarena_use_calloc(mdb->memarena);
 
        /* make bounding box equal size in all directions, add padding, and compute
@@ -1804,7 +1804,7 @@ static void harmonic_coordinates_bind(Scene *scene, MeshDeformModifierData *mmd,
 
        /* free temporary MDefBoundIsects */
        BLI_memarena_free(mdb->memarena);
-       mdb->memarena= BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE);
+       mdb->memarena= BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "harmonic coords arena");
 
        /* start with all cells untyped */
        for(a=0; a<mdb->size3; a++)
index d08ec2f92c515245010357bd654677b299de44a5..1e2b166ca82837b9a14c63703f9415126d219c1d 100644 (file)
@@ -518,12 +518,14 @@ static void init_internal_icons()
        else
                icontype= ICON_TYPE_BUFFER;
        
-       for (y=0; y<ICON_GRID_ROWS; y++) {
-               for (x=0; x<ICON_GRID_COLS; x++) {
-                       def_internal_icon(bbuf, BIFICONID_FIRST + y*ICON_GRID_COLS + x,
-                               x*(ICON_GRID_W+ICON_GRID_MARGIN)+ICON_GRID_MARGIN,
-                               y*(ICON_GRID_H+ICON_GRID_MARGIN)+ICON_GRID_MARGIN, ICON_GRID_W,
-                               icontype);
+       if(bbuf) {
+               for (y=0; y<ICON_GRID_ROWS; y++) {
+                       for (x=0; x<ICON_GRID_COLS; x++) {
+                               def_internal_icon(bbuf, BIFICONID_FIRST + y*ICON_GRID_COLS + x,
+                                       x*(ICON_GRID_W+ICON_GRID_MARGIN)+ICON_GRID_MARGIN,
+                                       y*(ICON_GRID_H+ICON_GRID_MARGIN)+ICON_GRID_MARGIN, ICON_GRID_W,
+                                       icontype);
+                       }
                }
        }
 
index 72219df04c9542519450c0f7352d31149f0edd93..b66fa6da06c80afb66e73cb04761e056dd2abac0 100644 (file)
@@ -648,8 +648,7 @@ void extrude_mesh(Scene *scene, Object *obedit, EditMesh *em, wmOperator *op, sh
                        * This shouldn't be necessary, derived queries should be
                        * automatically building this data if invalid. Or something.
                        */
-//             DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
-               object_handle_update(scene, obedit);
+               DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
 
                /* individual faces? */
 //             BIF_TransformSetUndo("Extrude");
index d3f9847d9b90b2e10460d8a02c349ea9394136b8..9a9461da62e52443def258588af7cd12716e6c31 100644 (file)
@@ -263,7 +263,7 @@ static int objects_bake_render_invoke(bContext *C, wmOperator *op, wmEvent *_eve
                steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, WM_JOB_EXCL_RENDER|WM_JOB_PRIORITY);
                WM_jobs_customdata(steve, bkr, bake_freejob);
                WM_jobs_timer(steve, 0.2, NC_IMAGE, 0); /* TODO - only draw bake image, can we enforce this */
-               WM_jobs_callbacks(steve, bake_startjob, NULL, bake_update);
+               WM_jobs_callbacks(steve, bake_startjob, NULL, bake_update, NULL);
 
                G.afbreek= 0;
 
index 6f5b8924a13206c825e99cda2a6e59030472a59e..1647892fd13c240477f8a4b9ec79fef1d856eb8c 100644 (file)
@@ -1005,7 +1005,7 @@ int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain)
        /* setup job */
        WM_jobs_customdata(steve, fb, fluidbake_free);
        WM_jobs_timer(steve, 0.1, NC_SCENE|ND_FRAME, NC_SCENE|ND_FRAME);
-       WM_jobs_callbacks(steve, fluidbake_startjob, NULL, NULL);
+       WM_jobs_callbacks(steve, fluidbake_startjob, NULL, NULL, NULL);
        
        WM_jobs_start(CTX_wm_manager(C), steve);
 
index 187f726519fc80ee97eab7a17b2c73b97806e703..47dd95eb17bbeb8a1223fea8b82327d7c77d09c4 100644 (file)
@@ -87,11 +87,11 @@ void image_buffer_rect_update(Scene *scene, RenderResult *rr, ImBuf *ibuf, volat
 
                /* xmin here is first subrect x coord, xmax defines subrect width */
                xmin = renrect->xmin + rr->crop;
-               xmax = renrect->xmax - xmin - rr->crop;
+               xmax = renrect->xmax - xmin + rr->crop;
                if (xmax<2) return;
 
                ymin= renrect->ymin + rr->crop;
-               ymax= renrect->ymax - ymin - rr->crop;
+               ymax= renrect->ymax - ymin + rr->crop;
                if(ymax<2)
                        return;
                renrect->ymin= renrect->ymax;
@@ -544,6 +544,13 @@ static void render_startjob(void *rjv, short *stop, short *do_update)
 //             free_main(mainp);
 }
 
+static void render_endjob(void *rjv)
+{
+       /* XXX render stability hack */
+       G.rendering = 0;
+       WM_main_add_notifier(NC_WINDOW, NULL);
+}
+
 /* called by render, check job 'stop' value or the global */
 static int render_breakjob(void *rjv)
 {
@@ -560,8 +567,9 @@ static int render_breakjob(void *rjv)
 static int screen_render_modal(bContext *C, wmOperator *op, wmEvent *event)
 {
        /* no running blender, remove handler and pass through */
-       if(0==WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C)))
+       if(0==WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C))) {
                return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH;
+       }
 
        /* running render */
        switch (event->type) {
@@ -645,7 +653,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event)
        steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, WM_JOB_EXCL_RENDER|WM_JOB_PRIORITY);
        WM_jobs_customdata(steve, rj, render_freejob);
        WM_jobs_timer(steve, 0.2, NC_SCENE|ND_RENDER_RESULT, 0);
-       WM_jobs_callbacks(steve, render_startjob, NULL, NULL);
+       WM_jobs_callbacks(steve, render_startjob, NULL, NULL, render_endjob);
 
        /* get a render result image, and make sure it is empty */
        ima= BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result");
@@ -669,6 +677,11 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event)
        WM_cursor_wait(0);
        WM_event_add_notifier(C, NC_SCENE|ND_RENDER_RESULT, scene);
 
+       /* we set G.rendering here already instead of only in the job, this ensure
+          main loop or other scene updates are disabled in time, since they may
+          have started before the job thread */
+       G.rendering = 1;
+
        /* add modal handler for ESC */
        WM_event_add_modal_handler(C, op);
 
index aef652cd116554554999f9e870947c57eb30eb5d..50d45f0c8e8722e1a71c1a4f435a932382e100c7 100644 (file)
@@ -1121,7 +1121,7 @@ void ED_preview_icon_job(const bContext *C, void *owner, ID *id, unsigned int *r
        /* setup job */
        WM_jobs_customdata(steve, sp, shader_preview_free);
        WM_jobs_timer(steve, 0.1, NC_MATERIAL, NC_MATERIAL);
-       WM_jobs_callbacks(steve, common_preview_startjob, NULL, NULL);
+       WM_jobs_callbacks(steve, common_preview_startjob, NULL, NULL, NULL);
 
        WM_jobs_start(CTX_wm_manager(C), steve);
 }
@@ -1147,7 +1147,7 @@ void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, M
        /* setup job */
        WM_jobs_customdata(steve, sp, shader_preview_free);
        WM_jobs_timer(steve, 0.1, NC_MATERIAL, NC_MATERIAL);
-       WM_jobs_callbacks(steve, common_preview_startjob, NULL, shader_preview_updatejob);
+       WM_jobs_callbacks(steve, common_preview_startjob, NULL, shader_preview_updatejob, NULL);
        
        WM_jobs_start(CTX_wm_manager(C), steve);
 }
index b6cb6978dc1c26afb64cbaed450bf661ec5b765a..122424385bea6c547c040144b0706b3047d0be06 100644 (file)
@@ -323,7 +323,7 @@ static int screencast_exec(bContext *C, wmOperator *op)
        /* setup job */
        WM_jobs_customdata(steve, sj, screenshot_freejob);
        WM_jobs_timer(steve, 0.1, 0, NC_SCREEN|ND_SCREENCAST);
-       WM_jobs_callbacks(steve, screenshot_startjob, NULL, screenshot_updatejob);
+       WM_jobs_callbacks(steve, screenshot_startjob, NULL, screenshot_updatejob, NULL);
        
        WM_jobs_start(CTX_wm_manager(C), steve);
        
index df2e4032257946d65e9046f06f4579d0a46f9a9e..40bc4dc4c875560f19124758a66e2345a3e9e0b9 100644 (file)
@@ -3083,7 +3083,7 @@ static void project_paint_begin(ProjPaintState *ps)
                ps->thread_tot = BLI_system_thread_count();
        }
        for (a=0; a<ps->thread_tot; a++) {
-               ps->arena_mt[a] = BLI_memarena_new(1<<16);
+               ps->arena_mt[a] = BLI_memarena_new(1<<16, "project paint arena");
        }
        
        arena = ps->arena_mt[0]; 
@@ -3706,7 +3706,7 @@ static void *do_projectpaint_thread(void *ph_v)
                pos_ofs[0] = pos[0] - lastpos[0];
                pos_ofs[1] = pos[1] - lastpos[1];
                
-               smearArena = BLI_memarena_new(1<<16);
+               smearArena = BLI_memarena_new(1<<16, "paint smear arena");
        }
        
        /* avoid a square root with every dist comparison */
index 06a574d2e83177e312b1e4e2128b45192b7be1fb..97cee5c730f5b3c09b4ec3fb2f9287412fc1dd4c 100644 (file)
@@ -262,6 +262,8 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn)
                                case ND_KEYINGSET:
                                        buttons_area_redraw(sa, BCONTEXT_SCENE);
                                        break;
+                               case ND_RENDER_RESULT:
+                                       break;
                                case ND_MODE:
                                case ND_LAYER:
                                default:
index 9dd16586946773c9a17a47a683fa92eb0fb8ae54..b5754404a0f8e4f62c3463af87b8756a180b1af0 100644 (file)
@@ -1352,7 +1352,7 @@ void thumbnails_start(struct FileList* filelist, const struct bContext* C)
        steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), filelist, 0);
        WM_jobs_customdata(steve, tj, thumbnails_free);
        WM_jobs_timer(steve, 0.5, NC_WINDOW, NC_WINDOW);
-       WM_jobs_callbacks(steve, thumbnails_startjob, NULL, thumbnails_update);
+       WM_jobs_callbacks(steve, thumbnails_startjob, NULL, thumbnails_update, NULL);
 
        /* start the job */
        WM_jobs_start(CTX_wm_manager(C), steve);
index 5d3c00b113dd5a681d4ae5fa221f6a41eb760079..7e79b4b822e1990d39228f24109a531a0359ad92 100644 (file)
@@ -349,11 +349,21 @@ static void node_shader_buts_vect_math(uiLayout *layout, bContext *C, PointerRNA
 
 static void node_shader_buts_geometry(uiLayout *layout, bContext *C, PointerRNA *ptr)
 {
+       PointerRNA obptr= CTX_data_pointer_get(C, "active_object");
        uiLayout *col;
-       
+
        col= uiLayoutColumn(layout, 0);
-       uiItemR(col, ptr, "uv_layer", 0, "UV", 0);
-       uiItemR(col, ptr, "color_layer", 0, "VCol", 0);
+
+       if(obptr.data && RNA_enum_get(&obptr, "type") == OB_MESH) {
+               PointerRNA dataptr= RNA_pointer_get(&obptr, "data");
+
+               uiItemPointerR(col, ptr, "uv_layer", &dataptr, "uv_textures", "", 0);
+               uiItemPointerR(col, ptr, "color_layer", &dataptr, "vertex_colors", "", 0);
+       }
+       else {
+               uiItemR(col, ptr, "uv_layer", 0, "UV", 0);
+               uiItemR(col, ptr, "color_layer", 0, "VCol", 0);
+       }
 }
 
 static void node_shader_buts_dynamic(uiLayout *layout, bContext *C, PointerRNA *ptr)
index f1aa9f745eed60ca33b34e90db869c4e1d3fe6a6..767dd7537664c84cb8e76619e7532748f0c1fce4 100644 (file)
@@ -176,7 +176,7 @@ void snode_composite_job(const bContext *C, ScrArea *sa)
        /* setup job */
        WM_jobs_customdata(steve, cj, compo_freejob);
        WM_jobs_timer(steve, 0.1, NC_SCENE, NC_SCENE|ND_COMPO_RESULT);
-       WM_jobs_callbacks(steve, compo_startjob, compo_initjob, compo_updatejob);
+       WM_jobs_callbacks(steve, compo_startjob, compo_initjob, compo_updatejob, NULL);
        
        WM_jobs_start(CTX_wm_manager(C), steve);
        
index 44baea0737f344bd9d8b31058cc66f4c909c1804..291c67d22ff02f5db19f5ae18fc14afa36eb97f2 100644 (file)
@@ -4764,11 +4764,9 @@ static void restrictbutton_r_lay_cb(bContext *C, void *poin, void *poin2)
 
 static void restrictbutton_modifier_cb(bContext *C, void *poin, void *poin2)
 {
-       Scene *scene = (Scene *)poin;
        Object *ob = (Object *)poin2;
        
        DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
-       object_handle_update(scene, ob);
 
        WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
 }
index ba521a5fb1af559c8888436d4f3bf91ed796d903..1d8e01f2b1becbbbeff6109163ef4b910cd25518 100644 (file)
@@ -13,5 +13,7 @@ incs += ' #source/kernel/gen_system'
 
 if env['WITH_BF_GAMEENGINE']:
        defs.append('GAMEBLENDER=1')
+if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'):
+       incs += ' ' + env['BF_PTHREADS_INC']
 
 env.BlenderLib ( 'bf_editors_space_view3d', sources, Split(incs), defines = defs, libtype=['core'], priority=[40] )
index e3bf1e8324759896c9a81b758111e8ac16971069..335e17b87968f079a4c1d0e921ce7adf27d7004d 100644 (file)
@@ -839,12 +839,6 @@ void draw_uvedit_main(SpaceImage *sima, ARegion *ar, Scene *scene, Object *obedi
        show_uvshadow= ED_space_image_show_uvshadow(sima, obedit);
 
        if(show_uvedit || show_uvshadow) {
-               /* this is basically the same object_handle_update as in the 3d view,
-                * here we have to do it as well for the object we are editing if we
-                * are displaying the final result */
-               if(obedit && (sima->flag & SI_DRAWSHADOW))
-                       object_handle_update(scene, obedit);
-
                if(show_uvshadow)
                        draw_uvs_shadow(sima, obedit);
                else
index dbc04f8549750d16433717425853bc255368ef9a..9dfa0934ad206b15f840f5da451cebe45f69c2a4 100644 (file)
@@ -4027,7 +4027,7 @@ static void p_smooth(PChart *chart)
        MEM_freeN(nodesx);
        MEM_freeN(nodesy);
 
-       arena = BLI_memarena_new(1<<16);
+       arena = BLI_memarena_new(1<<16, "param smooth arena");
        root = p_node_new(arena, tri, esize*2, minv, maxv, 0);
 
        for (v=chart->verts; v; v=v->nextlink)
@@ -4047,7 +4047,7 @@ ParamHandle *param_construct_begin()
        PHandle *handle = MEM_callocN(sizeof*handle, "PHandle");
        handle->construction_chart = p_chart_new(handle);
        handle->state = PHANDLE_STATE_ALLOCATED;
-       handle->arena = BLI_memarena_new((1<<16));
+       handle->arena = BLI_memarena_new((1<<16), "param construct arena");
        handle->aspx = 1.0f;
        handle->aspy = 1.0f;
 
index 28dd4911ffdea32259b388ebbe5ed7cd39c7eaa0..26566857e03c0279d12c2cb03f1ffef0869d6558 100644 (file)
@@ -27,7 +27,7 @@
 FILE(GLOB SRC intern/*.c)
 
 SET(INC 
-       . ../blenlib ../blenkernel ../makesdna ../include
+       . ../blenlib ../blenkernel ../makesdna ../makesrna ../include
        ../../../extern/glew/include ../../../intern/guardedalloc ../../../intern/smoke/extern ../imbuf)
 
 ADD_DEFINITIONS(-DGLEW_STATIC)
index 710dbde21b2877598fe9784ecd51b31d2325b130..056de9ab708a96bef8cfdfab908b43c8b87d28f8 100644 (file)
@@ -302,7 +302,7 @@ short imb_addrectImBuf(struct ImBuf * ibuf)
        imb_freerectImBuf(ibuf);
 
        size = ibuf->x * ibuf->y;
-        size = size * sizeof(unsigned int);
+       size = size * sizeof(unsigned int);
 
        if ( (ibuf->rect = MEM_mapallocN(size, "imb_addrectImBuf")) ){
                ibuf->mall |= IB_rect;
index 6eecd091b7f05fdd345add920d8c9773f8cc46e0..92e35326118051fa7a5e95404e0737fcefd5fc4c 100644 (file)
@@ -78,7 +78,7 @@ typedef enum PropertyUnit {
        PROP_UNIT_AREA = (2<<16),                       /* m^2 */
        PROP_UNIT_VOLUME = (3<<16),                     /* m^3 */
        PROP_UNIT_MASS = (4<<16),                       /* kg */
-       PROP_UNIT_ROTATION = (5<<16),           /* rad */
+       PROP_UNIT_ROTATION = (5<<16),           /* radians */
        PROP_UNIT_TIME = (6<<16),                       /* frame */
        PROP_UNIT_VELOCITY = (7<<16),           /* m/s */
        PROP_UNIT_ACCELERATION = (8<<16)        /* m/(s^2) */
index c9db05c30b13fee31c6d02470a23816cfce213db..c568fea38d71929f7c25734cacd3590ca244c38c 100644 (file)
@@ -30,7 +30,9 @@
 
 #include "MEM_guardedalloc.h"
 
+#include "RNA_access.h"
 #include "RNA_define.h"
+#include "RNA_types.h"
 
 #include "rna_internal.h"
 
@@ -483,13 +485,13 @@ static char *rna_def_property_get_func(FILE *f, StructRNA *srna, PropertyRNA *pr
 
                                        if(dp->dnaarraylength == 1) {
                                                if(prop->type == PROP_BOOLEAN && dp->booleanbit)
-                                                       fprintf(f, "            values[i]= (%s(data->%s & (%d<<i)) != 0);\n", (dp->booleannegative)? "!": "", dp->dnaname, dp->booleanbit);
+                                                       fprintf(f, "            values[i]= %s((data->%s & (%d<<i)) != 0);\n", (dp->booleannegative)? "!": "", dp->dnaname, dp->booleanbit);
                                                else
                                                        fprintf(f, "            values[i]= (%s)%s((&data->%s)[i]);\n", rna_type_type(prop), (dp->booleannegative)? "!": "", dp->dnaname);
                                        }
                                        else {
                                                if(prop->type == PROP_BOOLEAN && dp->booleanbit) {
-                                                       fprintf(f, "            values[i]= (%s(data->%s[i] & ", (dp->booleannegative)? "!": "", dp->dnaname);
+                                                       fprintf(f, "            values[i]= %s((data->%s[i] & ", (dp->booleannegative)? "!": "", dp->dnaname);
                                                        rna_int_print(f, dp->booleanbit);
                                                        fprintf(f, ") != 0);\n");
                                                }
@@ -514,7 +516,7 @@ static char *rna_def_property_get_func(FILE *f, StructRNA *srna, PropertyRNA *pr
                                else {
                                        rna_print_data_get(f, dp);
                                        if(prop->type == PROP_BOOLEAN && dp->booleanbit) {
-                                               fprintf(f, "    return (%s((data->%s) & ", (dp->booleannegative)? "!": "", dp->dnaname);
+                                               fprintf(f, "    return %s(((data->%s) & ", (dp->booleannegative)? "!": "", dp->dnaname);
                                                rna_int_print(f, dp->booleanbit);
                                                fprintf(f, ") != 0);\n");
                                        }
@@ -1684,7 +1686,7 @@ static const char *rna_property_subtype_unit(PropertyType type)
                case PROP_UNIT_TIME:            return "PROP_UNIT_TIME";
                case PROP_UNIT_VELOCITY:        return "PROP_UNIT_VELOCITY";
                case PROP_UNIT_ACCELERATION:return "PROP_UNIT_ACCELERATION";
-               default: return "PROP_UNKNOWN";
+               default:                                        return "PROP_UNIT_UNKNOWN";
        }
 }
 
index 6d1ae6db5628195c1a9f66832d90e27f27ceb6e5..42c9b3d38e7a6a7f78596a28d76b76727da6f941 100644 (file)
@@ -1322,7 +1322,7 @@ static void rna_def_object_modifiers(BlenderRNA *brna, PropertyRNA *cprop)
        /* add target */
        func= RNA_def_function(srna, "new", "rna_Object_modifier_new");
        RNA_def_function_flag(func, FUNC_USE_CONTEXT|FUNC_USE_REPORTS);
-       RNA_def_function_ui_description(func, "Add a new bone.");
+       RNA_def_function_ui_description(func, "Add a new modifier.");
        parm= RNA_def_string(func, "name", "Name", 0, "", "New name for the bone.");
        RNA_def_property_flag(parm, PROP_REQUIRED);
        /* modifier to add */
index 238098e85e200532b03ac48b021c1448cf9b15e3..4cd092972d16e3952385b574f6c719702d66b15d 100644 (file)
@@ -869,8 +869,6 @@ static void rna_def_effector_weight(BlenderRNA *brna)
        
        /* General */
        prop= RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE);
-       RNA_def_property_pointer_sdna(prop, NULL, "group");
-       RNA_def_property_struct_type(prop, "Group");
        RNA_def_property_flag(prop, PROP_EDITABLE);
        RNA_def_property_ui_text(prop, "Effector Group", "Limit effectors to this Group");
        RNA_def_property_update(prop, 0, "rna_EffectorWeight_dependency_update");
index e5c6d970687586a3c4f34b71771789dedd38122b..7e186f0a587577425ec2143f18453c94678184e9 100644 (file)
@@ -2366,6 +2366,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Edge Color", "");
        RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
        
+       /* threads */
        prop= RNA_def_property(srna, "threads", PROP_INT, PROP_NONE);
        RNA_def_property_int_sdna(prop, NULL, "threads");
        RNA_def_property_range(prop, 1, BLENDER_MAX_THREADS);
@@ -2379,6 +2380,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Threads Mode", "Determine the amount of render threads used");
        RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
        
+       /* motion blur */
        prop= RNA_def_property(srna, "motion_blur", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "mode", R_MBLUR);
        RNA_def_property_ui_text(prop, "Motion Blur", "Use multi-sampled 3D scene motion blur");
@@ -2390,6 +2392,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Motion Samples", "Number of scene samples to take with motion blur");
        RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
        
+       /* border */
        prop= RNA_def_property(srna, "use_border", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "mode", R_BORDER);
        RNA_def_property_ui_text(prop, "Border", "Render a user-defined border region, within the frame size. Note, this disables save_buffers and full_sample");
index ad7f80f0907c2043a94e2aace60a4a67e6c56f3a..dc1598fa6e96156c01e57be4348aa3e8b580edac 100644 (file)
@@ -10,8 +10,11 @@ incs += ' ../include ../blenlib ../makesdna ../blenkernel ../blenkernel/intern'
 
 incs += ' ' + env['BF_ZLIB_INC']
 
-defs = ''
+defs = []
+
+if env['BF_NO_ELBEEM']:
+       defs.append('DISABLE_ELBEEM')
 
 env.BlenderLib ( libname = 'modifiers', sources = sources,
-                 includes = Split(incs), defines = Split(defs),
-                 libtype=['core','player'], priority = [180, 20] )
\ No newline at end of file
+                 includes = Split(incs), defines=defs,
+                 libtype=['core','player'], priority = [180, 20] )
index bb1ede089e98cfe9828557ec20e56e461764f01c..6614625a6500186a6adcf41cf5cac1b6f283789d 100644 (file)
@@ -862,7 +862,7 @@ static void push_propagate_stack(SmoothEdge *edge, SmoothVert *vert, SmoothMesh
        }
        else {
                if(!mesh->arena) {
-                       mesh->arena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE);
+                       mesh->arena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "edgesplit arena");
                        BLI_memarena_use_calloc(mesh->arena);
                }
 
index 6e40c544c6fab425d1fcbe5e59d3efb3466a60a8..c136f945ca510c878ee875d3b840ce4357b21775 100644 (file)
@@ -15,7 +15,7 @@
 #
 # 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 #
 # The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
 # All rights reserved.
index b9e9a46b1a9ee8e350f6742ffae4a4c260a1d064..84ec56e131aac2c87e6832ef15a27c7286accb40 100644 (file)
@@ -497,12 +497,22 @@ void RE_rayobject_merge_bb(RayObject *r, float *min, float *max)
        else if(RE_rayobject_isVlakPrimitive(r))
        {
                VlakPrimitive *face = (VlakPrimitive*) RE_rayobject_align(r);
-               VlakRen *vlr = face->face;
+               RayFace nface;
+               RE_rayface_from_vlak(&nface, face->ob, face->face);
+
+               if(face->ob->transform_primitives)
+               {
+                       mul_m4_v3(face->ob->mat, nface.v1);
+                       mul_m4_v3(face->ob->mat, nface.v2);
+                       mul_m4_v3(face->ob->mat, nface.v3);
+                       if(RE_rayface_isQuad(&nface))
+                               mul_m4_v3(face->ob->mat, nface.v4);
+               }
 
-               DO_MINMAX( vlr->v1->co, min, max );
-               DO_MINMAX( vlr->v2->co, min, max );
-               DO_MINMAX( vlr->v3->co, min, max );
-               if(vlr->v4) DO_MINMAX( vlr->v4->co, min, max );
+               DO_MINMAX( nface.v1, min, max );
+               DO_MINMAX( nface.v2, min, max );
+               DO_MINMAX( nface.v3, min, max );
+               if(RE_rayface_isQuad(&nface)) DO_MINMAX( nface.v4, min, max );
        }
        else if(RE_rayobject_isRayAPI(r))
        {
index cdc3be4c52156c89fb7347e92fd51d0e11bbb56a..afffdd44f1fd8125fb7071061e8979cdb1c3f94e 100644 (file)
@@ -52,10 +52,10 @@ void bvh_done<QBVHTree>(QBVHTree *obj)
        rtbuild_done(obj->builder, &obj->rayobj.control);
        
        //TODO find a away to exactly calculate the needed memory
-       MemArena *arena1 = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE);
+       MemArena *arena1 = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "qbvh arena");
                                           BLI_memarena_use_malloc(arena1);
 
-       MemArena *arena2 = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE);
+       MemArena *arena2 = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "qbvh arena 2");
                                           BLI_memarena_use_malloc(arena2);
                                           BLI_memarena_use_align(arena2, 16);
 
index 67af596e3014eb0b2d7e26b407d594d1912860ea..389512ce469ee663eb9845d3366a78cdda53ab9d 100644 (file)
@@ -63,10 +63,10 @@ void bvh_done<SVBVHTree>(SVBVHTree *obj)
        rtbuild_done(obj->builder, &obj->rayobj.control);
        
        //TODO find a away to exactly calculate the needed memory
-       MemArena *arena1 = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE);
+       MemArena *arena1 = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "svbvh arena");
                                           BLI_memarena_use_malloc(arena1);
 
-       MemArena *arena2 = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE);
+       MemArena *arena2 = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "svbvh arena2");
                                           BLI_memarena_use_malloc(arena2);
                                           BLI_memarena_use_align(arena2, 16);
 
index 0190b971d84765eba333edcc5cebaebc5480d1ae..de1e6d349bec65964abdfb7453f99080ce8778df 100644 (file)
@@ -76,7 +76,7 @@ void bvh_done<VBVHTree>(VBVHTree *obj)
        rtbuild_done(obj->builder, &obj->rayobj.control);
        
        //TODO find a away to exactly calculate the needed memory
-       MemArena *arena1 = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE);
+       MemArena *arena1 = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "vbvh arena");
                                           BLI_memarena_use_malloc(arena1);
        
        //Build and optimize the tree
@@ -101,7 +101,7 @@ void bvh_done<VBVHTree>(VBVHTree *obj)
        {
 /*
        TODO
-               MemArena *arena2 = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE);
+               MemArena *arena2 = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "vbvh arena2");
                                                   BLI_memarena_use_malloc(arena2);
                                                   
                //Finds the optimal packing of this tree using a given cost model
index c313549f9b94453126e60b42a966d80d652062f6..5aaa66e7712ce6a5bf44cf348a186827edc033ef 100644 (file)
@@ -15,7 +15,7 @@
 #
 # 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 #
 # The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
 # All rights reserved.
index db242b0b1d974f9f09c722a8291b48a8ccc6ab7b..189c029d2e2266bc36a49812c9a226f5f92d4c76 100644 (file)
@@ -512,7 +512,7 @@ static void calc_vertexnormals(Render *re, ObjectRen *obr, int do_tangent, int d
        int a;
 
        if(do_nmap_tangent) {
-               arena= BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE);
+               arena= BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "nmap tangent arena");
                BLI_memarena_use_calloc(arena);
 
                vtangents= MEM_callocN(sizeof(VertexTangent*)*obr->totvert, "VertexTangent");
@@ -4949,7 +4949,7 @@ void RE_Database_FromScene(Render *re, Scene *scene, unsigned int lay, int use_c
        
        /* XXX add test if dbase was filled already? */
        
-       re->memArena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE);
+       re->memArena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "render db arena");
        re->totvlak=re->totvert=re->totstrand=re->totlamp=re->tothalo= 0;
        re->lights.first= re->lights.last= NULL;
        re->lampren.first= re->lampren.last= NULL;
@@ -5099,7 +5099,7 @@ static void database_fromscene_vectors(Render *re, Scene *scene, unsigned int la
        
        /* XXX add test if dbase was filled already? */
        
-       re->memArena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE);
+       re->memArena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "vector render db arena");
        re->totvlak=re->totvert=re->totstrand=re->totlamp=re->tothalo= 0;
        re->i.totface=re->i.totvert=re->i.totstrand=re->i.totlamp=re->i.tothalo= 0;
        re->lights.first= re->lights.last= NULL;
@@ -5635,7 +5635,7 @@ void RE_Database_Baking(Render *re, Scene *scene, unsigned int lay, int type, Ob
        }
        
        /* setup render stuff */
-       re->memArena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE);
+       re->memArena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "bake db arena");
        
        re->totvlak=re->totvert=re->totstrand=re->totlamp=re->tothalo= 0;
        re->lights.first= re->lights.last= NULL;
index ab656ad1c3b21235d2dc7693908e99784262f88e..ff718359a3e37b9e3f333f89360020f7d0e34835 100644 (file)
@@ -660,7 +660,7 @@ static OcclusionTree *occ_tree_build(Render *re)
        tree->doindirect= (re->wrld.ao_indirect_energy > 0.0f && re->wrld.ao_indirect_bounces > 0);
 
        /* allocation */
-       tree->arena= BLI_memarena_new(0x8000 * sizeof(OccNode));
+       tree->arena= BLI_memarena_new(0x8000 * sizeof(OccNode), "occ tree arena");
        BLI_memarena_use_calloc(tree->arena);
 
        if(re->wrld.aomode & WO_AOCACHE)
index 35d969f9f219f04f28e907499b22fac3f6da840e..7101ce5daafed81614b64e91ac3349cb094e1a13 100644 (file)
@@ -2204,7 +2204,7 @@ static void isb_make_buffer(RenderPart *pa, LampRen *lar)
        isbdata->recty= pa->recty;
        
        /* branches are added using memarena (32k branches) */
-       memarena = BLI_memarena_new(0x8000 * sizeof(ISBBranch));
+       memarena = BLI_memarena_new(0x8000 * sizeof(ISBBranch), "isb arena");
        BLI_memarena_use_calloc(memarena);
        
        /* samplebuf is in camera view space (pixels) */
@@ -2300,7 +2300,7 @@ static void isb_make_buffer(RenderPart *pa, LampRen *lar)
                        if(R.osa) {
                                ISBShadfacA **isbsa= isbdata->shadfaca= MEM_callocN(pa->rectx*pa->recty*sizeof(void *), "isb shadfacs");
                                
-                               isbdata->memarena = BLI_memarena_new(0x8000 * sizeof(ISBSampleA));
+                               isbdata->memarena = BLI_memarena_new(0x8000 * sizeof(ISBSampleA), "isb arena");
                                BLI_memarena_use_calloc(isbdata->memarena);
 
                                for(rd= pa->rectdaps, x=pa->rectx*pa->recty; x>0; x--, rd++, isbsa++) {
@@ -2412,7 +2412,7 @@ static void isb_make_buffer_transp(RenderPart *pa, APixstr *apixbuf, LampRen *la
        isbdata->recty= pa->recty;
        
        /* branches are added using memarena (32k branches) */
-       memarena = BLI_memarena_new(0x8000 * sizeof(ISBBranch));
+       memarena = BLI_memarena_new(0x8000 * sizeof(ISBBranch), "isb arena");
        BLI_memarena_use_calloc(memarena);
        
        /* samplebuf is in camera view space (pixels) */
@@ -2503,7 +2503,7 @@ static void isb_make_buffer_transp(RenderPart *pa, APixstr *apixbuf, LampRen *la
                        /* copy shadow samples to persistant buffer, reduce memory overhead */
                        isbsa= isbdata->shadfaca= MEM_callocN(pa->rectx*pa->recty*sizeof(void *), "isb shadfacs");
                        
-                       isbdata->memarena = BLI_memarena_new(0x8000 * sizeof(ISBSampleA));
+                       isbdata->memarena = BLI_memarena_new(0x8000 * sizeof(ISBSampleA), "isb arena");
                        
                        for(ap= apixbuf, x=pa->rectx*pa->recty; x>0; x--, ap++, isbsa++) {
                                        
index 836a60ef4f9fe02fb681fa854c0597c964440c74..bb5f8e9b8b4b68bffcde24db8a041cefd6e7a52c 100644 (file)
@@ -779,7 +779,7 @@ void scatter_tree_build(ScatterTree *tree)
        tmppoints= MEM_callocN(sizeof(ScatterPoint*)*totpoint, "ScatterTmpPoints");
        tree->tmppoints= tmppoints;
 
-       tree->arena= BLI_memarena_new(0x8000 * sizeof(ScatterNode));
+       tree->arena= BLI_memarena_new(0x8000 * sizeof(ScatterNode), "sss tree arena");
        BLI_memarena_use_calloc(tree->arena);
 
        /* build tree */
index 1bf1f1fe582d9165c8e6a0611e766459177aa56a..e342874147336114bd0aaa35dad86f773bd3ef48 100644 (file)
@@ -320,7 +320,7 @@ StrandShadeCache *strand_shade_cache_create()
        cache= MEM_callocN(sizeof(StrandShadeCache), "StrandShadeCache");
        cache->resulthash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp);
        cache->refcounthash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp);
-       cache->memarena= BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE);
+       cache->memarena= BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "strand shade cache arena");
        
        return cache;
 }
@@ -818,7 +818,7 @@ int zbuffer_strands_abuf(Render *re, RenderPart *pa, APixstrand *apixbuf, ListBa
        bounds[2]= (2*pa->disprect.ymin - winy-1)/(float)winy;
        bounds[3]= (2*pa->disprect.ymax - winy+1)/(float)winy;
 
-       memarena= BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE);
+       memarena= BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "strand sort arena");
        firstseg= NULL;
        sortseg= sortsegments;
        totsegment= 0;
index 889b261dc4131ef713a372cc3b35ce3d7914c1aa..070b03dd195b87431d73ee80d4f8cbd18f17f4b0 100644 (file)
@@ -309,7 +309,8 @@ void                WM_jobs_timer(struct wmJob *, double timestep, unsigned int note, unsigned
 void           WM_jobs_callbacks(struct wmJob *, 
                                                          void (*startjob)(void *, short *, short *),
                                                          void (*initjob)(void *),
-                                                         void (*update)(void *));
+                                                         void (*update)(void *),
+                                                         void (*endjob)(void *));
 
 void           WM_jobs_start(struct wmWindowManager *wm, struct wmJob *);
 void           WM_jobs_stop(struct wmWindowManager *wm, void *owner);
index 343b1f68c7fb076b6cf70761b2097211e0b77770..30c0c9a7aec53e35b6cd52dccb484382c06b82e6 100644 (file)
@@ -95,6 +95,8 @@ struct wmJob {
        void (*update)(void *);
        /* free entire customdata, doesn't run in thread */
        void (*free)(void *);
+       /* gets called when job is stopped, not in thread */
+       void (*endjob)(void *);
        
        /* running jobs each have own timer */
        double timestep;
@@ -179,11 +181,13 @@ void WM_jobs_timer(wmJob *steve, double timestep, unsigned int note, unsigned in
 void WM_jobs_callbacks(wmJob *steve, 
                                           void (*startjob)(void *, short *, short *),
                                           void (*initjob)(void *),
-                                          void (*update)(void  *))
+                                          void (*update)(void  *),
+                                          void (*endjob)(void  *))
 {
        steve->startjob= startjob;
        steve->initjob= initjob;
        steve->update= update;
+       steve->endjob= endjob;
 }
 
 static void *do_job_thread(void *job_v)
@@ -266,6 +270,9 @@ static void wm_jobs_kill_job(wmWindowManager *wm, wmJob *steve)
                /* signal job to end */
                steve->stop= 1;
                BLI_end_threads(&steve->threads);
+
+               if(steve->endjob)
+                       steve->endjob(steve->run_customdata);
        }
        
        if(steve->wt)
@@ -351,6 +358,9 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt)
                                }       
                                
                                if(steve->ready) {
+                                       if(steve->endjob)
+                                               steve->endjob(steve->run_customdata);
+
                                        /* free own data */
                                        steve->run_free(steve->run_customdata);
                                        steve->run_customdata= NULL;
index cf1a4c6c0e8e375e82ced5a3e2471c1649e7774e..42883ffd4ddd9928e9473465b0ba84fcce668878 100644 (file)
@@ -49,7 +49,9 @@ INCLUDE_DIRECTORIES(../../intern/guardedalloc
        ../../extern/glew/include
 )
 
-
+IF(WIN32)
+       INCLUDE_DIRECTORIES(${PTHREADS_INC})
+ENDIF(WIN32)
 
 IF(WITH_QUICKTIME)
        ADD_DEFINITIONS(-DWITH_QUICKTIME)
index 89506bdefc84d3811e16a355449ea778c62fb492..6364f256cc552a24896ac43ce36e86898d6449fa 100644 (file)
@@ -43,4 +43,7 @@ if env['BF_BUILDINFO']:
 if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'):
     incs += ' ' + env['BF_PTHREADS_INC']
 
+if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'):
+       incs += ' ' + env['BF_PTHREADS_INC']
+
 env.BlenderLib ( libname = 'bf_creator', sources = Split(sources), includes = Split(incs), defines = defs, libtype='core', priority = 0 )