Orange: tuesday sync with bf-blender
authorTon Roosendaal <ton@blender.org>
Tue, 6 Dec 2005 10:58:54 +0000 (10:58 +0000)
committerTon Roosendaal <ton@blender.org>
Tue, 6 Dec 2005 10:58:54 +0000 (10:58 +0000)
1  2 
source/blender/blenkernel/intern/effect.c
source/blender/renderconverter/intern/convertBlenderScene.c
source/blender/src/space.c

index e2582c5d86c6296321498bbe498efac442ad771f,acff6d80024622a20bd3c5fa08f634ad5437093a..17dbae4c0af2904f1e3bfaed1022e9cf4c6814df
  #include <stdlib.h>
  
  #include "MEM_guardedalloc.h"
 -#include "DNA_listBase.h"
 +
 +#include "DNA_curve_types.h"
  #include "DNA_effect_types.h"
 -#include "DNA_object_types.h"
 -#include "DNA_object_force.h"
 +#include "DNA_group_types.h"
 +#include "DNA_ipo_types.h"
 +#include "DNA_key_types.h"
 +#include "DNA_lattice_types.h"
 +#include "DNA_listBase.h"
  #include "DNA_mesh_types.h"
  #include "DNA_meshdata_types.h"
  #include "DNA_material_types.h"
 -#include "DNA_curve_types.h"
 -#include "DNA_key_types.h"
 +#include "DNA_object_types.h"
 +#include "DNA_object_force.h"
  #include "DNA_texture_types.h"
  #include "DNA_scene_types.h"
 -#include "DNA_lattice_types.h"
 -#include "DNA_ipo_types.h"
  
  #include "BLI_blenlib.h"
  #include "BLI_arithb.h"
