Revision: 16189
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16189
Author:   campbellbarton
Date:     2008-08-19 14:19:38 +0200 (Tue, 19 Aug 2008)

Log Message:
-----------
svn merge -r16186:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender

Modified Paths:
--------------
    branches/apricot/source/blender/blenkernel/BKE_effect.h
    branches/apricot/source/blender/blenkernel/intern/effect.c
    branches/apricot/source/blender/blenkernel/intern/implicit.c
    branches/apricot/source/blender/blenkernel/intern/particle_system.c
    branches/apricot/source/blender/makesdna/DNA_modifier_types.h
    branches/apricot/source/blender/src/buttons_object.c
    branches/apricot/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
    branches/apricot/source/gameengine/Ketsji/KX_PythonInit.cpp

Modified: branches/apricot/source/blender/blenkernel/BKE_effect.h
===================================================================
--- branches/apricot/source/blender/blenkernel/BKE_effect.h     2008-08-19 
11:53:24 UTC (rev 16188)
+++ branches/apricot/source/blender/blenkernel/BKE_effect.h     2008-08-19 
12:19:38 UTC (rev 16189)
@@ -66,7 +66,7 @@
 void                   pdDoEffectors(struct ListBase *lb, float *opco, float 
*force, float *speed, float cur_time, float loc_time, unsigned int flags);
 
 /* required for particle_system.c */
-void do_physical_effector(short type, float force_val, float distance, float 
falloff, float size, float damp, float *eff_velocity, float *vec_to_part, float 
*velocity, float *field, int planar, struct RNG *rng, float noise_factor);
+void do_physical_effector(Object *ob, float *opco, short type, float 
force_val, float distance, float falloff, float size, float damp, float 
*eff_velocity, float *vec_to_part, float *velocity, float *field, int planar, 
struct RNG *rng, float noise_factor);
 float effector_falloff(struct PartDeflect *pd, float *eff_velocity, float 
*vec_to_part);
 
 

Modified: branches/apricot/source/blender/blenkernel/intern/effect.c
===================================================================
--- branches/apricot/source/blender/blenkernel/intern/effect.c  2008-08-19 
11:53:24 UTC (rev 16188)
+++ branches/apricot/source/blender/blenkernel/intern/effect.c  2008-08-19 
12:19:38 UTC (rev 16189)
@@ -229,6 +229,60 @@
 /*                     Effectors               */
 /************************************************/
 
+// triangle - ray callback function
+static void eff_tri_ray_hit(void *userdata, int index, const BVHTreeRay *ray, 
BVHTreeRayHit *hit)
+{      
+       // whenever we hit a bounding box, we don't check further
+       hit->dist = -1;
+       hit->index = 1;
+}
+
+// get visibility of a wind ray
+static float eff_calc_visibility(Object *ob, float *co, float *dir)
+{
+       CollisionModifierData **collobjs = NULL;
+       int numcollobj = 0, i;
+       float norm[3], len = 0.0;
+       float visibility = 1.0;
+       
+       collobjs = get_collisionobjects(ob, &numcollobj);
+       
+       if(!collobjs)
+               return 0;
+       
+       VECCOPY(norm, dir);
+       VecMulf(norm, -1.0);
+       len = Normalize(norm);
+       
+       // check all collision objects
+       for(i = 0; i < numcollobj; i++)
+       {
+               CollisionModifierData *collmd = collobjs[i];
+               
+               if(collmd->bvhtree)
+               {
+                       BVHTreeRayHit hit;
+                       
+                       hit.index = -1;
+                       hit.dist = len + FLT_EPSILON;
+                       
+                       // check if the way is blocked
+                       if(BLI_bvhtree_ray_cast(collmd->bvhtree, co, norm, 
&hit, eff_tri_ray_hit, NULL)>=0)
+                       {
+                               // visibility is only between 0 and 1, 
calculated from 1-absorption
+                               visibility *= MAX2(0.0, MIN2(1.0, 
(1.0-((float)collmd->absorption)*0.01)));
+                               
+                               if(visibility <= 0.0f)
+                                       break;
+                       }
+               }
+       }
+       
+       MEM_freeN(collobjs);
+       
+       return visibility;
+}
+
 // noise function for wind e.g.
 static float wind_func(struct RNG *rng, float strength)
 {
@@ -315,12 +369,18 @@
        return falloff;
 }
 
