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

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

Modified Paths:
--------------
    branches/apricot/source/blender/blenkernel/BKE_collision.h
    branches/apricot/source/blender/blenkernel/BKE_effect.h
    branches/apricot/source/blender/blenkernel/intern/collision.c
    branches/apricot/source/blender/blenkernel/intern/effect.c
    branches/apricot/source/blender/blenkernel/intern/implicit.c
    branches/apricot/source/blender/blenkernel/intern/modifier.c
    branches/apricot/source/blender/blenkernel/intern/particle_system.c
    branches/apricot/source/blender/makesdna/DNA_modifier_types.h
    branches/apricot/source/blender/python/api2_2x/Material.c
    branches/apricot/source/blender/python/api2_2x/Text3d.c
    branches/apricot/source/blender/python/api2_2x/doc/Material.py
    branches/apricot/source/blender/python/api2_2x/doc/Text3d.py
    branches/apricot/source/blender/src/buttons_object.c
    branches/apricot/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp

Modified: branches/apricot/source/blender/blenkernel/BKE_collision.h
===================================================================
--- branches/apricot/source/blender/blenkernel/BKE_collision.h  2008-08-18 
23:48:59 UTC (rev 16185)
+++ branches/apricot/source/blender/blenkernel/BKE_collision.h  2008-08-19 
04:00:22 UTC (rev 16186)
@@ -119,8 +119,10 @@
 /////////////////////////////////////////////////
 // used in modifier.c from collision.c
 /////////////////////////////////////////////////
+
 BVHTree *bvhtree_build_from_mvert ( MFace *mfaces, unsigned int numfaces, 
MVert *x, unsigned int numverts, float epsilon );
 void bvhtree_update_from_mvert ( BVHTree * bvhtree, MFace *faces, int 
numfaces, MVert *x, MVert *xnew, int numverts, int moving );
+
 /////////////////////////////////////////////////
 
 LinkNode *BLI_linklist_append_fast ( LinkNode **listp, void *ptr );
@@ -134,6 +136,15 @@
 void interpolateOnTriangle ( float to[3], float v1[3], float v2[3], float 
v3[3], double w1, double w2, double w3 );
 
 /////////////////////////////////////////////////
+// used in effect.c
+/////////////////////////////////////////////////
+CollisionModifierData **get_collisionobjects(Object *self, int *numcollobj);
 
+/////////////////////////////////////////////////
+
+
+
+/////////////////////////////////////////////////
+
 #endif
 

Modified: branches/apricot/source/blender/blenkernel/BKE_effect.h
===================================================================
--- branches/apricot/source/blender/blenkernel/BKE_effect.h     2008-08-18 
23:48:59 UTC (rev 16185)
+++ branches/apricot/source/blender/blenkernel/BKE_effect.h     2008-08-19 
04:00:22 UTC (rev 16186)
@@ -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);
+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);
 float effector_falloff(struct PartDeflect *pd, float *eff_velocity, float 
*vec_to_part);
 
 

Modified: branches/apricot/source/blender/blenkernel/intern/collision.c
===================================================================
--- branches/apricot/source/blender/blenkernel/intern/collision.c       
2008-08-18 23:48:59 UTC (rev 16185)
+++ branches/apricot/source/blender/blenkernel/intern/collision.c       
2008-08-19 04:00:22 UTC (rev 16186)
@@ -31,10 +31,11 @@
 
 #include "BKE_cloth.h"
 
+#include "DNA_cloth_types.h"
 #include "DNA_group_types.h"
+#include "DNA_mesh_types.h"
 #include "DNA_object_types.h"
-#include "DNA_cloth_types.h"
-#include "DNA_mesh_types.h"
+#include "DNA_object_force.h"
 #include "DNA_scene_types.h"
 
 #include "BKE_DerivedMesh.h"
