diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-07-24 17:03:48 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-07-24 17:03:48 +0400 |
commit | 97d0846d2c4eb1610ca90120a8152b9dc54c5c57 (patch) | |
tree | bd1dd9b9c91ecb2da95cb8eb8a76161c7d0e878d /source/blender | |
parent | 1852cf26928ebcc6ead18f8241f99d138b666538 (diff) | |
parent | b09bb948ee5d59f80a4951ffd99733dd64f12a4a (diff) |
svn merge -r37335:37500 https://svn.blender.org/svnroot/bf-blender/trunk/blender
Diffstat (limited to 'source/blender')
66 files changed, 721 insertions, 642 deletions
diff --git a/source/blender/blenkernel/BKE_depsgraph.h b/source/blender/blenkernel/BKE_depsgraph.h index 14251fb1762..f36073ba841 100644 --- a/source/blender/blenkernel/BKE_depsgraph.h +++ b/source/blender/blenkernel/BKE_depsgraph.h @@ -51,22 +51,23 @@ struct GHash; /* **** DAG relation types *** */ /* scene link to object */ -#define DAG_RL_SCENE 1 +#define DAG_RL_SCENE (1<<0) /* object link to data */ -#define DAG_RL_DATA 2 +#define DAG_RL_DATA (1<<1) /* object changes object (parent, track, constraints) */ -#define DAG_RL_OB_OB 4 +#define DAG_RL_OB_OB (1<<2) /* object changes obdata (hooks, constraints) */ -#define DAG_RL_OB_DATA 8 +#define DAG_RL_OB_DATA (1<<3) /* data changes object (vertex parent) */ -#define DAG_RL_DATA_OB 16 +#define DAG_RL_DATA_OB (1<<4) /* data changes data (deformers) */ -#define DAG_RL_DATA_DATA 32 +#define DAG_RL_DATA_DATA (1<<5) -#define DAG_NO_RELATION 64 -#define DAG_RL_ALL 63 -#define DAG_RL_ALL_BUT_DATA 61 +#define DAG_NO_RELATION (1<<6) + +#define DAG_RL_ALL_BUT_DATA (DAG_RL_SCENE|DAG_RL_OB_OB|DAG_RL_OB_DATA|DAG_RL_DATA_OB|DAG_RL_DATA_DATA) +#define DAG_RL_ALL (DAG_RL_ALL_BUT_DATA|DAG_RL_DATA) typedef void (*graph_action_func)(void * ob, void **data); diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h index 4dfc53e1734..feeab98ad78 100644 --- a/source/blender/blenkernel/BKE_particle.h +++ b/source/blender/blenkernel/BKE_particle.h @@ -300,6 +300,8 @@ void psys_get_pointcache_start_end(struct Scene *scene, ParticleSystem *psys, in void psys_check_boid_data(struct ParticleSystem *psys); +void psys_get_birth_coordinates(struct ParticleSimulationData *sim, struct ParticleData *pa, struct ParticleKey *state, float dtime, float cfra); + void particle_system_update(struct Scene *scene, struct Object *ob, struct ParticleSystem *psys); /* ----------- functions needed only inside particlesystem ------------ */ diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index a1822848048..f16b2ae384c 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -180,7 +180,6 @@ static void clean_paths(Main *main) BLI_bpathIterator_free(bpi); for(scene= main->scene.first; scene; scene= scene->id.next) { - BLI_clean(scene->r.backbuf); BLI_clean(scene->r.pic); } } diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index 941f377ab42..f09d955033d 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -493,7 +493,7 @@ static void mesh_edges_nearest_point(void *userdata, int index, const float *co, // NOTE: casts to "float*" here are due to co being "const float*" closest_to_line_segment_v3(nearest_tmp, (float*)co, t0, t1); - dist = len_v3v3(nearest_tmp, (float*)co); + dist = len_squared_v3v3(nearest_tmp, (float*)co); if(dist < nearest->dist) { diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 64ac05fc2b1..161f05b6fc9 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -1168,7 +1168,7 @@ static void old_mdisps_rotate(int S, int UNUSED(newside), int oldside, int x, in static void old_mdisps_convert(MFace *mface, MDisps *mdisp) { - int newlvl = log(sqrt(mdisp->totdisp)-1)/log(2); + int newlvl = log(sqrt(mdisp->totdisp)-1)/M_LN2; int oldlvl = newlvl+1; int oldside = multires_side_tot[oldlvl]; int newside = multires_side_tot[newlvl]; diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index d742e32c9e3..4e3840832bb 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -59,7 +59,6 @@ #include "DNA_ipo_types.h" // XXX old animation system stuff... to be removed! #include "DNA_listBase.h" -#include "BLI_utildefines.h" #include "BLI_edgehash.h" #include "BLI_rand.h" #include "BLI_jitter.h" @@ -70,6 +69,7 @@ #include "BLI_listbase.h" #include "BLI_threads.h" #include "BLI_storage.h" /* For _LARGEFILE64_SOURCE; zlib needs this on some systems */ +#include "BLI_utildefines.h" #include "BKE_main.h" #include "BKE_animsys.h" @@ -356,9 +356,9 @@ void psys_calc_dmcache(Object *ob, DerivedMesh *dm, ParticleSystem *psys) origindex= dm->getVertDataArray(dm, CD_ORIGINDEX); } else { /* FROM_FACE/FROM_VOLUME */ - totdmelem= dm->getNumTessFaces(dm); + totdmelem= dm->getNumFaces(dm); totelem= me->totface; - origindex= dm->getTessFaceDataArray(dm, CD_ORIGINDEX); + origindex= dm->getFaceDataArray(dm, CD_ORIGINDEX); } nodedmelem= MEM_callocN(sizeof(LinkNode)*totdmelem, "psys node elems"); @@ -527,8 +527,8 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys) int a, a1, a2, a0mul, a1mul, a2mul, totface; int amax= from==PART_FROM_FACE ? 3 : 1; - totface=dm->getNumTessFaces(dm); - mface=mface_array=dm->getTessFaceDataArray(dm,CD_MFACE); + totface=dm->getNumFaces(dm); + mface_array= dm->getFaceDataArray(dm,CD_MFACE); for(a=0; a<amax; a++){ if(a==0){ a0mul=res*res; a1mul=res; a2mul=1; } @@ -787,7 +787,7 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch MFace *mface; pa->num = i = ctx->index[p]; - mface = dm->getTessFaceData(dm,i,CD_MFACE); + mface = dm->getFaceData(dm,i,CD_MFACE); switch(distr){ case PART_DISTR_JIT: @@ -817,7 +817,7 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch if(from==PART_FROM_VOLUME){ MVert *mvert=dm->getVertDataArray(dm,CD_MVERT); - tot=dm->getNumTessFaces(dm); + tot=dm->getNumFaces(dm); psys_interpolate_face(mvert,mface,0,0,pa->fuv,co1,nor,0,0,0,0); @@ -829,7 +829,7 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch min_d=2.0; intersect=0; - for(i=0,mface=dm->getTessFaceDataArray(dm,CD_MFACE); i<tot; i++,mface++){ + for(i=0,mface=dm->getFaceDataArray(dm,CD_MFACE); i<tot; i++,mface++){ if(i==pa->num) continue; v1=mvert[mface->v1].co; @@ -877,7 +877,7 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch return; } - mf= dm->getTessFaceData(dm, ctx->index[p], CD_MFACE); + mf= dm->getFaceData(dm, ctx->index[p], CD_MFACE); randu= rng_getFloat(thread->rng); randv= rng_getFloat(thread->rng); @@ -1044,7 +1044,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D if(totpart==0) return 0; - if (!finaldm->deformedOnly && !finaldm->getTessFaceDataArray(finaldm, CD_ORIGINDEX)) { + if (!finaldm->deformedOnly && !finaldm->getFaceDataArray(finaldm, CD_ORIGINDEX)) { printf("Can't create particles with the current modifier stack, disable destructive modifiers\n"); // XXX error("Can't paint with the current modifier stack, disable destructive modifiers"); return 0; @@ -1121,7 +1121,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D } /* Get total number of emission elements and allocate needed arrays */ - totelem = (from == PART_FROM_VERT) ? dm->getNumVerts(dm) : dm->getNumTessFaces(dm); + totelem = (from == PART_FROM_VERT) ? dm->getNumVerts(dm) : dm->getNumFaces(dm); if(totelem == 0){ distribute_invalid(scene, psys, children ? PART_FROM_CHILD : 0); @@ -1147,7 +1147,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D orcodata= dm->getVertDataArray(dm, CD_ORCO); for(i=0; i<totelem; i++){ - MFace *mf=dm->getTessFaceData(dm,i,CD_MFACE); + MFace *mf=dm->getFaceData(dm,i,CD_MFACE); if(orcodata) { VECCOPY(co1, orcodata[mf->v1]); @@ -1205,7 +1205,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D } else { /* PART_FROM_FACE / PART_FROM_VOLUME */ for(i=0;i<totelem; i++){ - MFace *mf=dm->getTessFaceData(dm,i,CD_MFACE); + MFace *mf=dm->getFaceData(dm,i,CD_MFACE); tweight = vweight[mf->v1] + vweight[mf->v2] + vweight[mf->v3]; if(mf->v4) { @@ -1280,7 +1280,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D } else { if(dm->numFaceData) - COMPARE_ORIG_INDEX= dm->getTessFaceDataArray(dm, CD_ORIGINDEX); + COMPARE_ORIG_INDEX= dm->getFaceDataArray(dm, CD_ORIGINDEX); } if(COMPARE_ORIG_INDEX) { @@ -1503,7 +1503,7 @@ void initialize_particle(ParticleSimulationData *sim, ParticleData *pa, int p) pa->time = (part->type == PART_HAIR) ? 0.f : part->sta + (part->end - part->sta)*ptex.time; } - + pa->hair_index = 0; /* we can't reset to -1 anymore since we've figured out correct index in distribute_particles */ /* usage other than straight after distribute has to handle this index by itself - jahka*/ @@ -1562,8 +1562,7 @@ static void initialize_all_particles(ParticleSimulationData *sim) } } } -/* sets particle to the emitter surface with initial velocity & rotation */ -void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, float cfra) +void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, ParticleKey *state, float dtime, float cfra) { Object *ob = sim->ob; ParticleSystem *psys = sim->psys; @@ -1576,17 +1575,6 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, int p = pa - psys->particles; part=psys->part; - /* get precise emitter matrix if particle is born */ - if(part->type!=PART_HAIR && dtime > 0.f && pa->time < cfra && pa->time >= sim->psys->cfra) { - /* we have to force RECALC_ANIM here since where_is_objec_time only does drivers */ - while(ob) { - BKE_animsys_evaluate_animdata(&ob->id, ob->adt, pa->time, ADT_RECALC_ANIM); - ob = ob->parent; - } - ob = sim->ob; - where_is_object_time(sim->scene, ob, pa->time); - } - /* get birth location from object */ if(part->tanfac != 0.f) psys_particle_on_emitter(sim->psmd, part->from,pa->num, pa->num_dmcache, pa->fuv,pa->foffset,loc,nor,utan,vtan,0,0); @@ -1594,7 +1582,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, psys_particle_on_emitter(sim->psmd, part->from,pa->num, pa->num_dmcache, pa->fuv,pa->foffset,loc,nor,0,0,0,0); /* get possible textural influence */ - psys_get_texture(sim, pa, &ptex, PAMAP_IVEL|PAMAP_LIFE, cfra); + psys_get_texture(sim, pa, &ptex, PAMAP_IVEL, cfra); /* particles live in global space so */ /* let's convert: */ @@ -1654,37 +1642,27 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, mat4_to_quat(rot,ob->obmat); mul_qt_qtqt(r_rot,r_rot,rot); } -#if 0 - } -#endif if(part->phystype==PART_PHYS_BOIDS && pa->boid) { - BoidParticle *bpa = pa->boid; float dvec[3], q[4], mat[3][3]; - copy_v3_v3(pa->state.co,loc); + copy_v3_v3(state->co,loc); /* boids don't get any initial velocity */ - zero_v3(pa->state.vel); + zero_v3(state->vel); /* boids store direction in ave */ if(fabsf(nor[2])==1.0f) { - sub_v3_v3v3(pa->state.ave, loc, ob->obmat[3]); - normalize_v3(pa->state.ave); + sub_v3_v3v3(state->ave, loc, ob->obmat[3]); + normalize_v3(state->ave); } else { - VECCOPY(pa->state.ave, nor); + VECCOPY(state->ave, nor); } - /* and gravity in r_ve */ - bpa->gravity[0] = bpa->gravity[1] = 0.0f; - bpa->gravity[2] = -1.0f; - if((sim->scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) - && sim->scene->physics_settings.gravity[2]!=0.0f) - bpa->gravity[2] = sim->scene->physics_settings.gravity[2]; /* calculate rotation matrix */ - project_v3_v3v3(dvec, r_vel, pa->state.ave); - sub_v3_v3v3(mat[0], pa->state.ave, dvec); + project_v3_v3v3(dvec, r_vel, state->ave); + sub_v3_v3v3(mat[0], state->ave, dvec); normalize_v3(mat[0]); negate_v3_v3(mat[2], r_vel); normalize_v3(mat[2]); @@ -1692,12 +1670,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, /* apply rotation */ mat3_to_quat_is_ok( q,mat); - copy_qt_qt(pa->state.rot, q); - - bpa->data.health = part->boids->health; - bpa->data.mode = eBoidMode_InAir; - bpa->data.state_id = ((BoidState*)part->boids->states.first)->id; - bpa->data.acc[0]=bpa->data.acc[1]=bpa->data.acc[2]=0.0f; + copy_qt_qt(state->rot, q); } else { /* conversion done so now we apply new: */ @@ -1710,7 +1683,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, /* *emitter velocity */ if(dtime != 0.f && part->obfac != 0.f){ - sub_v3_v3v3(vel, loc, pa->state.co); + sub_v3_v3v3(vel, loc, state->co); mul_v3_fl(vel, part->obfac/dtime); } @@ -1747,13 +1720,13 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, if(part->partfac != 0.f) madd_v3_v3fl(vel, p_vel, part->partfac); - mul_v3_v3fl(pa->state.vel, vel, ptex.ivel); + mul_v3_v3fl(state->vel, vel, ptex.ivel); /* -location from emitter */ - copy_v3_v3(pa->state.co,loc); + copy_v3_v3(state->co,loc); /* -rotation */ - unit_qt(pa->state.rot); + unit_qt(state->rot); if(part->rotmode){ /* create vector into which rotation is aligned */ @@ -1793,31 +1766,74 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, axis_angle_to_quat( q_phase,x_vec, phasefac*(float)M_PI); /* combine base rotation & phase */ - mul_qt_qtqt(pa->state.rot, rot, q_phase); + mul_qt_qtqt(state->rot, rot, q_phase); } /* -angular velocity */ - zero_v3(pa->state.ave); + zero_v3(state->ave); if(part->avemode){ switch(part->avemode){ case PART_AVE_SPIN: - copy_v3_v3(pa->state.ave, vel); + copy_v3_v3(state->ave, vel); break; case PART_AVE_RAND: - copy_v3_v3(pa->state.ave, r_ave); + copy_v3_v3(state->ave, r_ave); break; } - normalize_v3(pa->state.ave); - mul_v3_fl(pa->state.ave,part->avefac); + normalize_v3(state->ave); + mul_v3_fl(state->ave, part->avefac); + } + } +} +/* sets particle to the emitter surface with initial velocity & rotation */ +void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, float cfra) +{ + Object *ob = sim->ob; + ParticleSystem *psys = sim->psys; + ParticleSettings *part; + ParticleTexture ptex; + int p = pa - psys->particles; + part=psys->part; + + /* get precise emitter matrix if particle is born */ + if(part->type!=PART_HAIR && dtime > 0.f && pa->time < cfra && pa->time >= sim->psys->cfra) { + /* we have to force RECALC_ANIM here since where_is_objec_time only does drivers */ + while(ob) { + BKE_animsys_evaluate_animdata(&ob->id, ob->adt, pa->time, ADT_RECALC_ANIM); + ob = ob->parent; } + ob = sim->ob; + where_is_object_time(sim->scene, ob, pa->time); + } + + psys_get_birth_coordinates(sim, pa, &pa->state, dtime, cfra); + + if(part->phystype==PART_PHYS_BOIDS && pa->boid) { + BoidParticle *bpa = pa->boid; + + /* and gravity in r_ve */ + bpa->gravity[0] = bpa->gravity[1] = 0.0f; + bpa->gravity[2] = -1.0f; + if((sim->scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) + && sim->scene->physics_settings.gravity[2]!=0.0f) + bpa->gravity[2] = sim->scene->physics_settings.gravity[2]; + + bpa->data.health = part->boids->health; + bpa->data.mode = eBoidMode_InAir; + bpa->data.state_id = ((BoidState*)part->boids->states.first)->id; + bpa->data.acc[0]=bpa->data.acc[1]=bpa->data.acc[2]=0.0f; } + if(part->type == PART_HAIR){ pa->lifetime = 100.0f; } else{ + /* get possible textural influence */ + psys_get_texture(sim, pa, &ptex, PAMAP_LIFE, cfra); + pa->lifetime = part->lifetime * ptex.life; if(part->randlife != 0.0f) @@ -1903,6 +1919,7 @@ static void set_keyed_keys(ParticleSimulationData *sim) PARTICLE_P; ParticleKey *key; int totpart = psys->totpart, k, totkeys = psys->totkeyed; + int keyed_flag = 0; ksim.scene= sim->scene; @@ -1932,6 +1949,8 @@ static void set_keyed_keys(ParticleSimulationData *sim) for(k=0; k<totkeys; k++) { ksim.ob = pt->ob ? pt->ob : sim->ob; ksim.psys = BLI_findlink(&ksim.ob->particlesystem, pt->psys - 1); + keyed_flag = (ksim.psys->flag & PSYS_KEYED); + ksim.psys->flag &= ~PSYS_KEYED; LOOP_PARTICLES { key = pa->keys + k; @@ -1955,6 +1974,8 @@ static void set_keyed_keys(ParticleSimulationData *sim) if(psys->flag & PSYS_KEYED_TIMING && pt->duration!=0.0f) k++; + ksim.psys->flag |= keyed_flag; + pt = (pt->next && pt->next->flag & PTARGET_VALID)? pt->next : psys->targets.first; } @@ -3410,7 +3431,7 @@ static void do_hair_dynamics(ParticleSimulationData *sim) } if(!dm) { - dm = psys->hair_in_dm = CDDM_new(totpoint, totedge, 0, 0, 0); + dm = psys->hair_in_dm = CDDM_new(totpoint, totedge, 0); DM_add_vert_layer(dm, CD_MDEFORMVERT, CD_CALLOC, NULL); } diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c index 16cef67ea6d..0d523599598 100644 --- a/source/blender/blenkernel/intern/sca.c +++ b/source/blender/blenkernel/intern/sca.c @@ -430,6 +430,7 @@ void init_actuator(bActuator *act) act->data= MEM_callocN(sizeof(bCameraActuator), "camact"); ca = act->data; ca->axis = ACT_CAMERA_X; + ca->damping = 1.0/32.0; break; case ACT_EDIT_OBJECT: act->data= MEM_callocN(sizeof(bEditObjectActuator), "editobact"); diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 11cdcddae3a..51eaba3c05b 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -476,8 +476,7 @@ Scene *add_scene(const char *name) sce->audio.doppler_factor = 1.0; sce->audio.speed_of_sound = 343.3; - strcpy(sce->r.backbuf, "//backbuf"); - strcpy(sce->r.pic, U.renderdir); + BLI_strncpy(sce->r.pic, U.renderdir, sizeof(sce->r.pic)); BLI_init_rctf(&sce->r.safety, 0.1f, 0.9f, 0.1f, 0.9f); sce->r.osa= 8; diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index c19a74deff6..fbb5a77fa04 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -1582,7 +1582,7 @@ typedef struct WipeZone { static void precalc_wipe_zone(WipeZone *wipezone, WipeVars *wipe, int xo, int yo) { wipezone->flip = (wipe->angle < 0); - wipezone->angle = pow(fabsf(wipe->angle)/45.0f, log(xo)/log(2.0f)); + wipezone->angle = pow(fabsf(wipe->angle)/45.0f, log(xo)/M_LN2); wipezone->xo = xo; wipezone->yo = yo; wipezone->width = (int)(wipe->edgeWidth*((xo+yo)/2.0f)); diff --git a/source/blender/blenlib/intern/math_base_inline.c b/source/blender/blenlib/intern/math_base_inline.c index d37f1d6c5f0..2a2b1100fd9 100644 --- a/source/blender/blenlib/intern/math_base_inline.c +++ b/source/blender/blenlib/intern/math_base_inline.c @@ -114,7 +114,7 @@ MINLINE float shell_angle_to_dist(const float angle) /* used for zoom values*/ MINLINE float power_of_2(float val) { - return (float)pow(2.0, ceil(log((double)val) / log(2.0))); + return (float)pow(2.0, ceil(log((double)val) / M_LN2)); } MINLINE float minf(float a, float b) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index d0b0f3aa1e3..0e975ab2d2f 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -11713,6 +11713,21 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } } + + { + /* add default value for behind strength of camera actuator */ + Object *ob; + bActuator *act; + for(ob = main->object.first; ob; ob= ob->id.next) { + for(act= ob->actuators.first; act; act= act->next) { + if (act->type == ACT_CAMERA) { + bCameraActuator *ba= act->data; + + ba->damping = 1.0/32.0; + } + } + } + } } /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ diff --git a/source/blender/blenpluginapi/iff.h b/source/blender/blenpluginapi/iff.h index bccc7bdb769..77cdf889ea5 100644 --- a/source/blender/blenpluginapi/iff.h +++ b/source/blender/blenpluginapi/iff.h @@ -113,9 +113,10 @@ LIBIMPORT void interlace(struct ImBuf *ib); LIBIMPORT void IMB_rectcpy(struct ImBuf *dbuf, struct ImBuf *sbuf, int destx, int desty, int srcx, int srcy, int width, int height); -LIBIMPORT void IMB_rectfill(struct ImBuf *drect, float col[4]); +LIBIMPORT void IMB_rectfill(struct ImBuf *drect, const float col[4]); LIBIMPORT void IMB_rectfill_area(struct ImBuf *ibuf, float *col, int x1, int y1, int x2, int y2); LIBIMPORT void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, float *col, int x1, int y1, int x2, int y2); +LIBIMPORT void IMB_rectfill_alpha(struct ImBuf *drect, const float value); #endif /* IFF_H */ diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 72341e1caa2..10e6d611cc5 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -959,12 +959,12 @@ bool DocumentImporter::writeLight( const COLLADAFW::Light* light ) if(IS_EQ(linatt, 0.0f) && quadatt > 0.0f) { att2 = quadatt; - d = (1.0f/quadatt) * 2; + d = sqrt(1.0f/quadatt); } // linear light else if(IS_EQ(quadatt, 0.0f) && linatt > 0.0f) { att1 = linatt; - d = (1.0f/linatt) * 2; + d = (1.0f/linatt); } else if (IS_EQ(constatt, 1.0f)) { att1 = 1.0f; } else { @@ -987,9 +987,12 @@ bool DocumentImporter::writeLight( const COLLADAFW::Light* light ) case COLLADAFW::Light::SPOT_LIGHT: { lamp->type = LA_SPOT; - lamp->falloff_type = LA_FALLOFF_INVSQUARE; lamp->att1 = att1; lamp->att2 = att2; + if(IS_EQ(att1, 0.0f) && att2 > 0) + lamp->falloff_type = LA_FALLOFF_INVSQUARE; + if(IS_EQ(att2, 0.0f) && att1 > 0) + lamp->falloff_type = LA_FALLOFF_INVLINEAR; lamp->spotsize = light->getFallOffAngle().getValue(); lamp->spotblend = light->getFallOffExponent().getValue(); } @@ -1004,9 +1007,12 @@ bool DocumentImporter::writeLight( const COLLADAFW::Light* light ) case COLLADAFW::Light::POINT_LIGHT: { lamp->type = LA_LOCAL; - lamp->falloff_type = LA_FALLOFF_INVSQUARE; lamp->att1 = att1; lamp->att2 = att2; + if(IS_EQ(att1, 0.0f) && att2 > 0) + lamp->falloff_type = LA_FALLOFF_INVSQUARE; + if(IS_EQ(att2, 0.0f) && att1 > 0) + lamp->falloff_type = LA_FALLOFF_INVLINEAR; } break; case COLLADAFW::Light::UNDEFINED: diff --git a/source/blender/collada/LightExporter.cpp b/source/blender/collada/LightExporter.cpp index 89599c62768..12ccf77f6ad 100644 --- a/source/blender/collada/LightExporter.cpp +++ b/source/blender/collada/LightExporter.cpp @@ -68,20 +68,18 @@ void LightsExporter::operator()(Object *ob) std::string la_name(id_name(la)); COLLADASW::Color col(la->r * la->energy, la->g * la->energy, la->b * la->energy); float e, d, constatt, linatt, quadatt; - float r; d = la->dist; - r = d/2.0f; constatt = 1.0f; if(la->falloff_type==LA_FALLOFF_INVLINEAR) { - linatt = 1.0f / r; + linatt = 1.0f / d; quadatt = 0.0f; } else { linatt = 0.0f; - quadatt = 1.0f / r; + quadatt = 1.0f / (d * d); } // sun diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 99b4b68b42d..37e4cc7616b 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1733,7 +1733,7 @@ void ui_set_but_default(bContext *C, short all) static double soft_range_round_up(double value, double max) { /* round up to .., 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50, .. */ - double newmax= pow(10.0, ceil(log(value)/log(10.0))); + double newmax= pow(10.0, ceil(log(value)/M_LN10)); if(newmax*0.2 >= max && newmax*0.2 >= value) return newmax*0.2; @@ -1746,7 +1746,7 @@ static double soft_range_round_up(double value, double max) static double soft_range_round_down(double value, double max) { /* round down to .., 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50, .. */ - double newmax= pow(10.0, floor(log(value)/log(10.0))); + double newmax= pow(10.0, floor(log(value)/M_LN10)); if(newmax*5.0 <= max && newmax*5.0 <= value) return newmax*5.0; diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index bbd1bd8773b..32a20e82d2f 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -1586,21 +1586,22 @@ static uiBlock *curvemap_clipping_func(bContext *C, struct ARegion *ar, void *cu CurveMapping *cumap = cumap_v; uiBlock *block; uiBut *bt; + float width= 8*UI_UNIT_X; block= uiBeginBlock(C, ar, "curvemap_clipping_func", UI_EMBOSS); /* use this for a fake extra empy space around the buttons */ - uiDefBut(block, LABEL, 0, "", -4, 16, 128, 106, NULL, 0, 0, 0, 0, ""); + uiDefBut(block, LABEL, 0, "", -4, 16, width+8, 6*UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); bt= uiDefButBitI(block, TOG, CUMA_DO_CLIP, 1, "Use Clipping", - 0,100,120,18, &cumap->flag, 0.0, 0.0, 10, 0, ""); + 0,5*UI_UNIT_Y,width,UI_UNIT_Y, &cumap->flag, 0.0, 0.0, 10, 0, ""); uiButSetFunc(bt, curvemap_buttons_setclip, cumap, NULL); uiBlockBeginAlign(block); - uiDefButF(block, NUM, 0, "Min X ", 0,74,120,18, &cumap->clipr.xmin, -100.0, cumap->clipr.xmax, 10, 0, ""); - uiDefButF(block, NUM, 0, "Min Y ", 0,56,120,18, &cumap->clipr.ymin, -100.0, cumap->clipr.ymax, 10, 0, ""); - uiDefButF(block, NUM, 0, "Max X ", 0,38,120,18, &cumap->clipr.xmax, cumap->clipr.xmin, 100.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "Max Y ", 0,20,120,18, &cumap->clipr.ymax, cumap->clipr.ymin, 100.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "Min X ", 0,4*UI_UNIT_Y,width,UI_UNIT_Y, &cumap->clipr.xmin, -100.0, cumap->clipr.xmax, 10, 0, ""); + uiDefButF(block, NUM, 0, "Min Y ", 0,3*UI_UNIT_Y,width,UI_UNIT_Y, &cumap->clipr.ymin, -100.0, cumap->clipr.ymax, 10, 0, ""); + uiDefButF(block, NUM, 0, "Max X ", 0,2*UI_UNIT_Y,width,UI_UNIT_Y, &cumap->clipr.xmax, cumap->clipr.xmin, 100.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "Max Y ", 0,UI_UNIT_Y,width,UI_UNIT_Y, &cumap->clipr.ymax, cumap->clipr.ymin, 100.0, 10, 0, ""); uiBlockSetDirection(block, UI_RIGHT); @@ -1644,17 +1645,17 @@ static void curvemap_tools_dofunc(bContext *C, void *cumap_v, int event) static uiBlock *curvemap_tools_func(bContext *C, struct ARegion *ar, void *cumap_v) { uiBlock *block; - short yco= 0, menuwidth=120; + short yco= 0, menuwidth=10*UI_UNIT_X; block= uiBeginBlock(C, ar, "curvemap_tools_func", UI_EMBOSS); uiBlockSetButmFunc(block, curvemap_tools_dofunc, cumap_v); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset View", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Vector Handle", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Auto Handle", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Extend Horizontal", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Extend Extrapolated", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset Curve", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset View", 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 1, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Vector Handle", 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 2, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Auto Handle", 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 3, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Extend Horizontal", 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 4, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Extend Extrapolated", 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 5, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset Curve", 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); uiBlockSetDirection(block, UI_RIGHT); uiTextBoundsBlock(block, 50); @@ -1666,15 +1667,15 @@ static uiBlock *curvemap_tools_func(bContext *C, struct ARegion *ar, void *cumap static uiBlock *curvemap_brush_tools_func(bContext *C, struct ARegion *ar, void *cumap_v) { uiBlock *block; - short yco= 0, menuwidth=120; + short yco= 0, menuwidth=10*UI_UNIT_X; block= uiBeginBlock(C, ar, "curvemap_tools_func", UI_EMBOSS); uiBlockSetButmFunc(block, curvemap_tools_dofunc, cumap_v); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset View", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Vector Handle", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Auto Handle", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset Curve", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset View", 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 1, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Vector Handle", 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 2, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Auto Handle", 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 3, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset Curve", 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); uiBlockSetDirection(block, UI_RIGHT); uiTextBoundsBlock(block, 50); @@ -1728,15 +1729,15 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); if(cumap->cm[0].curve) { - bt= uiDefButI(block, ROW, 0, "X", 0, 0, dx, 16, &cumap->cur, 0.0, 0.0, 0.0, 0.0, ""); + bt= uiDefButI(block, ROW, 0, "X", 0, 0, dx, dx, &cumap->cur, 0.0, 0.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } if(cumap->cm[1].curve) { - bt= uiDefButI(block, ROW, 0, "Y", 0, 0, dx, 16, &cumap->cur, 0.0, 1.0, 0.0, 0.0, ""); + bt= uiDefButI(block, ROW, 0, "Y", 0, 0, dx, dx, &cumap->cur, 0.0, 1.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } if(cumap->cm[2].curve) { - bt= uiDefButI(block, ROW, 0, "Z", 0, 0, dx, 16, &cumap->cur, 0.0, 2.0, 0.0, 0.0, ""); + bt= uiDefButI(block, ROW, 0, "Z", 0, 0, dx, dx, &cumap->cur, 0.0, 2.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } } @@ -1746,19 +1747,19 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); if(cumap->cm[3].curve) { - bt= uiDefButI(block, ROW, 0, "C", 0, 0, dx, 16, &cumap->cur, 0.0, 3.0, 0.0, 0.0, ""); + bt= uiDefButI(block, ROW, 0, "C", 0, 0, dx, dx, &cumap->cur, 0.0, 3.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } if(cumap->cm[0].curve) { - bt= uiDefButI(block, ROW, 0, "R", 0, 0, dx, 16, &cumap->cur, 0.0, 0.0, 0.0, 0.0, ""); + bt= uiDefButI(block, ROW, 0, "R", 0, 0, dx, dx, &cumap->cur, 0.0, 0.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } if(cumap->cm[1].curve) { - bt= uiDefButI(block, ROW, 0, "G", 0, 0, dx, 16, &cumap->cur, 0.0, 1.0, 0.0, 0.0, ""); + bt= uiDefButI(block, ROW, 0, "G", 0, 0, dx, dx, &cumap->cur, 0.0, 1.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } if(cumap->cm[2].curve) { - bt= uiDefButI(block, ROW, 0, "B", 0, 0, dx, 16, &cumap->cur, 0.0, 2.0, 0.0, 0.0, ""); + bt= uiDefButI(block, ROW, 0, "B", 0, 0, dx, dx, &cumap->cur, 0.0, 2.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } } @@ -1768,15 +1769,15 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); if(cumap->cm[0].curve) { - bt= uiDefButI(block, ROW, 0, "H", 0, 0, dx, 16, &cumap->cur, 0.0, 0.0, 0.0, 0.0, ""); + bt= uiDefButI(block, ROW, 0, "H", 0, 0, dx, dx, &cumap->cur, 0.0, 0.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } if(cumap->cm[1].curve) { - bt= uiDefButI(block, ROW, 0, "S", 0, 0, dx, 16, &cumap->cur, 0.0, 1.0, 0.0, 0.0, ""); + bt= uiDefButI(block, ROW, 0, "S", 0, 0, dx, dx, &cumap->cur, 0.0, 1.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } if(cumap->cm[2].curve) { - bt= uiDefButI(block, ROW, 0, "V", 0, 0, dx, 16, &cumap->cur, 0.0, 2.0, 0.0, 0.0, ""); + bt= uiDefButI(block, ROW, 0, "V", 0, 0, dx, dx, &cumap->cur, 0.0, 2.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } } @@ -1791,24 +1792,24 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe uiBlockSetEmboss(block, UI_EMBOSSN); - bt= uiDefIconBut(block, BUT, 0, ICON_ZOOMIN, 0, 0, dx, 14, NULL, 0.0, 0.0, 0.0, 0.0, "Zoom in"); + bt= uiDefIconBut(block, BUT, 0, ICON_ZOOMIN, 0, 0, dx, dx, NULL, 0.0, 0.0, 0.0, 0.0, "Zoom in"); uiButSetFunc(bt, curvemap_buttons_zoom_in, cumap, NULL); - bt= uiDefIconBut(block, BUT, 0, ICON_ZOOMOUT, 0, 0, dx, 14, NULL, 0.0, 0.0, 0.0, 0.0, "Zoom out"); + bt= uiDefIconBut(block, BUT, 0, ICON_ZOOMOUT, 0, 0, dx, dx, NULL, 0.0, 0.0, 0.0, 0.0, "Zoom out"); uiButSetFunc(bt, curvemap_buttons_zoom_out, cumap, NULL); if(brush) - bt= uiDefIconBlockBut(block, curvemap_brush_tools_func, cumap, 0, ICON_MODIFIER, 0, 0, dx, 18, "Tools"); + bt= uiDefIconBlockBut(block, curvemap_brush_tools_func, cumap, 0, ICON_MODIFIER, 0, 0, dx, dx, "Tools"); else - bt= uiDefIconBlockBut(block, curvemap_tools_func, cumap, 0, ICON_MODIFIER, 0, 0, dx, 18, "Tools"); + bt= uiDefIconBlockBut(block, curvemap_tools_func, cumap, 0, ICON_MODIFIER, 0, 0, dx, dx, "Tools"); uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); if(cumap->flag & CUMA_DO_CLIP) icon= ICON_CLIPUV_HLT; else icon= ICON_CLIPUV_DEHLT; - bt= uiDefIconBlockBut(block, curvemap_clipping_func, cumap, 0, icon, 0, 0, dx, 18, "Clipping Options"); + bt= uiDefIconBlockBut(block, curvemap_clipping_func, cumap, 0, icon, 0, 0, dx, dx, "Clipping Options"); uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); - bt= uiDefIconBut(block, BUT, 0, ICON_X, 0, 0, dx, 18, NULL, 0.0, 0.0, 0.0, 0.0, "Delete points"); + bt= uiDefIconBut(block, BUT, 0, ICON_X, 0, 0, dx, dx, NULL, 0.0, 0.0, 0.0, 0.0, "Delete points"); uiButSetNFunc(bt, curvemap_buttons_delete, MEM_dupallocN(cb), cumap); uiBlockSetEmboss(block, UI_EMBOSS); diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 41bb12e4433..b6e255b6758 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -2326,39 +2326,43 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s wtb.outline= 0; widgetbase_draw(&wtb, wcol); - /* slider part */ - VECCOPY(outline, wcol->outline); - VECCOPY(wcol->outline, wcol->item); - VECCOPY(wcol->inner, wcol->item); + /* draw left/right parts only when not in text editing */ + if(!(state & UI_TEXTINPUT)) { + + /* slider part */ + VECCOPY(outline, wcol->outline); + VECCOPY(wcol->outline, wcol->item); + VECCOPY(wcol->inner, wcol->item); - if(!(state & UI_SELECT)) - SWAP(short, wcol->shadetop, wcol->shadedown); - - rect1= *rect; - - value= ui_get_but_val(but); - fac= ((float)value-but->softmin)*(rect1.xmax - rect1.xmin - offs)/(but->softmax - but->softmin); - - /* left part of slider, always rounded */ - rect1.xmax= rect1.xmin + ceil(offs+1.0f); - round_box_edges(&wtb1, roundboxalign & ~6, &rect1, offs); - wtb1.outline= 0; - widgetbase_draw(&wtb1, wcol); - - /* right part of slider, interpolate roundness */ - rect1.xmax= rect1.xmin + fac + offs; - rect1.xmin+= floor(offs-1.0f); - if(rect1.xmax + offs > rect->xmax) - offs*= (rect1.xmax + offs - rect->xmax)/offs; - else - offs= 0.0f; - round_box_edges(&wtb1, roundboxalign & ~9, &rect1, offs); - - widgetbase_draw(&wtb1, wcol); - VECCOPY(wcol->outline, outline); - - if(!(state & UI_SELECT)) - SWAP(short, wcol->shadetop, wcol->shadedown); + if(!(state & UI_SELECT)) + SWAP(short, wcol->shadetop, wcol->shadedown); + + rect1= *rect; + + value= ui_get_but_val(but); + fac= ((float)value-but->softmin)*(rect1.xmax - rect1.xmin - offs)/(but->softmax - but->softmin); + + /* left part of slider, always rounded */ + rect1.xmax= rect1.xmin + ceil(offs+1.0f); + round_box_edges(&wtb1, roundboxalign & ~6, &rect1, offs); + wtb1.outline= 0; + widgetbase_draw(&wtb1, wcol); + + /* right part of slider, interpolate roundness */ + rect1.xmax= rect1.xmin + fac + offs; + rect1.xmin+= floor(offs-1.0f); + if(rect1.xmax + offs > rect->xmax) + offs*= (rect1.xmax + offs - rect->xmax)/offs; + else + offs= 0.0f; + round_box_edges(&wtb1, roundboxalign & ~9, &rect1, offs); + + widgetbase_draw(&wtb1, wcol); + VECCOPY(wcol->outline, outline); + + if(!(state & UI_SELECT)) + SWAP(short, wcol->shadetop, wcol->shadedown); + } /* outline */ wtb.outline= 1; @@ -2597,6 +2601,7 @@ static void widget_box(uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED( /* store the box bg as gl clearcolor, to retrieve later when drawing semi-transparent rects * over the top to indicate disabled buttons */ + /* XXX, this doesnt work right since the color applies to buttons outside the box too. */ glClearColor(wcol->inner[0]/255.0, wcol->inner[1]/255.0, wcol->inner[2]/255.0, 1.0); VECCOPY(wcol->inner, old_col); @@ -2872,7 +2877,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct ThemeUI *tui= &btheme->tui; uiFontStyle *fstyle= &style->widget; uiWidgetType *wt= NULL; - + /* handle menus separately */ if(but->dt==UI_EMBOSSP) { switch (but->type) { diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index 5dc161c6267..5eb3606d68d 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -902,29 +902,7 @@ static void finish_images(MultiresBakeRender *bkr) if(ibuf->x<=0 || ibuf->y<=0) continue; - /* Margin */ - if(bkr->bake_filter) { - char *temprect; - - /* extend the mask +2 pixels from the image, - * this is so colors dont blend in from outside */ - - for(i=0; i<bkr->bake_filter; i++) - IMB_mask_filter_extend((char *)ibuf->userdata, ibuf->x, ibuf->y); - - temprect = MEM_dupallocN(ibuf->userdata); - - /* expand twice to clear this many pixels, so they blend back in */ - IMB_mask_filter_extend(temprect, ibuf->x, ibuf->y); - IMB_mask_filter_extend(temprect, ibuf->x, ibuf->y); - - /* clear all pixels in the margin */ - IMB_mask_clear(ibuf, temprect, FILTER_MASK_MARGIN); - MEM_freeN(temprect); - - for(i= 0; i<bkr->bake_filter; i++) - IMB_filter_extend(ibuf, (char *)ibuf->userdata); - } + RE_bake_ibuf_filter(ibuf, (unsigned char *)ibuf->userdata, bkr->bake_filter); ibuf->userflags|= IB_BITMAPDIRTY; if(ibuf->mipmap[0]) { @@ -1072,7 +1050,8 @@ static DerivedMesh *multiresbake_create_hiresdm(Scene *scene, Object *ob, int *l static void clear_images(MTFace *mtface, int totface) { int a; - float vec[4]= {0.0f, 0.0f, 0.0f, 0.0f}; + const float vec_alpha[4]= {0.0f, 0.0f, 0.0f, 0.0f}; + const float vec_solid[4]= {0.0f, 0.0f, 0.0f, 1.0f}; for(a= 0; a<totface; a++) mtface[a].tpage->id.flag&= ~LIB_DOIT; @@ -1083,7 +1062,7 @@ static void clear_images(MTFace *mtface, int totface) if((ima->id.flag&LIB_DOIT)==0) { ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); - IMB_rectfill(ibuf, vec); + IMB_rectfill(ibuf, (ibuf->depth == 32) ? vec_alpha : vec_solid); ima->id.flag|= LIB_DOIT; } } @@ -1376,7 +1355,6 @@ static void finish_bake_internal(BakeRender *bkr) /* freed when baking is done, but if its canceled we need to free here */ if (ibuf->userdata) { - printf("freed\n"); MEM_freeN(ibuf->userdata); ibuf->userdata= NULL; } diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 5cc9166e973..fca35683c6f 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -67,7 +67,6 @@ #include "BKE_object.h" #include "BKE_particle.h" #include "BKE_softbody.h" -#include "BKE_tessmesh.h" #include "RNA_access.h" #include "RNA_define.h" @@ -217,15 +216,15 @@ int ED_object_modifier_remove(ReportList *reports, Main *bmain, Scene *scene, Ob } if(ok) { - if(me->edit_btmesh) { - BMEditMesh *em= me->edit_btmesh; + if(me->edit_mesh) { + EditMesh *em= me->edit_mesh; /* CustomData_external_remove is used here only to mark layer as non-external for further free-ing, so zero element count looks safer than em->totface */ - CustomData_external_remove(&em->bm->ldata, &me->id, CD_MDISPS, 0); - BM_free_data_layer(em->bm, &em->bm->ldata, CD_MDISPS); + CustomData_external_remove(&em->fdata, &me->id, CD_MDISPS, 0); + EM_free_data_layer(em, &em->fdata, CD_MDISPS); } else { - CustomData_external_remove(&me->ldata, &me->id, CD_MDISPS, me->totloop); - CustomData_free_layer_active(&me->ldata, CD_MDISPS, me->totloop); + CustomData_external_remove(&me->fdata, &me->id, CD_MDISPS, me->totface); + CustomData_free_layer_active(&me->fdata, CD_MDISPS, me->totface); } } } @@ -400,16 +399,12 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene * static int modifier_apply_shape(ReportList *reports, Scene *scene, Object *ob, ModifierData *md) { - /* - It should be ridiculously easy to extract the original verts that we want - and form the shape data. We can probably use the CD KEYINDEX layer (or - whatever I ended up calling it, too tired to check now), though this would - by necassity have to make some potentially ugly assumptions about the order - of the mesh data :-/ you can probably assume in 99% of cases that the first - element of a given index is the original, and any subsequent duplicates are - copies/interpolates, but that's an assumption that would need to be tested - and then predominantly stated in comments in a half dozen headers. - */ + ModifierTypeInfo *mti= modifierType_getInfo(md->type); + + if (mti->isDisabled && mti->isDisabled(md, 0)) { + BKE_report(reports, RPT_ERROR, "Modifier is disabled, skipping apply"); + return 0; + } if (ob->type==OB_MESH) { DerivedMesh *dm; @@ -423,7 +418,7 @@ static int modifier_apply_shape(ReportList *reports, Scene *scene, Object *ob, M } mesh_pmv_off(me); - dm = mesh_create_derived_for_modifier(scene, ob, md, 0); + dm = mesh_create_derived_for_modifier(scene, ob, md); if (!dm) { BKE_report(reports, RPT_ERROR, "Modifier is disabled or returned error, skipping apply"); return 0; @@ -454,7 +449,7 @@ static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob, { ModifierTypeInfo *mti= modifierType_getInfo(md->type); - if (!(md->mode&eModifierMode_Realtime) || (mti->isDisabled && mti->isDisabled(md, 0))) { + if (mti->isDisabled && mti->isDisabled(md, 0)) { BKE_report(reports, RPT_ERROR, "Modifier is disabled, skipping apply"); return 0; } @@ -463,7 +458,12 @@ static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob, DerivedMesh *dm; Mesh *me = ob->data; MultiresModifierData *mmd= find_multires_modifier_before(scene, md); - + + if( me->key) { + BKE_report(reports, RPT_ERROR, "Modifier cannot be applied to Mesh with Shape Keys"); + return 0; + } + mesh_pmv_off(me); /* Multires: ensure that recent sculpting is applied */ @@ -476,22 +476,22 @@ static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob, return 0; } } else { - dm = mesh_create_derived_for_modifier(scene, ob, md, 1); + dm = mesh_create_derived_for_modifier(scene, ob, md); if (!dm) { BKE_report(reports, RPT_ERROR, "Modifier returned error, skipping apply"); return 0; } - DM_to_mesh(dm, me, ob); + DM_to_mesh(dm, me); dm->release(dm); if(md->type == eModifierType_Multires) { - CustomData_external_remove(&me->ldata, &me->id, CD_MDISPS, me->totloop); - CustomData_free_layer_active(&me->ldata, CD_MDISPS, me->totloop); + CustomData_external_remove(&me->fdata, &me->id, CD_MDISPS, me->totface); + CustomData_free_layer_active(&me->fdata, CD_MDISPS, me->totface); } } - } + } else if (ELEM(ob->type, OB_CURVE, OB_SURF)) { Curve *cu; int numVerts; @@ -537,6 +537,8 @@ static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob, int ED_object_modifier_apply(ReportList *reports, Scene *scene, Object *ob, ModifierData *md, int mode) { + int prev_mode; + if (scene->obedit) { BKE_report(reports, RPT_ERROR, "Modifiers cannot be applied in editmode"); return 0; @@ -548,12 +550,20 @@ int ED_object_modifier_apply(ReportList *reports, Scene *scene, Object *ob, Modi if (md!=ob->modifiers.first) BKE_report(reports, RPT_INFO, "Applied modifier was not first, result may not be as expected."); + /* allow apply of a not-realtime modifier, by first re-enabling realtime. */ + prev_mode= md->mode; + md->mode |= eModifierMode_Realtime; + if (mode == MODIFIER_APPLY_SHAPE) { - if (!modifier_apply_shape(reports, scene, ob, md)) + if (!modifier_apply_shape(reports, scene, ob, md)) { + md->mode= prev_mode; return 0; + } } else { - if (!modifier_apply_obdata(reports, scene, ob, md)) + if (!modifier_apply_obdata(reports, scene, ob, md)) { + md->mode= prev_mode; return 0; + } } BLI_remlink(&ob->modifiers, md); @@ -1100,66 +1110,6 @@ void OBJECT_OT_multires_reshape(wmOperatorType *ot) edit_modifier_properties(ot); } -static int multires_test_exec(bContext *C, wmOperator *op) -{ - Object *ob= ED_object_active_context(C); - Mesh *me = ob->data; - MPoly *mp; - MDisps *mdisps; - int i, x = RNA_int_get(op->ptr, "x"), y = RNA_int_get(op->ptr, "y"); - - if (ob->type != OB_MESH || !me) - return OPERATOR_CANCELLED; - - mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS); - if (!mdisps) - return OPERATOR_CANCELLED; - - mp = me->mpoly; - for (i=0; i<me->totpoly; i++, mp++) { - MLoop *ml; - int j; - - ml = me->mloop + mp->loopstart; - for (j=0; j<mp->totloop; j++, ml++) { - MLoop *ml2 = me->mloop + mp->loopstart + (j+mp->totloop-1)%mp->totloop; - MLoop *ml3 = me->mloop + mp->loopstart + (j+1)%mp->totloop; - - if ((me->mvert[ml->v].flag&SELECT) && (me->mvert[ml2->v].flag&SELECT) && (me->mvert[ml3->v].flag&SELECT)) { - MDisps *md = mdisps + mp->loopstart + j; - int res = sqrt(md->totdisp); - - if (x >= res) x = res-1; - if (y >= res) y = res-1; - - md->disps[y*res + x][2] += 1.0; - } - } - } - - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); - - return OPERATOR_FINISHED; -} - -void OBJECT_OT_test_multires(wmOperatorType *ot) -{ - ot->name= "Multires Object Mode Test"; - ot->description= ""; - ot->idname= "OBJECT_OT_test_multires"; - - ot->poll= multires_poll; - ot->exec= multires_test_exec; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - RNA_def_int(ot->srna, "x", 0, 0, 100, "x", "x", 0, 100); - RNA_def_int(ot->srna, "y", 0, 0, 100, "y", "y", 0, 100); -} - - - /****************** multires save external operator *********************/ static int multires_external_save_exec(bContext *C, wmOperator *op) @@ -1172,7 +1122,7 @@ static int multires_external_save_exec(bContext *C, wmOperator *op) if(!me) return OPERATOR_CANCELLED; - if(CustomData_external_test(&me->ldata, CD_MDISPS)) + if(CustomData_external_test(&me->fdata, CD_MDISPS)) return OPERATOR_CANCELLED; RNA_string_get(op->ptr, "filepath", path); @@ -1180,8 +1130,8 @@ static int multires_external_save_exec(bContext *C, wmOperator *op) if(relative) BLI_path_rel(path, G.main->name); - CustomData_external_add(&me->ldata, &me->id, CD_MDISPS, me->totloop, path); - CustomData_external_write(&me->ldata, &me->id, CD_MASK_MESH, me->totloop, 0); + CustomData_external_add(&me->fdata, &me->id, CD_MDISPS, me->totface, path); + CustomData_external_write(&me->fdata, &me->id, CD_MASK_MESH, me->totface, 0); return OPERATOR_FINISHED; } @@ -1201,7 +1151,7 @@ static int multires_external_save_invoke(bContext *C, wmOperator *op, wmEvent *U if (!mmd) return OPERATOR_CANCELLED; - if(CustomData_external_test(&me->ldata, CD_MDISPS)) + if(CustomData_external_test(&me->fdata, CD_MDISPS)) return OPERATOR_CANCELLED; if(!RNA_property_is_set(op->ptr, "relative_path")) @@ -1245,11 +1195,11 @@ static int multires_external_pack_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob = ED_object_active_context(C); Mesh *me= ob->data; - if(!CustomData_external_test(&me->ldata, CD_MDISPS)) + if(!CustomData_external_test(&me->fdata, CD_MDISPS)) return OPERATOR_CANCELLED; // XXX don't remove.. - CustomData_external_remove(&me->ldata, &me->id, CD_MDISPS, me->totloop); + CustomData_external_remove(&me->fdata, &me->id, CD_MDISPS, me->totface); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index 4aa9b942cf3..b573c77c7f3 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -56,6 +56,7 @@ #include "DNA_object_fluidsim.h" #include "BLI_blenlib.h" +#include "BLI_fileops.h" #include "BLI_threads.h" #include "BLI_math.h" #include "BLI_utildefines.h" @@ -125,7 +126,7 @@ static void get_fluid_gravity(float *gravity, Scene *scene, FluidsimSettings *fs if (scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) { copy_v3_v3(gravity, scene->physics_settings.gravity); } else { - copy_v3_v3(gravity, &fss->gravx); + copy_v3_v3(gravity, fss->grav); } } @@ -443,7 +444,7 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid Object *ob = fobj->object; FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim); float active= (float)(fluidmd->fss->flag & OB_FLUIDSIM_ACTIVE); - float rot_d[3], old_rot[3] = {0.f, 0.f, 0.f}; + float rot_d[3] = {0.f, 0.f, 0.f}, old_rot[3] = {0.f, 0.f, 0.f}; if (ELEM(fluidmd->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE)) continue; @@ -809,6 +810,44 @@ static void fluidbake_free_data(FluidAnimChannels *channels, ListBase *fobjects, } } +/* copied from rna_fluidsim.c: fluidsim_find_lastframe() */ +static void fluidsim_delete_until_lastframe(FluidsimSettings *fss) +{ + char targetDir[FILE_MAXFILE+FILE_MAXDIR], targetFile[FILE_MAXFILE+FILE_MAXDIR]; + char targetDirVel[FILE_MAXFILE+FILE_MAXDIR], targetFileVel[FILE_MAXFILE+FILE_MAXDIR]; + char previewDir[FILE_MAXFILE+FILE_MAXDIR], previewFile[FILE_MAXFILE+FILE_MAXDIR]; + int curFrame = 1, exists = 0; + + BLI_snprintf(targetDir, sizeof(targetDir), "%sfluidsurface_final_####.bobj.gz", fss->surfdataPath); + BLI_snprintf(targetDirVel, sizeof(targetDir), "%sfluidsurface_final_####.bvel.gz", fss->surfdataPath); + BLI_snprintf(previewDir, sizeof(targetDir), "%sfluidsurface_preview_####.bobj.gz", fss->surfdataPath); + + BLI_path_abs(targetDir, G.main->name); + BLI_path_abs(targetDirVel, G.main->name); + BLI_path_abs(previewDir, G.main->name); + + do { + BLI_strncpy(targetFile, targetDir, sizeof(targetFile)); + BLI_strncpy(targetFileVel, targetDirVel, sizeof(targetFileVel)); + BLI_strncpy(previewFile, previewDir, sizeof(previewFile)); + + BLI_path_frame(targetFile, curFrame, 0); + BLI_path_frame(targetFileVel, curFrame, 0); + BLI_path_frame(previewFile, curFrame, 0); + + curFrame++; + + if((exists = BLI_exist(targetFile))) + { + BLI_delete(targetFile, 0, 0); + BLI_delete(targetFileVel, 0, 0); + BLI_delete(previewFile, 0, 0); + } + } while(exists); + + return; +} + static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain) { Scene *scene= CTX_data_scene(C); @@ -878,6 +917,9 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain) // reset last valid frame domainSettings->lastgoodframe = -1; + + /* delete old baked files */ + fluidsim_delete_until_lastframe(domainSettings); /* rough check of settings... */ if(domainSettings->previewresxyz > domainSettings->resolutionxyz) { @@ -1018,6 +1060,13 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain) else if (domainSettings->typeFlags&OB_FSBND_PARTSLIP) fsset->domainobsType = FLUIDSIM_OBSTACLE_PARTSLIP; else if (domainSettings->typeFlags&OB_FSBND_FREESLIP) fsset->domainobsType = FLUIDSIM_OBSTACLE_FREESLIP; fsset->domainobsPartslip = domainSettings->partSlipValue; + + /* use domainobsType also for surface generation flag (bit: >=64) */ + if(domainSettings->typeFlags & OB_FSSG_NOOBS) + fsset->mFsSurfGenSetting = FLUIDSIM_FSSG_NOOBS; + else + fsset->mFsSurfGenSetting = 0; // "normal" mode + fsset->generateVertexVectors = (domainSettings->domainNovecgen==0); // init blender domain transform matrix diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index 6191ec9c035..d4de1386871 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -302,6 +302,9 @@ static void make_renderinfo_string(RenderStats *rs, Scene *scene, char *str) BLI_timestr(rs->lastframetime, info_time_str); spos+= sprintf(spos, "Time:%s ", info_time_str); + if(rs->curfsa) + spos+= sprintf(spos, "| Full Sample %d ", rs->curfsa); + if(rs->infostr && rs->infostr[0]) spos+= sprintf(spos, "| %s ", rs->infostr); diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index bd1c00e6fdb..3268f6293a7 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -2459,13 +2459,7 @@ static void SCREEN_OT_repeat_history(wmOperatorType *ot) static int redo_last_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event)) { - wmWindowManager *wm= CTX_wm_manager(C); - wmOperator *lastop; - - /* only for operators that are registered and did an undo push */ - for(lastop= wm->operators.last; lastop; lastop= lastop->prev) - if((lastop->type->flag & OPTYPE_REGISTER) && (lastop->type->flag & OPTYPE_UNDO)) - break; + wmOperator *lastop= WM_operator_last_redo(C); if(lastop) WM_operator_redo_popup(C, lastop); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 9414cc00341..691170bd80a 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -3591,7 +3591,7 @@ static int sculpt_brush_stroke_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int sculpt_brush_stroke_cacel(bContext *C, wmOperator *op) +static int sculpt_brush_stroke_cancel(bContext *C, wmOperator *op) { Object *ob= CTX_data_active_object(C); SculptSession *ss = ob->sculpt; @@ -3627,7 +3627,7 @@ static void SCULPT_OT_brush_stroke(wmOperatorType *ot) ot->modal= paint_stroke_modal; ot->exec= sculpt_brush_stroke_exec; ot->poll= sculpt_poll; - ot->cancel= sculpt_brush_stroke_cacel; + ot->cancel= sculpt_brush_stroke_cancel; /* flags (sculpt does own undo? (ton) */ ot->flag= OPTYPE_BLOCKING; diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c index bf5df87610c..905fed4f30b 100644 --- a/source/blender/editors/space_console/console_draw.c +++ b/source/blender/editors/space_console/console_draw.c @@ -83,11 +83,13 @@ typedef struct ConsoleDrawContext { int console_width; int winx; int ymin, ymax; +#if 0 /* used by textview, may use later */ int *xy; // [2] int *sel; // [2] int *pos_pick; // bottom of view == 0, top of file == combine chars, end of line is lower then start. int *mval; // [2] int draw; +#endif } ConsoleDrawContext; void console_scrollback_prompt_begin(struct SpaceConsole *sc, ConsoleLine *cl_dummy) diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index adce540cee4..0210b0dd78d 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -662,7 +662,6 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char block= uiLayoutGetBlock(layout); - imaptr= RNA_property_pointer_get(ptr, prop); ima= imaptr.data; iuser= userptr->data; @@ -719,21 +718,17 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char } } else { - row= uiLayoutRow(layout, 0); - uiItemR(row, &imaptr, "source", 0, NULL, ICON_NONE); + uiItemR(layout, &imaptr, "source", 0, NULL, ICON_NONE); if(ima->source != IMA_SRC_GENERATED) { row= uiLayoutRow(layout, 1); - split = uiLayoutSplit(row, 0.0, 0); if (ima->packedfile) - uiItemO(split, "", ICON_PACKAGE, "image.unpack"); + uiItemO(row, "", ICON_PACKAGE, "image.unpack"); else - uiItemO(split, "", ICON_UGLYPACKAGE, "image.pack"); + uiItemO(row, "", ICON_UGLYPACKAGE, "image.pack"); - split = uiLayoutSplit(row, 0.0, 0); - row= uiLayoutRow(split, 1); + row= uiLayoutRow(row, 0); uiLayoutSetEnabled(row, ima->packedfile==NULL); - uiItemR(row, &imaptr, "filepath", 0, "", ICON_NONE); uiItemO(row, "", ICON_FILE_REFRESH, "image.reload"); } @@ -771,11 +766,10 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char col= uiLayoutColumn(split, 0); uiItemR(col, &imaptr, "use_fields", 0, NULL, ICON_NONE); row= uiLayoutRow(col, 0); - uiItemR(row, &imaptr, "field_order", UI_ITEM_R_EXPAND, NULL, ICON_NONE); uiLayoutSetActive(row, RNA_boolean_get(&imaptr, "use_fields")); - - col= uiLayoutColumn(split, 0); - uiItemR(col, &imaptr, "use_premultiply", 0, NULL, ICON_NONE); + uiItemR(row, &imaptr, "field_order", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + + uiItemR(split, &imaptr, "use_premultiply", 0, NULL, ICON_NONE); } } @@ -787,10 +781,9 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char col= uiLayoutColumn(split, 0); sprintf(str, "(%d) Frames", iuser->framenr); - row= uiLayoutRow(col, 1); uiItemR(col, userptr, "frame_duration", 0, str, ICON_NONE); if(ima->anim) { - block= uiLayoutGetBlock(row); + block= uiLayoutGetBlock(col); but= uiDefBut(block, BUT, 0, "Match Movie Length", 0, 0, UI_UNIT_X*2, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Set the number of frames to match the movie or sequence."); uiButSetFunc(but, set_frames_cb, ima, iuser); } @@ -810,8 +803,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char uiItemR(col, &imaptr, "generated_width", 0, "X", ICON_NONE); uiItemR(col, &imaptr, "generated_height", 0, "Y", ICON_NONE); - col= uiLayoutColumn(split, 0); - uiItemR(col, &imaptr, "generated_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(split, &imaptr, "generated_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); } } diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index bce492f5a04..019ce2a714a 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -3786,6 +3786,8 @@ static void draw_actuator_camera(uiLayout *layout, PointerRNA *ptr) row = uiLayoutRow(layout, 1); uiItemR(row, ptr, "min", 0, NULL, ICON_NONE); uiItemR(row, ptr, "max", 0, NULL, ICON_NONE); + + uiItemR(layout, ptr, "damping", 0, NULL, ICON_NONE); } static void draw_actuator_constraint(uiLayout *layout, PointerRNA *ptr, bContext *C) diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 0c9f12966ef..5f8ab0dded5 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -288,7 +288,7 @@ static void node_update(const bContext *C, bNodeTree *ntree, bNode *node) RNA_pointer_create(&ntree->id, &RNA_Node, node, &ptr); layout= uiBlockLayout(node->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, - node->locx+NODE_DYS, dy, node->butr.xmax, 20, U.uistyles.first); + node->locx+NODE_DYS, dy, node->butr.xmax, NODE_DY, U.uistyles.first); node->typeinfo->uifunc(layout, (bContext *)C, &ptr); uiBlockEndAlign(node->block); @@ -392,6 +392,7 @@ static void node_update_group(const bContext *C, bNodeTree *UNUSED(ntree), bNode bNode *node; bNodeSocket *sock, *gsock; rctf *rect= &gnode->totr; + float node_group_frame= U.dpi*NODE_GROUP_FRAME/72; int counter; int dy; @@ -430,7 +431,7 @@ static void node_update_group(const bContext *C, bNodeTree *UNUSED(ntree), bNode dy = 0.5f*(rect->ymin+rect->ymax) + NODE_DY*(BLI_countlist(&gnode->inputs)-1); for(gsock=ngroup->inputs.first, sock=gnode->inputs.first; gsock; gsock=gsock->next, sock=sock->next) { gsock->locx = rect->xmin; - sock->locx = rect->xmin - NODE_GROUP_FRAME; + sock->locx = rect->xmin - node_group_frame; sock->locy = gsock->locy = dy; /* prevent long socket lists from growing out of the group box */ @@ -446,7 +447,7 @@ static void node_update_group(const bContext *C, bNodeTree *UNUSED(ntree), bNode dy = 0.5f*(rect->ymin+rect->ymax) + NODE_DY*(BLI_countlist(&gnode->outputs)-1); for(gsock=ngroup->outputs.first, sock=gnode->outputs.first; gsock; gsock=gsock->next, sock=sock->next) { gsock->locx = rect->xmax; - sock->locx = rect->xmax + NODE_GROUP_FRAME; + sock->locx = rect->xmax + node_group_frame; sock->locy = gsock->locy = dy - NODE_DYS; /* prevent long socket lists from growing out of the group box */ @@ -654,7 +655,7 @@ static uiBlock *socket_vector_menu(bContext *C, ARegion *ar, void *args_v) block= uiBeginBlock(C, ar, "socket menu", UI_EMBOSS); uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN); - layout= uiLayoutColumn(uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, args->x, args->y+2, args->width, 20, U.uistyles.first), 0); + layout= uiLayoutColumn(uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, args->x, args->y+2, args->width, NODE_DY, U.uistyles.first), 0); uiItemR(layout, &args->ptr, "default_value", UI_ITEM_R_EXPAND, "", ICON_NONE); @@ -675,7 +676,7 @@ static void node_draw_socket_button(bNodeTree *ntree, bNodeSocket *sock, const c switch (sock->type) { case SOCK_VALUE: bt=uiDefButR(block, NUM, B_NODE_EXEC, name, - x, y+1, width, 17, + x, y+1, width, NODE_DY-2, &ptr, "default_value", 0, sock->ns.min, sock->ns.max, -1, -1, NULL); if (cb) uiButSetFunc(bt, cb, arg1, arg2); @@ -693,7 +694,7 @@ static void node_draw_socket_button(bNodeTree *ntree, bNodeSocket *sock, const c args->arg2 = arg2; uiDefBlockButN(block, socket_vector_menu, args, name, - x, y+1, width, 17, + x, y+1, width, NODE_DY-2, ""); break; @@ -701,14 +702,14 @@ static void node_draw_socket_button(bNodeTree *ntree, bNodeSocket *sock, const c labelw= width - 40; bt=uiDefButR(block, COL, B_NODE_EXEC, "", - x, y+2, (labelw>0 ? 40 : width), 15, + x, y+2, (labelw>0 ? 40 : width), NODE_DY-2, &ptr, "default_value", 0, sock->ns.min, sock->ns.max, -1, -1, NULL); if (cb) uiButSetFunc(bt, cb, arg1, arg2); if (name[0]!='\0' && labelw>0) uiDefBut(block, LABEL, 0, name, - x + 40, y+2, labelw, 15, + x + 40, y+2, labelw, NODE_DY-2, NULL, 0, 0, 0, 0, ""); break; } @@ -719,6 +720,8 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN bNodeSocket *sock; rctf *rct= &node->totr; float iconofs; + float socket_size= NODE_SOCKSIZE*U.dpi/72; + float iconbutw= 0.8f*UI_UNIT_X; int color_id= node_get_colorid(node); char showname[128]; /* 128 used below */ View2D *v2d = &ar->v2d; @@ -761,32 +764,32 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN icon_id= ICON_MATERIAL; else icon_id= ICON_MATERIAL_DATA; - iconofs-=15.0f; + iconofs-=iconbutw; uiDefIconBut(node->block, LABEL, B_REDR, icon_id, iconofs, rct->ymax-NODE_DY, - UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, 0.5, ""); + iconbutw, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, 0.5, ""); } if(node->type == NODE_GROUP) { - iconofs-=15.0f; + iconofs-=iconbutw; uiDefIconBut(node->block, LABEL, B_REDR, ICON_NODETREE, iconofs, rct->ymax-NODE_DY, - UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, 0.5, ""); + iconbutw, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, 0.5, ""); } if(node->typeinfo->flag & NODE_OPTIONS) { - iconofs-=15.0f; + iconofs-=iconbutw; uiDefIconBut(node->block, LABEL, B_REDR, ICON_BUTS, iconofs, rct->ymax-NODE_DY, - UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, 0.5, ""); + iconbutw, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, 0.5, ""); } { /* always hide/reveal unused sockets */ int shade; - iconofs-=15.0f; + iconofs-=iconbutw; // XXX re-enable /*if(node_has_hidden_sockets(node)) shade= -40; else*/ shade= -90; uiDefIconBut(node->block, LABEL, B_REDR, ICON_PLUS, iconofs, rct->ymax-NODE_DY, - UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, 0.5, ""); + iconbutw, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, 0.5, ""); } /* title */ @@ -851,7 +854,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN /* socket inputs, buttons */ for(sock= node->inputs.first; sock; sock= sock->next) { if(!(sock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL))) { - socket_circle_draw(sock, NODE_SOCKSIZE); + socket_circle_draw(sock, socket_size); if(node->block && sock->link==NULL) { node_draw_socket_button(ntree, sock, sock->name, node->block, sock->locx+NODE_DYS, sock->locy-NODE_DYS, node->width-NODE_DY, node_sync_cb, snode, node); @@ -869,7 +872,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN float slen; int ofs= 0; - socket_circle_draw(sock, NODE_SOCKSIZE); + socket_circle_draw(sock, socket_size); UI_ThemeColor(TH_TEXT); slen= snode->aspect*UI_GetStringWidth(sock->name); @@ -904,6 +907,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b rctf *rct= &node->totr; float dx, centy= 0.5f*(rct->ymax+rct->ymin); float hiddenrad= 0.5f*(rct->ymax-rct->ymin); + float socket_size= NODE_SOCKSIZE*U.dpi/72; int color_id= node_get_colorid(node); char showname[128]; /* 128 is used below */ @@ -978,12 +982,12 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b /* sockets */ for(sock= node->inputs.first; sock; sock= sock->next) { if(!(sock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL))) - socket_circle_draw(sock, NODE_SOCKSIZE); + socket_circle_draw(sock, socket_size); } for(sock= node->outputs.first; sock; sock= sock->next) { if(!(sock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL))) - socket_circle_draw(sock, NODE_SOCKSIZE); + socket_circle_draw(sock, socket_size); } uiEndBlock(C, node->block); @@ -1043,17 +1047,30 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN { bNodeTree *ngroup= (bNodeTree *)gnode->id; bNodeSocket *sock; - rctf rect= gnode->totr; - int index; uiLayout *layout; PointerRNA ptr; uiBut *bt; + rctf rect= gnode->totr; + float socket_size= NODE_SOCKSIZE*U.dpi/72; + float node_group_frame= U.dpi*NODE_GROUP_FRAME/72; + float group_header= 26*U.dpi/72; + float arrowbutw= 0.8f*UI_UNIT_X; + /* layout stuff for buttons on group left frame */ + float col1= 6, colw1= 0.6f*node_group_frame; + float col2= col1 + colw1+6; + float col3= node_group_frame - arrowbutw - 6; + /* layout stuff for buttons on group right frame */ + float cor1= 6; + float cor2= cor1 + arrowbutw + 6; + float cor3= cor2 + arrowbutw + 6, corw3= node_group_frame - cor3-6; + + int index; /* backdrop header */ glEnable(GL_BLEND); uiSetRoundBox(3); UI_ThemeColorShadeAlpha(TH_NODE_GROUP, 0, -70); - uiDrawBox(GL_POLYGON, rect.xmin-NODE_GROUP_FRAME, rect.ymax, rect.xmax+NODE_GROUP_FRAME, rect.ymax+26, BASIS_RAD); + uiDrawBox(GL_POLYGON, rect.xmin-node_group_frame, rect.ymax, rect.xmax+node_group_frame, rect.ymax+group_header, BASIS_RAD); /* backdrop body */ UI_ThemeColorShadeAlpha(TH_BACK, -8, -70); @@ -1063,12 +1080,12 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN /* input column */ UI_ThemeColorShadeAlpha(TH_BACK, 10, -50); uiSetRoundBox(8); - uiDrawBox(GL_POLYGON, rect.xmin-NODE_GROUP_FRAME, rect.ymin, rect.xmin, rect.ymax, BASIS_RAD); + uiDrawBox(GL_POLYGON, rect.xmin-node_group_frame, rect.ymin, rect.xmin, rect.ymax, BASIS_RAD); /* output column */ UI_ThemeColorShadeAlpha(TH_BACK, 10, -50); uiSetRoundBox(4); - uiDrawBox(GL_POLYGON, rect.xmax, rect.ymin, rect.xmax+NODE_GROUP_FRAME, rect.ymax, BASIS_RAD); + uiDrawBox(GL_POLYGON, rect.xmax, rect.ymin, rect.xmax+node_group_frame, rect.ymax, BASIS_RAD); /* input column separator */ glColor4ub(200, 200, 200, 140); @@ -1088,15 +1105,15 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN uiSetRoundBox(15); glColor4ub(200, 200, 200, 140); glEnable( GL_LINE_SMOOTH ); - uiDrawBox(GL_LINE_LOOP, rect.xmin-NODE_GROUP_FRAME, rect.ymin, rect.xmax+NODE_GROUP_FRAME, rect.ymax+26, BASIS_RAD); + uiDrawBox(GL_LINE_LOOP, rect.xmin-node_group_frame, rect.ymin, rect.xmax+node_group_frame, rect.ymax+group_header, BASIS_RAD); glDisable( GL_LINE_SMOOTH ); glDisable(GL_BLEND); /* backdrop title */ UI_ThemeColor(TH_TEXT_HI); - layout = uiBlockLayout(gnode->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, (short)(rect.xmin+15), (short)(rect.ymax+23), - MIN2((int)(rect.xmax - rect.xmin-18.0f), 140), 20, U.uistyles.first); + layout = uiBlockLayout(gnode->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, (short)(rect.xmin+15), (short)(rect.ymax+group_header), + MIN2((int)(rect.xmax - rect.xmin-18.0f), node_group_frame+20), group_header, U.uistyles.first); RNA_pointer_create(&ntree->id, &RNA_Node, gnode, &ptr); uiTemplateIDBrowse(layout, (bContext*)C, &ptr, "node_tree", NULL, NULL, NULL); uiBlockLayoutResolve(gnode->block, NULL, NULL); @@ -1106,31 +1123,33 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN /* group sockets */ for(sock=ngroup->inputs.first, index=0; sock; sock=sock->next, ++index) { - socket_circle_draw(sock, NODE_SOCKSIZE); + float locx= sock->locx - node_group_frame; + + socket_circle_draw(sock, socket_size); /* small hack to use socket_circle_draw function with offset */ - sock->locx -= NODE_GROUP_FRAME; - socket_circle_draw(sock, NODE_SOCKSIZE); - sock->locx += NODE_GROUP_FRAME; + sock->locx -= node_group_frame; + socket_circle_draw(sock, socket_size); + sock->locx += node_group_frame; bt = uiDefBut(gnode->block, TEX, 0, "", - sock->locx-114, sock->locy+1, 72, NODE_DY, + locx+col1, sock->locy+1, colw1, NODE_DY, sock->name, 0, 31, 0, 0, ""); uiButSetFunc(bt, group_verify_cb, snode, ngroup); node_draw_socket_button(ngroup, sock, "", gnode->block, - sock->locx-114, sock->locy-NODE_DY, 72, + locx+col1, sock->locy-NODE_DY, colw1, NULL, NULL, NULL); uiBlockSetDirection(gnode->block, UI_TOP); uiBlockBeginAlign(gnode->block); bt = uiDefIconButO(gnode->block, BUT, "NODE_OT_group_socket_move_up", 0, ICON_TRIA_UP, - sock->locx-40, sock->locy, 16, 16, ""); + locx+col2, sock->locy, arrowbutw, arrowbutw, ""); if (!sock->prev) uiButSetFlag(bt, UI_BUT_DISABLED); RNA_int_set(uiButGetOperatorPtrRNA(bt), "index", index); RNA_enum_set(uiButGetOperatorPtrRNA(bt), "in_out", SOCK_IN); bt = uiDefIconButO(gnode->block, BUT, "NODE_OT_group_socket_move_down", 0, ICON_TRIA_DOWN, - sock->locx-40, sock->locy-16, 16, 16, ""); + locx+col2, sock->locy-arrowbutw, arrowbutw, arrowbutw, ""); if (!sock->next) uiButSetFlag(bt, UI_BUT_DISABLED); RNA_int_set(uiButGetOperatorPtrRNA(bt), "index", index); @@ -1140,22 +1159,24 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN uiBlockSetEmboss(gnode->block, UI_EMBOSSN); bt = uiDefIconButO(gnode->block, BUT, "NODE_OT_group_socket_remove", 0, ICON_X, - sock->locx-22, sock->locy-8, 16, 16, ""); + locx+col3, sock->locy-0.5f*arrowbutw, arrowbutw, arrowbutw, ""); RNA_int_set(uiButGetOperatorPtrRNA(bt), "index", index); RNA_enum_set(uiButGetOperatorPtrRNA(bt), "in_out", SOCK_IN); uiBlockSetEmboss(gnode->block, UI_EMBOSS); } for(sock=ngroup->outputs.first, index=0; sock; sock=sock->next, ++index) { - socket_circle_draw(sock, NODE_SOCKSIZE); + float locx= sock->locx; + + socket_circle_draw(sock, socket_size); /* small hack to use socket_circle_draw function with offset */ - sock->locx += NODE_GROUP_FRAME; - socket_circle_draw(sock, NODE_SOCKSIZE); - sock->locx -= NODE_GROUP_FRAME; + sock->locx += node_group_frame; + socket_circle_draw(sock, socket_size); + sock->locx -= node_group_frame; uiBlockSetEmboss(gnode->block, UI_EMBOSSN); bt = uiDefIconButO(gnode->block, BUT, "NODE_OT_group_socket_remove", 0, ICON_X, - sock->locx+6, sock->locy-8, 16, 16, ""); + locx+col1, sock->locy-0.5f*arrowbutw, arrowbutw, arrowbutw, ""); RNA_int_set(uiButGetOperatorPtrRNA(bt), "index", index); RNA_enum_set(uiButGetOperatorPtrRNA(bt), "in_out", SOCK_OUT); uiBlockSetEmboss(gnode->block, UI_EMBOSS); @@ -1163,13 +1184,13 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN uiBlockSetDirection(gnode->block, UI_TOP); uiBlockBeginAlign(gnode->block); bt = uiDefIconButO(gnode->block, BUT, "NODE_OT_group_socket_move_up", 0, ICON_TRIA_UP, - sock->locx+24, sock->locy, 16, 16, ""); + locx+cor2, sock->locy, arrowbutw, arrowbutw, ""); if (!sock->prev) uiButSetFlag(bt, UI_BUT_DISABLED); RNA_int_set(uiButGetOperatorPtrRNA(bt), "index", index); RNA_enum_set(uiButGetOperatorPtrRNA(bt), "in_out", SOCK_OUT); bt = uiDefIconButO(gnode->block, BUT, "NODE_OT_group_socket_move_down", 0, ICON_TRIA_DOWN, - sock->locx+24, sock->locy-16, 16, 16, ""); + locx+cor2, sock->locy-arrowbutw, arrowbutw, arrowbutw, ""); if (!sock->next) uiButSetFlag(bt, UI_BUT_DISABLED); RNA_int_set(uiButGetOperatorPtrRNA(bt), "index", index); @@ -1179,17 +1200,17 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN if (sock->link) { bt = uiDefBut(gnode->block, TEX, 0, "", - sock->locx+42, sock->locy-NODE_DYS+1, 72, NODE_DY, + locx+cor3, sock->locy-NODE_DYS+1, corw3, NODE_DY, sock->name, 0, 31, 0, 0, ""); uiButSetFunc(bt, group_verify_cb, snode, ngroup); } else { bt = uiDefBut(gnode->block, TEX, 0, "", - sock->locx+42, sock->locy+1, 72, NODE_DY, + locx+cor3, sock->locy+1, corw3, NODE_DY, sock->name, 0, 31, 0, 0, ""); uiButSetFunc(bt, group_verify_cb, snode, ngroup); - node_draw_socket_button(ngroup, sock, "", gnode->block, sock->locx+42, sock->locy-NODE_DY, 72, NULL, NULL, NULL); + node_draw_socket_button(ngroup, sock, "", gnode->block, locx+cor3, sock->locy-NODE_DY, corw3, NULL, NULL, NULL); } } diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 99f2ea99efc..46c66c55d51 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -1332,7 +1332,7 @@ static int node_resize_modal(bContext *C, wmOperator *op, wmEvent *event) } else { node->width= nsw->oldwidth + mx - nsw->mxstart; - CLAMP(node->width, node->typeinfo->minwidth, node->typeinfo->maxwidth); + CLAMP(node->width, UI_DPI_FAC*node->typeinfo->minwidth, UI_DPI_FAC*node->typeinfo->maxwidth); } } @@ -1366,10 +1366,17 @@ static int node_resize_invoke(bContext *C, wmOperator *op, wmEvent *event) UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &snode->mx, &snode->my); - /* rect we're interested in is just the bottom right corner */ totr= node->totr; - totr.xmin= totr.xmax-10.0f; - totr.ymax= totr.ymin+10.0f; + + if(node->flag & NODE_HIDDEN) { + /* right part of node */ + totr.xmin= node->totr.xmax-20.0f; + } + else { + /* bottom right corner */ + totr.xmin= totr.xmax-10.0f; + totr.ymax= totr.ymin+10.0f; + } if(BLI_in_rctf(&totr, snode->mx, snode->my)) { NodeSizeWidget *nsw= MEM_callocN(sizeof(NodeSizeWidget), "size widget op data"); diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h index fcf1c182600..a1c0f5535fe 100644 --- a/source/blender/editors/space_node/node_intern.h +++ b/source/blender/editors/space_node/node_intern.h @@ -152,8 +152,8 @@ extern const char *node_context_dir[]; // XXX from BSE_node.h #define HIDDEN_RAD 15.0f #define BASIS_RAD 8.0f -#define NODE_DYS 10 -#define NODE_DY 20 +#define NODE_DYS (U.widget_unit/2) +#define NODE_DY U.widget_unit #define NODE_SOCKSIZE 5 // XXX button events (butspace) diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c index 43e46d485ee..bd2d591a8c8 100644 --- a/source/blender/editors/space_outliner/outliner.c +++ b/source/blender/editors/space_outliner/outliner.c @@ -57,6 +57,7 @@ #include "BLI_blenlib.h" #include "BLI_utildefines.h" +#include "BLI_math_base.h" #if defined WIN32 && !defined _LIBC # include "BLI_fnmatch.h" /* use fnmatch included in blenlib */ @@ -436,7 +437,7 @@ static void outliner_sort(SpaceOops *soops, ListBase *lb) static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *idv, TreeElement *parent, short type, short index); -#define LOG2I(x) (int)(log(x)/log(2.0)) +#define LOG2I(x) (int)(log(x)/M_LN2) static void outliner_add_passes(SpaceOops *soops, TreeElement *tenla, ID *id, SceneRenderLayer *srl) { diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 6900271deea..c8965c4d3db 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -124,7 +124,7 @@ typedef struct TransSeq { int startstill, endstill; int startdisp, enddisp; int startofs, endofs; - int final_left, final_right; + /* int final_left, final_right; */ /* UNUSED */ int len; } TransSeq; diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 47ba48521c1..15e4c4155fe 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -1579,7 +1579,7 @@ static void restore_localviewdata(ScrArea *sa, int free) } } -static void endlocalview(Scene *scene, ScrArea *sa) +static void endlocalview(Main *bmain, Scene *scene, ScrArea *sa) { View3D *v3d= sa->spacedata.first; struct Base *base; @@ -1605,6 +1605,8 @@ static void endlocalview(Scene *scene, ScrArea *sa) base->object->lay= base->lay; } } + + DAG_on_visible_update(bmain, FALSE); } } @@ -1613,7 +1615,7 @@ static int localview_exec(bContext *C, wmOperator *UNUSED(unused)) View3D *v3d= CTX_wm_view3d(C); if(v3d->localvd) - endlocalview(CTX_data_scene(C), CTX_wm_area(C)); + endlocalview(CTX_data_main(C), CTX_data_scene(C), CTX_wm_area(C)); else initlocalview(CTX_data_main(C), CTX_data_scene(C), CTX_wm_area(C)); diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 60f5ee02b13..7969187d3ec 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -676,8 +676,9 @@ void recalcData(TransInfo *t) BMEditMesh *em = ((Mesh*)t->obedit->data)->edit_btmesh; /* mirror modifier clipping? */ if(t->state != TRANS_CANCEL) { - clipMirrorModifier(t, t->obedit); + /* apply clipping after so we never project past the clip plane [#25423] */ applyProject(t); + clipMirrorModifier(t, t->obedit); } if((t->options & CTX_NO_MIRROR) == 0 && (t->flag & T_MIRROR)) editbmesh_apply_to_mirror(t); diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index e83138acf46..3dd7514429e 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -106,42 +106,25 @@ void ED_editors_exit(bContext *C) if(sce->obedit) { Object *ob= sce->obedit; - /* global in meshtools... */ - //BMESH_TODO mesh_octree_table(NULL, NULL, NULL, 'e'); - //BMESH_TODO mesh_mirrtopo_table(NULL, 'e'); - if(ob) { if(ob->type==OB_MESH) { Mesh *me= ob->data; - if(me->edit_btmesh) { - EDBM_FreeEditBMesh(me->edit_btmesh); - MEM_freeN(me->edit_btmesh); - me->edit_btmesh= NULL; + if(me->edit_mesh) { + free_editMesh(me->edit_mesh); + MEM_freeN(me->edit_mesh); + me->edit_mesh= NULL; } } else if(ob->type==OB_ARMATURE) { ED_armature_edit_free(ob); } - else if(ob->type==OB_FONT) { - // free_editText(); - } - // else if(ob->type==OB_MBALL) - // BLI_freelistN(&editelems); - // free_editLatt(); - // free_posebuf(); // XXX this is still a global... - } - } - else if(sce->basact && sce->basact->object) { - Object *ob= sce->basact->object; - - /* if weight-painting is on, free mesh octree data */ - if(ob->mode & OB_MODE_WEIGHT_PAINT) { - //BMESH_TODO mesh_octree_table(NULL, NULL, NULL, 'e'); - //BMESH_TODO mesh_mirrtopo_table(NULL, 'e'); } } } - + + /* global in meshtools... */ + mesh_octree_table(NULL, NULL, NULL, 'e'); + mesh_mirrtopo_table(NULL, 'e'); } diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c index 24a868891de..8a6ec7f75db 100644 --- a/source/blender/editors/util/undo.c +++ b/source/blender/editors/util/undo.c @@ -156,11 +156,11 @@ static int ed_undo_step(bContext *C, int step, const char *undoname) int do_glob_undo= 0; if(obact && obact->mode & OB_MODE_TEXTURE_PAINT) { - if(!ED_undo_paint_step(C, UNDO_PAINT_IMAGE, step, undoname) && undoname) + if(!ED_undo_paint_step(C, UNDO_PAINT_IMAGE, step, undoname)) do_glob_undo= 1; } else if(obact && obact->mode & OB_MODE_SCULPT) { - if(!ED_undo_paint_step(C, UNDO_PAINT_MESH, step, undoname) && undoname) + if(!ED_undo_paint_step(C, UNDO_PAINT_MESH, step, undoname)) do_glob_undo= 1; } else if(obact && obact->mode & OB_MODE_PARTICLE_EDIT) { diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h index 5d61452e149..e9592fdc164 100644 --- a/source/blender/imbuf/IMB_imbuf.h +++ b/source/blender/imbuf/IMB_imbuf.h @@ -442,8 +442,9 @@ void IMB_freezbuffloatImBuf(struct ImBuf *ibuf); * * @attention Defined in rectop.c */ -void IMB_rectfill(struct ImBuf *drect, float col[4]); +void IMB_rectfill(struct ImBuf *drect, const float col[4]); void IMB_rectfill_area(struct ImBuf *ibuf, float *col, int x1, int y1, int x2, int y2); +void IMB_rectfill_alpha(struct ImBuf *ibuf, const float value); /* this should not be here, really, we needed it for operating on render data, IMB_rectfill_area calls it */ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, float *col, int x1, int y1, int x2, int y2); diff --git a/source/blender/imbuf/intern/rectop.c b/source/blender/imbuf/intern/rectop.c index 44af7ffdb3f..844478e03cb 100644 --- a/source/blender/imbuf/intern/rectop.c +++ b/source/blender/imbuf/intern/rectop.c @@ -450,7 +450,7 @@ void IMB_rectblend(struct ImBuf *dbuf, struct ImBuf *sbuf, int destx, /* fill */ -void IMB_rectfill(struct ImBuf *drect, float col[4]) +void IMB_rectfill(struct ImBuf *drect, const float col[4]) { int num; @@ -561,3 +561,18 @@ void IMB_rectfill_area(struct ImBuf *ibuf, float *col, int x1, int y1, int x2, i if (!ibuf) return; buf_rectfill_area((unsigned char *) ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y, col, x1, y1, x2, y2); } + + +void IMB_rectfill_alpha(ImBuf *ibuf, const float value) +{ + int i; + if (ibuf->rect_float) { + float *fbuf= ibuf->rect_float + 3; + for (i = ibuf->x * ibuf->y; i > 0; i--, fbuf+= 4) { *fbuf = value; } + } + else { + const unsigned char cvalue= value * 255; + unsigned char *cbuf= ((unsigned char *)ibuf->rect) + 3; + for (i = ibuf->x * ibuf->y; i > 0; i--, cbuf+= 4) { *cbuf = cvalue; } + } +} diff --git a/source/blender/makesdna/DNA_actuator_types.h b/source/blender/makesdna/DNA_actuator_types.h index 683d8142cc9..887a0300ee2 100644 --- a/source/blender/makesdna/DNA_actuator_types.h +++ b/source/blender/makesdna/DNA_actuator_types.h @@ -133,7 +133,7 @@ typedef struct bIpoActuator { typedef struct bCameraActuator { struct Object *ob; float height, min, max; - float pad; + float damping; short pad1, axis; float pad2; } bCameraActuator ; diff --git a/source/blender/makesdna/DNA_object_fluidsim.h b/source/blender/makesdna/DNA_object_fluidsim.h index 6f4c16cb7f3..578bf8dd415 100644 --- a/source/blender/makesdna/DNA_object_fluidsim.h +++ b/source/blender/makesdna/DNA_object_fluidsim.h @@ -69,7 +69,7 @@ typedef struct FluidsimSettings { short viscosityMode; short viscosityExponent; /* gravity strength */ - float gravx,gravy,gravz; + float grav[3]; /* anim start end time (in seconds) */ float animStart, animEnd; /* bake start end time (in blender frames) */ @@ -161,6 +161,9 @@ typedef struct FluidsimSettings { #define OB_FSBND_FREESLIP (1<<(OB_TYPEFLAG_START+4)) #define OB_FSINFLOW_LOCALCOORD (1<<(OB_TYPEFLAG_START+5)) +/* surface generation flag (part of enabling chapter 6 of "Free Surface Flows with Moving and Deforming Objects for LBM") */ +#define OB_FSSG_NOOBS (1<<(OB_TYPEFLAG_START+6)) + // guiDisplayMode particle flags #define OB_FSDOM_GEOM 1 #define OB_FSDOM_PREVIEW 2 diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 70e90cfc713..c6fa07482c5 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -253,19 +253,12 @@ typedef struct RenderData { */ short yparts; - short winpos, planes, imtype, subimtype; - - /** Mode bits: */ - /* 0: Enable backbuffering for images */ - short bufflag; - short quality; + short planes, imtype, subimtype, quality; /** * Render to image editor, fullscreen or to new window. */ short displaymode; - - short rpad1, rpad2; /** * Flags for render settings. Use bit-masking to access the settings. @@ -322,11 +315,7 @@ typedef struct RenderData { /** * Adjustment factors for the aspect ratio in the x direction, was a short in 2.45 */ - float xasp; - /** - * Adjustment factors for the aspect ratio in the x direction, was a short in 2.45 - */ - float yasp; + float xasp, yasp; float frs_sec_base; @@ -349,8 +338,8 @@ typedef struct RenderData { short bake_normal_space, bake_quad_split; float bake_maxdist, bake_biasdist, bake_pad; - /* paths to backbufffer, output */ - char backbuf[160], pic[160]; + /* path to render output */ + char pic[240]; /* stamps flags. */ int stamp; diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 1231f10b81f..b57e78a896c 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -305,7 +305,7 @@ typedef struct UserDef { int savetime; char tempdir[160]; // FILE_MAXDIR length char fontdir[160]; - char renderdir[160]; + char renderdir[240]; // FILE_MAX length char textudir[160]; char plugtexdir[160]; char plugseqdir[160]; diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index c7cf511d5c7..cddba59f979 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -922,6 +922,13 @@ static void rna_def_camera_actuator(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Max", ""); RNA_def_property_update(prop, NC_LOGIC, NULL); + prop= RNA_def_property(srna, "damping", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "damping"); + RNA_def_property_range(prop, 0, 10.0); + RNA_def_property_ui_range(prop, 0, 5.0, 1, 2); + RNA_def_property_ui_text(prop, "Damping", "Specify the strength of the constraint that drive the camera behind the target"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + /* x/y */ prop= RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "axis"); diff --git a/source/blender/makesrna/intern/rna_camera.c b/source/blender/makesrna/intern/rna_camera.c index 1705e2e5376..37912f810fc 100644 --- a/source/blender/makesrna/intern/rna_camera.c +++ b/source/blender/makesrna/intern/rna_camera.c @@ -133,7 +133,7 @@ void RNA_def_camera(BlenderRNA *brna) prop= RNA_def_property(srna, "ortho_scale", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "ortho_scale"); - RNA_def_property_range(prop, 0.01f, 1000.0f); + RNA_def_property_range(prop, 0.01f, 4000.0f); RNA_def_property_ui_text(prop, "Orthographic Scale", "Orthographic Camera scale (similar to zoom)"); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); diff --git a/source/blender/makesrna/intern/rna_controller.c b/source/blender/makesrna/intern/rna_controller.c index 92c762098c7..db5409bf7ef 100644 --- a/source/blender/makesrna/intern/rna_controller.c +++ b/source/blender/makesrna/intern/rna_controller.c @@ -87,6 +87,20 @@ static void rna_Controller_type_set(struct PointerRNA *ptr, int value) } } +static void rna_Controller_mode_set(struct PointerRNA *ptr, int value) +{ + bController *cont= (bController *)ptr->data; + bPythonCont *pycon= (bPythonCont *)cont->data; + + // if mode changed and previous mode were Script + if (value != pycon->mode && pycon->mode == CONT_PY_SCRIPT) + { + // clear script to avoid it to get linked with the controller + pycon->text = NULL; + } + pycon->mode = value; +} + static int rna_Controller_state_number_get(struct PointerRNA *ptr) { bController *cont= (bController *)ptr->data; @@ -222,6 +236,7 @@ void RNA_def_controller(BlenderRNA *brna) prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, python_controller_modes); + RNA_def_property_enum_funcs(prop, NULL, "rna_Controller_mode_set", NULL); RNA_def_property_ui_text(prop, "Execution Method", "Python script type (textblock or module - faster)"); RNA_def_property_update(prop, NC_LOGIC, NULL); diff --git a/source/blender/makesrna/intern/rna_fluidsim.c b/source/blender/makesrna/intern/rna_fluidsim.c index 7c93ae4168b..1ba2e32502f 100644 --- a/source/blender/makesrna/intern/rna_fluidsim.c +++ b/source/blender/makesrna/intern/rna_fluidsim.c @@ -312,7 +312,7 @@ static void rna_def_fluidsim_domain(BlenderRNA *brna) /* advanced settings */ prop= RNA_def_property(srna, "gravity", PROP_FLOAT, PROP_ACCELERATION); - RNA_def_property_float_sdna(prop, NULL, "gravx"); + RNA_def_property_float_sdna(prop, NULL, "grav"); RNA_def_property_array(prop, 3); RNA_def_property_range(prop, -1000.1, 1000.1); RNA_def_property_ui_text(prop, "Gravity", "Gravity in X, Y and Z direction"); @@ -384,6 +384,12 @@ static void rna_def_fluidsim_domain(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_text(prop, "Generate Speed Vectors", "Generate speed vectors for vector blur"); + /* no collision object surface */ + prop= RNA_def_property(srna, "surface_noobs", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "typeFlags", OB_FSSG_NOOBS); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Hide fluid surface", ""); + /* particles */ prop= RNA_def_property(srna, "tracer_particles", PROP_INT, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_group.c b/source/blender/makesrna/intern/rna_group.c index a5097cc8b41..5d71d204a72 100644 --- a/source/blender/makesrna/intern/rna_group.c +++ b/source/blender/makesrna/intern/rna_group.c @@ -95,7 +95,7 @@ static void rna_def_group_objects(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Add this object to a group"); /* object to add */ parm= RNA_def_pointer(func, "object", "Object", "", "Object to add."); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); /* remove object */ func= RNA_def_function(srna, "unlink", "rna_Group_objects_unlink"); diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index 3a80207ba15..9e3a31ddb2e 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -135,6 +135,7 @@ static void rna_Texture_update(Main *bmain, Scene *scene, PointerRNA *ptr) DAG_id_tag_update(&tex->id, 0); WM_main_add_notifier(NC_TEXTURE, tex); + WM_main_add_notifier(NC_MATERIAL|ND_SHADING_DRAW, NULL); } static void rna_Texture_voxeldata_update(Main *bmain, Scene *scene, PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index b67805c97b9..14af5ed7a3f 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -245,6 +245,13 @@ static void rna_UserDef_weight_color_update(Main *bmain, Scene *scene, PointerRN static void rna_UserDef_viewport_lights_update(Main *bmain, Scene *scene, PointerRNA *ptr) { + /* if all lights are off gpu_draw resets them all, [#27627] + * so disallow them all to be disabled */ + if(U.light[0].flag==0 && U.light[1].flag==0 && U.light[2].flag==0) { + SolidLight *light= ptr->data; + light->flag |= 1; + } + WM_main_add_notifier(NC_SPACE|ND_SPACE_VIEW3D|NS_VIEW3D_GPU, NULL); rna_userdef_update(bmain, scene, ptr); } diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c index 7b86731b5bb..98170a197cd 100644 --- a/source/blender/modifiers/intern/MOD_explode.c +++ b/source/blender/modifiers/intern/MOD_explode.c @@ -782,11 +782,11 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd, ParticleSettings *part=psmd->psys->part; ParticleSimulationData sim= {NULL}; ParticleData *pa=NULL, *pars=psmd->psys->particles; - ParticleKey state; + ParticleKey state, birth; EdgeHash *vertpahash; EdgeHashIterator *ehi; float *vertco= NULL, imat[4][4]; - float loc0[3], nor[3]; + float rot[4]; float cfra; /* float timestep; */ int *facepa=emd->facepa; @@ -817,7 +817,7 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd, for (i=0; i<totface; i++) { /* do mindex + totvert to ensure the vertex index to be the first * with BLI_edgehashIterator_getKey */ - if(facepa[i]==totpart || cfra <= (pars+facepa[i])->time) + if(facepa[i]==totpart || cfra < (pars+facepa[i])->time) mindex = totvert+totpart; else mindex = totvert+facepa[i]; @@ -871,26 +871,26 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd, /* get particle */ pa= pars+i; - /* get particle state */ - psys_particle_on_emitter(psmd,part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,loc0,nor,NULL,NULL,NULL,NULL); - mul_m4_v3(ob->obmat,loc0); + psys_get_birth_coordinates(&sim, pa, &birth, 0, 0); state.time=cfra; psys_get_particle_state(&sim, i, &state, 1); vertco=CDDM_get_vert(explode,v)->co; - mul_m4_v3(ob->obmat,vertco); - VECSUB(vertco,vertco,loc0); + sub_v3_v3(vertco, birth.co); /* apply rotation, size & location */ - mul_qt_v3(state.rot,vertco); + sub_qt_qtqt(rot, state.rot, birth.rot); + mul_qt_v3(rot, vertco); + if(emd->flag & eExplodeFlag_PaSize) mul_v3_fl(vertco,pa->size); - VECADD(vertco,vertco,state.co); - mul_m4_v3(imat,vertco); + add_v3_v3(vertco, state.co); + + mul_m4_v3(imat, vertco); } } BLI_edgehashIterator_free(ehi); @@ -914,7 +914,7 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd, orig_v4 = source.v4; - if(facepa[i]!=totpart && cfra <= pa->time) + if(facepa[i]!=totpart && cfra < pa->time) mindex = totvert+totpart; else mindex = totvert+facepa[i]; diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c index cd001455d7c..a42e8475e8d 100644 --- a/source/blender/modifiers/intern/MOD_fluidsim_util.c +++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c @@ -90,10 +90,10 @@ void fluidsim_init(FluidsimModifierData *fluidmd) fss->viscosityValue = 1.0; fss->viscosityExponent = 6; - // dg TODO: change this to [] - fss->gravx = 0.0; - fss->gravy = 0.0; - fss->gravz = -9.81; + fss->grav[0] = 0.0; + fss->grav[1] = 0.0; + fss->grav[2] = -9.81; + fss->animStart = 0.0; fss->animEnd = 4.0; fss->gstar = 0.005; // used as normgstar @@ -111,7 +111,7 @@ void fluidsim_init(FluidsimModifierData *fluidmd) // no bounding box needed // todo - reuse default init from elbeem! - fss->typeFlags = OB_FSBND_PARTSLIP; + fss->typeFlags = OB_FSBND_PARTSLIP | OB_FSSG_NOOBS; fss->domainNovecgen = 0; fss->volumeInitType = 1; // volume fss->partSlipValue = 0.2; diff --git a/source/blender/modifiers/intern/MOD_mask.c b/source/blender/modifiers/intern/MOD_mask.c index 965f5f1e98c..3a985b49c35 100644 --- a/source/blender/modifiers/intern/MOD_mask.c +++ b/source/blender/modifiers/intern/MOD_mask.c @@ -45,6 +45,7 @@ #include "DNA_modifier_types.h" #include "DNA_object_types.h" +#include "BKE_action.h" /* get_pose_channel */ #include "BKE_cdderivedmesh.h" #include "BKE_mesh.h" #include "BKE_modifier.h" @@ -102,7 +103,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *dm= derivedData, *result= NULL; GHash *vertHash=NULL, *edgeHash, *faceHash; GHashIterator *hashIter; - MDeformVert *dvert= NULL; + MDeformVert *dvert= NULL, *dv; int numFaces=0, numEdges=0, numVerts=0; int maxVerts, maxEdges, maxFaces; int i; @@ -130,50 +131,46 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, /* if mode is to use selected armature bones, aggregate the bone groups */ if (mmd->mode == MOD_MASK_MODE_ARM) /* --- using selected bones --- */ { - GHash *vgroupHash, *boneHash; + GHash *vgroupHash; Object *oba= mmd->ob_arm; bPoseChannel *pchan; bDeformGroup *def; + char *bone_select_array; + int bone_select_tot= 0; /* check that there is armature object with bones to use, otherwise return original mesh */ - if (ELEM(NULL, mmd->ob_arm, mmd->ob_arm->pose)) - return derivedData; - + if (ELEM3(NULL, mmd->ob_arm, mmd->ob_arm->pose, ob->defbase.first)) + return derivedData; + + bone_select_array= MEM_mallocN(BLI_countlist(&ob->defbase) * sizeof(char), "mask array"); + + for (i = 0, def = ob->defbase.first; def; def = def->next, i++) + { + if (((pchan= get_pose_channel(oba->pose, def->name)) && pchan->bone && (pchan->bone->flag & BONE_SELECTED))) + { + bone_select_array[i]= TRUE; + bone_select_tot++; + } + else { + bone_select_array[i]= FALSE; + } + } + /* hashes for finding mapping of: * - vgroups to indices -> vgroupHash (string, int) * - bones to vgroup indices -> boneHash (index of vgroup, dummy) */ vgroupHash= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "mask vgroup gh"); - boneHash= BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "mask bone gh"); /* build mapping of names of vertex groups to indices */ for (i = 0, def = ob->defbase.first; def; def = def->next, i++) BLI_ghash_insert(vgroupHash, def->name, SET_INT_IN_POINTER(i)); - /* get selected-posechannel <-> vertexgroup index mapping */ - for (pchan= oba->pose->chanbase.first; pchan; pchan= pchan->next) - { - /* check if bone is selected */ - // TODO: include checks for visibility too? - // FIXME: the depsgraph needs extensions to make this work in realtime... - if ( (pchan->bone) && (pchan->bone->flag & BONE_SELECTED) ) - { - /* check if hash has group for this bone */ - if (BLI_ghash_haskey(vgroupHash, pchan->name)) - { - int defgrp_index= GET_INT_FROM_POINTER(BLI_ghash_lookup(vgroupHash, pchan->name)); - - /* add index to hash (store under key only) */ - BLI_ghash_insert(boneHash, SET_INT_IN_POINTER(defgrp_index), pchan); - } - } - } - /* if no bones selected, free hashes and return original mesh */ - if (BLI_ghash_size(boneHash) == 0) + if (bone_select_tot == 0) { BLI_ghash_free(vgroupHash, NULL, NULL); - BLI_ghash_free(boneHash, NULL, NULL); + MEM_freeN(bone_select_array); return derivedData; } @@ -183,7 +180,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, if (dvert == NULL) { BLI_ghash_free(vgroupHash, NULL, NULL); - BLI_ghash_free(boneHash, NULL, NULL); + MEM_freeN(bone_select_array); return derivedData; } @@ -192,28 +189,29 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, vertHash= BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "mask vert gh"); /* add vertices which exist in vertexgroups into vertHash for filtering */ - for (i = 0; i < maxVerts; i++) + for (i= 0, dv= dvert; i < maxVerts; i++, dv++) { - MDeformWeight *def_weight = NULL; + MDeformWeight *dw= dv->dw; int j; - - for (j= 0; j < dvert[i].totweight; j++) + + for (j= dv->totweight; j > 0; j--, dw++) { - if (BLI_ghash_haskey(boneHash, SET_INT_IN_POINTER(dvert[i].dw[j].def_nr))) + if (bone_select_array[dw->def_nr]) { - def_weight = &dvert[i].dw[j]; - break; + if(dw->weight != 0.0f) { + break; + } } } /* check if include vert in vertHash */ if (mmd->flag & MOD_MASK_INV) { /* if this vert is in the vgroup, don't include it in vertHash */ - if (def_weight) continue; + if (dw) continue; } else { /* if this vert isn't in the vgroup, don't include it in vertHash */ - if (!def_weight) continue; + if (!dw) continue; } /* add to ghash for verts (numVerts acts as counter for mapping) */ @@ -223,7 +221,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, /* free temp hashes */ BLI_ghash_free(vgroupHash, NULL, NULL); - BLI_ghash_free(boneHash, NULL, NULL); + MEM_freeN(bone_select_array); } else /* --- Using Nominated VertexGroup only --- */ { @@ -241,28 +239,18 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, vertHash= BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "mask vert2 bh"); /* add vertices which exist in vertexgroup into ghash for filtering */ - for (i = 0; i < maxVerts; i++) + for (i= 0, dv= dvert; i < maxVerts; i++, dv++) { - MDeformWeight *def_weight = NULL; - int j; - - for (j= 0; j < dvert[i].totweight; j++) - { - if (dvert[i].dw[j].def_nr == defgrp_index) - { - def_weight = &dvert[i].dw[j]; - break; - } - } + const int weight_set= defvert_find_weight(dv, defgrp_index) != 0.0f; /* check if include vert in vertHash */ if (mmd->flag & MOD_MASK_INV) { /* if this vert is in the vgroup, don't include it in vertHash */ - if (def_weight) continue; + if (weight_set) continue; } else { /* if this vert isn't in the vgroup, don't include it in vertHash */ - if (!def_weight) continue; + if (!weight_set) continue; } /* add to ghash for verts (numVerts acts as counter for mapping) */ diff --git a/source/blender/nodes/intern/SHD_nodes/SHD_material.c b/source/blender/nodes/intern/SHD_nodes/SHD_material.c index 8b477af0689..f66df9bba90 100644 --- a/source/blender/nodes/intern/SHD_nodes/SHD_material.c +++ b/source/blender/nodes/intern/SHD_nodes/SHD_material.c @@ -209,6 +209,17 @@ static void node_shader_init_material(bNode* node) node->custom1= SH_NODE_MAT_DIFF|SH_NODE_MAT_SPEC; } +/* XXX this is also done as a local static function in gpu_codegen.c, + * but we need this to hack around the crappy material node. + */ +static GPUNodeLink *gpu_get_input_link(GPUNodeStack *in) +{ + if (in->link) + return in->link; + else + return GPU_uniform(in->vec); +} + static int gpu_shader_material(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out) { if(node->id) { @@ -229,18 +240,18 @@ static int gpu_shader_material(GPUMaterial *mat, bNode *node, GPUNodeStack *in, /* write values */ if(hasinput[MAT_IN_COLOR]) - shi.rgb = in[MAT_IN_COLOR].link; + shi.rgb = gpu_get_input_link(&in[MAT_IN_COLOR]); if(hasinput[MAT_IN_SPEC]) - shi.specrgb = in[MAT_IN_SPEC].link; + shi.specrgb = gpu_get_input_link(&in[MAT_IN_SPEC]); if(hasinput[MAT_IN_REFL]) - shi.refl = in[MAT_IN_REFL].link; + shi.refl = gpu_get_input_link(&in[MAT_IN_REFL]); /* retrieve normal */ if(hasinput[MAT_IN_NORMAL]) { GPUNodeLink *tmp; - shi.vn = in[MAT_IN_NORMAL].link; + shi.vn = gpu_get_input_link(&in[MAT_IN_NORMAL]); GPU_link(mat, "vec_math_normalize", shi.vn, &shi.vn, &tmp); } @@ -250,11 +261,11 @@ static int gpu_shader_material(GPUMaterial *mat, bNode *node, GPUNodeStack *in, if (node->type == SH_NODE_MATERIAL_EXT) { if(hasinput[MAT_IN_AMB]) - shi.amb= in[MAT_IN_AMB].link; + shi.amb= gpu_get_input_link(&in[MAT_IN_AMB]); if(hasinput[MAT_IN_EMIT]) - shi.emit= in[MAT_IN_EMIT].link; + shi.emit= gpu_get_input_link(&in[MAT_IN_EMIT]); if(hasinput[MAT_IN_ALPHA]) - shi.alpha= in[MAT_IN_ALPHA].link; + shi.alpha= gpu_get_input_link(&in[MAT_IN_ALPHA]); } GPU_shaderesult_set(&shi, &shr); /* clears shr */ diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h index 47230ab3089..23f301249ba 100644 --- a/source/blender/render/extern/include/RE_pipeline.h +++ b/source/blender/render/extern/include/RE_pipeline.h @@ -146,7 +146,7 @@ typedef struct RenderResult { typedef struct RenderStats { int cfra; int totface, totvert, totstrand, tothalo, totlamp, totpart; - short curfield, curblur, curpart, partsdone, convertdone; + short curfield, curblur, curpart, partsdone, convertdone, curfsa; double starttime, lastframetime; const char *infostr, *statstr; char scenename[32]; diff --git a/source/blender/render/extern/include/RE_shader_ext.h b/source/blender/render/extern/include/RE_shader_ext.h index 958c19ab9ca..a59ebdaa5a2 100644 --- a/source/blender/render/extern/include/RE_shader_ext.h +++ b/source/blender/render/extern/include/RE_shader_ext.h @@ -193,6 +193,8 @@ typedef struct ShadeInput /* node shaders... */ struct Tex; struct MTex; +struct ImBuf; + /* this one uses nodes */ int multitex_ext(struct Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, struct TexResult *texres); /* nodes disabled */ @@ -209,6 +211,6 @@ struct Object; void RE_shade_external(struct Render *re, struct ShadeInput *shi, struct ShadeResult *shr); int RE_bake_shade_all_selected(struct Render *re, int type, struct Object *actob, short *do_update, float *progress); struct Image *RE_bake_shade_get_image(void); +void RE_bake_ibuf_filter(struct ImBuf *ibuf, unsigned char *mask, const int filter); #endif /* RE_SHADER_EXT_H */ - diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h index cf16211b6d1..b2535ebc9ea 100644 --- a/source/blender/render/intern/include/render_types.h +++ b/source/blender/render/intern/include/render_types.h @@ -214,7 +214,7 @@ struct Render ListBase instancetable; int totinstance; - struct Image *backbuf, *bakebuf; + struct Image *bakebuf; struct GHash *orco_hash; diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 18da1f4a094..dc9ed29aace 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -4665,7 +4665,6 @@ void RE_Database_Free(Render *re) re->totvlak=re->totvert=re->totstrand=re->totlamp=re->tothalo= 0; re->i.convertdone= 0; - re->backbuf= NULL; re->bakebuf= NULL; if(re->scene) diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c index 1e40ab886ae..e2ab21ef877 100644 --- a/source/blender/render/intern/source/envmap.c +++ b/source/blender/render/intern/source/envmap.c @@ -149,7 +149,6 @@ static Render *envmap_render_copy(Render *re, EnvMap *env) envre->r.layers.first= envre->r.layers.last= NULL; envre->r.filtertype= 0; envre->r.xparts= envre->r.yparts= 2; - envre->r.bufflag= 0; envre->r.size= 100; envre->r.yasp= envre->r.xasp= 1; diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c index 7d2c7b35247..cb08ae96bf7 100644 --- a/source/blender/render/intern/source/imagetexture.c +++ b/source/blender/render/intern/source/imagetexture.c @@ -76,6 +76,8 @@ extern struct Render R; /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +static void boxsample(ImBuf *ibuf, float minx, float miny, float maxx, float maxy, TexResult *texres, int imaprepeat, int imapextend); + /* *********** IMAGEWRAPPING ****************** */ @@ -201,7 +203,16 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, float *texvec, TexResult *texre ibuf->rect+= (ibuf->x*ibuf->y); } - ibuf_get_color(&texres->tr, ibuf, x, y); + /* interpolate */ + if (tex->imaflag & TEX_INTERPOL) { + float filterx, filtery; + filterx = (0.5f * tex->filtersize) / ibuf->x; + filtery = (0.5f * tex->filtersize) / ibuf->y; + + boxsample(ibuf, fx-filterx, fy-filtery, fx+filterx, fy+filtery, texres, (tex->extend==TEX_REPEAT), (tex->extend==TEX_EXTEND)); + } + else /* no filtering */ + ibuf_get_color(&texres->tr, ibuf, x, y); if( (R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields) ) { ibuf->rect-= (ibuf->x*ibuf->y); diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 436f0ecd997..90f07586786 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -2065,36 +2065,6 @@ static void do_render_fields_3d(Render *re) re->display_draw(re->ddh, re->result, NULL); } -static void load_backbuffer(Render *re) -{ - if(re->r.alphamode == R_ADDSKY) { - ImBuf *ibuf; - char name[256]; - - BLI_strncpy(name, re->r.backbuf, sizeof(name)); - BLI_path_abs(name, re->main->name); - BLI_path_frame(name, re->r.cfra, 0); - - if(re->backbuf) { - re->backbuf->id.us--; - if(re->backbuf->id.us<1) - BKE_image_signal(re->backbuf, NULL, IMA_SIGNAL_RELOAD); - } - - re->backbuf= BKE_add_image_file(name); - ibuf= BKE_image_get_ibuf(re->backbuf, NULL); - if(ibuf==NULL) { - // error() doesnt work with render window open - //error("No backbuf there!"); - printf("Error: No backbuf %s\n", name); - } - else { - if (re->r.mode & R_FIELDS) - image_de_interlace(re->backbuf, re->r.mode & R_ODDFIELD); - } - } -} - /* main render routine, no compositing */ static void do_render_fields_blur_3d(Render *re) { @@ -2105,10 +2075,6 @@ static void do_render_fields_blur_3d(Render *re) G.afbreek= 1; return; } - - /* backbuffer initialize */ - if(re->r.bufflag & 1) - load_backbuffer(re); /* now use renderdata and camera to set viewplane */ RE_SetCamera(re, camera); @@ -2203,6 +2169,24 @@ static void render_scene(Render *re, Scene *sce, int cfra) do_render_fields_blur_3d(resc); } +/* helper call to detect if this scene needs a render, or if there's a any render layer to render */ +static int composite_needs_render(Scene *sce, int this_scene) +{ + bNodeTree *ntree= sce->nodetree; + bNode *node; + + if(ntree==NULL) return 1; + if(sce->use_nodes==0) return 1; + if((sce->r.scemode & R_DOCOMP)==0) return 1; + + for(node= ntree->nodes.first; node; node= node->next) { + if(node->type==CMP_NODE_R_LAYERS) + if(this_scene==0 || node->id==NULL || node->id==&sce->id) + return 1; + } + return 0; +} + static void tag_scenes_for_render(Render *re) { bNode *node; @@ -2211,7 +2195,8 @@ static void tag_scenes_for_render(Render *re) for(sce= re->main->scene.first; sce; sce= sce->id.next) sce->id.flag &= ~LIB_DOIT; - re->scene->id.flag |= LIB_DOIT; + if(RE_GetCamera(re) && composite_needs_render(re->scene, 1)) + re->scene->id.flag |= LIB_DOIT; if(re->scene->nodetree==NULL) return; @@ -2258,24 +2243,6 @@ static void ntree_render_scenes(Render *re) set_scene_bg(re->main, re->scene); } -/* helper call to detect if theres a composite with render-result node */ -static int composite_needs_render(Scene *sce) -{ - bNodeTree *ntree= sce->nodetree; - bNode *node; - - if(ntree==NULL) return 1; - if(sce->use_nodes==0) return 1; - if((sce->r.scemode & R_DOCOMP)==0) return 1; - - for(node= ntree->nodes.first; node; node= node->next) { - if(node->type==CMP_NODE_R_LAYERS) - if(node->id==NULL || node->id==&sce->id) - return 1; - } - return 0; -} - /* bad call... need to think over proper method still */ static void render_composit_stats(void *UNUSED(arg), char *str) { @@ -2291,6 +2258,16 @@ static void do_merge_fullsample(Render *re, bNodeTree *ntree) float *rectf, filt[3][3]; int sample; + /* interaction callbacks */ + if(ntree) { + ntree->stats_draw= render_composit_stats; + ntree->test_break= re->test_break; + ntree->progress= re->progress; + ntree->sdh= re->sdh; + ntree->tbh= re->tbh; + ntree->prh= re->prh; + } + /* filtmask needs it */ R= *re; @@ -2298,25 +2275,27 @@ static void do_merge_fullsample(Render *re, bNodeTree *ntree) rectf= MEM_mapallocN(re->rectx*re->recty*sizeof(float)*4, "fullsample rgba"); for(sample=0; sample<re->r.osa; sample++) { + Render *re1; RenderResult rres; int x, y, mask; - /* set all involved renders on the samplebuffers (first was done by render itself) */ + /* enable full sample print */ + R.i.curfsa= sample+1; + + /* set all involved renders on the samplebuffers (first was done by render itself, but needs tagged) */ /* also function below assumes this */ - if(sample) { - Render *re1; - tag_scenes_for_render(re); - for(re1= RenderGlobal.renderlist.first; re1; re1= re1->next) { - if(re1->scene->id.flag & LIB_DOIT) { - if(re1->r.scemode & R_FULL_SAMPLE) { + tag_scenes_for_render(re); + for(re1= RenderGlobal.renderlist.first; re1; re1= re1->next) { + if(re1->scene->id.flag & LIB_DOIT) { + if(re1->r.scemode & R_FULL_SAMPLE) { + if(sample) read_render_result(re1, sample); - ntreeCompositTagRender(re1->scene); /* ensure node gets exec to put buffers on stack */ - } + ntreeCompositTagRender(re1->scene); /* ensure node gets exec to put buffers on stack */ } } } - + /* composite */ if(ntree) { ntreeCompositTagRender(re->scene); @@ -2359,6 +2338,17 @@ static void do_merge_fullsample(Render *re, bNodeTree *ntree) break; } + /* clear interaction callbacks */ + if(ntree) { + ntree->stats_draw= NULL; + ntree->test_break= NULL; + ntree->progress= NULL; + ntree->tbh= ntree->sdh= ntree->prh= NULL; + } + + /* disable full sample print */ + R.i.curfsa= 0; + BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE); if(re->result->rectf) MEM_freeN(re->result->rectf); @@ -2398,8 +2388,10 @@ void RE_MergeFullSample(Render *re, Main *bmain, Scene *sce, bNodeTree *ntree) } /* own render result should be read/allocated */ - if(re->scene->id.flag & LIB_DOIT) + if(re->scene->id.flag & LIB_DOIT) { RE_ReadRenderResult(re->scene, re->scene); + re->scene->id.flag &= ~LIB_DOIT; + } /* and now we can draw (result is there) */ re->display_init(re->dih, re->result); @@ -2417,12 +2409,21 @@ static void do_render_composite_fields_blur_3d(Render *re) /* INIT seeding, compositor can use random texture */ BLI_srandom(re->r.cfra); - if(composite_needs_render(re->scene)) { + if(composite_needs_render(re->scene, 1)) { /* save memory... free all cached images */ ntreeFreeCache(ntree); do_render_fields_blur_3d(re); - } else { + } + else { + /* ensure new result gets added, like for regular renders */ + BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE); + + RE_FreeRenderResult(re->result); + re->result= new_render_result(re, &re->disprect, 0, RR_USEMEM); + + BLI_rw_mutex_unlock(&re->resultmutex); + /* scene render process already updates animsys */ update_newframe = 1; } @@ -2758,7 +2759,7 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, void *erh, vo } if(scene->r.scemode & R_FULL_SAMPLE) { - if(composite_needs_render(scene)==0) { + if(composite_needs_render(scene, 0)==0) { error(erh, "Full Sample AA not supported without 3d rendering"); return 0; } diff --git a/source/blender/render/intern/source/pixelshading.c b/source/blender/render/intern/source/pixelshading.c index 2d42938f6ac..56a1c870904 100644 --- a/source/blender/render/intern/source/pixelshading.c +++ b/source/blender/render/intern/source/pixelshading.c @@ -502,21 +502,6 @@ int shadeHaloFloat(HaloRen *har, float *col, int zz, /* ------------------------------------------------------------------------- */ -static void fillBackgroundImage(float *collector, float fx, float fy) -{ - collector[0] = 0.0; - collector[1] = 0.0; - collector[2] = 0.0; - collector[3] = 0.0; - - if(R.backbuf) { - float dx= 1.0f/(float)R.winx; - float dy= 1.0f/(float)R.winy; - - image_sample(R.backbuf, fx*dx, fy*dy, dx, dy, collector); - } -} - /* Only view vector is important here. Result goes to colf[3] */ void shadeSkyView(float *colf, float *rco, float *view, float *dxyview, short thread) { @@ -626,18 +611,14 @@ void shadeSkyPixel(float *collector, float fx, float fy, short thread) float fac; - /* 1. Do a backbuffer image: */ - if(R.r.bufflag & 1) { - fillBackgroundImage(collector, fx, fy); - } - else if((R.wrld.skytype & (WO_SKYBLEND+WO_SKYTEX))==0) { - /* 2. solid color */ + if((R.wrld.skytype & (WO_SKYBLEND+WO_SKYTEX))==0) { + /* 1. solid color */ VECCOPY(collector, &R.wrld.horr); collector[3] = 0.0f; } else { - /* 3. */ + /* 2. */ /* This one true because of the context of this routine */ if(R.wrld.skytype & WO_SKYPAPER) { diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index 5f5dab94ba3..c4587b83fcd 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -2192,6 +2192,7 @@ void do_material_tex(ShadeInput *shi) } } else if(mtex->texco==TEXCO_REFL) { + calc_R_ref(shi); co= shi->ref; dx= shi->dxref; dy= shi->dyref; } else if(mtex->texco==TEXCO_NORM) { @@ -2509,9 +2510,6 @@ void do_material_tex(ShadeInput *shi) shi->orn[0]= -shi->vn[0]; shi->orn[1]= -shi->vn[1]; shi->orn[2]= -shi->vn[2]; - - /* reflection vector */ - calc_R_ref(shi); } } diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 0087be8cca9..6b50ba417eb 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -2464,7 +2464,8 @@ static int get_next_bake_face(BakeShade *bs) if(tface && tface->tpage) { Image *ima= tface->tpage; ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); - float vec[4]= {0.0f, 0.0f, 0.0f, 0.0f}; + const float vec_alpha[4]= {0.0f, 0.0f, 0.0f, 0.0f}; + const float vec_solid[4]= {0.0f, 0.0f, 0.0f, 1.0f}; if(ibuf==NULL) continue; @@ -2484,7 +2485,7 @@ static int get_next_bake_face(BakeShade *bs) imb_freerectImBuf(ibuf); /* clear image */ if(R.r.bake_flag & R_BAKE_CLEAR) - IMB_rectfill(ibuf, vec); + IMB_rectfill(ibuf, (ibuf->depth == 32) ? vec_alpha : vec_solid); /* might be read by UI to set active image for display */ R.bakebuf= ima; @@ -2589,6 +2590,48 @@ static void *do_bake_thread(void *bs_v) return NULL; } +void RE_bake_ibuf_filter(ImBuf *ibuf, unsigned char *mask, const int filter) +{ + /* must check before filtering */ + const short is_new_alpha= (ibuf->depth != 32) && BKE_alphatest_ibuf(ibuf); + + /* Margin */ + if(filter) { + char *temprect; + int i; + + /* extend the mask +2 pixels from the image, + * this is so colors dont blend in from outside */ + + for(i=0; i< filter; i++) + IMB_mask_filter_extend((char *)ibuf->userdata, ibuf->x, ibuf->y); + + temprect = MEM_dupallocN(ibuf->userdata); + + /* expand twice to clear this many pixels, so they blend back in */ + IMB_mask_filter_extend(temprect, ibuf->x, ibuf->y); + IMB_mask_filter_extend(temprect, ibuf->x, ibuf->y); + + /* clear all pixels in the margin */ + IMB_mask_clear(ibuf, temprect, FILTER_MASK_MARGIN); + MEM_freeN(temprect); + + for(i= 0; i < filter; i++) + IMB_filter_extend(ibuf, (char *)ibuf->userdata); + } + + /* if the bake results in new alpha then change the image setting */ + if(is_new_alpha) { + ibuf->depth= 32; + } + else { + if(filter && ibuf->depth != 32) { + /* clear alpha added by filtering */ + IMB_rectfill_alpha(ibuf, 1.0f); + } + } +} + /* using object selection tags, the faces with UV maps get baked */ /* render should have been setup */ /* returns 0 if nothing was handled */ @@ -2675,36 +2718,7 @@ int RE_bake_shade_all_selected(Render *re, int type, Object *actob, short *do_up if(!ibuf) continue; - if(re->r.bake_filter) { - if (usemask) { - /* extend the mask +2 pixels from the image, - * this is so colors dont blend in from outside */ - char *temprect; - - for(a=0; a<re->r.bake_filter; a++) - IMB_mask_filter_extend((char *)ibuf->userdata, ibuf->x, ibuf->y); - - temprect = MEM_dupallocN(ibuf->userdata); - - /* expand twice to clear this many pixels, so they blend back in */ - IMB_mask_filter_extend(temprect, ibuf->x, ibuf->y); - IMB_mask_filter_extend(temprect, ibuf->x, ibuf->y); - - /* clear all pixels in the margin*/ - IMB_mask_clear(ibuf, temprect, FILTER_MASK_MARGIN); - MEM_freeN(temprect); - } - - for(a=0; a<re->r.bake_filter; a++) { - /*the mask, ibuf->userdata - can be null, in this case only zero alpha is used */ - IMB_filter_extend(ibuf, (char *)ibuf->userdata); - } - - if (ibuf->userdata) { - MEM_freeN(ibuf->userdata); - ibuf->userdata= NULL; - } - } + RE_bake_ibuf_filter(ibuf, (unsigned char *)ibuf->userdata, re->r.bake_filter); ibuf->userflags |= IB_BITMAPDIRTY; if (ibuf->rect_float) IMB_rect_from_float(ibuf); diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c index 77141d9b445..e22ddd28dda 100644 --- a/source/blender/render/intern/source/shadeinput.c +++ b/source/blender/render/intern/source/shadeinput.c @@ -543,11 +543,6 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert shi->orn[2]= -shi->vn[2]; } - if(texco & TEXCO_REFL) { - /* mirror reflection color textures (and envmap) */ - calc_R_ref(shi); /* wrong location for normal maps! XXXXXXXXXXXXXX */ - } - if(texco & TEXCO_STRESS) { /* not supported */ } @@ -1205,11 +1200,6 @@ void shade_input_set_shade_texco(ShadeInput *shi) shi->orn[2]= -shi->vn[2]; } - if(texco & TEXCO_REFL) { - /* mirror reflection color textures (and envmap) */ - calc_R_ref(shi); /* wrong location for normal maps! XXXXXXXXXXXXXX */ - } - if(texco & TEXCO_STRESS) { float *s1, *s2, *s3; diff --git a/source/blender/render/intern/source/sunsky.c b/source/blender/render/intern/source/sunsky.c index f645c29a7a5..5877fa42292 100644 --- a/source/blender/render/intern/source/sunsky.c +++ b/source/blender/render/intern/source/sunsky.c @@ -460,7 +460,7 @@ void AtmospherePixleShader( struct SunSky* sunSky, float view[3], float s, float vec3opv(sunSky->atm_BetaRM, sunSky->atm_BetaRay, +, sunSky->atm_BetaMie); //e^(-(beta_1 + beta_2) * s) = E1 - vec3opf(E1, sunSky->atm_BetaRM, *, -s/log(2)); + vec3opf(E1, sunSky->atm_BetaRM, *, -s/M_LN2); E1[0] = exp(E1[0]); E1[1] = exp(E1[1]); E1[2] = exp(E1[2]); diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 57c3e2e233c..c801ca58b71 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -329,7 +329,6 @@ static void free_openrecent(void) /* bad stuff*/ -extern ListBase editelems; extern wchar_t *copybuf; extern wchar_t *copybufinfo; @@ -395,10 +394,6 @@ void WM_exit(bContext *C) free_anim_drivers_copybuf(); free_fmodifiers_copybuf(); free_posebuf(); -// free_vertexpaint(); -// free_imagepaint(); - -// fsmenu_free(); BLF_exit(); @@ -421,10 +416,6 @@ void WM_exit(bContext *C) BPY_python_end(); #endif - if (!G.background) { -// XXX UI_filelist_free_icons(); - } - GPU_buffer_pool_free(NULL); GPU_free_unused_buffers(); GPU_extensions_exit(); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 1b7333024e7..06d049d2cb5 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -921,7 +921,16 @@ static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op) if(ED_undo_valid(C, op->type->name)==0) uiLayoutSetEnabled(layout, 0); - uiLayoutOperatorButs(C, layout, op, NULL, 'H', UI_LAYOUT_OP_SHOW_TITLE); + if(op->type->flag & OPTYPE_MACRO) { + for(op= op->macro.first; op; op= op->next) { + uiItemL(layout, op->type->name, ICON_NONE); + uiLayoutOperatorButs(C, layout, op, NULL, 'H', UI_LAYOUT_OP_SHOW_TITLE); + } + } + else { + uiLayoutOperatorButs(C, layout, op, NULL, 'H', UI_LAYOUT_OP_SHOW_TITLE); + } + uiPopupBoundsBlock(block, 4, 0, 0); uiEndBlock(C, block); @@ -1476,6 +1485,14 @@ static int wm_open_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED( { const char *openname= G.main->name; + if(CTX_wm_window(C) == NULL) { + /* in rare cases this could happen, when trying to invoke in background + * mode on load for example. Don't use poll for this because exec() + * can still run without a window */ + BKE_report(op->reports, RPT_ERROR, "Context window not set"); + return OPERATOR_CANCELLED; + } + /* if possible, get the name of the most recently used .blend file */ if (G.recent_files.first) { struct RecentFile *recent = G.recent_files.first; @@ -1526,7 +1543,7 @@ static void WM_OT_open_mainfile(wmOperatorType *ot) ot->invoke= wm_open_mainfile_invoke; ot->exec= wm_open_mainfile_exec; - ot->poll= WM_operator_winactive; + /* ommit window poll so this can work in background mode */ WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_BLENDER, FILE_OPENFILE, WM_FILESEL_FILEPATH); @@ -1945,7 +1962,7 @@ static void WM_OT_save_mainfile(wmOperatorType *ot) ot->invoke= wm_save_mainfile_invoke; ot->exec= wm_save_as_mainfile_exec; ot->check= blend_save_check; - ot->poll= NULL; + /* ommit window poll so this can work in background mode */ WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH); RNA_def_boolean(ot->srna, "compress", 0, "Compress", "Write compressed .blend file"); @@ -3125,7 +3142,6 @@ static int radial_control_cancel(bContext *C, wmOperator *op) static int radial_control_modal(bContext *C, wmOperator *op, wmEvent *event) { RadialControl *rc = op->customdata; - wmWindowManager *wm; float new_value, dist, zoom[2]; float delta[2], snap, ret = OPERATOR_RUNNING_MODAL; |