-void do_physical_effector(short type, float force_val, float distance, float 
falloff, float size, float damp, float *eff_velocity, float *vec_to_part, float 
*velocity, float *field, int planar, struct RNG *rng, float noise_factor)
+void do_physical_effector(Object *ob, float *opco, short type, float 
force_val, float distance, float falloff, float size, float damp, float 
*eff_velocity, float *vec_to_part, float *velocity, float *field, int planar, 
struct RNG *rng, float noise_factor)
 {
        float mag_vec[3]={0,0,0};
        float temp[3], temp2[3];
        float eff_vel[3];
-       float noise = 0;
+       float noise = 0, visibility;
+       
+       // calculate visibility
+       visibility = eff_calc_visibility(ob, opco, vec_to_part);
+       if(visibility <= 0.0)
+               return;
+       falloff *= visibility;
 
        VecCopyf(eff_vel,eff_velocity);
        Normalize(eff_vel);
@@ -330,7 +390,7 @@
                        VECCOPY(mag_vec,eff_vel);
                        
                        // add wind noise here, only if we have wind
-                       if((noise_factor> 0.0f) && (force_val > FLT_EPSILON))
+                       if((noise_factor > 0.0f) && (force_val > FLT_EPSILON))
                                noise = wind_func(rng, noise_factor);
                        
                        VecMulf(mag_vec,(force_val+noise)*falloff);
@@ -393,56 +453,6 @@
        }
 }
 
-
-static void eff_tri_ray_hit(void *userdata, int index, const BVHTreeRay *ray, 
BVHTreeRayHit *hit)
-{      
-       hit->dist = -1;
-       hit->index = 1;
-}
-
-float eff_calc_visibility(Object *ob, float *co, float *dir, float cur_time)
-{
-       CollisionModifierData **collobjs = NULL;
-       int numcollobj = 0, i;
-       float norm[3], len = 0.0;
-       float visibility = 1.0;
-       
-       collobjs = get_collisionobjects(ob, &numcollobj);
-       
-       if(!collobjs)
-               return 0;
-       
-       VECCOPY(norm, dir);
-       VecMulf(norm, -1.0);
-       len = Normalize(norm);
-       
-       // check all collision objects
-       for(i = 0; i < numcollobj; i++)
-       {
-               CollisionModifierData *collmd = collobjs[i];
-               
-               if(collmd->bvhtree)
-               {
-                       BVHTreeRayHit hit;
-                       
-                       hit.index = -1;
-                       hit.dist = len + FLT_EPSILON;
-                       
-                       
-                       // check if the way is blocked
-                       if(BLI_bvhtree_ray_cast(collmd->bvhtree, co, norm, 
&hit, eff_tri_ray_hit, NULL)>=0)
-                       {
-                               visibility *= MAX2(0.0, MIN2(1.0, 
(1.0-((float)collmd->absorbation)*0.01)));
-                       }
-               }
-       }
-       
-       MEM_freeN(collobjs);
-       
-       return visibility;
-}
-
-
 /*  -------- pdDoEffectors() --------
     generic force/speed system, now used for particles and softbodies
        lb                      = listbase with objects that take part in 
effecting
@@ -478,7 +488,7 @@
        float *obloc;
        
        float distance, vec_to_part[3];
-       float falloff, visibility;
+       float falloff;
 
        /* Cycle through collected objects, get total of (1/(gravity_strength * 
dist^gravity_power)) */
        /* Check for min distance here? (yes would be cool to add that, ton) */
@@ -499,20 +509,15 @@
                VecSubf(vec_to_part, opco, ob->obmat[3]);
                distance = VecLength(vec_to_part);
 
-               falloff=effector_falloff(pd,ob->obmat[2],vec_to_part);
+               falloff=effector_falloff(pd,ob->obmat[2],vec_to_part);          
                
                if(falloff<=0.0f)