@@@ -328,57 -326,42 +328,57 @@@ typedef struct pEffectorCache 
        Object obcopy;  /* for restoring transformation data */
  } pEffectorCache;
  
 +static void add_to_effectorcache(ListBase *lb, Object *ob, Object *obsrc)
 +{
 +      pEffectorCache *ec;
 +      PartDeflect *pd= ob->pd;
 +                      
 +      if(pd->forcefield == PFIELD_GUIDE) {
 +              if(ob->type==OB_CURVE && obsrc->type==OB_MESH) {        /* guides only do mesh particles */
 +                      Curve *cu= ob->data;
 +                      if(cu->flag & CU_PATH) {
 +                              if(cu->path==NULL || cu->path->data==NULL)
 +                                      makeDispListCurveTypes(ob, 0);
 +                              if(cu->path && cu->path->data) {
 +                                      ec= MEM_callocN(sizeof(pEffectorCache), "effector cache");
 +                                      ec->ob= ob;
 +                                      BLI_addtail(lb, ec);
 +                              }
 +                      }
 +              }
 +      }
 +      else if(pd->forcefield) {
 +              ec= MEM_callocN(sizeof(pEffectorCache), "effector cache");
 +              ec->ob= ob;
 +              BLI_addtail(lb, ec);
 +      }
 +}
  
  /* returns ListBase handle with objects taking part in the effecting */
 -ListBase *pdInitEffectors(Object *obsrc)
 +ListBase *pdInitEffectors(Object *obsrc, Group *group)
  {
        static ListBase listb={NULL, NULL};
        pEffectorCache *ec;
 -      unsigned int layer= obsrc->lay;
        Base *base;
 -
 -      for(base = G.scene->base.first; base; base= base->next) {
 -              if( (base->lay & layer) && base->object->pd && base->object!=obsrc) {
 -                      Object *ob= base->object;
 -                      PartDeflect *pd= ob->pd;
 -                      
 -                      if(pd->forcefield == PFIELD_GUIDE) {
 -                              if(ob->type==OB_CURVE && obsrc->type==OB_MESH) {        /* guides only do mesh particles */
 -                                      Curve *cu= ob->data;
 -                                      if(cu->flag & CU_PATH) {
 -                                              if(cu->path==NULL || cu->path->data==NULL)
 -                                                      makeDispListCurveTypes(ob, 0);
 -                                              if(cu->path && cu->path->data) {
 -                                                      ec= MEM_callocN(sizeof(pEffectorCache), "effector cache");
 -                                                      ec->ob= ob;
 -                                                      BLI_addtail(&listb, ec);
 -                                              }
 -                                      }
 -                              }
 +      unsigned int layer= obsrc->lay;
 +      
 +      if(group) {
 +              GroupObject *go;
 +              
 +              for(go= group->gobject.first; go; go= go->next) {
 +                      if( (go->ob->lay & layer) && go->ob->pd && go->ob!=obsrc) {
 +                              add_to_effectorcache(&listb, go->ob, obsrc);
                        }
 -                      else if(pd->forcefield) {
 -                              ec= MEM_callocN(sizeof(pEffectorCache), "effector cache");
 -                              ec->ob= ob;
 -                              BLI_addtail(&listb, ec);
 +              }
 +      }
 +      else {
 +              for(base = G.scene->base.first; base; base= base->next) {
 +                      if( (base->lay & layer) && base->object->pd && base->object!=obsrc) {
 +                              add_to_effectorcache(&listb, base->object, obsrc);
                        }
                }
        }
 -
 +      
        /* make a full copy */
        for(ec= listb.first; ec; ec= ec->next) {
                ec->obcopy= *(ec->ob);
@@@ -1530,16 -1513,15 +1530,15 @@@ typedef struct pMatrixCache 
  static pMatrixCache *cache_object_matrices(Object *ob, int start, int end)
  {
        pMatrixCache *mcache, *mc;
-       Object *par;
-       float framelenold, sfrao;
-       int cfrao;
+       Object *par, ob_store;
+       float framelenold, cfrao;
        
        mcache= mc= MEM_mallocN( (end-start+1)*sizeof(pMatrixCache), "ob matrix cache");
        
        framelenold= G.scene->r.framelen;
        G.scene->r.framelen= 1.0f;
        cfrao= G.scene->r.cfra;
-       sfrao= ob->sf;
+       ob_store= *ob;  /* quick copy of all settings */
        ob->sf= 0.0f;
        
        for(G.scene->r.cfra= start; G.scene->r.cfra<=end; G.scene->r.cfra++, mc++) {
        /* restore */
        G.scene->r.cfra= cfrao;
        G.scene->r.framelen= framelenold;
-       ob->sf= sfrao;
+       *ob= ob_store;
        
-       /* restore hierarchy */
+       /* restore hierarchy, weak code destroying potential depgraph stuff... */
        par= ob;
        while(par) {
                /* do not do ob->ipo: keep insertkey */
-               par->ctime= -1234567.0;         /* hrms? */
                do_ob_key(par);
                
                if(par->type==OB_ARMATURE) {
                par= par->parent;
        }
        
-       where_is_object(ob);
-       
        return mcache;
  }
  
@@@ -1684,7 -1663,7 +1680,7 @@@ void build_particle_system(Object *ob
        }
        
        /* get the effectors */
 -      effectorbase= pdInitEffectors(ob);
 +      effectorbase= pdInitEffectors(ob, paf->group);
        
        /* init geometry, return is 6 x float * me->totvert in size */
        vertexcosnos= (VeNoCo *)mesh_get_mapped_verts_nors(ob);
index 14726c6ca849753ce6a0f238de8581a1da38e6cd,e1fc8556d730004fe233a414256d95d02267174b..a4dbad1000a7c3bd1240486ae3875ed8d1e31776
@@@ -53,7 -53,6 +53,7 @@@
  #include "DNA_material_types.h"
  #include "DNA_curve_types.h"
  #include "DNA_effect_types.h"
 +#include "DNA_group_types.h"
  #include "DNA_lamp_types.h"
  #include "DNA_lattice_types.h"
  #include "DNA_mesh_types.h"
@@@ -75,7 -74,6 +75,7 @@@
  #include "BKE_DerivedMesh.h"
  #include "BKE_effect.h"
  #include "BKE_global.h"
 +#include "BKE_group.h"
  #include "BKE_key.h"
  #include "BKE_ipo.h"
  #include "BKE_lattice.h"
@@@ -1382,13 -1380,13 +1382,13 @@@ static void init_render_mesh(Object *ob
        Material *ma;
        MSticky *ms = NULL;
        PartEff *paf;
+       DispListMesh *dlm = NULL;
+       DerivedMesh *dm;
        unsigned int *vertcol;
        float xn, yn, zn,  imat[3][3], mat[4][4];  //nor[3],
        float *orco=0;
        int a, a1, ok, need_orco=0, totvlako, totverto, vertofs;
-       int end, do_autosmooth=0, totvert = 0;
-       DispListMesh *dlm = NULL;
-       DerivedMesh *dm;
+       int end, do_autosmooth=0, totvert = 0, dm_needsfree;
        
        me= ob->data;
  
        
        if(need_orco) orco = get_object_orco(ob);
        
-       dm = mesh_create_derived_render(ob);
+       /* duplicators don't call modifier stack */
+       if(ob->flag&OB_FROMDUPLI) {
+               dm= ob->derivedFinal;
+               dm_needsfree= 0;
+       }
+       else {
+               dm = mesh_create_derived_render(ob);
+               dm_needsfree= 1;
+       }
+       
+       if(dm==NULL) return;    /* in case duplicated object fails? */
+       
        dlm = dm->convertToDispListMesh(dm, 1);
  
        mvert= dlm->mvert;
        calc_vertexnormals(totverto, totvlako);
  
        if(dlm) displistmesh_free(dlm);
-       dm->release(dm);
+       if(dm_needsfree) dm->release(dm);
  }
  
  /* ------------------------------------------------------------------------- */
@@@ -1660,10 -1669,23 +1671,10 @@@ static void area_lamp_vectors(LampRen *
  void RE_add_render_lamp(Object *ob, int actual_render)
  {
        Lamp *la;
 -      LampRen *lar, **temp;
 +      LampRen *lar;
 +      GroupObject *go;
        float mat[4][4], hoek, xn, yn;
        int c;
 -      static int rlalen=LAMPINITSIZE; /*number of currently allocated lampren pointers*/
 -      
 -      if(R.totlamp>=rlalen) { /* Need more Lamp pointers....*/
 -              printf("Alocating %i more lamp groups, %i total.\n", 
 -                      LAMPINITSIZE, rlalen+LAMPINITSIZE);
 -              temp=R.la;
 -              R.la=(LampRen**)MEM_callocN(sizeof(void*)*(rlalen+LAMPINITSIZE) , "renderlamparray");
 -              memcpy(R.la, temp, rlalen*sizeof(void*));
 -              memset(&(R.la[R.totlamp]), 0, LAMPINITSIZE*sizeof(void*));
 -              rlalen+=LAMPINITSIZE;  
 -              MEM_freeN(temp);        
 -      }
 -      
 -      la= ob->data;
  
        /* prevent only shadow from rendering light, but only return on render, not preview */
        if(actual_render) {
                        if((R.r.mode & R_SHADOW)==0)
                                return;
        }
 -
 +      
 +      go= MEM_callocN(sizeof(GroupObject), "groupobject");
 +      BLI_addtail(&R.lights, go);
 +      R.totlamp++;
        lar= (LampRen *)MEM_callocN(sizeof(LampRen),"lampren");
 -      R.la[R.totlamp++]= lar;
 +      go->lampren= lar;
 +      go->ob= ob;
  
        MTC_Mat4MulMat4(mat, ob->obmat, R.viewmat);
        MTC_Mat4Invert(ob->imat, mat);
        MTC_Mat3CpyMat4(lar->mat, mat);
        MTC_Mat3CpyMat4(lar->imat, ob->imat);
  
 +      la= ob->data;
 +      
        lar->bufsize = la->bufsize;
        lar->samp = la->samp;
        lar->soft = la->soft;
@@@ -2355,7 -2371,6 +2366,7 @@@ void RE_freeRotateBlenderScene(void
  {
        ShadBuf *shb;
        Object *ob = NULL;
 +      GroupObject *go;
        unsigned long *ztile;
        int a, b, v;
        char *ctile;
        
        BLI_memarena_free(R.memArena);
        R.memArena = NULL;
 -
 -      for(a=0; a<R.totlamp; a++) {
 -              if(R.la[a]->shb) {
 -                      shb= R.la[a]->shb;
 +      
 +      for(go= R.lights.first; go; go= go->next) {
 +              struct LampRen *lar= go->lampren;
 +              if(lar->shb) {
 +                      shb= lar->shb;
                        v= (shb->size*shb->size)/256;
                        ztile= shb->zbuf;
                        ctile= shb->cbuf;
                        
                        MEM_freeN(shb->zbuf);
                        MEM_freeN(shb->cbuf);
 -                      MEM_freeN(R.la[a]->shb);
 +                      MEM_freeN(lar->shb);
                }
 -              if(R.la[a]->jitter) MEM_freeN(R.la[a]->jitter);
 -              MEM_freeN(R.la[a]);
 +              if(lar->jitter) MEM_freeN(lar->jitter);
 +              MEM_freeN(lar);
        }
 +      
 +      BLI_freelistN(&R.lights);
  
        /* note; these pointer arrays were allocated, with last element NULL to stop loop */
        a=0;
  
        free_mesh_orco_hash();
  
 -      end_render_textures();
 -      end_render_materials();
        end_radio_render();
        if(R.wrld.aosphere) {
                MEM_freeN(R.wrld.aosphere);
@@@ -2572,25 -2586,7 +2583,25 @@@ static void check_non_flat_quads(void
        }
  }
  
 -
 +static void set_material_lightgroups(void)
 +{
 +      GroupObject *go, *gol;
 +      Material *ma;
 +      
 +      /* it's a bit too many loops in loops... but will survive */
 +      for(ma= G.main->mat.first; ma; ma=ma->id.next) {
 +              if(ma->group) {
 +                      for(go= ma->group->gobject.first; go; go= go->next) {
 +                              for(gol= R.lights.first; gol; gol= gol->next) {
 +                                      if(gol->ob==go->ob) {
 +                                              go->lampren= gol->lampren;
 +                                              break;
 +                                      }
 +                              }
 +                      }
 +              }
 +      }
 +}
  
  extern int slurph_opt;        /* key.c */
  extern ListBase duplilist;
@@@ -2602,12 -2598,13 +2613,12 @@@ void RE_rotateBlenderScene(void
        unsigned int lay;
        float mat[4][4];
  
 -      if(G.scene->camera==0) return;
 +      if(G.scene->camera==NULL) return;
  
        R.memArena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE);
 -
 -      slurph_opt= 0;
 -
        R.totvlak=R.totvert=R.totlamp=R.tothalo= 0;
 +      
 +      slurph_opt= 0;
  
        /* in localview, lamps are using normal layers, objects only local bits */
        if(G.scene->lay & 0xFF000000) lay= G.scene->lay & 0xFF000000;
        }
  
        sort_halos();
 -
 +      
 +      set_material_lightgroups();
 +      
        if(R.wrld.mode & WO_STARS) RE_make_stars(NULL, NULL, NULL);
  
        slurph_opt= 1;
index 32c1feb971879102fb0f9c2ea2e4e05262a61981,5c07f1ba341badd98ae0f5c1391e37a6e39a35fc..9228455371e528eab8c45f60ee582cc7deea48fd
@@@ -89,6 -89,6 +89,7 @@@
  #include "BIF_editarmature.h"
  #include "BIF_editconstraint.h"
  #include "BIF_editfont.h"
++#include "BIF_editgroup.h"
  #include "BIF_editkey.h"
  #include "BIF_editlattice.h"
  #include "BIF_editmesh.h"
@@@ -577,10 -577,31 +578,10 @@@ static void select_parent(void) /* Make
        }
  }
  
 -
 -void select_group_menu(void)
 -{
 -      char *str;
 -      short nr;
 -
 -      /* make menu string */
 -      
 -      str= MEM_mallocN(160, "groupmenu");
 -      strcpy(str, "Select Grouped%t|Children%x1|"
 -                  "Immediate Children%x2|Parent%x3|"
 -                  "Objects on Shared Layers%x4");
 -
 -      /* here we go */
 -      
 -      nr= pupmenu(str);
 -      MEM_freeN(str);
 -      
 -      select_group(nr);
 -}
 -
 -void select_group(short nr)
 +void select_grouped(short nr)
  {
        Base *base;
 -
 +      
        if(nr==4) {
                base= FIRSTBASE;
                while(base) {
        allqueue(REDRAWIPO, 0);
  }
  
 +static void select_grouped_menu(void)
 +{
 +      char *str;
 +      short nr;
 +
 +      /* make menu string */
 +      
 +      str= MEM_mallocN(160, "groupmenu");
 +      strcpy(str, "Select Grouped%t|Children%x1|"
 +                  "Immediate Children%x2|Parent%x3|"
 +                  "Objects on Shared Layers%x4");
 +
 +      /* here we go */
 +      
 +      nr= pupmenu(str);
 +      MEM_freeN(str);
 +      
 +      select_grouped(nr);
 +}
 +
 +
  static unsigned short convert_for_nonumpad(unsigned short event)
  {
        if (event>=ZEROKEY && event<=NINEKEY) {
@@@ -1262,9 -1262,10 +1263,9 @@@ static void winqreadview3dspace(ScrAre
                                
                                break;
                        case GKEY:
 -                              /* RMGRP if(G.qual & LR_CTRLKEY) add_selected_to_group();
 -                              else if(G.qual & LR_ALTKEY) rem_selected_from_group(); */
 -                              if((G.qual==LR_SHIFTKEY))
 -                                      select_group_menu();
 +                              if(G.qual & LR_CTRLKEY) group_operation_with_menu();
 +                              else if((G.qual==LR_SHIFTKEY))
 +                                      select_grouped_menu();
                                else if(G.qual==LR_ALTKEY) {
                                        if(okee("Clear location")) {
                                                clear_object('g');
@@@ -2656,17 -2657,17 +2657,17 @@@ void drawinfospace(ScrArea *sa, void *s
                uiBlockEndAlign(block);
  
  
-               uiDefBut(block, LABEL,0,"Editmode undo:",
+               uiDefBut(block, LABEL,0,"Undo:",
                        (xpos+(2*edgsp)+mpref),y3label, mpref,buth,
                        0, 0, 0, 0, 0, "");
                uiBlockBeginAlign(block);
                uiDefButS(block, NUMSLI, B_DRAWINFO, "Steps:",
                        (xpos+edgsp+mpref+midsp),y2,mpref,buth,
-                       &(U.undosteps), 0, 64, 0, 0, "Number of undo steps available in Edit Mode (smaller values conserve memory)");
+                       &(U.undosteps), 0, 64, 0, 0, "Number of undo steps available (smaller values conserve memory)");
  
                uiDefButBitI(block, TOG, USER_GLOBALUNDO, B_DRAWINFO, "Global undo",
                        (xpos+edgsp+mpref+midsp),y1,mpref,buth,
-                       &(U.uiflag), 2, 64, 0, 0, "");
+                       &(U.uiflag), 2, 64, 0, 0, "Global undo works by keeping a full copy of the file itself in memory, so takes extra memory");
                uiBlockEndAlign(block);
  
  
@@@ -3866,7 -3867,8 +3867,7 @@@ static void winqreadimagespace(ScrArea 
                                        sample_vpaint();
                                break;
                        case AKEY:
 -                              if((G.qual==0))
 -                                      select_swap_tface_uv();
 +                              select_swap_tface_uv();
                                break;
                        case BKEY:
                                if(G.qual==LR_SHIFTKEY)
                                        stitch_uv_tface(0);
                                else if(G.qual==LR_SHIFTKEY)
                                        stitch_uv_tface(1);
 +                              else if(G.qual==LR_CTRLKEY)
 +                                      minimize_stretch_tface_uv();
                                break;
                        case WKEY:
                                weld_align_menu_tface_uv();