This commit is contained in:
2008-01-15 13:00:29 +00:00
82 changed files with 1929 additions and 470 deletions

View File

@@ -34,6 +34,8 @@
#ifndef BKE_ANIM_H
#define BKE_ANIM_H
#define MAX_DUPLI_RECUR 8
struct Path;
struct Object;
struct PartEff;
@@ -46,6 +48,7 @@ typedef struct DupliObject {
unsigned int origlay;
int index, no_draw, type;
float mat[4][4], omat[4][4];
float orco[3], uv[2];
} DupliObject;
void free_path(struct Path *path);

View File

@@ -180,7 +180,7 @@ typedef struct Global {
#define G_DRAW_FACEAREA (1 << 23)
#define G_DRAW_EDGEANG (1 << 24)
#define G_RECORDKEYS (1 << 25)
/* #define G_RECORDKEYS (1 << 25) also removed */
/*#ifdef WITH_VERSE*/
#define G_VERSE_CONNECTED (1 << 26)
#define G_DRAW_VERSE_DEBUG (1 << 27)
@@ -189,7 +189,7 @@ typedef struct Global {
#define G_SCULPTMODE (1 << 29)
#define G_PARTICLEEDIT (1 << 30)
#define G_AUTOMATKEYS (1 << 30)
/* #define G_AUTOMATKEYS (1 << 30) also removed */
#define G_HIDDENHANDLES (1 << 31) /* used for curves only */
/* macro for testing face select mode

View File

@@ -244,6 +244,8 @@ float psys_get_child_time(struct ParticleSystem *psys, struct ChildParticle *cpa
float psys_get_child_size(struct ParticleSystem *psys, struct ChildParticle *cpa, float cfra, float *pa_time);
void psys_get_particle_on_path(struct Object *ob, struct ParticleSystem *psys, int pa_num, struct ParticleKey *state, int vel);
int psys_get_particle_state(struct Object *ob, struct ParticleSystem *psys, int p, struct ParticleKey *state, int always);
void psys_get_dupli_texture(struct Object *ob, struct ParticleSettings *part, struct ParticleSystemModifierData *psmd, struct ParticleData *pa, struct ChildParticle *cpa, float *uv, float *orco);
void psys_get_dupli_path_transform(struct Object *ob, struct ParticleSettings *part, struct ParticleSystemModifierData *psmd, struct ParticleData *pa, struct ChildParticle *cpa, struct ParticleCacheKey *cache, float mat[][4], float *scale);
ParticleThread *psys_threads_create(struct Object *ob, struct ParticleSystem *psys, int totthread);
int psys_threads_init_distribution(ParticleThread *threads, struct DerivedMesh *dm, int from);

View File

@@ -32,7 +32,7 @@ FILE(GLOB SRC intern/*.c)
SET(INC
. ../../../intern/guardedalloc ../include ../blenlib ../makesdna
../python ../render/extern/include ../../../intern/decimation/extern
../imbuf ../avi ../../../intern/elbeem/extern
../imbuf ../avi ../../../intern/elbeem/extern ../../../intern/opennl/extern
../../../intern/iksolver/extern ../blenloader ../quicktime
../../../intern/bmfont
../nodes

View File

@@ -2135,9 +2135,13 @@ static void mesh_calc_modifiers(Object *ob, float (*inputVertexCos)[3],
}
/* add an orco layer if needed */
if(dataMask & CD_MASK_ORCO)
if(dataMask & CD_MASK_ORCO) {
add_orco_dm(ob, finaldm, orcodm);
if(deform_r && *deform_r)
add_orco_dm(ob, *deform_r, NULL);
}
*final_r = finaldm;
if(orcodm)

View File

@@ -69,6 +69,7 @@ CPPFLAGS += $(NAN_SDLCFLAGS)
CPPFLAGS += -I$(NAN_IKSOLVER)/include
CPPFLAGS += -I$(NAN_DECIMATION)/include
CPPFLAGS += -I$(NAN_ELBEEM)/include
CPPFLAGS += -I$(NAN_OPENNL)/include
# path to zlib
CPPFLAGS += -I$(NAN_ZLIB)/include

View File

@@ -441,6 +441,8 @@ static float get_actionstrip_frame(bActionStrip *strip, float cframe, int invert
float length, actlength, repeat, scale;
repeat = (strip->flag & ACTSTRIP_USESTRIDE) ? (1.0f) : (strip->repeat);
if(strip->scale == 0.0f) strip->scale= 1.0f;
scale = abs(strip->scale); /* scale must be positive (for now) */
actlength = strip->actend-strip->actstart;

View File

@@ -75,8 +75,6 @@
#include <config.h>
#endif
#define MAX_DUPLI_RECUR 4
static void object_duplilist_recursive(ID *id, Object *ob, ListBase *duplilist, float par_space_mat[][4], int level);
void free_path(Path *path)
@@ -378,10 +376,12 @@ struct vertexDupliData {
float pmat[4][4];
float obmat[4][4]; /* Only used for dupliverts inside dupligroups, where the ob->obmat is modified */
Object *ob, *par;
float (*orco)[3];
};
static void vertex_dupli__mapFunc(void *userData, int index, float *co, float *no_f, short *no_s)
{
DupliObject *dob;
struct vertexDupliData *vdd= userData;
float vec[3], *q2, mat[3][3], tmat[4][4], obmat[4][4];
@@ -407,7 +407,9 @@ static void vertex_dupli__mapFunc(void *userData, int index, float *co, float *n
Mat4CpyMat4(tmat, obmat);
Mat4MulMat43(obmat, tmat, mat);
}
new_dupli_object(vdd->lb, vdd->ob, obmat, vdd->par->lay, index, OB_DUPLIVERTS);
dob= new_dupli_object(vdd->lb, vdd->ob, obmat, vdd->par->lay, index, OB_DUPLIVERTS);
if(vdd->orco)
VECCOPY(dob->orco, vdd->orco[index]);
if(vdd->ob->transflag & OB_DUPLI) {
float tmpmat[4][4];
@@ -429,16 +431,25 @@ static void vertex_duplilist(ListBase *lb, ID *id, Object *par, float par_space_
Scene *sce = NULL;
Group *group = NULL;
GroupObject * go = NULL;
CustomDataMask dataMask = CD_MASK_BAREMESH;
Mat4CpyMat4(pmat, par->obmat);
/* simple preventing of too deep nested groups */
if(level>MAX_DUPLI_RECUR) return;
if(G.rendering)
dataMask |= CD_MASK_ORCO;
if(par==G.obedit)
dm= editmesh_get_derived_cage(CD_MASK_BAREMESH);
dm= editmesh_get_derived_cage(dataMask);
else
dm = mesh_get_derived_deform(par, CD_MASK_BAREMESH);
dm= mesh_get_derived_deform(par, dataMask);
if(G.rendering)
vdd.orco= dm->getVertDataArray(dm, CD_ORCO);
else
vdd.orco= NULL;
totvert = dm->getNumVerts(dm);
@@ -517,25 +528,31 @@ static void face_duplilist(ListBase *lb, ID *id, Object *par, float par_space_ma
{
Object *ob, *ob_iter;
Base *base = NULL;
DupliObject *dob;
DerivedMesh *dm;
Mesh *me;
MTFace *mtface;
MFace *mface;
MVert *mvert;
float pmat[4][4], imat[3][3];
float pmat[4][4], imat[3][3], (*orco)[3], w;
int lay, oblay, totface, a;
Scene *sce = NULL;
Group *group = NULL;
GroupObject *go = NULL;
CustomDataMask dataMask = CD_MASK_BAREMESH;
float ob__obmat[4][4]; /* needed for groups where the object matrix needs to be modified */
/* simple preventing of too deep nested groups */
if(level>MAX_DUPLI_RECUR) return;
Mat4CpyMat4(pmat, par->obmat);
if(G.rendering)
dataMask |= CD_MASK_ORCO;
Mat4CpyMat4(pmat, par->obmat);
if(par==G.obedit) {
int totvert;
dm= editmesh_get_derived_cage(CD_MASK_BAREMESH);
dm= editmesh_get_derived_cage(dataMask);
totface= dm->getNumFaces(dm);
mface= MEM_mallocN(sizeof(MFace)*totface, "mface temp");
@@ -545,13 +562,22 @@ static void face_duplilist(ListBase *lb, ID *id, Object *par, float par_space_ma
dm->copyVertArray(dm, mvert);
}
else {
dm = mesh_get_derived_deform(par, CD_MASK_BAREMESH);
dm = mesh_get_derived_deform(par, dataMask);
totface= dm->getNumFaces(dm);
mface= dm->getFaceArray(dm);
mvert= dm->getVertArray(dm);
}
if(G.rendering) {
me= (Mesh*)par->data;
orco= dm->getVertDataArray(dm, CD_ORCO);
mtface= me->mtface;
}
else {
orco= NULL;
mtface= NULL;
}
/* having to loop on scene OR group objects is NOT FUN */
if (GS(id->name) == ID_SCE) {
@@ -595,10 +621,14 @@ static void face_duplilist(ListBase *lb, ID *id, Object *par, float par_space_ma
if(ob->type!=OB_MBALL) ob->flag |= OB_DONE; /* doesnt render */
for(a=0; a<totface; a++) {
float *v1= mvert[ mface[a].v1 ].co;
float *v2= mvert[ mface[a].v2 ].co;
float *v3= mvert[ mface[a].v3 ].co;
float *v4= mface[a].v4?mvert[ mface[a].v4 ].co:NULL;
int mv1 = mface[a].v1;
int mv2 = mface[a].v2;
int mv3 = mface[a].v3;
int mv4 = mface[a].v4;
float *v1= mvert[mv1].co;
float *v2= mvert[mv2].co;
float *v3= mvert[mv3].co;
float *v4= (mv4)? mvert[mv4].co: NULL;
float cent[3], quat[4], mat[3][3], mat3[3][3], tmat[4][4], obmat[4][4];
/* translation */
@@ -632,7 +662,32 @@ static void face_duplilist(ListBase *lb, ID *id, Object *par, float par_space_ma
Mat4CpyMat4(tmat, obmat);
Mat4MulMat43(obmat, tmat, mat);
new_dupli_object(lb, ob, obmat, lay, a, OB_DUPLIFACES);
dob= new_dupli_object(lb, ob, obmat, lay, a, OB_DUPLIFACES);
if(G.rendering) {
w= (mv4)? 0.25f: 1.0f/3.0f;
if(orco) {
VECADDFAC(dob->orco, dob->orco, orco[mv1], w);
VECADDFAC(dob->orco, dob->orco, orco[mv2], w);
VECADDFAC(dob->orco, dob->orco, orco[mv3], w);
if(mv4)
VECADDFAC(dob->orco, dob->orco, orco[mv4], w);
}
if(mtface) {
dob->uv[0] += w*mtface[a].uv[0][0];
dob->uv[1] += w*mtface[a].uv[0][1];
dob->uv[0] += w*mtface[a].uv[1][0];
dob->uv[1] += w*mtface[a].uv[1][1];
dob->uv[0] += w*mtface[a].uv[2][0];
dob->uv[1] += w*mtface[a].uv[2][1];
if(mv4) {
dob->uv[0] += w*mtface[a].uv[3][0];
dob->uv[1] += w*mtface[a].uv[3][1];
}
}
}
if(ob->transflag & OB_DUPLI) {
float tmpmat[4][4];
@@ -660,38 +715,14 @@ static void face_duplilist(ListBase *lb, ID *id, Object *par, float par_space_ma
dm->release(dm);
}
static void particle_dupli_path_rotation(Object *ob, ParticleSettings *part, ParticleSystemModifierData *psmd, ParticleData *pa, ChildParticle *cpa, ParticleCacheKey *cache, float mat[][4], float *scale)
{
float loc[3], nor[3], vec[3], side[3], len;
VecSubf(vec, (cache+cache->steps-1)->co, cache->co);
len= Normalize(vec);
if(pa)
psys_particle_on_emitter(ob,psmd,part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,loc,nor,0,0,0,0);
else
psys_particle_on_emitter(ob, psmd,
(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);
Crossf(side, nor, vec);
Normalize(side);
Crossf(nor, vec, side);
Mat4One(mat);
VECCOPY(mat[0], vec);
VECCOPY(mat[1], side);
VECCOPY(mat[2], nor);
*scale= len;
}
static void new_particle_duplilist(ListBase *lb, ID *id, Object *par, float par_space_mat[][4], ParticleSystem *psys, int level)
{
GroupObject *go;
Object *ob=0, **oblist=0;
DupliObject *dob;
ParticleSettings *part;
ParticleData *pa;
ChildParticle *cpa=0;
ParticleKey state;
ParticleCacheKey *cache;
ParticleSystemModifierData *psmd;
@@ -773,10 +804,11 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Object *par, float par_
}
else {
/* TODO: figure these two out */
cpa= &psys->child[a - totpart];
pa_num = a;
pa_time = psys->particles[psys->child[a - totpart].parent].time;
pa_time = psys->particles[cpa->parent].time;
size=psys_get_child_size(psys, &psys->child[a - totpart], ctime, 0);
size=psys_get_child_size(psys, cpa, ctime, 0);
}
if(part->draw_as==PART_DRAW_GR) {
@@ -795,12 +827,11 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Object *par, float par_
if(hair) {
if(a < totpart) {
cache = psys->pathcache[a];
particle_dupli_path_rotation(par, part, psmd, pa, 0, cache, pamat, &scale);
psys_get_dupli_path_transform(par, part, psmd, pa, 0, cache, pamat, &scale);
}
else {
ChildParticle *cpa= psys->child+(a-totpart);
cache = psys->childcache[a-totpart];
particle_dupli_path_rotation(par, part, psmd, 0, cpa, cache, pamat, &scale);
psys_get_dupli_path_transform(par, part, psmd, 0, cpa, cache, pamat, &scale);
}
VECCOPY(pamat[3], cache->co);
@@ -833,7 +864,9 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Object *par, float par_
else
Mat4CpyMat4(mat, tmat);
new_dupli_object(lb, go->ob, mat, par->lay, counter, OB_DUPLIPARTS);
dob= new_dupli_object(lb, go->ob, mat, par->lay, counter, OB_DUPLIPARTS);
if(G.rendering)
psys_get_dupli_texture(par, part, psmd, pa, cpa, dob->uv, dob->orco);
}
}
else {
@@ -857,7 +890,9 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Object *par, float par_
else
Mat4CpyMat4(mat, tmat);
new_dupli_object(lb, ob, mat, par->lay, counter, OB_DUPLIPARTS);
dob= new_dupli_object(lb, ob, mat, par->lay, counter, OB_DUPLIPARTS);
if(G.rendering)
psys_get_dupli_texture(par, part, psmd, pa, cpa, dob->uv, dob->orco);
}
}
}

View File

@@ -1490,7 +1490,7 @@ void makeBevelList(Object *ob)
resolu= nu->resolu;
if((nu->type & 7)==CU_POLY) {
len= nu->pntsu;
bl= MEM_callocN(sizeof(BevList)+len*sizeof(BevPoint), "makeBevelList");
BLI_addtail(&(cu->bev), bl);
@@ -1974,7 +1974,7 @@ float calc_curve_subdiv_radius(Curve *cu, Nurb *nu, int cursubdiv)
}
if ( ((nu->type & 7)==CU_NURBS) && (nu->flagu & CU_CYCLIC)) {
if (bp == bplast) bp = bpfirst;
if (bp >= bplast) bp = bpfirst;
else bp++;
}

View File

@@ -1287,7 +1287,7 @@ void multires_edge_level_update(Object *ob, Mesh *me)
if(!G.obedit) {
MultiresLevel *cr_lvl= BLI_findlink(&me->mr->levels,me->mr->current-1);
MultiresLevel *edge_lvl= BLI_findlink(&me->mr->levels,me->mr->edgelvl-1);
const int threshold= edge_lvl->totedge * powf(2, me->mr->current - me->mr->edgelvl);
const int threshold= edge_lvl->totedge * pow(2, me->mr->current - me->mr->edgelvl);
unsigned i;
for(i=0; i<cr_lvl->totedge; ++i) {

View File

@@ -3563,3 +3563,78 @@ int psys_get_particle_state(Object *ob, ParticleSystem *psys, int p, ParticleKey
//}
}
void psys_get_dupli_texture(Object *ob, ParticleSettings *part, ParticleSystemModifierData *psmd, ParticleData *pa, ChildParticle *cpa, float *uv, float *orco)
{
MFace *mface;
MTFace *mtface;
float loc[3];
int num;
if(cpa) {
if(part->childtype == PART_CHILD_FACES) {
mtface= CustomData_get_layer(&psmd->dm->faceData, CD_MTFACE);
if(mtface) {
mface= psmd->dm->getFaceData(psmd->dm, cpa->num, CD_MFACE);
mtface += cpa->num;
psys_interpolate_uvs(mtface, mface->v4, cpa->fuv, uv);
}
else
uv[0]= uv[1]= 0.0f;
}
else
uv[0]= uv[1]= 0.0f;
psys_particle_on_emitter(ob, psmd,
(part->childtype == PART_CHILD_FACES)? PART_FROM_FACE: PART_FROM_PARTICLE,
cpa->num,DMCACHE_ISCHILD,cpa->fuv,cpa->foffset,loc,0,0,0,orco,0);
}
else {
if(part->from == PART_FROM_FACE) {
mtface= CustomData_get_layer(&psmd->dm->faceData, CD_MTFACE);
num= pa->num_dmcache;
if(num == DMCACHE_NOTFOUND)
if(pa->num < psmd->dm->getNumFaces(psmd->dm))
num= pa->num;
if(mtface && num != DMCACHE_NOTFOUND) {
mface= psmd->dm->getFaceData(psmd->dm, num, CD_MFACE);
mtface += num;
psys_interpolate_uvs(mtface, mface->v4, pa->fuv, uv);
}
else
uv[0]= uv[1]= 0.0f;
}
else
uv[0]= uv[1]= 0.0f;
psys_particle_on_emitter(ob,psmd,part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,loc,0,0,0,orco,0);
}
}
void psys_get_dupli_path_transform(Object *ob, ParticleSettings *part, ParticleSystemModifierData *psmd, ParticleData *pa, ChildParticle *cpa, ParticleCacheKey *cache, float mat[][4], float *scale)
{
float loc[3], nor[3], vec[3], side[3], len;
VecSubf(vec, (cache+cache->steps-1)->co, cache->co);
len= Normalize(vec);
if(pa)
psys_particle_on_emitter(ob,psmd,part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,loc,nor,0,0,0,0);
else
psys_particle_on_emitter(ob, psmd,
(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);
Crossf(side, nor, vec);
Normalize(side);
Crossf(nor, vec, side);
Mat4One(mat);
VECCOPY(mat[0], vec);
VECCOPY(mat[1], side);
VECCOPY(mat[2], nor);
*scale= len;
}

View File

@@ -1138,7 +1138,7 @@ int psys_threads_init_distribution(ParticleThread *threads, DerivedMesh *finaldm
double step, pos;
step= (totpart <= 1)? 0.5: 1.0/(totpart-1);
pos= 0.0f;
pos= 1e-16f; /* tiny offset to avoid zero weight face */
i= 0;
for(p=0; p<totpart; p++, pos+=step) {
@@ -1146,6 +1146,8 @@ int psys_threads_init_distribution(ParticleThread *threads, DerivedMesh *finaldm
i++;
index[p]= MIN2(tot-1, i);
/* avoid zero weight face */
if(p == totpart-1 && weight[index[p]] == 0.0f)
index[p]= index[p-1];

View File

@@ -153,6 +153,7 @@ void free_scene(Scene *sce)
}
BLI_freelistN(&sce->markers);
BLI_freelistN(&sce->transform_spaces);
BLI_freelistN(&sce->r.layers);
if(sce->toolsettings){
@@ -703,4 +704,6 @@ void sculpt_reset_curve(SculptData *sd)
cm->curve[4].y= 0.20611;
cm->curve[5].x= 1;
cm->curve[5].y= 0;
curvemapping_changed(sd->cumap, 0);
}

View File

@@ -1510,14 +1510,20 @@ void scan_for_ext_spring_forces(Object *ob,float timenow)
}
f = Normalize(vel);
f = -0.0001f*f*f*sb->aeroedge;
/* todo add a nice angle dependant function */
/* look up one at bergman scheafer */
/* (todo) add a nice angle dependant function done for now BUT */
/* still there could be some nice drag/lift function, but who needs it */
VECSUB(sp, sb->bpoint[bs->v1].pos , sb->bpoint[bs->v2].pos);
Projf(pr,vel,sp);
VECSUB(vel,vel,pr);
Normalize(vel);
Vec3PlusStVec(bs->ext_force,f,vel);
if (ob->softflag & OB_SB_AERO_ANGLE){
Normalize(sp);
Vec3PlusStVec(bs->ext_force,f*(1.0f-ABS(Inpf(vel,sp))),vel);
}
else{
Vec3PlusStVec(bs->ext_force,f,vel); // to keep compatible with 2.45 release files
}
}
/* --- springs seeing wind */
}
@@ -2252,15 +2258,7 @@ static void softbody_calc_forces(Object *ob, float forcetime, float timenow, int
float defforce[3];
do_deflector = sb_detect_aabb_collisionCached(defforce,ob->lay,ob,timenow);
}
/*
if (do_selfcollision ){
float ce[3];
VecMidf(ce,sb->scratch->aabbmax,sb->scratch->aabbmin);
for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
bp->octantflag = set_octant_flags(ce,bp->pos,bp->colball);
}
}
*/
for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
/* clear forces accumulator */
bp->force[0]= bp->force[1]= bp->force[2]= 0.0;
@@ -3622,7 +3620,7 @@ SoftBody *sbNew(void)
sb->inspring= 0.5f;
sb->infrict= 0.5f;
/*todo backward file compat should copy infrict to inpush while reading old files*/
/*todo backward file compat should copy inspring to inpush while reading old files*/
sb->inpush = 0.5f;
sb->interval= 10;