@@ -1307,10 +1308,35 @@
        for ( base = G.scene->base.first; base; base = base->next )
        {
                coll_ob = base->object;
-               collmd = ( CollisionModifierData * ) modifiers_findByType ( 
coll_ob, eModifierType_Collision );
-       
-               if ( !collmd )
+               
+               if(coll_ob->pd && coll_ob->pd->deflect)
                {
+                       collmd = ( CollisionModifierData * ) 
modifiers_findByType ( coll_ob, eModifierType_Collision );
+               }
+               
+               if ( collmd )
+               {
+                       if(coll_ob == self)
+                               continue;
+                       
+                       if(numobj >= maxobj)
+                       {
+                               // realloc
+                               int oldmax = maxobj;
+                               CollisionModifierData **tmp;
+                               maxobj *= 2;
+                               tmp = MEM_callocN(sizeof(CollisionModifierData 
*)*maxobj, "CollisionObjectsArray");
+                               memcpy(tmp, objs, sizeof(CollisionModifierData 
*)*oldmax);
+                               MEM_freeN(objs);
+                               objs = tmp;
+                               
+                       }
+                       
+                       objs[numobj] = collmd;
+                       numobj++;
+               }
+               else
+               {
                        if ( coll_ob->dup_group )
                        {
                                GroupObject *go;
@@ -1319,9 +1345,13 @@
                                for ( go= group->gobject.first; go; go= 
go->next )
                                {
                                        coll_ob = go->ob;
+                                       collmd = NULL;
+                                       
+                                       if(coll_ob->pd && coll_ob->pd->deflect)
+                                       {
+                                               collmd = ( 
CollisionModifierData * ) modifiers_findByType ( coll_ob, 
eModifierType_Collision );
+                                       }
 
-                                       collmd = ( CollisionModifierData * ) 
modifiers_findByType ( coll_ob, eModifierType_Collision );
-
                                        if ( !collmd )
                                                continue;
 
@@ -1347,27 +1377,6 @@
                                        numobj++;
                                }
                        }
-               }
-               else
-               {
-                       if(coll_ob == self)
-                               continue;
-                       
-                       if(numobj >= maxobj)
-                       {
-                               // realloc
-                               int oldmax = maxobj;
-                               CollisionModifierData **tmp;
-                               maxobj *= 2;
-                               tmp = MEM_callocN(sizeof(CollisionModifierData 
*)*maxobj, "CollisionObjectsArray");
-                               memcpy(tmp, objs, sizeof(CollisionModifierData 
*)*oldmax);
-                               MEM_freeN(objs);
-                               objs = tmp;
-                               
-                       }
-                       
-                       objs[numobj] = collmd;
-                       numobj++;
                }       
        }
        *numcollobj = numobj;
@@ -1484,6 +1493,9 @@
                        BVHTreeOverlap *overlap = NULL;
                        int result = 0;
                        
+                       if(!collmd->bvhtree)
+                               continue;
+                       
                        /* move object to position (step) in time */
                        collision_move_object ( collmd, step + dt, step );
                        

Modified: branches/apricot/source/blender/blenkernel/intern/effect.c
===================================================================
--- branches/apricot/source/blender/blenkernel/intern/effect.c  2008-08-18 
23:48:59 UTC (rev 16185)
+++ branches/apricot/source/blender/blenkernel/intern/effect.c  2008-08-19 
04:00:22 UTC (rev 16186)
@@ -59,6 +59,7 @@
 #include "BKE_armature.h"
 #include "BKE_bad_level_calls.h"
 #include "BKE_blender.h"
+#include "BKE_collision.h"
 #include "BKE_constraint.h"
 #include "BKE_deform.h"
 #include "BKE_depsgraph.h"
@@ -314,12 +315,12 @@
        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)
+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)
 {
        float mag_vec[3]={0,0,0};
        float temp[3], temp2[3];
        float eff_vel[3];
-       float wind = 0;
+       float noise = 0;
 
        VecCopyf(eff_vel,eff_velocity);
        Normalize(eff_vel);
@@ -328,11 +329,11 @@
                case PFIELD_WIND:
                        VECCOPY(mag_vec,eff_vel);
                        
-                       // add wind noise here
-                       if(noise> 0.0f)
-                               wind = wind_func(rng, noise);
-
-                       VecMulf(mag_vec,(force_val+wind)*falloff);
+                       // add wind noise here, only if we have wind
+                       if((noise_factor> 0.0f) && (force_val > FLT_EPSILON))
+                               noise = wind_func(rng, noise_factor);
+                       
+                       VecMulf(mag_vec,(force_val+noise)*falloff);
                        VecAddf(field,field,mag_vec);
                        break;
 
@@ -393,8 +394,55 @@
 }
 
 
+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
@@ -430,7 +478,7 @@
        float *obloc;
        
        float distance, vec_to_part[3];
-       float falloff;
+       float falloff, visibility;
 
        /* 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) */
@@ -452,14 +500,19 @@
                distance = VecLength(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,
-                                                               
falloff,pd->f_dist,pd->f_damp,ob->obmat[2],vec_to_part,
+                                                               
visibility*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-18 23:48:59 UTC (rev 16185)
+++ branches/apricot/source/blender/blenkernel/intern/implicit.c        
2008-08-19 04:00:22 UTC (rev 16186)
@@ -1405,6 +1405,7 @@
        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 */
@@ -1451,7 +1452,7 @@
                        float triunnormal[3]={0,0,0}; // 
not-normalized-triangle normal
                        float tmp[3]={0,0,0};
                        float factor = (mfaces[i].v4) ? 0.25 : 1.0 / 3.0;
-                       factor *= 0.05;
+                       factor *= 0.02;
                        
                        // calculate face normal
                        if(mfaces[i].v4)

Modified: branches/apricot/source/blender/blenkernel/intern/modifier.c
===================================================================
--- branches/apricot/source/blender/blenkernel/intern/modifier.c        
2008-08-18 23:48:59 UTC (rev 16185)
+++ branches/apricot/source/blender/blenkernel/intern/modifier.c        
2008-08-19 04:00:22 UTC (rev 16186)
@@ -5493,7 +5493,7 @@
                
                numverts = dm->getNumVerts ( dm );
                
-               if(current_time > collmd->time)
+               if((current_time > collmd->time)|| 
(BKE_ptcache_get_continue_physics()))
                {       
                        // check if mesh has changed

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