-                       continue;
-               
-               visibility = eff_calc_visibility(ob, opco, vec_to_part, 
cur_time);
-               
-               if((visibility*falloff)<=0.0f)
                        ;       /* don't do anything */
                else {
                        float field[3]={0,0,0}, tmp[3];
                        VECCOPY(field, force);
-                       
do_physical_effector(pd->forcefield,pd->f_strength,distance,
-                                                               
visibility*falloff,pd->f_dist,pd->f_damp,ob->obmat[2],vec_to_part,
+                       do_physical_effector(ob, opco, 
pd->forcefield,pd->f_strength,distance,
+                                                               
falloff,pd->f_dist,pd->f_damp,ob->obmat[2],vec_to_part,
                                                                
speed,force,pd->flag&PFIELD_PLANAR, pd->rng, pd->f_noise);
                        
                        // for softbody backward compatibility

Modified: branches/apricot/source/blender/blenkernel/intern/implicit.c
===================================================================
--- branches/apricot/source/blender/blenkernel/intern/implicit.c        
2008-08-19 11:53:24 UTC (rev 16188)
+++ branches/apricot/source/blender/blenkernel/intern/implicit.c        
2008-08-19 12:19:38 UTC (rev 16189)
@@ -1405,7 +1405,6 @@
        unsigned int numverts = cloth->numverts;
        LinkNode *search = cloth->springs;
        lfVector *winvec;
-       ClothVertex *verts = cloth->verts;
 
        VECCOPY(gravity, clmd->sim_parms->gravity);
        mul_fvector_S(gravity, gravity, 0.001f); /* scale gravity force */

Modified: branches/apricot/source/blender/blenkernel/intern/particle_system.c
===================================================================
--- branches/apricot/source/blender/blenkernel/intern/particle_system.c 
2008-08-19 11:53:24 UTC (rev 16188)
+++ branches/apricot/source/blender/blenkernel/intern/particle_system.c 
2008-08-19 12:19:38 UTC (rev 16189)
@@ -2616,7 +2616,7 @@
                                                                        
pd->flag & PFIELD_TEX_OBJECT, (pd->flag & PFIELD_TEX_ROOTCO) ? rootco : 
state->co, eob->obmat,
                                                                        
pd->f_strength, falloff, force_field);
                                } else {
-                                       
do_physical_effector(pd->forcefield,pd->f_strength,distance,
+                                       do_physical_effector(eob, state->co, 
pd->forcefield,pd->f_strength,distance,
                                                                                
falloff,pd->f_dist,pd->f_damp,eob->obmat[2],vec_to_part,
                                                                                
pa->state.vel,force_field,pd->flag&PFIELD_PLANAR, pd->rng, pd->f_noise);
                                }
@@ -2665,7 +2665,7 @@
                                                if(falloff<=0.0f)
                                                        ;       /* don't do 
anything */
                                                else
-                                                       
do_physical_effector(pd->forcefield,pd->f_strength,distance,
+                                                       
do_physical_effector(eob, state->co, pd->forcefield,pd->f_strength,distance,
                                                        
falloff,epart->size,pd->f_damp,estate.vel,vec_to_part,
                                                        
state->vel,force_field,0, pd->rng, pd->f_noise);
                                        }

Modified: branches/apricot/source/blender/makesdna/DNA_modifier_types.h
===================================================================
--- branches/apricot/source/blender/makesdna/DNA_modifier_types.h       
2008-08-19 11:53:24 UTC (rev 16188)
+++ branches/apricot/source/blender/makesdna/DNA_modifier_types.h       
2008-08-19 12:19:38 UTC (rev 16189)
@@ -390,7 +390,7 @@
        
        unsigned int numverts;
        unsigned int numfaces;
-       short absorbation; /* used for forces, in % */
+       short absorption; /* used for forces, in % */
        short pad;
        float time;             /* cfra time of modifier */
        struct BVHTree *bvhtree; /* bounding volume hierarchy for this cloth 
object */

Modified: branches/apricot/source/blender/src/buttons_object.c
===================================================================
--- branches/apricot/source/blender/src/buttons_object.c        2008-08-19 
11:53:24 UTC (rev 16188)
+++ branches/apricot/source/blender/src/buttons_object.c        2008-08-19 
12:19:38 UTC (rev 16189)
@@ -3319,7 +3319,7 @@
                        // collision options
                        if(collmd)
                        {
-                               uiDefButS(block, NUM, B_FIELD_CHANGE, 
"Absoption: ",    10,0,150,20, &collmd->absorbation, 0.0, 100, 1, 2, "How much 
of effector force gets lost during collision with this object (in percent).");
+                               uiDefButS(block, NUM, B_FIELD_CHANGE, 
"Absorption: ",   10,0,150,20, &collmd->absorption, 0.0, 100, 1, 2, "How much 
of effector force gets lost during collision with this object (in percent).");
                        }
                }
        }

Modified: 
branches/apricot/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
===================================================================
--- branches/apricot/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp  
2008-08-19 11:53:24 UTC (rev 16188)
+++ branches/apricot/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp  
2008-08-19 12:19:38 UTC (rev 16189)
@@ -118,7 +118,9 @@
        // Acquire Python's GIL (global interpreter lock)
        // so we can safely run Python code and API calls
        PyGILState_STATE gilstate = PyGILState_Ensure();
-
+       
+       PyObject *pyGlobalDict = PyDict_New(); /* python utility storage, spans 
blend file loading */
+       
        bgl::InitExtensions(true);
 
        do
@@ -315,6 +317,7 @@

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to