Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2010-09-18 04:50:13 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2010-09-18 04:50:13 +0400
commit28d618e41b33fe1f351af4fa7100c84ed68a4b13 (patch)
tree6b15f23f128c65cb46101864c667dd81cd073b2b /source/blender
parent56303415e4d534d4f2f4075a818a2aa19ea19fbd (diff)
parent3e1ff2e590970c6db02859df0f73531692767cbf (diff)
Merged changes in the trunk up to revision 31987.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenfont/intern/blf_font.c9
-rw-r--r--source/blender/blenkernel/BKE_exotic.h4
-rw-r--r--source/blender/blenkernel/BKE_image.h2
-rw-r--r--source/blender/blenkernel/BKE_node.h2
-rw-r--r--source/blender/blenkernel/BKE_unit.h7
-rw-r--r--source/blender/blenkernel/intern/anim.c14
-rw-r--r--source/blender/blenkernel/intern/boids.c70
-rw-r--r--source/blender/blenkernel/intern/effect.c1
-rw-r--r--source/blender/blenkernel/intern/exotic.c1706
-rw-r--r--source/blender/blenkernel/intern/fluidsim.c1
-rw-r--r--source/blender/blenkernel/intern/image.c23
-rw-r--r--source/blender/blenkernel/intern/node.c15
-rw-r--r--source/blender/blenkernel/intern/particle.c3
-rw-r--r--source/blender/blenkernel/intern/particle_system.c3
-rw-r--r--source/blender/blenkernel/intern/pointcache.c2
-rw-r--r--source/blender/blenkernel/intern/seqcache.c2
-rw-r--r--source/blender/blenkernel/intern/smoke.c2
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c2
-rw-r--r--source/blender/blenkernel/intern/unit.c64
-rw-r--r--source/blender/blenkernel/intern/writeffmpeg.c1
-rw-r--r--source/blender/blenlib/BLI_math_color.h5
-rw-r--r--source/blender/blenlib/BLI_storage.h5
-rw-r--r--source/blender/blenlib/CMakeLists.txt11
-rw-r--r--source/blender/blenlib/intern/bpath.c2
-rw-r--r--source/blender/blenlib/intern/dynlib.c2
-rw-r--r--source/blender/blenlib/intern/fileops.c2
-rw-r--r--source/blender/blenlib/intern/math_color.c25
-rw-r--r--source/blender/blenlib/intern/math_matrix.c4
-rw-r--r--source/blender/blenlib/intern/path_util.c15
-rw-r--r--source/blender/blenlib/intern/storage.c6
-rw-r--r--source/blender/blenlib/intern/winstuff.c2
-rw-r--r--source/blender/blenloader/intern/readblenentry.c1
-rw-r--r--source/blender/blenloader/intern/readfile.c16
-rw-r--r--source/blender/collada/DocumentExporter.cpp45
-rw-r--r--source/blender/editors/animation/anim_channels_defines.c11
-rw-r--r--source/blender/editors/armature/editarmature.c97
-rw-r--r--source/blender/editors/armature/poseobject.c15
-rw-r--r--source/blender/editors/include/ED_armature.h8
-rw-r--r--source/blender/editors/include/UI_interface.h20
-rw-r--r--source/blender/editors/interface/interface.c23
-rw-r--r--source/blender/editors/interface/interface_draw.c29
-rw-r--r--source/blender/editors/interface/interface_handlers.c65
-rw-r--r--source/blender/editors/interface/interface_intern.h5
-rw-r--r--source/blender/editors/interface/interface_widgets.c5
-rw-r--r--source/blender/editors/mesh/editmesh.c5
-rw-r--r--source/blender/editors/object/object_constraint.c2
-rw-r--r--source/blender/editors/physics/particle_edit.c2
-rw-r--r--source/blender/editors/screen/area.c7
-rw-r--r--source/blender/editors/screen/screen_edit.c4
-rw-r--r--source/blender/editors/screen/screen_ops.c6
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c68
-rw-r--r--source/blender/editors/space_file/file_draw.c14
-rw-r--r--source/blender/editors/space_file/file_intern.h6
-rw-r--r--source/blender/editors/space_file/file_ops.c186
-rw-r--r--source/blender/editors/space_file/file_panels.c6
-rw-r--r--source/blender/editors/space_file/filesel.c15
-rw-r--r--source/blender/editors/space_file/fsmenu.c12
-rw-r--r--source/blender/editors/space_image/image_ops.c13
-rw-r--r--source/blender/editors/space_nla/nla_buttons.c2
-rw-r--r--source/blender/editors/space_nla/nla_draw.c9
-rw-r--r--source/blender/editors/space_node/node_draw.c11
-rw-r--r--source/blender/editors/space_node/node_edit.c27
-rw-r--r--source/blender/editors/space_node/space_node.c20
-rw-r--r--source/blender/editors/space_outliner/space_outliner.c1
-rw-r--r--source/blender/editors/space_sequencer/sequencer_draw.c64
-rw-r--r--source/blender/editors/space_time/space_time.c1
-rw-r--r--source/blender/editors/space_view3d/drawarmature.c64
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c3
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c20
-rw-r--r--source/blender/editors/transform/transform_ops.c2
-rw-r--r--source/blender/ikplugin/BIK_api.h1
-rw-r--r--source/blender/ikplugin/CMakeLists.txt23
-rw-r--r--source/blender/ikplugin/SConscript6
-rw-r--r--source/blender/ikplugin/intern/Makefile3
-rw-r--r--source/blender/ikplugin/intern/ikplugin_api.c12
-rw-r--r--source/blender/ikplugin/intern/itasc_plugin.cpp2
-rw-r--r--source/blender/imbuf/IMB_imbuf.h2
-rw-r--r--source/blender/imbuf/intern/IMB_filetype.h28
-rw-r--r--source/blender/imbuf/intern/allocimbuf.c2
-rw-r--r--source/blender/imbuf/intern/bmp.c2
-rw-r--r--source/blender/imbuf/intern/dds/dds_api.cpp3
-rw-r--r--source/blender/imbuf/intern/dds/dds_api.h2
-rw-r--r--source/blender/imbuf/intern/filetype.c1
-rw-r--r--source/blender/imbuf/intern/iris.c2
-rw-r--r--source/blender/imbuf/intern/jp2.c2
-rw-r--r--source/blender/imbuf/intern/jpeg.c6
-rw-r--r--source/blender/imbuf/intern/module.c1
-rw-r--r--source/blender/imbuf/intern/openexr/openexr_api.cpp4
-rw-r--r--source/blender/imbuf/intern/openexr/openexr_api.h2
-rw-r--r--source/blender/imbuf/intern/png.c4
-rw-r--r--source/blender/imbuf/intern/radiance_hdr.c2
-rw-r--r--source/blender/imbuf/intern/readimage.c6
-rw-r--r--source/blender/imbuf/intern/targa.c6
-rw-r--r--source/blender/imbuf/intern/tiff.c6
-rw-r--r--source/blender/makesdna/DNA_boid_types.h4
-rw-r--r--source/blender/makesrna/intern/rna_armature.c25
-rw-r--r--source/blender/makesrna/intern/rna_armature_api.c22
-rw-r--r--source/blender/makesrna/intern/rna_boid.c6
-rw-r--r--source/blender/makesrna/intern/rna_image.c4
-rw-r--r--source/blender/makesrna/intern/rna_internal.h1
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c4
-rw-r--r--source/blender/makesrna/intern/rna_object.c3
-rw-r--r--source/blender/makesrna/intern/rna_pose_api.c20
-rw-r--r--source/blender/makesrna/intern/rna_sensor.c6
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c4
-rw-r--r--source/blender/makesrna/intern/rna_wm.c38
-rw-r--r--source/blender/makesrna/intern/rna_wm_api.c9
-rw-r--r--source/blender/python/intern/bpy_interface.c10
-rw-r--r--source/blender/python/intern/bpy_operator_wrap.c3
-rw-r--r--source/blender/python/intern/bpy_rna.c8
-rw-r--r--source/blender/readblenfile/intern/BLO_readblenfile.c3
-rw-r--r--source/blender/render/intern/raytrace/reorganize.h1
-rw-r--r--source/blender/windowmanager/WM_api.h4
-rw-r--r--source/blender/windowmanager/WM_types.h6
-rw-r--r--source/blender/windowmanager/intern/wm.c6
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c28
-rw-r--r--source/blender/windowmanager/intern/wm_files.c32
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c35
-rw-r--r--source/blender/windowmanager/intern/wm_window.c38
-rw-r--r--source/blender/windowmanager/wm_event_types.h9
-rw-r--r--source/blender/windowmanager/wm_window.h2
121 files changed, 1145 insertions, 2236 deletions
diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c
index 4c7e6410585..04f40ac825b 100644
--- a/source/blender/blenfont/intern/blf_font.c
+++ b/source/blender/blenfont/intern/blf_font.c
@@ -200,9 +200,14 @@ void blf_font_buffer(FontBLF *font, char *str)
}
chx= pen_x + ((int)g->pos_x);
+ chy= (int)font->pos[1] + g->height;
- pen_y= (int)font->pos[1] - (g->height - ((int)g->pos_y));
- chy= pen_y - ((int)g->pos_y);
+ if (g->pitch < 0) {
+ pen_y = (int)font->pos[1] + (g->height - (int)g->pos_y);
+ }
+ else {
+ pen_y = (int)font->pos[1] - (g->height - (int)g->pos_y);
+ }
if ((chx + g->width) >= 0 && chx < font->bw && (pen_y + g->height) >= 0 && pen_y < font->bh) {
/* dont draw beyond the buffer bounds */
diff --git a/source/blender/blenkernel/BKE_exotic.h b/source/blender/blenkernel/BKE_exotic.h
index bd5af66c6a8..740a94b6169 100644
--- a/source/blender/blenkernel/BKE_exotic.h
+++ b/source/blender/blenkernel/BKE_exotic.h
@@ -34,9 +34,6 @@
struct Mesh;
struct Scene;
-void mcol_to_rgba(unsigned int col, float *r, float *g, float *b, float *a);
-unsigned int *mcol_to_vcol(struct Mesh *me); // used in py_main.c
-
/**
* Reads all 3D fileformats other than Blender fileformat
* @retval 0 The file could not be read.
@@ -46,7 +43,6 @@ unsigned int *mcol_to_vcol(struct Mesh *me); // used in py_main.c
int BKE_read_exotic(struct Scene *scene, char *name);
void write_dxf(struct Scene *scene, char *str);
-void write_vrml(struct Scene *scene, char *str);
void write_stl(struct Scene *scene, char *str);
#endif
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h
index c842efaa3b2..e246b51af09 100644
--- a/source/blender/blenkernel/BKE_image.h
+++ b/source/blender/blenkernel/BKE_image.h
@@ -48,7 +48,7 @@ void BKE_stamp_info(struct Scene *scene, struct ImBuf *ibuf);
void BKE_stamp_buf(struct Scene *scene, unsigned char *rect, float *rectf, int width, int height, int channels);
int BKE_write_ibuf(struct Scene *scene, struct ImBuf *ibuf, char *name, int imtype, int subimtype, int quality);
void BKE_makepicstring(char *string, char *base, int frame, int imtype, int use_ext);
-void BKE_add_image_extension(char *string, int imtype);
+int BKE_add_image_extension(char *string, int imtype);
int BKE_ftype_to_imtype(int ftype);
int BKE_imtype_to_ftype(int imtype);
int BKE_imtype_is_movie(int imtype);
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 4bd4cc3792f..7b4925b7a46 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -192,7 +192,7 @@ int nodeSetActiveID(struct bNodeTree *ntree, short idtype, struct ID *id);
void nodeClearActiveID(struct bNodeTree *ntree, short idtype);
void NodeTagChanged(struct bNodeTree *ntree, struct bNode *node);
-void NodeTagIDChanged(struct bNodeTree *ntree, struct ID *id);
+int NodeTagIDChanged(struct bNodeTree *ntree, struct ID *id);
/* ************** Groups ****************** */
diff --git a/source/blender/blenkernel/BKE_unit.h b/source/blender/blenkernel/BKE_unit.h
index 36ccc1f1497..7461d43e721 100644
--- a/source/blender/blenkernel/BKE_unit.h
+++ b/source/blender/blenkernel/BKE_unit.h
@@ -36,12 +36,18 @@ void bUnit_AsString(char *str, int len_max, double value, int prec, int system,
/* replace units with values, used before python button evaluation */
int bUnit_ReplaceString(char *str, int len_max, char *str_prev, double scale_pref, int system, int type);
+/* make string keyboard-friendly: 10µm --> 10um */
+void bUnit_ToUnitAltName(char *str, int len_max, char *orig_str, int system, int type);
+
/* the size of the unit used for this value (used for calculating the ckickstep) */
double bUnit_ClosestScalar(double value, int system, int type);
/* base scale for these units */
double bUnit_BaseScalar(int system, int type);
+/* return true is the unit system exists */
+int bUnit_IsValid(int system, int type);
+
/* loop over scales, coudl add names later */
//double bUnit_Iter(void **unit, char **name, int system, int type);
@@ -60,6 +66,7 @@ double bUnit_GetScaler(void *usys_pt, int index);
#define B_UNIT_TIME 6
#define B_UNIT_VELOCITY 7
#define B_UNIT_ACCELERATION 8
+#define B_UNIT_MAXDEF 9
#ifdef __cplusplus
}
diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c
index 4b9ffb1e374..98bdf3b2e9f 100644
--- a/source/blender/blenkernel/intern/anim.c
+++ b/source/blender/blenkernel/intern/anim.c
@@ -1357,19 +1357,25 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
VECCOPY(vec, obmat[3]);
obmat[3][0] = obmat[3][1] = obmat[3][2] = 0.0f;
- copy_m4_m4(mat, pamat);
+ /* Normal particles and cached hair live in global space so we need to
+ * remove the real emitter's transformation before 2nd order duplication.
+ */
+ if(par_space_mat)
+ mul_m4_m4m4(mat, pamat, psys->imat);
+ else
+ copy_m4_m4(mat, pamat);
mul_m4_m4m4(tmat, obmat, mat);
mul_mat3_m4_fl(tmat, size*scale);
- if(part->draw & PART_DRAW_GLOBAL_OB)
- VECADD(tmat[3], tmat[3], vec);
-
if(par_space_mat)
mul_m4_m4m4(mat, tmat, par_space_mat);
else
copy_m4_m4(mat, tmat);
+ if(part->draw & PART_DRAW_GLOBAL_OB)
+ VECADD(mat[3], mat[3], vec);
+
dob= new_dupli_object(lb, ob, mat, ob->lay, counter, OB_DUPLIPARTS, animated);
copy_m4_m4(dob->omat, oldobmat);
if(G.rendering)
diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c
index 54ffda6c0a9..69a42e52247 100644
--- a/source/blender/blenkernel/intern/boids.c
+++ b/source/blender/blenkernel/intern/boids.c
@@ -240,6 +240,7 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
mul_v3_fl(bbd->wanted_co, (1.0f - t) * val->personal_space * pa->size);
bbd->wanted_speed = sqrt(t) * len_v3(pa->prev_state.vel);
+ bbd->wanted_speed = MAX2(bbd->wanted_speed, val->min_speed);
return 1;
}
@@ -736,6 +737,7 @@ static void set_boid_values(BoidValues *val, BoidSettings *boids, ParticleData *
val->jump_speed = 0.0f; /* no jumping in air */
}
}
+
static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float *ground_co, float *ground_nor)
{
BoidParticle *bpa = pa->boid;
@@ -765,16 +767,15 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float *gro
if(!bbd->sim->colliders)
return NULL;
+ /* first try to find below boid */
copy_v3_v3(col.co1, pa->state.co);
- copy_v3_v3(col.co2, pa->state.co);
- add_v3_v3(col.co1, zvec);
+ sub_v3_v3v3(col.co2, pa->state.co, zvec);
sub_v3_v3(col.co2, zvec);
sub_v3_v3v3(ray_dir, col.co2, col.co1);
col.t = 0.0f;
hit.index = -1;
hit.dist = col.ray_len = len_v3(ray_dir);
- /* find out upmost deflector object */
for(coll = bbd->sim->colliders->first; coll; coll = coll->next){
col.ob = coll->ob;
col.md = coll->collmd;
@@ -789,14 +790,37 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float *gro
normalize_v3_v3(ground_nor, col.nor);
return col.hit_ob;
}
- else {
- /* default to z=0 */
- VECCOPY(ground_co, pa->state.co);
- ground_co[2] = 0;
- ground_nor[0] = ground_nor[1] = 0.0f;
- ground_nor[2] = 1.0f;
- return NULL;
+
+ /* couldn't find below, so find upmost deflector object */
+ add_v3_v3v3(col.co1, pa->state.co, zvec);
+ sub_v3_v3v3(col.co2, pa->state.co, zvec);
+ sub_v3_v3(col.co2, zvec);
+ sub_v3_v3v3(ray_dir, col.co2, col.co1);
+ col.t = 0.0f;
+ hit.index = -1;
+ hit.dist = col.ray_len = len_v3(ray_dir);
+
+ for(coll = bbd->sim->colliders->first; coll; coll = coll->next){
+ col.ob = coll->ob;
+ col.md = coll->collmd;
+
+ if(col.md && col.md->bvhtree)
+ BLI_bvhtree_ray_cast(col.md->bvhtree, col.co1, ray_dir, radius, &hit, particle_intersect_face, &col);
+ }
+ /* then use that object */
+ if(hit.index>=0) {
+ t = hit.dist/col.ray_len;
+ interp_v3_v3v3(ground_co, col.co1, col.co2, t);
+ normalize_v3_v3(ground_nor, col.nor);
+ return col.hit_ob;
}
+
+ /* default to z=0 */
+ VECCOPY(ground_co, pa->state.co);
+ ground_co[2] = 0;
+ ground_nor[0] = ground_nor[1] = 0.0f;
+ ground_nor[2] = 1.0f;
+ return NULL;
}
}
static int boid_rule_applies(ParticleData *pa, BoidSettings *boids, BoidRule *rule)
@@ -1226,8 +1250,8 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
VECADDFAC(pa->state.vel, pa->state.vel, acc, dtime);
- if(bpa->data.mode != eBoidMode_InAir)
- bpa->ground = boid_find_ground(bbd, pa, ground_co, ground_nor);
+ //if(bpa->data.mode != eBoidMode_InAir)
+ bpa->ground = boid_find_ground(bbd, pa, ground_co, ground_nor);
/* change modes, constrain movement & keep track of down vector */
switch(bpa->data.mode) {
@@ -1255,11 +1279,18 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
boid_find_ground(bbd, pa, ground_co, ground_nor);
boid_climb(boids, pa, ground_co, ground_nor);
}
- /* land boid when belowg ground */
- else if(boids->options & BOID_ALLOW_LAND && pa->state.co[2] <= ground_co[2] + pa->size * boids->height) {
- pa->state.co[2] = ground_co[2] + pa->size * boids->height;
- pa->state.vel[2] = 0.0f;
- bpa->data.mode = eBoidMode_OnLand;
+ else if(pa->state.co[2] <= ground_co[2] + pa->size * boids->height) {
+ /* land boid when below ground */
+ if(boids->options & BOID_ALLOW_LAND) {
+ pa->state.co[2] = ground_co[2] + pa->size * boids->height;
+ pa->state.vel[2] = 0.0f;
+ bpa->data.mode = eBoidMode_OnLand;
+ }
+ /* fly above ground */
+ else {
+ pa->state.co[2] = ground_co[2] + pa->size * boids->height;
+ pa->state.vel[2] = 0.0f;
+ }
}
break;
}
@@ -1355,7 +1386,9 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
/* save direction to state.ave unless the boid is falling */
/* (boids can't effect their direction when falling) */
if(bpa->data.mode!=eBoidMode_Falling && len_v3(pa->state.vel) > 0.1*pa->size) {
- normalize_v3_v3(pa->state.ave, pa->state.vel);
+ copy_v3_v3(pa->state.ave, pa->state.vel);
+ pa->state.ave[2] *= bbd->part->boids->pitch;
+ normalize_v3(pa->state.ave);
}
/* apply damping */
@@ -1440,6 +1473,7 @@ void boid_default_settings(BoidSettings *boids)
boids->landing_smoothness = 3.0f;
boids->banking = 1.0f;
+ boids->pitch = 1.0f;
boids->height = 1.0f;
boids->health = 1.0f;
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index 05fcabd371f..0da5e0da2c4 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -29,6 +29,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
+#include <stddef.h>
#include "BLI_storage.h" /* _LARGEFILE_SOURCE */
#include <math.h>
diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c
index cdefbb54ecf..9dac409226b 100644
--- a/source/blender/blenkernel/intern/exotic.c
+++ b/source/blender/blenkernel/intern/exotic.c
@@ -29,12 +29,14 @@
*
* ***** END GPL LICENSE BLOCK *****/
+#include <stddef.h>
#include "BLI_storage.h"
+#include <stdlib.h>
#include <ctype.h> /* isdigit, isspace */
#include <math.h>
#include <stdio.h>
-#include <stdlib.h>
+
#include <fcntl.h>
#include <string.h>
#include <errno.h>
@@ -449,1328 +451,10 @@ static void read_stl_mesh_ascii(Scene *scene, char *str)
#undef STLREADLINE
#undef STLREADVERT
-/* ***************** INVENTOR ******************* */
-
-
-#define IV_MAXSTACK 3000000
-#define IV_MAXFIELD 10
-#define IV_MAXCOL 16
-
-static float *iv_data_stack;
-static float ivcolors[IV_MAXCOL][3];
-static Object *ivsurf;
-static ListBase ivbase;
-
-struct IvNode {
- struct IvNode *next, *prev;
- char *nodename;
- char *fieldname[IV_MAXFIELD];
- int datalen[IV_MAXFIELD];
- float *data[IV_MAXFIELD];
-};
-
-static int iv_curcol=0;
-
-static int iv_colornumber(struct IvNode *iv)
-{
- float *fp, fr = 0.0, fg = 0.0, fb = 0.0;
- int a;
- char *cp;
-
- /* search back to last material */
- while(iv) {
- if( strcmp(iv->nodename, "Material")==0) {
- fp= iv->data[0];
- if(fp==0) fp= iv->data[1];
- if(fp) {
- fr= fp[0];
- fg= fp[1];
- fb= fp[2];
- }
- break;
- }
- else if( strcmp(iv->nodename, "BaseColor")==0) {
- fp= iv->data[0];
- fr= fp[0];
- fg= fp[1];
- fb= fp[2];
- break;
- }
- else if( strcmp(iv->nodename, "PackedColor")==0) {
- cp= (char *)iv->data[0];
- fr= cp[3]/255.0f;
- fg= cp[2]/255.0f;
- fb= cp[1]/255.0f;
- break;
- }
- iv= iv->prev;
-
- }
- if(iv==0) return 0;
- if(iv->datalen[0]<3) return 0;
-
- for(a=0; a<iv_curcol; a++) {
-
- if(ivcolors[a][0]== fr)
- if(ivcolors[a][1]== fg)
- if(ivcolors[a][2]== fb) return a+1
- ;
- }
-
- if(a>=IV_MAXCOL) a= IV_MAXCOL-1;
- iv_curcol= a+1;
- ivcolors[a][0]= fr;
- ivcolors[a][1]= fg;
- ivcolors[a][2]= fb;
-
- return iv_curcol;
-}
-
-static int iv_finddata(struct IvNode *iv, char *field, int fieldnr)
-{
- /* search for "field", count data size and make datablock. return skipdata */
- float *fp;
- int len, stackcount, skipdata=0;
- char *cpa, terminator, str[64];
- intptr_t i;
-
- len= strlen(field);
-
- cpa= iv->nodename+1;
- while( *cpa != '}' ) {
-
- if( *cpa == *field ) {
- if( strncmp(cpa, field, len)==0 ) {
- iv->fieldname[fieldnr]= cpa;
-
- /* read until first character */
- cpa+= len;
- skipdata+= len;
- *cpa= 0;
- cpa++;
- skipdata++;
-
- while( *cpa==32 || *cpa==13 || *cpa==10 || *cpa==9) cpa++;
- if( *cpa=='[' ) {
- terminator= ']';
- cpa++;
- skipdata++;
- }
- else terminator= 13;
-
- stackcount= 0;
- fp= iv_data_stack;
-
- while( *cpa!=terminator && *cpa != '}' ) {
-
- /* in fact, isdigit should include the dot and minus */
- if( (isdigit(*cpa) || *cpa=='.' || *cpa=='-') && (isspace(cpa[-1]) || cpa[-1]==0 || cpa[-1]==',') ) {
- if(cpa[1]=='x') {
- memcpy(str, cpa, 16);
- str[16]= 0;
-
- sscanf(str, "%x", (int *)fp);
- }
- else {
- /* atof doesn't stop after the first float
- * in a long string at Windows... so we copy
- * the float to a new string then atof... */
- char *cpa_temp = strpbrk(cpa, ", \n");
- i = cpa_temp - cpa;
-
- if (i>63) *fp= 0.0;
- else {
- memcpy(str, cpa, i);
- str[i]=0;
-
- *fp= (float) atof(str);
- }
- }
-
- stackcount++;
- if(stackcount>=IV_MAXSTACK) {
- printf("stackoverflow in IV read\n");
- break;
- }
- fp++;
- }
- cpa++;
- skipdata++;
- }
-
- iv->datalen[fieldnr]= stackcount;
- if(stackcount) {
- iv->data[fieldnr]= MEM_mallocN(sizeof(float)*stackcount, "iv_finddata");
- memcpy(iv->data[fieldnr], iv_data_stack, sizeof(float)*stackcount);
- }
- else iv->data[fieldnr]= 0;
-
- return skipdata;
- }
- }
- cpa++;
- skipdata++;
- }
-
- return skipdata;
-}
-
-static void read_iv_index(float *data, float *baseadr, float *index, int nr, int coordtype)
-{
- /* write in data: baseadr with offset index (and number nr) */
- float *fp;
- int ofs;
-
- while(nr--) {
- ofs= (int) *index;
- fp= baseadr+coordtype*ofs;
- VECCOPY(data, fp);
- data+= 3;
- index++;
- }
-}
-
-
-
-static void read_inventor(Scene *scene, char *str, struct ListBase *listb)
-{
- struct IvNode *iv, *ivp, *ivn;
- char *maindata, *md, *cpa;
- float *index, *data, *fp;
- int file, filelen, count, lll, face, nr = 0;
- int skipdata, ok, a, b, tot, first, colnr, coordtype, polytype, *idata;
- struct DispList *dl;
- ReportList *reports= NULL; /* XXX */
-
- ivbase.first= ivbase.last= 0;
- iv_curcol= 0;
- ivsurf= 0;
-
- file= open(str, O_BINARY|O_RDONLY);
- if(file== -1) {
- BKE_reportf(reports, RPT_ERROR, "Can't read file: %s.", strerror(errno));
- return;
- }
-
- filelen= BLI_filesize(file);
- if(filelen < 1) {
- close(file);
- return;
- }
-
- maindata= MEM_mallocN(filelen, "leesInventor");
- if(read(file, maindata, filelen) < filelen) {
- BKE_reportf(reports, RPT_ERROR, "Failed reading file: premature end of file.");
- close(file);
- return;
- }
- close(file);
-
- iv_data_stack= MEM_mallocN(sizeof(float)*IV_MAXSTACK, "ivstack");
-
- /* preprocess: remove comments */
- md= maindata+20;
- count= 20;
- while(count<filelen) {
- if( *md=='#' ) { /* comment */
- while( *md!=13 && *md!=10) { /* enters */
- *md= 32;
- md++;
- count++;
- if(count>=filelen) break;
- }
- }
- md++;
- count++;
- }
-
-
- /* now time to collect: which are the nodes and fields? */
- md= maindata;
- count= 0;
- while(count<filelen) {
- if( *md=='{' ) { /* read back */
-
- cpa= md-1;
- while( *cpa==32 || *cpa==13 || *cpa==10 || *cpa==9) { /* remove spaces/enters/tab */
- *cpa= 0;
- cpa--;
- }
-
- while( *cpa>32 && *cpa<128) cpa--;
- cpa++;
- *md= 0;
-
- ok= 0;
- skipdata= 0;
- iv= MEM_callocN(sizeof(struct IvNode), "leesInventor");
- iv->nodename= cpa;
-
- if(strcmp(cpa, "Coordinate3")==0 || strcmp(cpa, "Coordinate4")==0) {
- skipdata= iv_finddata(iv, "point", 0);
- ok= 1;
- }
- else if(strcmp(cpa, "VertexProperty")==0) {
- skipdata= iv_finddata(iv, "vertex", 0);
- ok= 1;
- }
- else if(strcmp(cpa, "IndexedLineSet")==0) {
- skipdata= iv_finddata(iv, "coordIndex", 0);
- ok= 1;
- }
- else if(strcmp(cpa, "IndexedTriangleMesh")==0) {
- skipdata= iv_finddata(iv, "coordIndex", 0);
- ok= 1;
- }
- else if(strcmp(cpa, "IndexedFaceSet")==0) {
- skipdata= iv_finddata(iv, "coordIndex", 0);
- ok= 1;
- }
- else if(strcmp(cpa, "FaceSet")==0) {
- skipdata= iv_finddata(iv, "numVertices", 0);
- ok= 1;
- }
- else if(strcmp(cpa, "Material")==0) {
- iv_finddata(iv, "diffuseColor", 0);
- iv_finddata(iv, "ambientColor", 1);
- ok= 1;
- }
- else if(strcmp(cpa, "BaseColor")==0) {
- iv_finddata(iv, "rgb", 0);
- ok= 1;
- }
- else if(strcmp(cpa, "PackedColor")==0) {
- iv_finddata(iv, "rgba", 0);
- ok= 1;
- }
- else if(strcmp(cpa, "QuadMesh")==0) {
- iv_finddata(iv, "verticesPerColumn", 0);
- iv_finddata(iv, "verticesPerRow", 1);
-
- ok= 1;
- }
- else if(strcmp(cpa, "IndexedTriangleStripSet")==0) {
- skipdata= iv_finddata(iv, "coordIndex", 0);
- ok= 1;
- }
- else if(strcmp(cpa, "TriangleStripSet")==0) {
- skipdata= iv_finddata(iv, "numVertices", 0);
- ok= 1;
- }
- else if(strcmp(cpa, "IndexedNurbsSurface")==0 || strcmp(cpa, "NurbsSurface")==0) {
- iv_finddata(iv, "numUControlPoints", 0);
- iv_finddata(iv, "numVControlPoints", 1);
- iv_finddata(iv, "uKnotVector", 2);
- iv_finddata(iv, "vKnotVector", 3);
- ok= 1;
- }
- else {
- /* to the end */
- while( *md != '}') {
- md++;
- count++;
- if(count<filelen) break;
- }
- }
-
-
- if(ok) {
- BLI_addtail(&ivbase, iv);
- md+= skipdata;
- count+= skipdata;
- }
- else MEM_freeN(iv);
-
- }
- md++;
- count++;
- }
-
- /* join nodes */
- iv= ivbase.first;
-
- while(iv) {
- ivn= iv->next;
-
- if( strncmp(iv->nodename, "Indexed", 7)==0) {
- /* seek back: same name? */
-
- ivp= iv->prev;
- while(ivp) {
- if(strcmp(iv->nodename, ivp->nodename)==0) break;
-
- if(strcmp(ivp->nodename, "Coordinate3")==0 ||
- strcmp(ivp->nodename, "Coordinate4")==0 ||
- strcmp(ivp->nodename, "VertexProperty")==0) {
- ivp= 0;
- break;
- }
- ivp= ivp->prev;
- }
-
- if(ivp) {
- /* add iv to ivp */
-
- tot= iv->datalen[0] + ivp->datalen[0];
- if(tot) {
- data= MEM_mallocN(tot*sizeof(float), "samenvoeg iv");
- memcpy(data, ivp->data[0], sizeof(float)*ivp->datalen[0]);
- memcpy(data+ivp->datalen[0], iv->data[0], sizeof(float)*iv->datalen[0]);
-
- ivp->datalen[0]+= iv->datalen[0];
- MEM_freeN(ivp->data[0]);
- ivp->data[0]= data;
-
- BLI_remlink(&ivbase, iv);
- MEM_freeN(iv->data[0]);
- MEM_freeN(iv);
- }
- }
- }
-
- iv= ivn;
- }
-
-
- /* convert Nodes to DispLists */
- iv= ivbase.first;
- while(iv) {
-
- /* printf(" Node: %s\n", iv->nodename); */
- /* if(iv->fieldname[0]) printf(" Field: %s len %d\n", iv->fieldname[0], iv->datalen[0]); */
- coordtype= 3;
-
- if( strcmp(iv->nodename, "IndexedLineSet")==0 ) {
-
- colnr= iv_colornumber(iv);
-
- /* seek back to data */
- ivp= iv;
- while(ivp->prev) {
- ivp= ivp->prev;
- if( strcmp(ivp->nodename, "Coordinate3")==0 ) {
- coordtype= 3;
- break;
- }
- if( strcmp(ivp->nodename, "Coordinate4")==0 ) {
- coordtype= 4;
- break;
- }
- }
- if(ivp) {
-
- /* count the nr of lines */
- tot= 0;
- index= iv->data[0];
- lll = iv->datalen[0]-1;
- for(a=0; a<lll; a++) {
- if(index[0]!= -1 && index[1]!= -1) tot++;
- index++;
- }
-
- tot*= 2; /* nr of vertices */
- dl= MEM_callocN(sizeof(struct DispList)+tot*3*sizeof(float), "leesInventor1");
- BLI_addtail(listb, dl);
- dl->type= DL_SEGM;
- dl->nr= 2;
- dl->parts= tot/2;
- dl->col= colnr;
- data= (float *)(dl+1);
-
- index= iv->data[0];
- for(a=0; a<lll; a++) {
- if(index[0]!= -1 && index[1]!= -1) {
- read_iv_index(data, ivp->data[0], index, 2, coordtype);
- data+= 6;
- }
- index++;
- }
- }
- }
- else if( strcmp(iv->nodename, "FaceSet")==0 ) {
-
- colnr= iv_colornumber(iv);
-
- /* seek back to data */
- ivp= iv;
- while(ivp->prev) {
- ivp= ivp->prev;
- if( strcmp(ivp->nodename, "Coordinate3")==0 ) {
- coordtype= 3;
- break;
- }
- if( strcmp(ivp->nodename, "Coordinate4")==0 ) {
- coordtype= 4;
- break;
- }
- }
-
- if(ivp) {
- /* count triangles */
- tot= 0;
-
- index= iv->data[0];
- polytype= (int) index[0];
-
- for(a=0; a<iv->datalen[0]; a++) {
- if(index[0]== polytype) tot++; /* one kind? */
- index++;
- }
-
-
- tot*= polytype; /* nr of vertices */
- dl= MEM_callocN(sizeof(struct DispList)+tot*3*sizeof(float), "leesInventor4");
- BLI_addtail(listb, dl);
- dl->type= DL_POLY;
- dl->nr= polytype;
- dl->parts= tot/polytype;
- dl->col= colnr;
- data= (float *)(dl+1);
-
- index= ivp->data[0];
- first= 1;
- for(a=0; a<iv->datalen[0]; a++) {
-
- VECCOPY(data, index);
- data+= 3;
- index+= 3;
-
- VECCOPY(data, index);
- data+= 3;
- index+= 3;
-
- VECCOPY(data, index);
- data+= 3;
- index+= 3;
-
- if(polytype==4) {
- VECCOPY(data, index);
- data+= 3;
- index+= 3;
- }
- }
- }
- }
- else if( strcmp(iv->nodename, "TriangleStripSet")==0 ) {
-
- colnr= iv_colornumber(iv);
-
- /* seek back to data */
- ivp= iv;
- while(ivp->prev) {
- ivp= ivp->prev;
- if( strcmp(ivp->nodename, "Coordinate3")==0 ) {
- coordtype= 3;
- break;
- }
- if( strcmp(ivp->nodename, "Coordinate4")==0 ) {
- coordtype= 4;
- break;
- }
- }
-
- if(ivp) {
- /* count triangles */
- tot= 0;
- face= 0;
-
- index= iv->data[0]; /* strip size */
-
- for(a=0; a<iv->datalen[0]; a++) {
- tot+= (int) index[0];
- face+= ((int) index[0]) - 2;
- index++;
- }
-
- dl= MEM_callocN(sizeof(struct DispList), "leesInventor4");
- dl->verts= MEM_callocN( tot*3*sizeof(float), "dl verts");
- dl->index= MEM_callocN( face*3*sizeof(int), "dl index");
-
- dl->type= DL_INDEX3;
- dl->nr= tot;
- dl->parts= face;
-
- BLI_addtail(listb, dl);
- dl->col= colnr;
-
- index= iv->data[0]; /* strip size */
- fp= ivp->data[0]; /* vertices */
- data= dl->verts;
- idata= dl->index;
- first= 0;
-
- for(a=0; a<iv->datalen[0]; a++) {
-
- /* vertices */
- for(b=0; b<index[0]; b++) {
- VECCOPY(data, fp);
- data+= 3;
- fp+= coordtype;
- }
-
- /* indices */
- lll = index[0] - 2;
- for(b=0; b<lll; b++) {
- idata[0]= first;
- idata[1]= first+1;
- idata[2]= first+2;
- first++;
- idata+= 3;
- }
- first+= 2;
-
- index++;
- }
- }
- }
- else if( strcmp(iv->nodename, "IndexedFaceSet")==0 ) {
-
- colnr= iv_colornumber(iv);
-
- /* seek back to data */
- ivp= iv;
- while(ivp->prev) {
- ivp= ivp->prev;
- if( strcmp(ivp->nodename, "Coordinate3")==0 ) {
- coordtype= 3;
- break;
- }
- if( strcmp(ivp->nodename, "Coordinate4")==0 ) {
- coordtype= 4;
- break;
- }
- }
- if(ivp) {
-
- /* count triangles */
- face= 0;
- index= iv->data[0];
- lll = iv->datalen[0]-2;
- for(a=0; a<lll; a++) {
- if(index[0]!= -1 && index[1]!= -1 && index[2]!= -1) face++;
- index++;
- }
-
- /*number of vertices */
- tot= ivp->datalen[0]/coordtype;
-
- if(tot) {
- dl= MEM_callocN(sizeof(struct DispList), "leesInventor5");
- BLI_addtail(listb, dl);
- dl->type= DL_INDEX3;
- dl->nr= tot;
- dl->parts= face;
- dl->col= colnr;
-
- dl->verts= MEM_callocN( tot*3*sizeof(float), "dl verts");
- dl->index= MEM_callocN(sizeof(int)*3*face, "dl index");
-
- /* vertices */
- fp= ivp->data[0];
- data= dl->verts;
- for(b=tot; b>0; b--) {
- VECCOPY(data, fp);
- data+= 3;
- fp+= coordtype;
- }
-
- /* indices */
- index= iv->data[0];
- idata= dl->index;
- first= 1;
- lll=iv->datalen[0]-2;
- for(a=0; a<lll; a++) {
-
- if(index[0]!= -1 && index[1]!= -1 && index[2]!= -1) {
-
- /* this trick is to fill poly's with more than 3 vertices correctly */
- if(first) {
- nr= (int) index[0];
- first= 0;
- }
- idata[0]= nr;
- idata[1]= (int) index[1];
- idata[2]= (int) index[2];
- idata+= 3;
- }
- else first= 1;
-
- index++;
- }
- }
- }
- }
- else if( strcmp(iv->nodename, "IndexedTriangleMesh")==0 ||
- strcmp(iv->nodename, "IndexedTriangleStripSet")==0 ) {
-
- colnr= iv_colornumber(iv);
-
- /* seek back to data */
- ivp= iv;
- while(ivp->prev) {
- ivp= ivp->prev;
- if( strcmp(ivp->nodename, "Coordinate3")==0 ) {
- coordtype= 3;
- break;
- }
- if( strcmp(ivp->nodename, "Coordinate4")==0 ) {
- coordtype= 4;
- break;
- }
- }
- if(ivp) {
-
- /* count triangles */
- face= 0;
- index= iv->data[0];
- lll=iv->datalen[0]-2;
- for(a=0; a<lll; a++) {
- if(index[0]!= -1 && index[1]!= -1 && index[2]!= -1) face++;
- index++;
- }
-
- /* nr of vertices */
- tot= ivp->datalen[0]/coordtype;
-
- dl= MEM_callocN(sizeof(struct DispList), "leesInventor6");
- BLI_addtail(listb, dl);
- dl->type= DL_INDEX3;
- dl->nr= tot;
- dl->parts= face;
- dl->col= colnr;
-
- dl->verts= MEM_callocN( tot*3*sizeof(float), "dl verts");
- dl->index= MEM_callocN(sizeof(int)*3*face, "dl index");
-
- /* vertices */
- fp= ivp->data[0];
- data= dl->verts;
- for(b=tot; b>0; b--) {
- VECCOPY(data, fp);
- data+= 3;
- fp+= coordtype;
- }
-
- /* indices */
- index= iv->data[0];
- idata= dl->index;
-
- lll=iv->datalen[0]-2;
- for(a=lll; a>0; a--) {
-
- if(index[0]!= -1 && index[1]!= -1 && index[2]!= -1) {
- idata[0]= (int) index[0];
- idata[1]= (int) index[1];
- idata[2]= (int) index[2];
- idata+= 3;
- }
- index++;
- }
- }
- }
- else if( strcmp(iv->nodename, "QuadMesh")==0 ) {
-
- colnr= iv_colornumber(iv);
-
- /* seek back to data */
- ivp= iv;
- while(ivp->prev) {
- ivp= ivp->prev;
- if( strcmp(ivp->nodename, "Coordinate3")==0 ) {
- coordtype= 3;
- break;
- }
- if( strcmp(ivp->nodename, "VertexProperty")==0 ) {
- coordtype= 3;
- break;
- }
- if( strcmp(ivp->nodename, "Coordinate4")==0 ) {
- coordtype= 4;
- break;
- }
- }
-
- if(ivp) {
- tot= (int) (floor(*(iv->data[0])+0.5) * floor(*(iv->data[1])+0.5));
-
- if(tot>0) {
- dl= MEM_callocN(sizeof(struct DispList)+tot*3*sizeof(float), "leesInventor8");
- BLI_addtail(listb, dl);
- dl->type= DL_SURF;
- dl->parts= (int) floor(*(iv->data[0])+0.5);
- dl->nr= (int) floor(*(iv->data[1])+0.5);
- dl->col= colnr;
- data= (float *)(dl+1);
- memcpy(data, ivp->data[0], tot*3*sizeof(float));
- }
- }
- }
- else if(strcmp(iv->nodename, "IndexedNurbsSurface")==0 || strcmp(iv->nodename, "NurbsSurface")==0) {
-
- colnr= iv_colornumber(iv);
-
- /* sek back to data */
- ivp= iv;
- while(ivp->prev) {
- ivp= ivp->prev;
- if( strcmp(ivp->nodename, "Coordinate3")==0 ) {
- coordtype= 3;
- break;
- }
- if( strcmp(ivp->nodename, "Coordinate4")==0 ) {
- coordtype= 4;
- break;
- }
- }
- if(ivp) {
- a= (int) *(iv->data[0]);
- b= (int) *(iv->data[1]);
-
- tot= a*b;
-
- if( (a>=4 || b>=4) && tot>6) {
- Object *ob;
- Curve *cu;
- Nurb *nu;
- BPoint *bp;
-
- if(ivsurf==0) {
- ob= add_object(scene, OB_SURF);
- ivsurf= ob;
- }
- else ob= ivsurf;
- cu= ob->data;
- nu = (Nurb*) MEM_callocN(sizeof(Nurb),"addNurbprim") ;
- BLI_addtail(&cu->nurb, nu);
- nu->type= CU_NURBS;
-
- nu->pntsu= a;
- nu->pntsv= b;
- nu->resolu= 2*a;
- nu->resolv= 2*b;
-
- nu->flagu= 0;
- nu->flagv= 0;
-
- nu->bp = bp =
- (BPoint*)MEM_callocN(tot * sizeof(BPoint), "addNurbprim3");
- a= tot;
- data= ivp->data[0];
- while(a--) {
- VECCOPY(bp->vec, data);
- if(coordtype==4) {
- bp->vec[3]= data[3];
- mul_v3_fl(bp->vec, 1.0f/data[3]);
- }
- else bp->vec[3]= 1.0;
- data+= coordtype;
- bp++;
- }
-
- /* iv->datalen[2] / [3] is number of knots */
- nu->orderu= iv->datalen[2] - nu->pntsu;
- nu->orderv= iv->datalen[3] - nu->pntsv;
-
- nu->knotsu= MEM_mallocN( sizeof(float)*(iv->datalen[2]), "knots");
- memcpy(nu->knotsu, iv->data[2], sizeof(float)*(iv->datalen[2]));
- nu->knotsv= MEM_mallocN( sizeof(float)*(iv->datalen[3]), "knots");
- memcpy(nu->knotsv, iv->data[3], sizeof(float)*(iv->datalen[3]));
-
- switchdirectionNurb(nu);
-
- }
- else {
- dl= MEM_callocN(sizeof(struct DispList)+tot*3*sizeof(float), "leesInventor3");
- BLI_addtail(listb, dl);
- dl->type= DL_SURF;
- dl->nr= (int) *(iv->data[0]);
- dl->parts= (int) *(iv->data[1]);
- dl->col= colnr;
- data= (float *)(dl+1);
-
- a= tot;
- fp= ivp->data[0];
- while(a--) {
- VECCOPY(data, fp);
- fp+= coordtype;
- data+= 3;
- }
- }
- }
- }
- iv= iv->next;
- }
-
- /* free */
- iv= ivbase.first;
- while(iv) {
- for(a=0; a<IV_MAXFIELD; a++) {
- if(iv->data[a]) MEM_freeN(iv->data[a]);
- }
- iv= iv->next;
- }
-
- BLI_freelistN(&ivbase);
- MEM_freeN(maindata);
- MEM_freeN(iv_data_stack);
-
-}
-
/* ************************************************************ */
-static void displist_to_mesh(Scene *scene, DispList *dlfirst)
-{
- Object *ob;
- Mesh *me;
- Material *ma;
- DispList *dl;
- MVert *mvert;
- MFace *mface;
- float *data, vec[3], min[3], max[3];
- int a, b, startve, *idata, totedge=0, tottria=0, totquad=0, totvert=0, totface, totcol=0, colnr;
- int p1, p2, p3, p4;
- unsigned int maxvertidx;
-
- /* count first */
- INIT_MINMAX(min, max);
-
- dl= dlfirst;
- while(dl) {
-
- /* PATCH 1 (polyfill) can't be done, there's no listbase here. do that first! */
- /* PATCH 2 */
- if(dl->type==DL_SEGM && dl->nr>2) {
- data= (float *)(dl+1);
- if(data[0]==data[3*(dl->nr-1)]) {
- if(data[1]==data[3*(dl->nr-1)+1]) {
- if(data[2]==data[3*(dl->nr-1)+2]) {
- dl->type= DL_POLY;
- dl->nr--;
- }
- }
- }
- }
-
- /* colors */
- if(dl->col > totcol) totcol= dl->col;
-
- /* size and count */
- if(dl->type==DL_SURF) {
- a= dl->nr;
- b= dl->parts;
- if(dl->flag & DL_CYCL_U) a++;
- if(dl->flag & DL_CYCL_V) b++;
-
- totquad+= a*b;
-
- totvert+= dl->nr*dl->parts;
-
- data= (float *)(dl+1);
- for(a= dl->nr*dl->parts; a>0; a--) {
- DO_MINMAX(data, min, max);
- data+= 3;
- }
- }
- else if(dl->type==DL_POLY) {
- if(dl->nr==3 || dl->nr==4) {
- if(dl->nr==3) tottria+= dl->parts;
- else totquad+= dl->parts;
-
- totvert+= dl->nr*dl->parts;
-
- data= (float *)(dl+1);
- for(a= dl->nr*dl->parts; a>0; a--) {
- DO_MINMAX(data, min, max);
- data+= 3;
- }
- }
- else if(dl->nr>4) {
-
- tottria+= dl->nr*dl->parts;
- totvert+= dl->nr*dl->parts;
-
- data= (float *)(dl+1);
- for(a= dl->nr*dl->parts; a>0; a--) {
- DO_MINMAX(data, min, max);
- data+= 3;
- }
-
- }
- }
- else if(dl->type==DL_INDEX3) {
- tottria+= dl->parts;
- totvert+= dl->nr;
-
- data= dl->verts;
- for(a= dl->nr; a>0; a--) {
- DO_MINMAX(data, min, max);
- data+= 3;
- }
- }
- else if(dl->type==DL_SEGM) {
-
- tottria+= (dl->nr-1)*dl->parts;
- totvert+= dl->nr*dl->parts;
-
- data= (float *)(dl+1);
- for(a= dl->nr*dl->parts; a>0; a--) {
- DO_MINMAX(data, min, max);
- data+= 3;
- }
- }
-
- dl= dl->next;
- }
-
- if(totvert==0) {
- return;
- }
-
- vec[0]= (min[0]+max[0])/2;
- vec[1]= (min[1]+max[1])/2;
- vec[2]= (min[2]+max[2])/2;
-
- ob= add_object(scene, OB_MESH);
- VECCOPY(ob->loc, vec);
- where_is_object(scene, ob);
-
- me= ob->data;
-
- /* colors */
- if(totcol) {
- ob->mat= MEM_callocN(sizeof(void *)*totcol, "ob->mat");
- ob->matbits= MEM_callocN(sizeof(char)*totcol, "ob->matbits");
- me->mat= MEM_callocN(sizeof(void *)*totcol, "me->mat");
- me->totcol= totcol;
- ob->totcol= (unsigned char) me->totcol;
- ob->actcol= 1;
- }
-
- /* materials */
- for(a=0; a<totcol; a++) {
- ma= G.main->mat.first;
- while(ma) {
- if(ma->mtex[0]==0) {
- if(ivcolors[a][0]==ma->r && ivcolors[a][1]==ma->g && ivcolors[a][2]==ma->b) {
- me->mat[a]= ma;
- ma->id.us++;
- break;
- }
- }
- ma= ma->id.next;
- }
- if(ma==0) {
- ma= add_material("ext");
- me->mat[a]= ma;
- ma->r= ivcolors[a][0];
- ma->g= ivcolors[a][1];
- ma->b= ivcolors[a][2];
- automatname(ma);
- }
- }
-
- totface= totquad+tottria+totedge;
-
- printf("Import: %d vertices %d faces\n", totvert, totface);
-
- me->totvert= totvert;
- me->totface= totface;
- me->mvert= CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC,
- NULL, me->totvert);
- me->mface= CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC,
- NULL, me->totface);
- maxvertidx= totvert-1;
-
- mvert= me->mvert;
- mface= me->mface;
-
- startve= 0;
-
- dl= dlfirst;
- while(dl) {
-
- colnr= dl->col;
- if(colnr) colnr--;
-
- if(dl->type==DL_SURF) {
- data= (float *)(dl+1);
-
- for(a=dl->parts*dl->nr; a>0; a--) {
- mvert->co[0]= data[0] -vec[0];
- mvert->co[1]= data[1] -vec[1];
- mvert->co[2]= data[2] -vec[2];
-
- data+=3;
- mvert++;
- }
-
- for(a=0; a<dl->parts; a++) {
-
- if (surfindex_displist(dl, a, &b, &p1, &p2, &p3, &p4)==0)
- break;
-
- p1+= startve;
- p2+= startve;
- p3+= startve;
- p4+= startve;
-
- for(; b<dl->nr; b++) {
-
- mface->v1= p1;
- mface->v2= p2;
- mface->v3= p4;
- mface->v4= p3;
-
- mface->mat_nr= colnr;
- test_index_face(mface, NULL, 0, 4);
-
- mface++;
-
- p4= p3;
- p3++;
- p2= p1;
- p1++;
- }
- }
-
- startve += dl->parts*dl->nr;
-
- }
- else if(dl->type==DL_POLY) {
-
- if(dl->nr==3 || dl->nr==4) {
- data= (float *)(dl+1);
-
- for(a=dl->parts*dl->nr; a>0; a--) {
- mvert->co[0]= data[0] -vec[0];
- mvert->co[1]= data[1] -vec[1];
- mvert->co[2]= data[2] -vec[2];
- data+=3;
- mvert++;
- }
-
- for(a=0; a<dl->parts; a++) {
- if(dl->nr==3) {
- mface->v1= startve+a*dl->nr;
- mface->v2= startve+a*dl->nr+1;
- mface->v3= startve+a*dl->nr+2;
- mface->mat_nr= colnr;
- test_index_face(mface, NULL, 0, 3);
- mface++;
- }
- else {
- mface->v1= startve+a*dl->nr;
- mface->v2= startve+a*dl->nr+1;
- mface->v3= startve+a*dl->nr+2;
- mface->v4= startve+a*dl->nr+3;
- mface->mat_nr= colnr;
- test_index_face(mface, NULL, 0, 4);
- mface++;
- }
- }
- startve += dl->parts*dl->nr;
- }
- else if(dl->nr>4) {
- data= (float *)(dl+1);
-
- for(a=dl->parts*dl->nr; a>0; a--) {
- mvert->co[0]= data[0] -vec[0];
- mvert->co[1]= data[1] -vec[1];
- mvert->co[2]= data[2] -vec[2];
-
- data+=3;
- mvert++;
- }
-
- for(b=0; b<dl->parts; b++) {
- for(a=0; a<dl->nr; a++) {
- mface->v1= startve+a;
-
- if(a==dl->nr-1) mface->v2= startve;
- else mface->v2= startve+a+1;
-
- mface->mat_nr= colnr;
-
- mface++;
- }
- startve += dl->nr;
- }
- }
- }
- else if(dl->type==DL_INDEX3) {
- data= dl->verts;
-
- for(a=dl->nr; a>0; a--) {
- mvert->co[0]= data[0] -vec[0];
- mvert->co[1]= data[1] -vec[1];
- mvert->co[2]= data[2] -vec[2];
- data+=3;
- mvert++;
- }
-
- idata= dl->index;
- for(b=dl->parts; b>0; b--) {
- mface->v1= startve+idata[0];
- mface->v2= startve+idata[1];
- mface->v3= startve+idata[2];
- mface->mat_nr= colnr;
-
- if (mface->v1>maxvertidx) mface->v1= maxvertidx;
- if (mface->v2>maxvertidx) mface->v2= maxvertidx;
- if (mface->v3>maxvertidx) mface->v3= maxvertidx;
-
- test_index_face(mface, NULL, 0, 3);
- mface++;
- idata+= 3;
- }
- startve += dl->nr;
- }
- else if(dl->type==DL_SEGM) {
- data= (float *)(dl+1);
-
- for(a=dl->parts*dl->nr; a>0; a--) {
- mvert->co[0]= data[0] -vec[0];
- mvert->co[1]= data[1] -vec[1];
- mvert->co[2]= data[2] -vec[2];
- data+=3;
- mvert++;
- }
-
- for(b=0; b<dl->parts; b++) {
- for(a=0; a<dl->nr-1; a++) {
- mface->v1= startve+a;
- mface->v2= startve+a+1;
- mface->mat_nr= colnr;
- mface++;
- }
- startve += dl->nr;
- }
- }
- dl= dl->next;
- }
-
- mesh_add_normals_flags(me);
- make_edges(me, 0);
-}
-
-static void displist_to_objects(Scene *scene, ListBase *lbase)
-{
- DispList *dl, *first, *prev, *next;
- ListBase tempbase;
- int maxaantal, curcol, totvert=0, vert;
-
- /* irst this: is still active */
- if(ivsurf) {
- where_is_object(scene, ivsurf);
-// XXX docenter_new();
- }
-
- dl= lbase->first;
- while(dl) {
- next= dl->next;
-
- /* PATCH 1: polyfill */
- if(dl->type==DL_POLY && dl->nr>4) {
- /* solution: put them together in separate listbase */
- ;
- }
- /* PATCH 2: poly's of 2 points */
- if(dl->type==DL_POLY && dl->nr==2) dl->type= DL_SEGM;
-
- dl= next;
- }
-
- /* count vertices */
-
- dl= lbase->first;
- while(dl) {
-
- if(dl->type==DL_SURF) totvert+= dl->nr*dl->parts;
- else if(dl->type==DL_POLY) {
- if(dl->nr==3 || dl->nr==4) totvert+= dl->nr*dl->parts;
- else if(dl->nr>4) totvert+= dl->nr*dl->parts;
- }
- else if(dl->type==DL_INDEX3) totvert+= dl->nr;
- else if(dl->type==DL_SEGM) totvert+= dl->nr*dl->parts;
-
- dl= dl->next;
- }
-
- if(totvert==0) {
-
- if(ivsurf==0) {}; //XXX error("Found no data");
- if(lbase->first) BLI_freelistN(lbase);
-
- return;
- }
-
- maxaantal= 32000;
-
- if(totvert>maxaantal) {
-
- /* try to put colors together */
- curcol= 0;
- tempbase.first= tempbase.last= 0;
-
- while(lbase->first) {
- dl= lbase->first;
- while(dl) {
- next= dl->next;
- if(dl->col==curcol) {
- BLI_remlink(lbase, dl);
- BLI_addtail(&tempbase, dl);
- dl->col= 0;
- }
-
- dl= next;
- }
-
- /* in tempbase are all 'curcol' */
- totvert= 0;
- dl= first= tempbase.first;
- while(dl) {
- vert= 0;
-
- if(dl->type==DL_SURF) vert= dl->nr*dl->parts;
- else if(dl->type==DL_POLY) {
- if(dl->nr==3 || dl->nr==4) vert= dl->nr*dl->parts;
- else if(dl->nr>4) vert= dl->nr*dl->parts;
- }
- else if(dl->type==DL_INDEX3) totvert+= dl->nr;
- else if(dl->type==DL_SEGM) vert= dl->nr*dl->parts;
-
- totvert+= vert;
- if(totvert > maxaantal || dl->next==0) {
- if(dl->next==0) {
- displist_to_mesh(scene, first);
- }
- else if(dl->prev) {
- prev= dl->prev;
- prev->next= 0;
- displist_to_mesh(scene, first);
- prev->next= dl;
- first= dl;
- totvert= 0;
- }
- }
-
- dl= dl->next;
- }
-
- freedisplist(&tempbase);
-
- curcol++;
- }
- }
- else displist_to_mesh(scene, lbase->first);
-
- freedisplist(lbase);
-
-}
-
int BKE_read_exotic(Scene *scene, char *name)
{
- ListBase lbase={0, 0};
int len;
gzFile gzfile;
char str[32];
@@ -1793,21 +477,7 @@ int BKE_read_exotic(Scene *scene, char *name)
if ((*s0 != FORM) && (strncmp(str, "BLEN", 4) != 0) && !BLI_testextensie(name,".blend.gz")) {
//XXX waitcursor(1);
- if(strncmp(str, "#Inventor V1.0", 14)==0) {
- if( strncmp(str+15, "ascii", 5)==0) {
- read_inventor(scene, name, &lbase);
- displist_to_objects(scene, &lbase);
- retval = 1;
- } else {
- //XXX error("Can only read Inventor 1.0 ascii");
- }
- }
- else if((strncmp(str, "#VRML V1.0 asc", 14)==0)) {
- read_inventor(scene, name, &lbase);
- displist_to_objects(scene, &lbase);
- retval = 1;
- }
- else if(is_dxf(name)) {
+ if(is_dxf(name)) {
dxf_read(scene, name);
retval = 1;
}
@@ -1907,15 +577,8 @@ void write_stl(Scene *scene, char *str)
FILE *fpSTL;
int numfacets = 0;
ReportList *reports= NULL; /* XXX */
-
- if(BLI_testextensie(str,".blend")) str[ strlen(str)-6]= 0;
- if(BLI_testextensie(str,".ble")) str[ strlen(str)-4]= 0;
- if(BLI_testextensie(str,".stl")==0) strcat(str, ".stl");
- if (BLI_exists(str)) {
- ; //XXX if(saveover(str)==0)
- //XXX return;
- }
+ /* XXX, operator needs to manage filename extension */
fpSTL= fopen(str, "wb");
@@ -1965,7 +628,6 @@ void write_stl(Scene *scene, char *str)
//XXX waitcursor(0);
}
-/* ******************************* WRITE VRML ***************************** */
static void replace_chars(char *str1, char *str2)
{
@@ -1978,354 +640,6 @@ static void replace_chars(char *str1, char *str2)
}
}
-
-static void write_material_vrml(FILE *fp, Material *ma)
-{
- char str[32];
-
- replace_chars(str, ma->id.name+2);
-
- fprintf(fp, "\tDEF %s\n", str);
- fprintf(fp, "\tMaterial {\n");
-
- fprintf(fp, "\t\tdiffuseColor %f %f %f\n", ma->r, ma->g, ma->b);
- fprintf(fp, "\t\tspecularColor %f %f %f\n", ma->specr, ma->specg, ma->specb);
- fprintf(fp, "\t\tshininess %f \n", ((float)ma->har)/100.0);
- fprintf(fp, "\t\ttransparency %f \n", 1.0-ma->alpha);
-
- fprintf(fp, "\t}\n");
-
-}
-
-unsigned int *mcol_to_vcol(Mesh *me)
-{
- MFace *mface;
- unsigned int *mcol, *mcoln, *mcolmain;
- int a;
-
- if(me->totface==0 || me->mcol==0) return 0;
-
- mcoln= mcolmain= MEM_mallocN(sizeof(int)*me->totvert, "mcoln");
- mcol = (unsigned int *)me->mcol;
- mface= me->mface;
-
- for(a=me->totface; a>0; a--, mface++) {
- mcoln[mface->v1]= mcol[0];
- mcoln[mface->v2]= mcol[1];
- mcoln[mface->v3]= mcol[2];
- if(mface->v4) mcoln[mface->v4]= mcol[3];
-
- mcol+= 4;
- }
-
- return mcolmain;
-}
-
-void mcol_to_rgba(unsigned int col, float *r, float *g, float *b, float *a)
-{
- char *cp;
-
- cp = (char *)&col;
-
- *r= cp[3];
- *r /= 255.0;
-
- *g= cp[2];
- *g /= 255.0;
-
- *b= cp[1];
- *b /= 255.0;
-
- *a= cp[0];
- *a /= 255.0;
-}
-
-static void write_mesh_vrml(FILE *fp, Mesh *me)
-{
- Material *ma;
- MVert *mvert;
- MFace *mface;
- MTFace *tface;
- Image *ima;
- int a, b, totcol, texind;
- char str[32];
-
- replace_chars(str, me->id.name+2);
-
- fprintf(fp, "\tDEF %s\n", str);
- fprintf(fp, "\tSeparator {\n");
-
- if(me->mtface) {
- ima= ((MTFace *)me->mtface)->tpage;
- if(ima) {
- fprintf(fp, "\t\tTexture2 {\n");
- fprintf(fp, "\t\t\tfilename %s\n", ima->name);
- fprintf(fp, "\t\t\twrapS REPEAT \n");
- fprintf(fp, "\t\t\twrapT REPEAT \n");
- fprintf(fp, "\t\t}\n");
- }
- }
-
- if(me->mcol) {
- unsigned int *mcol, *mcolmain;
- float r, g, b, cola;
-
- fprintf(fp, "\t\tMaterial {\n");
- fprintf(fp, "\t\t\tdiffuseColor [\n");
-
- a= me->totvert;
- mcol= mcolmain= mcol_to_vcol(me);
- if(mcol) {
- while(a--) {
- mcol_to_rgba(*mcol, &r, &g, &b, &cola);
- fprintf(fp, "\t\t\t\t %f %f %f,\n", r, g, b);
- mcol++;
- }
- MEM_freeN(mcolmain);
- }
- fprintf(fp, "\t\t\t]\n");
- fprintf(fp, "\t\t}\n");
-
- fprintf(fp, "\t\tMaterialBinding { value PER_VERTEX_INDEXED }\n");
- }
-
-
- fprintf(fp, "\t\tCoordinate3 {\n");
- fprintf(fp, "\t\t\tpoint [\n");
-
- a= me->totvert;
- mvert= me->mvert;
- while(a--) {
- fprintf(fp, "\t\t\t\t %f %f %f,\n", mvert->co[0], mvert->co[1], mvert->co[2]);
- mvert++;
- }
- fprintf(fp, "\t\t\t]\n");
- fprintf(fp, "\t\t}\n");
-
-
- totcol= me->totcol;
- if(totcol==0) totcol= 1;
- texind= 0; // index for uv coords
-
- for(b=0; b<totcol; b++) {
-
- if(me->mcol==0) {
- if(me->mat) {
- ma= me->mat[b];
- if(ma) {
- replace_chars(str, ma->id.name+2);
-
- fprintf(fp, "\t\tUSE %s\n\n", str);
- }
- }
- }
-
- if(me->mtface) {
- fprintf(fp, "\t\tTextureCoordinate2 {\n");
- fprintf(fp, "\t\t\tpoint [\n");
-
- a= me->totface;
- mface= me->mface;
- tface= me->mtface;
- while(a--) {
- if(mface->mat_nr==b) {
- fprintf(fp, "\t\t\t\t %f %f,\n", tface->uv[0][0], tface->uv[0][1]);
- fprintf(fp, "\t\t\t\t %f %f,\n", tface->uv[1][0], tface->uv[1][1]);
- fprintf(fp, "\t\t\t\t %f %f,\n", tface->uv[2][0], tface->uv[2][1]);
- if(mface->v4) fprintf(fp, "\t\t\t\t %f %f,\n", tface->uv[3][0], tface->uv[3][1]);
- }
- mface++;
- tface++;
- }
- fprintf(fp, "\t\t\t]\n");
- fprintf(fp, "\t\t}\n");
- }
-
- fprintf(fp, "\t\tIndexedFaceSet {\n");
- fprintf(fp, "\t\t\tcoordIndex [\n");
-
- a= me->totface;
- mface= me->mface;
- while(a--) {
- if(mface->mat_nr==b) {
- if(mface->v4) fprintf(fp, "\t\t\t\t %d, %d, %d, %d, -1,\n", mface->v1, mface->v2, mface->v3, mface->v4);
- else fprintf(fp, "\t\t\t\t %d, %d, %d, -1,\n", mface->v1, mface->v2, mface->v3);
- }
- mface++;
- }
- fprintf(fp, "\t\t\t]\n");
-
- if(me->mtface) {
- fprintf(fp, "\t\t\ttextureCoordIndex [\n");
-
- a= me->totface;
- mface= me->mface;
- while(a--) {
- if(mface->mat_nr==b) {
- if(mface->v4) {
- fprintf(fp, "\t\t\t\t %d, %d, %d, %d, -1,\n", texind, texind+1, texind+2, texind+3);
- texind+= 4;
- }
- else {
- fprintf(fp, "\t\t\t\t %d, %d, %d, -1,\n", texind, texind+1, texind+2);
- texind+= 3;
- }
- }
- mface++;
- }
- fprintf(fp, "\t\t\t]\n");
- }
- fprintf(fp, "\t\t}\n");
- }
-
- fprintf(fp, "\t}\n");
-}
-
-static void write_camera_vrml(FILE *fp, Object *ob)
-{
- Camera *cam;
-
- if(ob==0) return;
- invert_m4_m4(ob->imat, ob->obmat);
-
- fprintf(fp, "\tMatrixTransform {\n");
-
- fprintf(fp, "\tmatrix \n");
-
- fprintf(fp, "\t\t%f %f %f %f\n", ob->imat[0][0], ob->imat[0][1], ob->imat[0][2], ob->imat[0][3]);
- fprintf(fp, "\t\t%f %f %f %f\n", ob->imat[1][0], ob->imat[1][1], ob->imat[1][2], ob->imat[1][3]);
- fprintf(fp, "\t\t%f %f %f %f\n", ob->imat[2][0], ob->imat[2][1], ob->imat[2][2], ob->imat[2][3]);
- fprintf(fp, "\t\t%f %f %f %f\n", ob->imat[3][0], ob->imat[3][1], ob->imat[3][2], ob->imat[3][3]);
-
- fprintf(fp, "\t}\n");
-
- cam= ob->data;
-
- fprintf(fp, "\tPerspectiveCamera {\n");
- fprintf(fp, "\t\tfocalDistance %f\n", cam->lens/10.0);
-
- fprintf(fp, "\t}\n");
-
-}
-
-static void write_object_vrml(FILE *fp, Object *ob)
-{
- ID *id;
- char str[32];
-
- fprintf(fp, "\tSeparator {\n");
- fprintf(fp, "\t\tMatrixTransform {\n");
-
- fprintf(fp, "\t\tmatrix \n");
-
- fprintf(fp, "\t\t\t%f %f %f %f\n", ob->obmat[0][0], ob->obmat[0][1], ob->obmat[0][2], ob->obmat[0][3]);
- fprintf(fp, "\t\t\t%f %f %f %f\n", ob->obmat[1][0], ob->obmat[1][1], ob->obmat[1][2], ob->obmat[1][3]);
- fprintf(fp, "\t\t\t%f %f %f %f\n", ob->obmat[2][0], ob->obmat[2][1], ob->obmat[2][2], ob->obmat[2][3]);
- fprintf(fp, "\t\t\t%f %f %f %f\n", ob->obmat[3][0], ob->obmat[3][1], ob->obmat[3][2], ob->obmat[3][3]);
-
- fprintf(fp, "\t\t}\n");
-
- id= ob->data;
-
- replace_chars(str, id->name+2);
-
- fprintf(fp, "\t\tUSE %s\n", str);
- fprintf(fp, "\t}\n");
-}
-
-
-void write_vrml(Scene *scene, char *str)
-{
- Mesh *me;
- Material *ma;
- Base *base;
- FILE *fp;
-
- if(BLI_testextensie(str,".blend")) str[ strlen(str)-6]= 0;
- if(BLI_testextensie(str,".ble")) str[ strlen(str)-4]= 0;
- if(BLI_testextensie(str,".wrl")==0) strcat(str, ".wrl");
- //XXX saveover() if(saveover(str)==0) return;
-
- fp= fopen(str, "w");
-
- if(fp==NULL) {
- //XXX error("Can't write file");
- return;
- }
- strcpy(temp_dir, str);
-
- //XXX waitcursor(1);
-
- /* FIRST: write all the datablocks */
-
- fprintf(fp, "#VRML V1.0 ascii\n\n# Blender V%d\n\n# 'Switch' is used as a hack, to ensure it is not part of the drawing\n\n", BLENDER_VERSION);
- fprintf(fp, "Separator {\n");
- fprintf(fp, "Switch {\n");
-
- ma= G.main->mat.first;
- while(ma) {
- if(ma->id.us) {
- write_material_vrml(fp, ma);
- }
- ma= ma->id.next;
- }
-
- /* only write meshes we're using in this scene */
- flag_listbase_ids(&G.main->mesh, LIB_DOIT, 0);
-
- for(base= scene->base.first; base; base= base->next)
- if(base->object->type== OB_MESH)
- ((ID *)base->object->data)->flag |= LIB_DOIT;
-
- me= G.main->mesh.first;
- while(me) {
- if(me->id.flag & LIB_DOIT) { /* is the mesh used in this scene ? */
- write_mesh_vrml(fp, me);
- }
- me= me->id.next;
- }
-
- /* THEN:Hidden Objects */
- fprintf(fp, "\n\t# Hidden Objects, in invisible layers\n\n");
- base= scene->base.first;
- while(base) {
- if(base->object->type== OB_MESH) {
- if( (base->lay & scene->lay)==0 ) {
- write_object_vrml(fp, base->object);
- }
- }
- base= base->next;
- }
-
- fprintf(fp, "}\n");
- fprintf(fp, "\n# Visible Objects\n\n");
- fprintf(fp, "Separator {\n");
-
- /* The camera */
-
- write_camera_vrml(fp, scene->camera);
-
- /* THEN:The Objects */
-
- base= scene->base.first;
- while(base) {
- if(base->object->type== OB_MESH) {
- if(base->lay & scene->lay) {
- write_object_vrml(fp, base->object);
- }
- }
- base= base->next;
- }
-
- fprintf(fp, "}\n");
- fprintf(fp, "}\n");
-
- fclose(fp);
-
- //XXX waitcursor(0);
-}
-
-
/* ******************************* WRITE DXF ***************************** */
#define write_group(id,data) fprintf(fp, "%d\n%s\n", id, data)
@@ -2551,15 +865,7 @@ void write_dxf(struct Scene *scene, char *str)
Base *base;
FILE *fp;
- if(BLI_testextensie(str,".blend")) str[ strlen(str)-6]= 0;
- if(BLI_testextensie(str,".ble")) str[ strlen(str)-4]= 0;
- if(BLI_testextensie(str,".dxf")==0) strcat(str, ".dxf");
-
-
- if (BLI_exists(str)) {
- ; //XXX if(saveover(str)==0)
- // return;
- }
+ /* XXX, operator needs to handle overwrite & rename */
fp= fopen(str, "w");
diff --git a/source/blender/blenkernel/intern/fluidsim.c b/source/blender/blenkernel/intern/fluidsim.c
index 04ce6c39694..ef89d39864a 100644
--- a/source/blender/blenkernel/intern/fluidsim.c
+++ b/source/blender/blenkernel/intern/fluidsim.c
@@ -28,6 +28,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
+#include <stddef.h>
#include "BLI_storage.h" /* _LARGEFILE_SOURCE */
#include "MEM_guardedalloc.h"
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 0e282aa6449..f3dfd4292c6 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -69,6 +69,7 @@
#include "BKE_main.h"
#include "BKE_packedFile.h"
#include "BKE_scene.h"
+#include "BKE_node.h"
//XXX #include "BIF_editseq.h"
@@ -756,9 +757,9 @@ int BKE_imtype_is_movie(int imtype)
return 0;
}
-void BKE_add_image_extension(char *string, int imtype)
+int BKE_add_image_extension(char *string, int imtype)
{
- char *extension="";
+ char *extension= NULL;
if(imtype== R_IRIS) {
if(!BLI_testextensie(string, ".rgb"))
@@ -829,7 +830,12 @@ void BKE_add_image_extension(char *string, int imtype)
extension= ".jpg";
}
- strcat(string, extension);
+ if(extension) {
+ return BLI_replace_extension(string, FILE_MAX, extension);
+ }
+ else {
+ return FALSE;
+ }
}
/* could allow access externally - 512 is for long names, 64 is for id names */
@@ -1447,6 +1453,17 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal)
}
break;
}
+
+ /* dont use notifiers because they are not 100% sure to succseed
+ * this also makes sure all scenes are accounted for. */
+ {
+ Scene *scene;
+ for(scene= G.main->scene.first; scene; scene= scene->id.next) {
+ if(scene->nodetree) {
+ NodeTagIDChanged(scene->nodetree, &ima->id);
+ }
+ }
+ }
}
/* if layer or pass changes, we need an index for the imbufs list */
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 5af2c64da18..135ddbab2b7 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -1787,18 +1787,25 @@ void NodeTagChanged(bNodeTree *ntree, bNode *node)
}
}
-void NodeTagIDChanged(bNodeTree *ntree, ID *id)
+int NodeTagIDChanged(bNodeTree *ntree, ID *id)
{
+ int change = FALSE;
+
if(id==NULL)
- return;
+ return change;
if(ntree->type==NTREE_COMPOSIT) {
bNode *node;
- for(node= ntree->nodes.first; node; node= node->next)
- if(node->id==id)
+ for(node= ntree->nodes.first; node; node= node->next) {
+ if(node->id==id) {
+ change= TRUE;
NodeTagChanged(ntree, node);
+ }
+ }
}
+
+ return change;
}
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 94a316a2c94..07b712c4330 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -384,9 +384,6 @@ void free_hair(Object *ob, ParticleSystem *psys, int dynamics)
{
PARTICLE_P;
- if(psys->part->type != PART_HAIR)
- return;
-
LOOP_PARTICLES {
if(pa->hair)
MEM_freeN(pa->hair);
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 0d14c3cb9f6..5318754951f 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -29,6 +29,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
+#include <stddef.h>
#include "BLI_storage.h" /* _LARGEFILE_SOURCE */
#include <stdlib.h>
@@ -3440,7 +3441,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
else if(part->phystype == PART_PHYS_NO)
reset_particle(sim, pa, dtime, cfra);
- if(dfra>0.0 && ELEM(pa->alive,PARS_ALIVE,PARS_DYING)){
+ if(pa_dfra>0.0 && ELEM(pa->alive,PARS_ALIVE,PARS_DYING)){
switch(part->phystype){
case PART_PHYS_NEWTON:
/* do global forces & effectors */
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index a35e40d7cf7..741580048cf 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -1454,7 +1454,7 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec)
if(!pm && !pf) {
if(pid->cache->flag & PTCACHE_DISK_CACHE) {
pf=NULL;
- while(cfrai > pid->cache->startframe && !pf) {
+ while(cfrai >= pid->cache->startframe && !pf) {
cfrai--;
pf= ptcache_file_open(pid, PTCACHE_FILE_READ, cfrai);
cfra1 = cfrai;
diff --git a/source/blender/blenkernel/intern/seqcache.c b/source/blender/blenkernel/intern/seqcache.c
index 4d58ec8212a..487ec78b2bd 100644
--- a/source/blender/blenkernel/intern/seqcache.c
+++ b/source/blender/blenkernel/intern/seqcache.c
@@ -68,7 +68,7 @@ static unsigned int HashHash(void *key_)
rval ^= *(unsigned int*) &key->cfra;
rval += key->type;
- rval ^= ((unsigned int) key->seq) << 6;
+ rval ^= ((intptr_t) key->seq) << 6;
return rval;
}
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index 11012843131..d2d8d5a6e07 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -1350,7 +1350,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM
if(framenr > endframe)
return;
- if(!smd->domain->fluid && (framenr != startframe))
+ if(!smd->domain->fluid && (framenr != startframe) && (cache->flag & PTCACHE_BAKED)==0)
return;
// printf("startframe: %d, framenr: %d\n", startframe, framenr);
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index 4c85656dd91..d6486c3ee4d 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -1421,7 +1421,7 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, v
DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs);
}
- if(!doDraw || (setDrawOptions && !setDrawOptions(userData, origIndex))) {
+ if(!doDraw || (setDrawOptions && (origIndex != ORIGINDEX_NONE) && !setDrawOptions(userData, origIndex))) {
a += gridFaces*gridFaces*numVerts;
continue;
}
diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c
index 133f858e9ea..36a4cfea7a0 100644
--- a/source/blender/blenkernel/intern/unit.c
+++ b/source/blender/blenkernel/intern/unit.c
@@ -24,6 +24,8 @@
#include <stdio.h>
#include <ctype.h>
#include <string.h>
+#include "BKE_unit.h"
+
#ifdef WIN32
#define _USE_MATH_DEFINES
#endif
@@ -31,6 +33,7 @@
#include "BLI_winstuff.h"
+
#define TEMP_STR_SIZE 256
#define SEP_CHR '#'
@@ -44,7 +47,8 @@ typedef struct bUnitDef {
char *name;
char *name_plural; /* abused a bit for the display name */
char *name_short; /* this is used for display*/
- char *name_alt; /* can be NULL */
+ char *name_alt; /* keyboard-friendly ASCII-only version of name_short, can be NULL */
+ /* if name_short has non-ASCII chars, name_alt should be present */
char *name_display; /* can be NULL */
@@ -76,7 +80,7 @@ static struct bUnitCollection buDummyCollecton = {buDummyDef, 0, 0, sizeof(buDum
static struct bUnitDef buMetricLenDef[] = {
{"kilometer", "kilometers", "km", NULL, "Kilometers", 1000.0, 0.0, B_UNIT_DEF_NONE},
{"hectometer", "hectometers", "hm", NULL, "100 Meters", 100.0, 0.0, B_UNIT_DEF_SUPPRESS},
- {"dekameter", "dekameters", "dkm",NULL, "10 Meters", 10.0, 0.0, B_UNIT_DEF_SUPPRESS},
+ {"dekameter", "dekameters", "dam",NULL, "10 Meters", 10.0, 0.0, B_UNIT_DEF_SUPPRESS},
{"meter", "meters", "m", NULL, "Meters", 1.0, 0.0, B_UNIT_DEF_NONE}, /* base unit */
{"decimetre", "decimetres", "dm", NULL, "10 Centimeters", 0.1, 0.0, B_UNIT_DEF_SUPPRESS},
{"centimeter", "centimeters", "cm", NULL, "Centimeters", 0.01, 0.0, B_UNIT_DEF_NONE},
@@ -126,7 +130,8 @@ static struct bUnitDef buNaturalRotDef[] = {
};
static struct bUnitCollection buNaturalRotCollection = {buNaturalRotDef, 0, 0, sizeof(buNaturalRotDef)/sizeof(bUnitDef)};
-#define UNIT_SYSTEM_MAX 3
+#define UNIT_SYSTEM_TOT (((sizeof(bUnitSystems) / 8) / sizeof(void *)) - 1)
+
static struct bUnitCollection *bUnitSystems[][8] = {
{0,0,0,0,0,&buNaturalRotCollection,&buNaturalTimeCollecton,0},
{0,&buMetricLenCollecton, 0,0,0, &buNaturalRotCollection, &buNaturalTimeCollecton,0}, /* metric */
@@ -134,6 +139,8 @@ static struct bUnitCollection *bUnitSystems[][8] = {
{0,0,0,0,0,0,0,0}
};
+
+
/* internal, has some option not exposed */
static bUnitCollection *unit_get_system(int system, int type)
{
@@ -458,7 +465,7 @@ int bUnit_ReplaceString(char *str, int len_max, char *str_prev, double scale_pre
bUnitCollection *usys_iter;
int system_iter;
- for(system_iter= 0; system_iter<UNIT_SYSTEM_MAX; system_iter++) {
+ for(system_iter= 0; system_iter<UNIT_SYSTEM_TOT; system_iter++) {
if (system_iter != system) {
usys_iter= unit_get_system(system_iter, type);
if (usys_iter) {
@@ -543,6 +550,49 @@ int bUnit_ReplaceString(char *str, int len_max, char *str_prev, double scale_pre
return change;
}
+/* 45µm --> 45um */
+void bUnit_ToUnitAltName(char *str, int len_max, char *orig_str, int system, int type)
+{
+ bUnitCollection *usys = unit_get_system(system, type);
+
+ bUnitDef *unit;
+ bUnitDef *unit_def= unit_default(usys);
+
+ /* find and substitute all units */
+ for(unit= usys->units; unit->name; unit++) {
+ if(len_max > 0 && (unit->name_alt || unit == unit_def))
+ {
+ char *found= NULL;
+
+ found= unit_find_str(orig_str, unit->name_short);
+ if(found) {
+ int offset= found - orig_str;
+ int len_name= 0;
+
+ /* copy everything before the unit */
+ offset= (offset<len_max? offset: len_max);
+ strncpy(str, orig_str, offset);
+
+ str+= offset;
+ orig_str+= offset + strlen(unit->name_short);
+ len_max-= offset;
+
+ /* print the alt_name */
+ if(unit->name_alt)
+ len_name= snprintf(str, len_max, "%s", unit->name_alt);
+ else
+ len_name= 0;
+
+ len_name= (len_name<len_max? len_name: len_max);
+ str+= len_name;
+ len_max-= len_name;
+ }
+ }
+ }
+
+ /* finally copy the rest of the string */
+ strncpy(str, orig_str, len_max);
+}
double bUnit_ClosestScalar(double value, int system, int type)
{
@@ -566,6 +616,12 @@ double bUnit_BaseScalar(int system, int type)
}
/* external access */
+int bUnit_IsValid(int system, int type)
+{
+ return !(type < 0 || type >= B_UNIT_MAXDEF || system < 0 || system > UNIT_SYSTEM_TOT);
+}
+
+
void bUnit_GetSystem(void **usys_pt, int *len, int system, int type)
{
bUnitCollection *usys = unit_get_system(system, type);
diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c
index 8ebf98ef930..6cd207f628c 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -515,6 +515,7 @@ static AVStream* alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex
if (codec_id == CODEC_ID_XVID) {
/* arghhhh ... */
c->pix_fmt = PIX_FMT_YUV420P;
+ c->codec_tag = (('D'<<24) + ('I'<<16) + ('V'<<8) + 'X');
}
if (codec_id == CODEC_ID_H264) {
diff --git a/source/blender/blenlib/BLI_math_color.h b/source/blender/blenlib/BLI_math_color.h
index a297878ec20..2f40520e59a 100644
--- a/source/blender/blenlib/BLI_math_color.h
+++ b/source/blender/blenlib/BLI_math_color.h
@@ -86,7 +86,10 @@ void linearrgb_to_srgb_rgba_rgba_buf(float *col_to, float *col_from, int tot);
int constrain_rgb(float *r, float *g, float *b);
void minmax_rgb(short c[3]);
-
+
+void rgb_float_set_hue_float_offset(float * rgb, float hue_offset);
+void rgb_byte_set_hue_float_offset(char * rgb, float hue_offset);
+
/***************** lift/gamma/gain / ASC-CDL conversion *****************/
void lift_gamma_gain_to_asc_cdl(float *lift, float *gamma, float *gain, float *offset, float *slope, float *power);
diff --git a/source/blender/blenlib/BLI_storage.h b/source/blender/blenlib/BLI_storage.h
index 0d9db40fc97..83537e4f3c4 100644
--- a/source/blender/blenlib/BLI_storage.h
+++ b/source/blender/blenlib/BLI_storage.h
@@ -42,12 +42,13 @@
struct direntry;
+
void BLI_adddirstrings(void);
void BLI_builddir(char *dirname, char *relname);
int BLI_compare(struct direntry *entry1, struct direntry *entry2);
-int BLI_filesize(int file);
-int BLI_filepathsize(const char *path);
+size_t BLI_filesize(int file);
+size_t BLI_filepathsize(const char *path);
double BLI_diskfree(char *dir);
char *BLI_getwdN(char *dir);
diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt
index 1e0359d1847..0ef2346ded4 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -39,11 +39,12 @@ SET(INC
${ZLIB_INC}
)
+# unused
+LIST(REMOVE_ITEM SRC "${CMAKE_CURRENT_SOURCE_DIR}/intern/BLI_bfile.c")
+
+
IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
-SET(INC
- ${INC}
- ${BINRELOC_INC}
-)
+ LIST(APPEND INC "${BINRELOC_INC}")
ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
IF(WIN32)
@@ -51,7 +52,7 @@ IF(WIN32)
ENDIF(WIN32)
IF(WITH_OPENMP)
- ADD_DEFINITIONS(-DPARALLEL=1)
+ ADD_DEFINITIONS(-DPARALLEL=1)
ENDIF(WITH_OPENMP)
BLENDERLIB(bf_blenlib "${SRC}" "${INC}")
diff --git a/source/blender/blenlib/intern/bpath.c b/source/blender/blenlib/intern/bpath.c
index d1a8de14181..cf7eb873409 100644
--- a/source/blender/blenlib/intern/bpath.c
+++ b/source/blender/blenlib/intern/bpath.c
@@ -633,7 +633,7 @@ static int findFileRecursive(char *filename_new, const char *dirname, const char
if (S_ISREG(status.st_mode)) { /* is file */
if (strncmp(filename, de->d_name, FILE_MAX)==0) { /* name matches */
/* open the file to read its size */
- size = BLI_filepathsize(path);
+ size = status.st_size;
if ((size > 0) && (size > *filesize)) { /* find the biggest file */
*filesize = size;
BLI_strncpy(filename_new, path, FILE_MAX);
diff --git a/source/blender/blenlib/intern/dynlib.c b/source/blender/blenlib/intern/dynlib.c
index f42b342e326..55d6ce7a241 100644
--- a/source/blender/blenlib/intern/dynlib.c
+++ b/source/blender/blenlib/intern/dynlib.c
@@ -87,7 +87,7 @@ char *PIL_dynlib_get_error_as_string(PILdynlib* lib) {
return buf;
}
- return err;
+ return NULL;
}
void PIL_dynlib_close(PILdynlib *lib) {
diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c
index fde770c238c..06b427240ba 100644
--- a/source/blender/blenlib/intern/fileops.c
+++ b/source/blender/blenlib/intern/fileops.c
@@ -41,12 +41,12 @@
#ifdef WIN32
#include <io.h>
#include "BLI_winstuff.h"
+#include "BLI_callbacks.h"
#else
#include <unistd.h> // for read close
#include <sys/param.h>
#endif
-
#include "BLI_blenlib.h"
#include "BKE_utildefines.h"
diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c
index 693fd885b50..787e126a42b 100644
--- a/source/blender/blenlib/intern/math_color.c
+++ b/source/blender/blenlib/intern/math_color.c
@@ -464,3 +464,28 @@ void lift_gamma_gain_to_asc_cdl(float *lift, float *gamma, float *gain, float *o
}
}
+/* ******************************************** other ************************************************* */
+
+/* Applies an hue offset to a float rgb color */
+void rgb_float_set_hue_float_offset(float rgb[3], float hue_offset)
+{
+ float hsv[3];
+
+ rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2);
+
+ hsv[0]+= hue_offset;
+ if(hsv[0]>1.0) hsv[0]-=1.0;
+ else if(hsv[0]<0.0) hsv[0]+= 1.0;
+
+ hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2);
+}
+
+/* Applies an hue offset to a byte rgb color */
+void rgb_byte_set_hue_float_offset(char rgb[3], float hue_offset)
+{
+ float rgb_float[3];
+
+ rgb_byte_to_float(rgb, rgb_float);
+ rgb_float_set_hue_float_offset(rgb_float, hue_offset);
+ rgb_float_to_byte(rgb_float, rgb);
+}
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c
index 64c3e746982..3b5ffa2d442 100644
--- a/source/blender/blenlib/intern/math_matrix.c
+++ b/source/blender/blenlib/intern/math_matrix.c
@@ -998,7 +998,7 @@ void rotate_m4(float mat[][4], const char axis, const float angle)
void blend_m3_m3m3(float out[][3], float dst[][3], float src[][3], float srcweight)
{
float squat[4], dquat[4], fquat[4];
- float ssize[3], dsize[3], fsize[4];
+ float ssize[3], dsize[3], fsize[3];
float rmat[3][3], smat[3][3];
mat3_to_quat(dquat,dst);
@@ -1020,7 +1020,7 @@ void blend_m3_m3m3(float out[][3], float dst[][3], float src[][3], float srcweig
void blend_m4_m4m4(float out[][4], float dst[][4], float src[][4], float srcweight)
{
float squat[4], dquat[4], fquat[4];
- float ssize[3], dsize[3], fsize[4];
+ float ssize[3], dsize[3], fsize[3];
float sloc[3], dloc[3], floc[3];
mat4_to_quat(dquat,dst);
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index cf773d575e5..50c5095afe7 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -311,10 +311,17 @@ void BLI_cleanup_file(const char *relabase, char *dir)
dir[0]= '/';
dir[1]= 0;
return;
- }
+ }
+
+ /* support for odd paths: eg /../home/me --> /home/me
+ * this is a valid path in blender but we cant handle this the useual way below
+ * simply strip this prefix then evaluate the path as useual. pythons os.path.normpath() does this */
+ while((strncmp(dir, "/../", 4)==0)) {
+ memmove( dir, dir + 4, strlen(dir + 4) + 1 );
+ }
while ( (start = strstr(dir, "/../")) ) {
- eind = start + strlen("/../") - 1;
+ eind = start + (4 - 1) /* strlen("/../") - 1 */;
a = start-dir-1;
while (a>0) {
if (dir[a] == '/') break;
@@ -328,12 +335,12 @@ void BLI_cleanup_file(const char *relabase, char *dir)
}
while ( (start = strstr(dir,"/./")) ){
- eind = start + strlen("/./") - 1;
+ eind = start + (3 - 1) /* strlen("/./") - 1 */;
memmove( start, eind, strlen(eind)+1 );
}
while ( (start = strstr(dir,"//" )) ){
- eind = start + strlen("//") - 1;
+ eind = start + (2 - 1) /* strlen("//") - 1 */;
memmove( start, eind, strlen(eind)+1 );
}
diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c
index 80310b1ef8a..9c31557619b 100644
--- a/source/blender/blenlib/intern/storage.c
+++ b/source/blender/blenlib/intern/storage.c
@@ -421,7 +421,7 @@ unsigned int BLI_getdir(char *dirname, struct direntry **filelist)
}
-int BLI_filesize(int file)
+size_t BLI_filesize(int file)
{
struct stat buf;
@@ -430,11 +430,11 @@ int BLI_filesize(int file)
return (buf.st_size);
}
-int BLI_filepathsize(const char *path)
+size_t BLI_filepathsize(const char *path)
{
int size, file = open(path, O_BINARY|O_RDONLY);
- if (file < 0)
+ if (file == -1)
return -1;
size = BLI_filesize(file);
diff --git a/source/blender/blenlib/intern/winstuff.c b/source/blender/blenlib/intern/winstuff.c
index 81a635205f9..b3438590321 100644
--- a/source/blender/blenlib/intern/winstuff.c
+++ b/source/blender/blenlib/intern/winstuff.c
@@ -33,7 +33,7 @@
#include <stdlib.h>
#include <stdio.h>
-
+#include "MEM_guardedalloc.h"
#include "BLI_path_util.h"
#include "BLI_string.h"
#define WIN32_SKIP_HKEY_PROTECTION // need to use HKEY
diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c
index da441214b37..b637d538b91 100644
--- a/source/blender/blenloader/intern/readblenentry.c
+++ b/source/blender/blenloader/intern/readblenentry.c
@@ -28,6 +28,7 @@
* .blend file reading entry point
*/
+#include <stddef.h>
#include "BLI_storage.h" /* _LARGEFILE_SOURCE */
#include <stdlib.h>
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index a03634e0625..46caab94ce7 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -10836,6 +10836,15 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
SEQ_END
}
+ /* particle brush strength factor was changed from int to float */
+ for(sce= main->scene.first; sce; sce=sce->id.next) {
+ ParticleEditSettings *pset= &sce->toolsettings->particle;
+ int a;
+
+ for(a=0; a<PE_TOT_BRUSH; a++)
+ pset->brush[a].strength /= 100.0;
+ }
+
for(ma = main->mat.first; ma; ma=ma->id.next)
if(ma->mode & MA_TRACEBLE)
ma->shade_flag |= MA_APPROX_OCCLUSION;
@@ -11247,6 +11256,13 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
}
}
+ {
+ ParticleSettings *part;
+ for(part = main->particle.first; part; part = part->id.next) {
+ if(part->boids)
+ part->boids->pitch = 1.0f;
+ }
+ }
/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
/* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */
diff --git a/source/blender/collada/DocumentExporter.cpp b/source/blender/collada/DocumentExporter.cpp
index b9201a6cdfa..9fdc07f391b 100644
--- a/source/blender/collada/DocumentExporter.cpp
+++ b/source/blender/collada/DocumentExporter.cpp
@@ -1640,13 +1640,13 @@ public:
if (ma->spec_shader == MA_SPEC_BLINN) {
ep.setShaderType(COLLADASW::EffectProfile::BLINN);
// shininess
- ep.setShininess(ma->spec);
+ ep.setShininess(ma->har);
}
else if (ma->spec_shader == MA_SPEC_PHONG) {
ep.setShaderType(COLLADASW::EffectProfile::PHONG);
// shininess
// XXX not sure, stolen this from previous Collada plugin
- ep.setShininess(ma->har / 4);
+ ep.setShininess(ma->har);
}
else {
// XXX write warning "Current shader type is not supported"
@@ -1663,17 +1663,19 @@ public:
COLLADASW::ColorOrTexture cot;
// transparency
- // Tod: because we are in A_ONE mode transparency is calculated like this:
- ep.setTransparency(1.0f);
- cot = getcol(0.0f, 0.0f, 0.0f, ma->alpha);
- ep.setTransparent(cot);
+ if (ma->mode & MA_TRANSP) {
+ // Tod: because we are in A_ONE mode transparency is calculated like this:
+ ep.setTransparency(ma->alpha);
+ // cot = getcol(1.0f, 1.0f, 1.0f, 1.0f);
+ // ep.setTransparent(cot);
+ }
// emission
cot=getcol(ma->emit, ma->emit, ma->emit, 1.0f);
ep.setEmission(cot);
- // diffuse
- cot = getcol(ma->r, ma->g, ma->b, 1.0f);
+ // diffuse multiplied by diffuse intensity
+ cot = getcol(ma->r * ma->ref, ma->g * ma->ref, ma->b * ma->ref, 1.0f);
ep.setDiffuse(cot);
// ambient
@@ -1686,15 +1688,15 @@ public:
ep.setReflective(cot);
ep.setReflectivity(ma->ray_mirror);
}
- else {
- cot = getcol(ma->specr, ma->specg, ma->specb, 1.0f);
- ep.setReflective(cot);
- ep.setReflectivity(ma->spec);
- }
+ // else {
+ // cot = getcol(ma->specr, ma->specg, ma->specb, 1.0f);
+ // ep.setReflective(cot);
+ // ep.setReflectivity(ma->spec);
+ // }
// specular
if (ep.getShaderType() != COLLADASW::EffectProfile::LAMBERT) {
- cot = getcol(ma->specr, ma->specg, ma->specb, 1.0f);
+ cot = getcol(ma->specr * ma->spec, ma->specg * ma->spec, ma->specb * ma->spec, 1.0f);
ep.setSpecular(cot);
}
@@ -1720,12 +1722,15 @@ public:
// create only one <sampler>/<surface> pair for each unique image
if (im_samp_map.find(key) == im_samp_map.end()) {
- //<newparam> <surface> <init_from>
- // COLLADASW::Surface surface(COLLADASW::Surface::SURFACE_TYPE_2D,
-// key + COLLADASW::Surface::SURFACE_SID_SUFFIX);
-// COLLADASW::SurfaceInitOption sio(COLLADASW::SurfaceInitOption::INIT_FROM);
-// sio.setImageReference(key);
-// surface.setInitOption(sio);
+ // //<newparam> <surface> <init_from>
+ // COLLADASW::Surface surface(COLLADASW::Surface::SURFACE_TYPE_2D,
+ // key + COLLADASW::Surface::SURFACE_SID_SUFFIX);
+ // COLLADASW::SurfaceInitOption sio(COLLADASW::SurfaceInitOption::INIT_FROM);
+ // sio.setImageReference(key);
+ // surface.setInitOption(sio);
+
+ // COLLADASW::NewParamSurface surface(mSW);
+ // surface->setParamType(COLLADASW::CSW_SURFACE_TYPE_2D);
//<newparam> <sampler> <source>
COLLADASW::Sampler sampler(COLLADASW::Sampler::SAMPLER_TYPE_2D,
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index 09fbdf2d70d..3fb8e441d6f 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -83,11 +83,6 @@
}
-/* XXX */
-extern void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad);
-extern void gl_round_box_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadetop, float shadedown);
-
-
/* *********************************************** */
/* Generic Functions (Type independent) */
@@ -115,7 +110,7 @@ static void acf_generic_root_backdrop(bAnimContext *ac, bAnimListElem *ale, floa
/* rounded corners on LHS only - top only when expanded, but bottom too when collapsed */
uiSetRoundBox((expanded)? (1):(1|8));
- gl_round_box(GL_POLYGON, offset, yminc, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc, 8);
+ uiDrawBox(GL_POLYGON, offset, yminc, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc, 8);
}
@@ -405,7 +400,7 @@ static void acf_summary_backdrop(bAnimContext *ac, bAnimListElem *ale, float ymi
* - special hack: make the top a bit higher, since we are first...
*/
uiSetRoundBox((1|8));
- gl_round_box(GL_POLYGON, 0, yminc-2, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc, 8);
+ uiDrawBox(GL_POLYGON, 0, yminc-2, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc, 8);
}
/* name for summary entries */
@@ -755,7 +750,7 @@ static void acf_group_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc
/* rounded corners on LHS only - top only when expanded, but bottom too when collapsed */
uiSetRoundBox((expanded)? (1):(1|8));
- gl_round_box(GL_POLYGON, offset, yminc, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc, 8);
+ uiDrawBox(GL_POLYGON, offset, yminc, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc, 8);
}
/* name for group entries */
diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c
index 6bda6b5069c..f2bc4b3d46a 100644
--- a/source/blender/editors/armature/editarmature.c
+++ b/source/blender/editors/armature/editarmature.c
@@ -178,18 +178,37 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone
eBone->flag = curBone->flag;
/* fix selection flags */
+
if (eBone->flag & BONE_SELECTED) {
+ /* if the bone is selected the copy its root selection to the parents tip */
eBone->flag |= BONE_TIPSEL;
- if (eBone->parent && (eBone->flag & BONE_CONNECTED))
+ if (eBone->parent && (eBone->flag & BONE_CONNECTED)) {
eBone->parent->flag |= BONE_TIPSEL;
- else
+ eBone->flag &= ~BONE_ROOTSEL; /* this is ignored when there is a connected parent, so unset it */
+ }
+ else {
eBone->flag |= BONE_ROOTSEL;
+ }
}
- else
- eBone->flag &= ~BONE_ROOTSEL;
-
- VECCOPY(eBone->head, curBone->arm_head);
- VECCOPY(eBone->tail, curBone->arm_tail);
+ else {
+ /* if the bone is not selected, but connected to its parent
+ * copy the parents tip selection state */
+ if(eBone->parent && (eBone->flag & BONE_CONNECTED)) {
+ /* selecting with the mouse gives this behavior */
+ if(eBone->parent->flag & BONE_TIPSEL) {
+ eBone->flag |= BONE_ROOTSEL;
+ }
+ else {
+ eBone->flag &= ~BONE_ROOTSEL;
+ }
+
+ /* probably not selected but just incase */
+ eBone->flag &= ~BONE_TIPSEL;
+ }
+ }
+
+ copy_v3_v3(eBone->head, curBone->arm_head);
+ copy_v3_v3(eBone->tail, curBone->arm_tail);
eBone->roll= 0.0f;
@@ -570,8 +589,8 @@ static int apply_armature_pose2bones_exec (bContext *C, wmOperator *op)
curbone= editbone_name_exists(arm->edbo, pchan->name);
/* simply copy the head/tail values from pchan over to curbone */
- VECCOPY(curbone->head, pchan->pose_head);
- VECCOPY(curbone->tail, pchan->pose_tail);
+ copy_v3_v3(curbone->head, pchan->pose_head);
+ copy_v3_v3(curbone->tail, pchan->pose_tail);
/* fix roll:
* 1. find auto-calculated roll value for this bone now
@@ -2056,7 +2075,7 @@ float ED_rollBoneToVector(EditBone *bone, float new_up_axis[3])
sub_v3_v3v3(nor, bone->tail, bone->head);
vec_roll_to_mat3(nor, 0, mat);
- VECCOPY(up_axis, mat[2]);
+ copy_v3_v3(up_axis, mat[2]);
roll = angle_normalized_v3v3(new_up_axis, up_axis);
@@ -2083,12 +2102,12 @@ static void auto_align_ebone_zaxisup(Scene *scene, View3D *v3d, EditBone *ebone)
vec_roll_to_mat3(delta, 0.0f, curmat);
/* Make new matrix based on y axis & z-up */
- VECCOPY(yaxis, curmat[1]);
+ copy_v3_v3(yaxis, curmat[1]);
unit_m3(targetmat);
- VECCOPY(targetmat[0], xaxis);
- VECCOPY(targetmat[1], yaxis);
- VECCOPY(targetmat[2], zaxis);
+ copy_v3_v3(targetmat[0], xaxis);
+ copy_v3_v3(targetmat[1], yaxis);
+ copy_v3_v3(targetmat[2], zaxis);
normalize_m3(targetmat);
/* Find the difference between the two matrices */
@@ -2111,7 +2130,7 @@ void auto_align_ebone_topoint(EditBone *ebone, float *cursor)
sub_v3_v3v3(delta, ebone->tail, ebone->head);
vec_roll_to_mat3(delta, ebone->roll, curmat);
copy_m4_m3(mat, curmat);
- VECCOPY(mat[3], ebone->head);
+ copy_v3_v3(mat[3], ebone->head);
/* multiply bone-matrix by object matrix (so that bone-matrix is in WorldSpace) */
invert_m4_m4(imat, mat);
@@ -2416,19 +2435,19 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *op)
arm->act_edbone= newbone;
if (to_root) {
- VECCOPY(newbone->head, ebone->head);
+ copy_v3_v3(newbone->head, ebone->head);
newbone->rad_head= ebone->rad_tail;
newbone->parent= ebone->parent;
}
else {
- VECCOPY(newbone->head, ebone->tail);
+ copy_v3_v3(newbone->head, ebone->tail);
newbone->rad_head= ebone->rad_tail;
newbone->parent= ebone;
newbone->flag |= BONE_CONNECTED;
}
curs= give_cursor(scene, v3d);
- VECCOPY(newbone->tail, curs);
+ copy_v3_v3(newbone->tail, curs);
sub_v3_v3v3(newbone->tail, newbone->tail, obedit->obmat[3]);
if (a==1)
@@ -2472,7 +2491,7 @@ static int armature_click_extrude_invoke(bContext *C, wmOperator *op, wmEvent *e
fp= give_cursor(scene, v3d);
- VECCOPY(oldcurs, fp);
+ copy_v3_v3(oldcurs, fp);
mx= event->x - ar->winrct.xmin;
my= event->y - ar->winrct.ymin;
@@ -2502,7 +2521,7 @@ static int armature_click_extrude_invoke(bContext *C, wmOperator *op, wmEvent *e
retv= armature_click_extrude_exec(C, op);
/* restore previous 3d cursor position */
- VECCOPY(fp, oldcurs);
+ copy_v3_v3(fp, oldcurs);
return retv;
}
@@ -2531,8 +2550,8 @@ static EditBone *add_points_bone (Object *obedit, float head[], float tail[])
ebo= ED_armature_edit_bone_add(obedit->data, "Bone");
- VECCOPY(ebo->head, head);
- VECCOPY(ebo->tail, tail);
+ copy_v3_v3(ebo->head, head);
+ copy_v3_v3(ebo->tail, tail);
return ebo;
}
@@ -2859,10 +2878,10 @@ static void fill_add_joint (EditBone *ebo, short eb_tail, ListBase *points)
short found= 0;
if (eb_tail) {
- VECCOPY(vec, ebo->tail);
+ copy_v3_v3(vec, ebo->tail);
}
else {
- VECCOPY(vec, ebo->head);
+ copy_v3_v3(vec, ebo->head);
}
for (ebp= points->first; ebp; ebp= ebp->next) {
@@ -2891,11 +2910,11 @@ static void fill_add_joint (EditBone *ebo, short eb_tail, ListBase *points)
ebp= MEM_callocN(sizeof(EditBonePoint), "EditBonePoint");
if (eb_tail) {
- VECCOPY(ebp->vec, ebo->tail);
+ copy_v3_v3(ebp->vec, ebo->tail);
ebp->tail_owner= ebo;
}
else {
- VECCOPY(ebp->vec, ebo->head);
+ copy_v3_v3(ebp->vec, ebo->head);
ebp->head_owner= ebo;
}
@@ -3107,8 +3126,8 @@ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone
/* step 2a: parent children of in-between bones to newbone */
for (chain= chains->first; chain; chain= chain->next) {
/* ick: we need to check if parent of each bone in chain is one of the bones in the */
+ short found= 0;
for (ebo= chain->data; ebo; ebo= ebo->parent) {
- short found= 0;
/* try to find which bone from the list to be removed, is the parent */
for (ebone= end; ebone; ebone= ebone->parent) {
@@ -3124,6 +3143,9 @@ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone
break;
}
}
+ if (found) {
+ break;
+ }
}
/* step 2b: parent child of end to newbone (child from this chain) */
@@ -3135,6 +3157,9 @@ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone
ebone= (ebo == start) ? (NULL) : (ebo->parent);
bone_free(arm, ebo);
}
+
+ newbone->flag |= (BONE_ROOTSEL|BONE_TIPSEL|BONE_SELECTED);
+ ED_armature_sync_selection(arm->edbo);
}
@@ -5688,7 +5713,7 @@ void transform_armature_mirror_update(Object *obedit)
/* Also move connected children, in case children's name aren't mirrored properly */
for (children=arm->edbo->first; children; children=children->next) {
if (children->parent == eboflip && children->flag & BONE_CONNECTED) {
- VECCOPY(children->head, eboflip->tail);
+ copy_v3_v3(children->head, eboflip->tail);
children->rad_head = ebo->rad_tail;
}
}
@@ -5703,7 +5728,7 @@ void transform_armature_mirror_update(Object *obedit)
if (eboflip->parent && eboflip->flag & BONE_CONNECTED)
{
EditBone *parent = eboflip->parent;
- VECCOPY(parent->tail, eboflip->head);
+ copy_v3_v3(parent->tail, eboflip->head);
parent->rad_tail = ebo->rad_head;
}
}
@@ -5744,7 +5769,7 @@ EditBone * subdivideByAngle(Scene *scene, Object *obedit, ReebArc *arc, ReebNode
parent = ED_armature_edit_bone_add(arm, "Bone");
parent->flag |= BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL;
- VECCOPY(parent->head, head->p);
+ copy_v3_v3(parent->head, head->p);
root = parent;
@@ -5769,17 +5794,17 @@ EditBone * subdivideByAngle(Scene *scene, Object *obedit, ReebArc *arc, ReebNode
if (len1 > 0.0f && len2 > 0.0f && dot_v3v3(vec1, vec2) < angleLimit)
{
- VECCOPY(parent->tail, previous);
+ copy_v3_v3(parent->tail, previous);
child = ED_armature_edit_bone_add(arm, "Bone");
- VECCOPY(child->head, parent->tail);
+ copy_v3_v3(child->head, parent->tail);
child->parent = parent;
child->flag |= BONE_CONNECTED|BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL;
parent = child; /* new child is next parent */
}
}
- VECCOPY(parent->tail, tail->p);
+ copy_v3_v3(parent->tail, tail->p);
/* If the bone wasn't subdivided, delete it and return NULL
* to let subsequent subdivision methods do their thing.
@@ -5898,7 +5923,7 @@ void generateSkeletonFromReebGraph(Scene *scene, ReebGraph *rg)
obedit= scene->basact->object;
/* Copy orientation from source */
- VECCOPY(dst->loc, src->obmat[3]);
+ copy_v3_v3(dst->loc, src->obmat[3]);
mat4_to_eul( dst->rot,src->obmat);
mat4_to_size( dst->size,src->obmat);
@@ -5980,8 +6005,8 @@ void generateSkeletonFromReebGraph(Scene *scene, ReebGraph *rg)
bone = ED_armature_edit_bone_add(obedit->data, "Bone");
bone->flag |= BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL;
- VECCOPY(bone->head, head->p);
- VECCOPY(bone->tail, tail->p);
+ copy_v3_v3(bone->head, head->p);
+ copy_v3_v3(bone->tail, tail->p);
/* set first and last bone, since there's only one */
lastBone = bone;
diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c
index 3bbbb271bda..b8c945f0d77 100644
--- a/source/blender/editors/armature/poseobject.c
+++ b/source/blender/editors/armature/poseobject.c
@@ -157,7 +157,7 @@ static short pose_has_protected_selected(Object *ob, short only_selected, short
}
/* only for real IK, not for auto-IK */
-int ED_pose_channel_in_IK_chain(Object *ob, bPoseChannel *pchan)
+static int pose_channel_in_IK_chain(Object *ob, bPoseChannel *pchan, int level)
{
bConstraint *con;
Bone *bone;
@@ -167,18 +167,25 @@ int ED_pose_channel_in_IK_chain(Object *ob, bPoseChannel *pchan)
for(con= pchan->constraints.first; con; con= con->next) {
if(con->type==CONSTRAINT_TYPE_KINEMATIC) {
bKinematicConstraint *data= con->data;
- if((data->flag & CONSTRAINT_IK_AUTO)==0)
- return 1;
+ if(data->rootbone == 0 || data->rootbone > level) {
+ if((data->flag & CONSTRAINT_IK_AUTO)==0)
+ return 1;
+ }
}
}
for(bone= pchan->bone->childbase.first; bone; bone= bone->next) {
pchan= get_pose_channel(ob->pose, bone->name);
- if(pchan && ED_pose_channel_in_IK_chain(ob, pchan))
+ if(pchan && pose_channel_in_IK_chain(ob, pchan, level + 1))
return 1;
}
return 0;
}
+int ED_pose_channel_in_IK_chain(Object *ob, bPoseChannel *pchan)
+{
+ return pose_channel_in_IK_chain(ob, pchan, 0);
+}
+
/* ********************************************** */
/* Motion Paths */
diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h
index 52db36e188d..5df04435abe 100644
--- a/source/blender/editors/include/ED_armature.h
+++ b/source/blender/editors/include/ED_armature.h
@@ -78,12 +78,12 @@ typedef struct EditBone
short segments;
} EditBone;
-#define BONESEL_ROOT 0x10000000
-#define BONESEL_TIP 0x20000000
-#define BONESEL_BONE 0x40000000
+#define BONESEL_ROOT (1<<28)
+#define BONESEL_TIP (1<<29)
+#define BONESEL_BONE (1<<30)
#define BONESEL_ANY (BONESEL_TIP|BONESEL_ROOT|BONESEL_BONE)
-#define BONESEL_NOSEL 0x80000000 /* Indicates a negative number */
+#define BONESEL_NOSEL (1<<31) /* Indicates a negative number */
/* useful macros */
#define EBONE_VISIBLE(arm, ebone) ((arm->layer & ebone->layer) && !(ebone->flag & BONE_HIDDEN_A))
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 40985a918d4..7d56698f7b9 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -146,15 +146,16 @@ typedef struct uiLayout uiLayout;
#define UI_BUT_ANIMATED (1<<20)
#define UI_BUT_ANIMATED_KEY (1<<21)
#define UI_BUT_DRIVEN (1<<22)
-#define UI_BUT_INACTIVE (1<<23)
-#define UI_BUT_LAST_ACTIVE (1<<24)
-#define UI_BUT_UNDO (1<<25)
-#define UI_BUT_IMMEDIATE (1<<26)
-#define UI_BUT_NO_TOOLTIP (1<<27)
-#define UI_BUT_NO_UTF8 (1<<28)
+#define UI_BUT_REDALERT (1<<23)
+#define UI_BUT_INACTIVE (1<<24)
+#define UI_BUT_LAST_ACTIVE (1<<25)
+#define UI_BUT_UNDO (1<<26)
+#define UI_BUT_IMMEDIATE (1<<27)
+#define UI_BUT_NO_TOOLTIP (1<<28)
+#define UI_BUT_NO_UTF8 (1<<29)
-#define UI_BUT_VEC_SIZE_LOCK (1<<29) /* used to flag if color hsv-circle should keep luminance */
-#define UI_BUT_COLOR_CUBIC (1<<30) /* cubic saturation for the color wheel */
+#define UI_BUT_VEC_SIZE_LOCK (1<<30) /* used to flag if color hsv-circle should keep luminance */
+#define UI_BUT_COLOR_CUBIC (1<<31) /* cubic saturation for the color wheel */
#define UI_PANEL_WIDTH 340
#define UI_COMPACT_PANEL_WIDTH 160
@@ -250,6 +251,9 @@ int uiGetRoundBox(void);
void uiRoundRect(float minx, float miny, float maxx, float maxy, float rad);
void uiDrawMenuBox(float minx, float miny, float maxx, float maxy, short flag, short direction);
void uiDrawBoxShadow(unsigned char alpha, float minx, float miny, float maxx, float maxy);
+void uiDrawBox(int mode, float minx, float miny, float maxx, float maxy, float rad);
+void uiDrawBoxShade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadetop, float shadedown);
+void uiDrawBoxVerticalShade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadeLeft, float shadeRight);
/* state for scrolldrawing */
#define UI_SCROLL_PRESSED 1
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 021dcc940e6..f6ba948db7d 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -1234,11 +1234,13 @@ int ui_is_but_unit(uiBut *but)
if(but->rnaprop==NULL)
return 0;
-
+
unit_type = RNA_SUBTYPE_UNIT(RNA_property_subtype(but->rnaprop));
-
+
+#if 0 // removed so angle buttons get correct snapping
if (scene->unit.flag & USER_UNIT_ROT_RADIANS && unit_type == PROP_UNIT_ROTATION)
return 0;
+#endif
/* for now disable time unit conversion */
if (unit_type == PROP_UNIT_TIME)
@@ -1443,6 +1445,23 @@ static double ui_get_but_scale_unit(uiBut *but, double value)
}
}
+/* str will be overwritten */
+void ui_convert_to_unit_alt_name(uiBut *but, char *str, int maxlen)
+{
+ if(ui_is_but_unit(but)) {
+ int unit_type= RNA_SUBTYPE_UNIT_VALUE(RNA_property_subtype(but->rnaprop));
+ char *orig_str;
+ Scene *scene= CTX_data_scene((bContext *)but->block->evil_C);
+
+ orig_str= MEM_callocN(sizeof(char)*maxlen + 1, "textedit sub str");
+ memcpy(orig_str, str, maxlen);
+
+ bUnit_ToUnitAltName(str, maxlen, orig_str, scene->unit.system, unit_type);
+
+ MEM_freeN(orig_str);
+ }
+}
+
static void ui_get_but_string_unit(uiBut *but, char *str, int len_max, double value, int pad)
{
Scene *scene= CTX_data_scene((bContext *)but->block->evil_C);
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index 2a9a1335b1f..cf6970dc59f 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -48,6 +48,7 @@
#include "UI_interface.h"
+/* own include */
#include "interface_intern.h"
#define UI_RB_ALPHA 16
@@ -76,7 +77,7 @@ int uiGetRoundBox(void)
return roundboxtype;
}
-void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad)
+void uiDrawBox(int mode, float minx, float miny, float maxx, float maxy, float rad)
{
float vec[7][2]= {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, {0.707, 0.293},
{0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}};
@@ -146,7 +147,7 @@ static void round_box_shade_col(float *col1, float *col2, float fac)
/* linear horizontal shade within button or in outline */
/* view2d scrollers use it */
-void gl_round_box_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadetop, float shadedown)
+void uiDrawBoxShade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadetop, float shadedown)
{
float vec[7][2]= {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, {0.707, 0.293},
{0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}};
@@ -253,7 +254,7 @@ void gl_round_box_shade(int mode, float minx, float miny, float maxx, float maxy
/* linear vertical shade within button or in outline */
/* view2d scrollers use it */
-void gl_round_box_vertical_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadeLeft, float shadeRight)
+void uiDrawBoxVerticalShade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadeLeft, float shadeRight)
{
float vec[7][2]= {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, {0.707, 0.293},
{0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}};
@@ -371,7 +372,7 @@ void uiRoundRect(float minx, float miny, float maxx, float maxy, float rad)
glEnable( GL_LINE_SMOOTH );
glEnable( GL_BLEND );
- gl_round_box(GL_LINE_LOOP, minx, miny, maxx, maxy, rad);
+ uiDrawBox(GL_LINE_LOOP, minx, miny, maxx, maxy, rad);
glDisable( GL_BLEND );
glDisable( GL_LINE_SMOOTH );
@@ -397,7 +398,7 @@ void uiRoundRectFakeAA(float minx, float miny, float maxx, float maxy, float rad
/* draw lots of lines on top of each other */
for (i=passes; i>=(-passes); i--) {
- gl_round_box(GL_LINE_LOOP, minx, miny, maxx, maxy, rad+(i*raddiff));
+ uiDrawBox(GL_LINE_LOOP, minx, miny, maxx, maxy, rad+(i*raddiff));
}
glDisable( GL_BLEND );
@@ -419,13 +420,13 @@ void uiRoundBox(float minx, float miny, float maxx, float maxy, float rad)
}
/* solid part */
- gl_round_box(GL_POLYGON, minx, miny, maxx, maxy, rad);
+ uiDrawBox(GL_POLYGON, minx, miny, maxx, maxy, rad);
/* set antialias line */
glEnable( GL_LINE_SMOOTH );
glEnable( GL_BLEND );
- gl_round_box(GL_LINE_LOOP, minx, miny, maxx, maxy, rad);
+ uiDrawBox(GL_LINE_LOOP, minx, miny, maxx, maxy, rad);
glDisable( GL_BLEND );
glDisable( GL_LINE_SMOOTH );
@@ -710,7 +711,7 @@ static void draw_scope_end(rctf *rect, GLint *scissor)
/* outline */
glColor4f(0.f, 0.f, 0.f, 0.5f);
uiSetRoundBox(15);
- gl_round_box(GL_LINE_LOOP, rect->xmin-1, rect->ymin, rect->xmax+1, rect->ymax+1, 3.0f);
+ uiDrawBox(GL_LINE_LOOP, rect->xmin-1, rect->ymin, rect->xmax+1, rect->ymax+1, 3.0f);
}
void histogram_draw_one(float r, float g, float b, float alpha, float x, float y, float w, float h, float *data, int res)
@@ -771,7 +772,7 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *
glColor4f(0.f, 0.f, 0.f, 0.3f);
uiSetRoundBox(15);
- gl_round_box(GL_POLYGON, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f);
+ uiDrawBox(GL_POLYGON, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f);
glColor4f(1.f, 1.f, 1.f, 0.08f);
/* draw grid lines here */
@@ -840,7 +841,7 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *r
glColor4f(0.f, 0.f, 0.f, 0.3f);
uiSetRoundBox(15);
- gl_round_box(GL_POLYGON, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f);
+ uiDrawBox(GL_POLYGON, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f);
/* need scissor test, waveform can draw outside of boundary */
@@ -1051,7 +1052,7 @@ void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti
glColor4f(0.f, 0.f, 0.f, 0.3f);
uiSetRoundBox(15);
- gl_round_box(GL_POLYGON, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f);
+ uiDrawBox(GL_POLYGON, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f);
/* need scissor test, hvectorscope can draw outside of boundary */
glGetIntegerv(GL_VIEWPORT, scissor);
@@ -1237,7 +1238,7 @@ void ui_draw_but_NORMAL(uiBut *but, uiWidgetColors *wcol, rcti *rect)
/* backdrop */
glColor3ubv((unsigned char*)wcol->inner);
uiSetRoundBox(15);
- gl_round_box(GL_POLYGON, rect->xmin, rect->ymin, rect->xmax, rect->ymax, 5.0f);
+ uiDrawBox(GL_POLYGON, rect->xmin, rect->ymin, rect->xmax, rect->ymax, 5.0f);
/* sphere color */
glMaterialfv(GL_FRONT, GL_DIFFUSE, diffn);
@@ -1584,13 +1585,13 @@ void ui_dropshadow(rctf *rct, float radius, float aspect, int select)
glColor4ub(0, 0, 0, alpha);
alpha+= 2;
- gl_round_box(GL_POLYGON, rct->xmin - a, rct->ymin - a, rct->xmax + a, rct->ymax-10.0f + a, rad+a);
+ uiDrawBox(GL_POLYGON, rct->xmin - a, rct->ymin - a, rct->xmax + a, rct->ymax-10.0f + a, rad+a);
}
/* outline emphasis */
glEnable( GL_LINE_SMOOTH );
glColor4ub(0, 0, 0, 100);
- gl_round_box(GL_LINE_LOOP, rct->xmin-0.5f, rct->ymin-0.5f, rct->xmax+0.5f, rct->ymax+0.5f, radius);
+ uiDrawBox(GL_LINE_LOOP, rct->xmin-0.5f, rct->ymin-0.5f, rct->xmax+0.5f, rct->ymax+0.5f, radius);
glDisable( GL_LINE_SMOOTH );
glDisable(GL_BLEND);
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 484c78cd831..fea152bb4a7 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -44,6 +44,7 @@
#include "BKE_idprop.h"
#include "BKE_report.h"
#include "BKE_texture.h"
+#include "BKE_unit.h"
#include "ED_screen.h"
#include "ED_util.h"
@@ -1555,7 +1556,8 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data)
int i;
for(i=0; data->str[i]; i++) {
if(!isascii(data->str[i])) {
- data->str[i]= '\0';
+ /* no stripping actually: just convert to alt name */
+ ui_convert_to_unit_alt_name(but, data->str, data->maxlen);
break;
}
}
@@ -2194,26 +2196,47 @@ static int ui_do_but_EXIT(bContext *C, uiBut *but, uiHandleButtonData *data, wmE
}
/* var names match ui_numedit_but_NUM */
-static float ui_numedit_apply_snapf(float tempf, float softmin, float softmax, float softrange, int snap)
+static float ui_numedit_apply_snapf(uiBut *but, float tempf, float softmin, float softmax, float softrange, int snap)
{
- if(tempf==softmin || tempf==softmax)
- return tempf;
+ if(tempf==softmin || tempf==softmax || snap==0) {
+ /* pass */
+ }
+ else {
+ float fac= 1.0f;
+
+ if(ui_is_but_unit(but)) {
+ Scene *scene= CTX_data_scene((bContext *)but->block->evil_C);
+ int unit_type = RNA_SUBTYPE_UNIT_VALUE(RNA_property_subtype(but->rnaprop));
+
+ if(bUnit_IsValid(scene->unit.system, unit_type)) {
+ fac= (float)bUnit_BaseScalar(scene->unit.system, unit_type);
+ if(ELEM3(unit_type, B_UNIT_LENGTH, B_UNIT_AREA, B_UNIT_VOLUME)) {
+ fac /= scene->unit.scale_length;
+ }
+ }
+ }
- switch(snap) {
- case 0:
- break;
- case 1:
- if(tempf==softmin || tempf==softmax) { }
- else if(softrange < 2.10) tempf= 0.1*floor(10*tempf);
- else if(softrange < 21.0) tempf= floor(tempf);
- else tempf= 10.0*floor(tempf/10.0);
- break;
- case 2:
- if(tempf==softmin || tempf==softmax) { }
- else if(softrange < 2.10) tempf= 0.01*floor(100.0*tempf);
- else if(softrange < 21.0) tempf= 0.1*floor(10.0*tempf);
- else tempf= floor(tempf);
- break;
+ if(fac != 1.0f) {
+ /* snap in unit-space */
+ tempf /= fac;
+ softmin /= fac;
+ softmax /= fac;
+ softrange /= fac;
+ }
+
+ if(snap==1) {
+ if(softrange < 2.10) tempf= 0.1*floor(10*tempf);
+ else if(softrange < 21.0) tempf= floor(tempf);
+ else tempf= 10.0*floor(tempf/10.0);
+ }
+ else if(snap==2) {
+ if(softrange < 2.10) tempf= 0.01*floor(100.0*tempf);
+ else if(softrange < 21.0) tempf= 0.1*floor(10.0*tempf);
+ else tempf= floor(tempf);
+ }
+
+ if(fac != 1.0f)
+ tempf *= fac;
}
return tempf;
@@ -2266,7 +2289,7 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i
if(ui_is_but_float(but)) {
fac *= 0.01*but->a1;
tempf = data->startvalue + ((mx - data->dragstartx) * fac);
- tempf= ui_numedit_apply_snapf(tempf, softmin, softmax, softrange, snap);
+ tempf= ui_numedit_apply_snapf(but, tempf, softmin, softmax, softrange, snap);
#if 1 /* fake moving the click start, nicer for dragging back after passing the limit */
if(tempf < softmin) {
@@ -2359,7 +2382,7 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i
}
else {
temp= 0;
- tempf= ui_numedit_apply_snapf(tempf, softmin, softmax, softrange, snap);
+ tempf= ui_numedit_apply_snapf(but, tempf, softmin, softmax, softrange, snap);
CLAMP(tempf, softmin, softmax);
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 84d6605651b..d5f6b089544 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -356,6 +356,7 @@ extern void ui_set_but_vectorf(uiBut *but, float *vec);
extern void ui_hsvcircle_vals_from_pos(float *valrad, float *valdist, rcti *rect, float mx, float my);
extern void ui_get_but_string(uiBut *but, char *str, int maxlen);
+extern void ui_convert_to_unit_alt_name(uiBut *but, char *str, int maxlen);
extern int ui_set_but_string(struct bContext *C, uiBut *but, const char *str);
extern int ui_get_but_string_max_length(uiBut *but);
@@ -440,10 +441,6 @@ extern void ui_draw_aligned_panel(struct ARegion *ar, struct uiStyle *style, uiB
/* interface_draw.c */
extern void ui_dropshadow(rctf *rct, float radius, float aspect, int select);
-extern void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad);
-extern void gl_round_box_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadetop, float shadedown);
-extern void gl_round_box_vertical_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadeLeft, float shadeRight);
-
void ui_draw_gradient(rcti *rect, float *rgb, int type, float alpha);
void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect);
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index c5f0913e35d..08ce130a300 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -1437,6 +1437,11 @@ static void widget_state(uiWidgetType *wt, int state)
wt->wcol.inner[2]= wt->wcol.inner[2]>=240? 255 : wt->wcol.inner[2]+15;
}
}
+
+ if(state & UI_BUT_REDALERT) {
+ char red[4]= {255, 0, 0};
+ widget_state_blend(wt->wcol.inner, red, 0.4f);
+ }
}
/* sliders use special hack which sets 'item' as inner when drawing filling */
diff --git a/source/blender/editors/mesh/editmesh.c b/source/blender/editors/mesh/editmesh.c
index e6ba228c260..ff2fad3f551 100644
--- a/source/blender/editors/mesh/editmesh.c
+++ b/source/blender/editors/mesh/editmesh.c
@@ -1526,6 +1526,11 @@ static int mesh_separate_exec(bContext *C, wmOperator *op)
if(retval) {
WM_event_add_notifier(C, NC_GEOM|ND_DATA, base->object->data);
+
+ // XXX: new object was created, but selection wasn't actually changed
+ // need this for outliner update without adding new ND. nazgul.
+ WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene);
+
return OPERATOR_FINISHED;
}
return OPERATOR_CANCELLED;
diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c
index de4a931e069..baf71cb21d6 100644
--- a/source/blender/editors/object/object_constraint.c
+++ b/source/blender/editors/object/object_constraint.c
@@ -805,6 +805,8 @@ static int constraint_delete_exec (bContext *C, wmOperator *op)
/* there's no active constraint now, so make sure this is the case */
constraints_set_active(lb, NULL);
+ ED_object_constraint_update(ob); /* needed to set the flags on posebones correctly */
+
/* notifiers */
WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob);
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index 87b20ab1c41..132533fc123 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -3573,7 +3573,7 @@ static void brush_edit_apply_event(bContext *C, wmOperator *op, wmEvent *event)
RNA_collection_add(op->ptr, "stroke", &itemptr);
RNA_float_set_array(&itemptr, "mouse", mouse);
- RNA_boolean_set(&itemptr, "flip", event->shift != 0); // XXX hardcoded
+ RNA_boolean_set(&itemptr, "pen_flip", event->shift != 0); // XXX hardcoded
/* apply */
brush_edit_apply(C, op, &itemptr);
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 90f9d5683c2..07d1e47f74e 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -1095,13 +1095,6 @@ void ED_area_prevspace(bContext *C, ScrArea *sa)
{
SpaceLink *sl = (sa) ? sa->spacedata.first : CTX_wm_space_data(C);
- /* Special handling of filebrowser to stop background thread for
- thumbnail creation - don't want to waste cpu resources if not showing
- the filebrowser */
- if (sl->spacetype == SPACE_FILE) {
- ED_fileselect_exit(C, (SpaceFile*)sl);
- }
-
if(sl->next) {
/* workaround for case of double prevspace, render window
with a file browser on top of it */
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index 2aceabcea76..1ca8bff3193 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -1090,6 +1090,10 @@ void ED_area_exit(bContext *C, ScrArea *sa)
ScrArea *prevsa= CTX_wm_area(C);
ARegion *ar;
+ if (sa->spacetype == SPACE_FILE) {
+ ED_fileselect_exit(C, (SpaceFile*)(sa) ? sa->spacedata.first : CTX_wm_space_data(C));
+ }
+
CTX_wm_area_set(C, sa);
for(ar= sa->regionbase.first; ar; ar= ar->next)
ED_region_exit(C, ar);
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index ffe61b3e4d6..0c92d6bbc6a 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -1415,13 +1415,17 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event)
ED_region_toggle_hidden(C, rmd->ar);
}
else {
+ int maxsize=0;
delta= event->y - rmd->origy;
if(rmd->edge=='b') delta= -delta;
rmd->ar->sizey= rmd->origval + delta;
CLAMP(rmd->ar->sizey, 0, rmd->maxsize);
- if(rmd->ar->sizey < 24) {
+ if(rmd->ar->regiontype == RGN_TYPE_TOOL_PROPS)
+ maxsize = rmd->maxsize - ((rmd->sa->headertype==2)?48:24) - 10;
+
+ if(rmd->ar->sizey < 24 || (maxsize > 0 && (rmd->ar->sizey > maxsize)) ) {
rmd->ar->sizey= rmd->origval;
if(!(rmd->ar->flag & RGN_FLAG_HIDDEN))
ED_region_toggle_hidden(C, rmd->ar);
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 418bac69974..e7a06f27f67 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -4534,29 +4534,8 @@ static void paint_redraw(bContext *C, ImagePaintState *s, int final)
if(s->image)
GPU_free_image(s->image);
+ /* compositor listener deals with updating */
WM_event_add_notifier(C, NC_IMAGE|NA_EDITED, s->image);
-
- // XXX node update
-#if 0
- if(!s->sima && s->image) {
- /* after paint, tag Image or RenderResult nodes changed */
- if(s->scene->nodetree) {
- imagepaint_composite_tags(s->scene->nodetree, image, &s->sima->iuser);
- }
- /* signal composite (hurmf, need an allqueue?) */
- if(s->sima->lock) {
- ScrArea *sa;
- for(sa=s->screen->areabase.first; sa; sa= sa->next) {
- if(sa->spacetype==SPACE_NODE) {
- if(((SpaceNode *)sa->spacedata.first)->treetype==NTREE_COMPOSIT) {
- addqueue(sa->win, UI_BUT_EVENT, B_NODE_TREE_EXEC);
- break;
- }
- }
- }
- }
- }
-#endif
}
else {
if(!s->sima || !s->sima->lock)
@@ -5156,11 +5135,40 @@ static int sample_color_invoke(bContext *C, wmOperator *op, wmEvent *event)
ARegion *ar= CTX_wm_region(C);
int location[2];
- location[0]= event->x - ar->winrct.xmin;
- location[1]= event->y - ar->winrct.ymin;
- RNA_int_set_array(op->ptr, "location", location);
+ if(ar) {
+ location[0]= event->x - ar->winrct.xmin;
+ location[1]= event->y - ar->winrct.ymin;
+ RNA_int_set_array(op->ptr, "location", location);
- return sample_color_exec(C, op);
+ sample_color_exec(C, op);
+ }
+
+ WM_event_add_modal_handler(C, op);
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+static int sample_color_modal(bContext *C, wmOperator *op, wmEvent *event)
+{
+ ARegion *ar= CTX_wm_region(C);
+ int location[2];
+
+ switch(event->type) {
+ case LEFTMOUSE:
+ case RIGHTMOUSE: // XXX hardcoded
+ return OPERATOR_FINISHED;
+ case MOUSEMOVE:
+ if(ar) {
+ location[0]= event->x - ar->winrct.xmin;
+ location[1]= event->y - ar->winrct.ymin;
+ RNA_int_set_array(op->ptr, "location", location);
+
+ sample_color_exec(C, op);
+ }
+ break;
+ }
+
+ return OPERATOR_RUNNING_MODAL;
}
void PAINT_OT_sample_color(wmOperatorType *ot)
@@ -5172,6 +5180,7 @@ void PAINT_OT_sample_color(wmOperatorType *ot)
/* api callbacks */
ot->exec= sample_color_exec;
ot->invoke= sample_color_invoke;
+ ot->modal= sample_color_modal;
ot->poll= image_paint_poll;
/* flags */
@@ -5515,6 +5524,13 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
if(h > maxsize) h= maxsize;
ibuf= ED_view3d_draw_offscreen_imbuf(CTX_data_scene(C), CTX_wm_view3d(C), CTX_wm_region(C), w, h, IB_rect);
+ if(!ibuf) {
+ /* Mostly happens when OpenGL offscreen buffer was failed to create, */
+ /* but could be other reasons. Should be handled in the future. nazgul */
+ BKE_report(op->reports, RPT_ERROR, "Failed to create OpenGL offscreen buffer.");
+ return OPERATOR_CANCELLED;
+ }
+
image= BKE_add_image_imbuf(ibuf);
if(image) {
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 5f435aa0cbe..0f627bda3dc 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -172,6 +172,10 @@ void file_draw_buttons(const bContext *C, ARegion *ar)
/* Text input fields for directory and file. */
if (available_w > 0) {
+ int overwrite_alert= file_draw_check_exists(sfile);
+ /* callbacks for operator check functions */
+ uiBlockSetFunc(block, file_draw_check_cb, NULL, NULL);
+
but = uiDefBut(block, TEX, B_FS_DIRNAME, "",
min_x, line1_y, line1_w-chan_offs, btn_h,
params->dir, 0.0, (float)FILE_MAX-1, 0, 0,
@@ -182,9 +186,17 @@ void file_draw_buttons(const bContext *C, ARegion *ar)
but = uiDefBut(block, TEX, B_FS_FILENAME, "",
min_x, line2_y, line2_w-chan_offs, btn_h,
params->file, 0.0, (float)FILE_MAXFILE-1, 0, 0,
- "File name.");
+ overwrite_alert ?"File name, overwrite existing." : "File name.");
uiButSetCompleteFunc(but, autocomplete_file, NULL);
uiButSetFlag(but, UI_BUT_NO_UTF8);
+
+ /* check if this overrides a file and if the operator option is used */
+ if(overwrite_alert) {
+ uiButSetFlag(but, UI_BUT_REDALERT);
+ }
+
+ /* clear func */
+ uiBlockSetFunc(block, NULL, NULL, NULL);
}
/* Filename number increment / decrement buttons. */
diff --git a/source/blender/editors/space_file/file_intern.h b/source/blender/editors/space_file/file_intern.h
index c77379b39a0..07a24454520 100644
--- a/source/blender/editors/space_file/file_intern.h
+++ b/source/blender/editors/space_file/file_intern.h
@@ -46,6 +46,9 @@ void file_calc_previews(const bContext *C, ARegion *ar);
void file_draw_previews(const bContext *C, ARegion *ar);
void file_draw_list(const bContext *C, ARegion *ar);
+void file_draw_check_cb(bContext *C, void *arg1, void *arg2);
+int file_draw_check_exists(SpaceFile *sfile);
+
/* file_ops.h */
struct wmOperatorType;
struct wmOperator;
@@ -84,6 +87,9 @@ int file_delete_exec(bContext *C, struct wmOperator *unused);
int file_hilight_set(struct SpaceFile *sfile, struct ARegion *ar, int mx, int my);
+void file_sfile_to_operator(struct wmOperator *op, struct SpaceFile *sfile, char *filepath);
+void file_operator_to_sfile(struct SpaceFile *sfile, struct wmOperator *op);
+
/* filesel.c */
float file_string_width(const char* str);
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 2a50b505c57..7888fdeef8a 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -206,7 +206,11 @@ static FileSelect file_select(bContext* C, const rcti* rect, short selecting, sh
}
}
- }
+ }
+
+ /* update operator for name change event */
+ file_draw_check_cb(C, NULL, NULL);
+
return retval;
}
@@ -503,18 +507,11 @@ void FILE_OT_highlight(struct wmOperatorType *ot)
int file_cancel_exec(bContext *C, wmOperator *unused)
{
SpaceFile *sfile= CTX_wm_space_file(C);
-
- folderlist_free(sfile->folders_prev);
- folderlist_free(sfile->folders_next);
-
- WM_event_fileselect_event(C, sfile->op, EVT_FILESELECT_CANCEL);
- sfile->op = NULL;
+ wmOperator *op = sfile->op;
- if (sfile->files) {
- ED_fileselect_clear(C, sfile);
- MEM_freeN(sfile->files);
- sfile->files= NULL;
- }
+ sfile->op = NULL;
+
+ WM_event_fileselect_event(C, op, EVT_FILESELECT_CANCEL);
return OPERATOR_FINISHED;
}
@@ -541,6 +538,118 @@ void FILE_OT_cancel(struct wmOperatorType *ot)
ot->poll= file_operator_poll;
}
+
+void file_sfile_to_operator(wmOperator *op, SpaceFile *sfile, char *filepath)
+{
+ BLI_join_dirfile(filepath, sfile->params->dir, sfile->params->file);
+ if(RNA_struct_find_property(op->ptr, "relative_path")) {
+ if(RNA_boolean_get(op->ptr, "relative_path")) {
+ BLI_path_rel(filepath, G.sce);
+ }
+ }
+
+ if(RNA_struct_find_property(op->ptr, "filename")) {
+ RNA_string_set(op->ptr, "filename", sfile->params->file);
+ }
+ if(RNA_struct_find_property(op->ptr, "directory")) {
+ RNA_string_set(op->ptr, "directory", sfile->params->dir);
+ }
+ if(RNA_struct_find_property(op->ptr, "filepath")) {
+ RNA_string_set(op->ptr, "filepath", filepath);
+ }
+
+ /* some ops have multiple files to select */
+ {
+ PointerRNA itemptr;
+ int i, numfiles = filelist_numfiles(sfile->files);
+ struct direntry *file;
+ if(RNA_struct_find_property(op->ptr, "files")) {
+ for (i=0; i<numfiles; i++) {
+ file = filelist_file(sfile->files, i);
+ if(file->flags & ACTIVEFILE) {
+ if ((file->type & S_IFDIR)==0) {
+ RNA_collection_add(op->ptr, "files", &itemptr);
+ RNA_string_set(&itemptr, "name", file->relname);
+ }
+ }
+ }
+ }
+
+ if(RNA_struct_find_property(op->ptr, "dirs")) {
+ for (i=0; i<numfiles; i++) {
+ file = filelist_file(sfile->files, i);
+ if(file->flags & ACTIVEFILE) {
+ if ((file->type & S_IFDIR)) {
+ RNA_collection_add(op->ptr, "dirs", &itemptr);
+ RNA_string_set(&itemptr, "name", file->relname);
+ }
+ }
+ }
+ }
+ }
+}
+
+void file_operator_to_sfile(SpaceFile *sfile, wmOperator *op)
+{
+ int change= FALSE;
+ if(RNA_struct_find_property(op->ptr, "filename")) {
+ RNA_string_get(op->ptr, "filename", sfile->params->file);
+ change= TRUE;
+ }
+ if(RNA_struct_find_property(op->ptr, "directory")) {
+ RNA_string_get(op->ptr, "directory", sfile->params->dir);
+ change= TRUE;
+ }
+
+ /* If neither of the above are set, split the filepath back */
+ if(RNA_struct_find_property(op->ptr, "filepath")) {
+ if(change==FALSE) {
+ char filepath[FILE_MAX];
+ RNA_string_get(op->ptr, "filepath", filepath);
+ BLI_split_dirfile(filepath, sfile->params->dir, sfile->params->file);
+ }
+ }
+
+ /* XXX, files and dirs updates missing, not really so important though */
+}
+
+void file_draw_check_cb(bContext *C, void *dummy1, void *dummy2)
+{
+ SpaceFile *sfile= CTX_wm_space_file(C);
+ wmOperator *op= sfile->op;
+ if(op) { /* fail on reload */
+ if(op->type->check) {
+ char filepath[FILE_MAX];
+ file_sfile_to_operator(op, sfile, filepath);
+
+ /* redraw */
+ if(op->type->check(C, op)) {
+ file_operator_to_sfile(sfile, op);
+
+ /* redraw, else the changed settings wont get updated */
+ ED_area_tag_redraw(CTX_wm_area(C));
+ }
+ }
+ }
+}
+
+int file_draw_check_exists(SpaceFile *sfile)
+{
+ if(sfile->op) { /* fails on reload */
+ if(RNA_struct_find_property(sfile->op->ptr, "check_existing")) {
+ if(RNA_boolean_get(sfile->op->ptr, "check_existing")) {
+ char filepath[FILE_MAX];
+ BLI_join_dirfile(filepath, sfile->params->dir, sfile->params->file);
+ if(BLI_exists(filepath) && !BLI_is_dir(filepath)) {
+ return TRUE;
+ }
+ }
+ }
+ }
+
+ return FALSE;
+}
+
/* sends events now, so things get handled on windowqueue level */
int file_exec(bContext *C, wmOperator *exec_op)
{
@@ -568,64 +677,13 @@ int file_exec(bContext *C, wmOperator *exec_op)
sfile->op = NULL;
- BLI_join_dirfile(filepath, sfile->params->dir, sfile->params->file);
- if(RNA_struct_find_property(op->ptr, "relative_path")) {
- if(RNA_boolean_get(op->ptr, "relative_path")) {
- BLI_path_rel(filepath, G.sce);
- }
- }
-
- if(RNA_struct_find_property(op->ptr, "filename")) {
- RNA_string_set(op->ptr, "filename", sfile->params->file);
- }
- if(RNA_struct_find_property(op->ptr, "directory")) {
- RNA_string_set(op->ptr, "directory", sfile->params->dir);
- }
- if(RNA_struct_find_property(op->ptr, "filepath")) {
- RNA_string_set(op->ptr, "filepath", filepath);
- }
-
- /* some ops have multiple files to select */
- {
- PointerRNA itemptr;
- int i, numfiles = filelist_numfiles(sfile->files);
- struct direntry *file;
- if(RNA_struct_find_property(op->ptr, "files")) {
- for (i=0; i<numfiles; i++) {
- file = filelist_file(sfile->files, i);
- if(file->flags & ACTIVEFILE) {
- if ((file->type & S_IFDIR)==0) {
- RNA_collection_add(op->ptr, "files", &itemptr);
- RNA_string_set(&itemptr, "name", file->relname);
- }
- }
- }
- }
-
- if(RNA_struct_find_property(op->ptr, "dirs")) {
- for (i=0; i<numfiles; i++) {
- file = filelist_file(sfile->files, i);
- if(file->flags & ACTIVEFILE) {
- if ((file->type & S_IFDIR)) {
- RNA_collection_add(op->ptr, "dirs", &itemptr);
- RNA_string_set(&itemptr, "name", file->relname);
- }
- }
- }
- }
- }
-
- folderlist_free(sfile->folders_prev);
- folderlist_free(sfile->folders_next);
+ file_sfile_to_operator(op, sfile, filepath);
fsmenu_insert_entry(fsmenu_get(), FS_CATEGORY_RECENT, sfile->params->dir,0, 1);
BLI_make_file_string(G.sce, filepath, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE);
fsmenu_write_file(fsmenu_get(), filepath);
WM_event_fileselect_event(C, op, EVT_FILESELECT_EXEC);
- ED_fileselect_clear(C, sfile);
- MEM_freeN(sfile->files);
- sfile->files= NULL;
}
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c
index 4a505bc022f..33d740e18a6 100644
--- a/source/blender/editors/space_file/file_panels.c
+++ b/source/blender/editors/space_file/file_panels.c
@@ -170,7 +170,9 @@ static void file_panel_operator(const bContext *C, Panel *pa)
SpaceFile *sfile= CTX_wm_space_file(C);
wmOperator *op= sfile->op;
int empty= 1, flag;
-
+
+ uiBlockSetFunc(uiLayoutGetBlock(pa->layout), file_draw_check_cb, NULL, NULL);
+
if(op->type->ui) {
op->layout= pa->layout;
op->type->ui((bContext*)C, op);
@@ -197,6 +199,8 @@ static void file_panel_operator(const bContext *C, Panel *pa)
if(empty)
uiItemL(pa->layout, "No properties.", 0);
}
+
+ uiBlockSetFunc(uiLayoutGetBlock(pa->layout), NULL, NULL, NULL);
}
void file_panels_register(ARegionType *art)
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index 52d59270663..e2099be6f03 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -531,5 +531,18 @@ void ED_fileselect_clear(struct bContext *C, struct SpaceFile *sfile)
void ED_fileselect_exit(struct bContext *C, struct SpaceFile *sfile)
{
- thumbnails_stop(sfile->files, C);
+ if(!sfile) return;
+ if(sfile->op)
+ WM_event_fileselect_event(C, sfile->op, EVT_FILESELECT_EXTERNAL_CANCEL);
+ sfile->op = NULL;
+
+ folderlist_free(sfile->folders_prev);
+ folderlist_free(sfile->folders_next);
+
+ if (sfile->files) {
+ ED_fileselect_clear(C, sfile);
+ MEM_freeN(sfile->files);
+ sfile->files= NULL;
+ }
+
}
diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c
index 8211257da02..a043fc8cfd1 100644
--- a/source/blender/editors/space_file/fsmenu.c
+++ b/source/blender/editors/space_file/fsmenu.c
@@ -280,13 +280,10 @@ void fsmenu_read_bookmarks(struct FSMenu* fsmenu, const char *filename)
void fsmenu_read_system(struct FSMenu* fsmenu)
{
char line[256];
- FILE *fp;
-
#ifdef WIN32
/* Add the drive names to the listing */
{
__int64 tmp;
- char folder[256];
char tmps[4];
int i;
@@ -304,10 +301,10 @@ void fsmenu_read_system(struct FSMenu* fsmenu)
}
/* Adding Desktop and My Documents */
- SHGetSpecialFolderPath(0, folder, CSIDL_PERSONAL, 0);
- fsmenu_insert_entry(fsmenu,FS_CATEGORY_BOOKMARKS, folder, 1, 0);
- SHGetSpecialFolderPath(0, folder, CSIDL_DESKTOPDIRECTORY, 0);
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, folder, 1, 0);
+ SHGetSpecialFolderPath(0, line, CSIDL_PERSONAL, 0);
+ fsmenu_insert_entry(fsmenu,FS_CATEGORY_BOOKMARKS, line, 1, 0);
+ SHGetSpecialFolderPath(0, line, CSIDL_DESKTOPDIRECTORY, 0);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0);
}
#else
#ifdef __APPLE__
@@ -474,6 +471,7 @@ void fsmenu_read_system(struct FSMenu* fsmenu)
/* loop over mount points */
struct mntent *mnt;
int len;
+ FILE *fp;
fp = setmntent (MOUNTED, "r");
if (fp == NULL) {
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 11b39af2e03..5a7e2e6fa1b 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -960,6 +960,18 @@ static int save_as_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
+
+static int save_as_check(bContext *C, wmOperator *op)
+{
+ char filepath[FILE_MAX];
+ RNA_string_get(op->ptr, "filepath", filepath);
+ if(BKE_add_image_extension(filepath, RNA_enum_get(op->ptr, "file_type"))) {
+ RNA_string_set(op->ptr, "filepath", filepath);
+ return TRUE;
+ }
+ return FALSE;
+}
+
static int save_as_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
SpaceImage *sima= CTX_wm_space_image(C);
@@ -1022,6 +1034,7 @@ void IMAGE_OT_save_as(wmOperatorType *ot)
/* api callbacks */
ot->exec= save_as_exec;
+ ot->check= save_as_check;
ot->invoke= save_as_invoke;
ot->poll= space_image_buffer_exists_poll;
diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c
index fc869c4b46f..a728cc900c2 100644
--- a/source/blender/editors/space_nla/nla_buttons.c
+++ b/source/blender/editors/space_nla/nla_buttons.c
@@ -309,7 +309,7 @@ static void nla_panel_properties(const bContext *C, Panel *pa)
/* settings */
column= uiLayoutColumn(layout, 1);
- uiLayoutSetActive(column, !(RNA_boolean_get(&strip_ptr, "animated_influence") || RNA_boolean_get(&strip_ptr, "use_animated_time")));
+ uiLayoutSetActive(column, !(RNA_boolean_get(&strip_ptr, "use_animated_influence") || RNA_boolean_get(&strip_ptr, "use_animated_time")));
uiItemL(column, "Playback Settings:", 0);
uiItemR(column, &strip_ptr, "mute", 0, NULL, 0);
uiItemR(column, &strip_ptr, "use_reverse", 0, NULL, 0);
diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c
index f489fc4774f..ef9c46c8042 100644
--- a/source/blender/editors/space_nla/nla_draw.c
+++ b/source/blender/editors/space_nla/nla_draw.c
@@ -64,9 +64,6 @@
#include "nla_intern.h" // own include
-/* XXX */
-extern void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad);
-extern void gl_round_box_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadetop, float shadedown);
/* *********************************************** */
/* Strips */
@@ -347,7 +344,7 @@ static void nla_draw_strip (SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStr
/* draw 'inside' of strip itself */
glColor3fv(color);
uiSetRoundBox(15); /* all corners rounded */
- gl_round_box_shade(GL_POLYGON, strip->start, yminc, strip->end, ymaxc, 0.0, 0.5, 0.1);
+ uiDrawBoxShade(GL_POLYGON, strip->start, yminc, strip->end, ymaxc, 0.0, 0.5, 0.1);
/* draw strip's control 'curves'
@@ -373,7 +370,7 @@ static void nla_draw_strip (SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStr
setlinestyle(4);
/* draw outline */
- gl_round_box_shade(GL_LINE_LOOP, strip->start, yminc, strip->end, ymaxc, 0.0, 0.0, 0.1);
+ uiDrawBoxShade(GL_LINE_LOOP, strip->start, yminc, strip->end, ymaxc, 0.0, 0.0, 0.1);
/* if action-clip strip, draw lines delimiting repeats too (in the same color as outline) */
if ((strip->type == NLASTRIP_TYPE_CLIP) && IS_EQ(strip->repeat, 1.0f)==0) {
@@ -708,7 +705,7 @@ static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, Vie
/* draw slightly shifted up vertically to look like it has more separtion from other channels,
* but we then need to slightly shorten it so that it doesn't look like it overlaps
*/
- gl_round_box(GL_POLYGON, x+offset, yminc+NLACHANNEL_SKIP, (float)v2d->cur.xmax, ymaxc+NLACHANNEL_SKIP-1, 8);
+ uiDrawBox(GL_POLYGON, x+offset, yminc+NLACHANNEL_SKIP, (float)v2d->cur.xmax, ymaxc+NLACHANNEL_SKIP-1, 8);
/* clear group value, otherwise we cause errors... */
group = 0;
diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c
index cc7c966e397..0b33196c646 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -67,7 +67,6 @@
// XXX interface.h
extern void ui_dropshadow(rctf *rct, float radius, float aspect, int select);
-extern void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad);
extern void ui_draw_tria_icon(float x, float y, char dir);
void ED_node_changed_update(ID *id, bNode *node)
@@ -749,7 +748,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
glEnable(GL_BLEND);
glColor4ub(200, 200, 200, 140);
uiSetRoundBox(15-4);
- gl_round_box(GL_LINE_LOOP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, BASIS_RAD);
+ uiDrawBox(GL_LINE_LOOP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, BASIS_RAD);
glDisable(GL_BLEND);
}
@@ -857,7 +856,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
if(node->flag & NODE_ACTIVE) {
glEnable(GL_BLEND);
glColor4ub(200, 200, 200, 140);
- gl_round_box(GL_LINE_LOOP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, hiddenrad);
+ uiDrawBox(GL_LINE_LOOP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, hiddenrad);
glDisable(GL_BLEND);
}
@@ -1009,18 +1008,18 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN
glEnable(GL_BLEND);
uiSetRoundBox(3);
UI_ThemeColorShadeAlpha(TH_NODE_GROUP, 0, -70);
- gl_round_box(GL_POLYGON, rect.xmin, rect.ymax, rect.xmax, rect.ymax+NODE_DY, BASIS_RAD);
+ uiDrawBox(GL_POLYGON, rect.xmin, rect.ymax, rect.xmax, rect.ymax+NODE_DY, BASIS_RAD);
/* backdrop body */
UI_ThemeColorShadeAlpha(TH_BACK, -8, -70);
uiSetRoundBox(12);
- gl_round_box(GL_POLYGON, rect.xmin, rect.ymin, rect.xmax, rect.ymax, BASIS_RAD);
+ uiDrawBox(GL_POLYGON, rect.xmin, rect.ymin, rect.xmax, rect.ymax, BASIS_RAD);
/* selection outline */
uiSetRoundBox(15);
glColor4ub(200, 200, 200, 140);
glEnable( GL_LINE_SMOOTH );
- gl_round_box(GL_LINE_LOOP, rect.xmin, rect.ymin, rect.xmax, rect.ymax+NODE_DY, BASIS_RAD);
+ uiDrawBox(GL_LINE_LOOP, rect.xmin, rect.ymin, rect.xmax, rect.ymax+NODE_DY, BASIS_RAD);
glDisable( GL_LINE_SMOOTH );
glDisable(GL_BLEND);
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index 829c74fd26d..5aa512ea904 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -1919,33 +1919,6 @@ void NODE_OT_read_fullsamplelayers(wmOperatorType *ot)
}
-/* ************************* */
-
-void imagepaint_composite_tags(bNodeTree *ntree, Image *image, ImageUser *iuser)
-{
- bNode *node;
-
- if(ntree==NULL)
- return;
-
- /* search for renderresults */
- if(image->type==IMA_TYPE_R_RESULT) {
- for(node= ntree->nodes.first; node; node= node->next) {
- if(node->type==CMP_NODE_R_LAYERS && node->id==NULL) {
- /* imageuser comes from ImageWin, so indexes are offset 1 */
- if(node->custom1==iuser->layer-1)
- NodeTagChanged(ntree, node);
- }
- }
- }
- else {
- for(node= ntree->nodes.first; node; node= node->next) {
- if(node->id== &image->id)
- NodeTagChanged(ntree, node);
- }
- }
-}
-
/* ****************** Make Group operator ******************* */
static int node_group_make_exec(bContext *C, wmOperator *op)
diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c
index d9a4dda9d6e..c94fcb52e38 100644
--- a/source/blender/editors/space_node/space_node.c
+++ b/source/blender/editors/space_node/space_node.c
@@ -42,6 +42,7 @@
#include "BKE_context.h"
#include "BKE_screen.h"
+#include "BKE_node.h"
#include "ED_render.h"
#include "ED_screen.h"
@@ -158,7 +159,10 @@ static void node_init(struct wmWindowManager *wm, ScrArea *sa)
static void node_area_listener(ScrArea *sa, wmNotifier *wmn)
{
-
+ /* note, ED_area_tag_refresh will re-execute compositor */
+ /* XXX, should edit some to check for the nodeTree type, especially NC_NODE|NA_EDITED which refreshes all types */
+ SpaceNode *snode= sa->spacedata.first;
+
/* preview renders */
switch(wmn->category) {
case NC_SCENE:
@@ -200,6 +204,20 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn)
if (wmn->action == NA_EDITED)
ED_area_tag_refresh(sa);
break;
+
+ case NC_IMAGE:
+ if (wmn->action == NA_EDITED) {
+ if(snode->treetype==NTREE_COMPOSIT) {
+ Scene *scene= wmn->window->screen->scene;
+
+ /* note that NodeTagIDChanged is alredy called by BKE_image_signal() on all
+ * scenes so really this is just to know if the images is used in the compo else
+ * painting on images could become very slow when the compositor is open. */
+ if(NodeTagIDChanged(scene->nodetree, wmn->reference))
+ ED_area_tag_refresh(sa);
+ }
+ }
+ break;
}
}
diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c
index d3db64d6d03..1a46c32713e 100644
--- a/source/blender/editors/space_outliner/space_outliner.c
+++ b/source/blender/editors/space_outliner/space_outliner.c
@@ -120,6 +120,7 @@ static void outliner_main_area_listener(ARegion *ar, wmNotifier *wmn)
ED_region_tag_redraw(ar);
break;
}
+ break;
case NC_GROUP:
/* all actions now, todo: check outliner view mode? */
ED_region_tag_redraw(ar);
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index afd8895edd9..7c6fd83c6aa 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -63,6 +63,7 @@
/* own include */
#include "sequencer_intern.h"
+
#define SEQ_LEFTHANDLE 1
#define SEQ_RIGHTHANDLE 2
@@ -75,19 +76,21 @@ static void draw_shadedstrip(Sequence *seq, char *col, float x1, float y1, float
static void get_seq_color3ubv(Scene *curscene, Sequence *seq, char *col)
{
char blendcol[3];
- float hsv[3], rgb[3];
SolidColorVars *colvars = (SolidColorVars *)seq->effectdata;
switch(seq->type) {
case SEQ_IMAGE:
UI_GetThemeColor3ubv(TH_SEQ_IMAGE, col);
break;
+
case SEQ_META:
UI_GetThemeColor3ubv(TH_SEQ_META, col);
break;
+
case SEQ_MOVIE:
UI_GetThemeColor3ubv(TH_SEQ_MOVIE, col);
break;
+
case SEQ_SCENE:
UI_GetThemeColor3ubv(TH_SEQ_SCENE, col);
@@ -95,24 +98,17 @@ static void get_seq_color3ubv(Scene *curscene, Sequence *seq, char *col)
UI_GetColorPtrBlendShade3ubv(col, col, col, 1.0, 20);
}
break;
-
+
/* transitions */
case SEQ_CROSS:
case SEQ_GAMCROSS:
case SEQ_WIPE:
- /* slightly offset hue to distinguish different effects */
UI_GetThemeColor3ubv(TH_SEQ_TRANSITION, col);
-
- rgb[0] = col[0]/255.0; rgb[1] = col[1]/255.0; rgb[2] = col[2]/255.0;
- rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2);
-
- if (seq->type == SEQ_CROSS) hsv[0]+= 0.04;
- if (seq->type == SEQ_GAMCROSS) hsv[0]+= 0.08;
- if (seq->type == SEQ_WIPE) hsv[0]+= 0.12;
-
- if(hsv[0]>1.0) hsv[0]-=1.0; else if(hsv[0]<0.0) hsv[0]+= 1.0;
- hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2);
- col[0] = (char)(rgb[0]*255); col[1] = (char)(rgb[1]*255); col[2] = (char)(rgb[2]*255);
+
+ /* slightly offset hue to distinguish different effects */
+ if (seq->type == SEQ_CROSS) rgb_byte_set_hue_float_offset(col,0.04);
+ if (seq->type == SEQ_GAMCROSS) rgb_byte_set_hue_float_offset(col,0.08);
+ if (seq->type == SEQ_WIPE) rgb_byte_set_hue_float_offset(col,0.12);
break;
/* effects */
@@ -126,42 +122,37 @@ static void get_seq_color3ubv(Scene *curscene, Sequence *seq, char *col)
case SEQ_OVERDROP:
case SEQ_GLOW:
case SEQ_MULTICAM:
- /* slightly offset hue to distinguish different effects */
UI_GetThemeColor3ubv(TH_SEQ_EFFECT, col);
- rgb[0] = col[0]/255.0; rgb[1] = col[1]/255.0; rgb[2] = col[2]/255.0;
- rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2);
-
- if (seq->type == SEQ_ADD) hsv[0]+= 0.04;
- if (seq->type == SEQ_SUB) hsv[0]+= 0.08;
- if (seq->type == SEQ_MUL) hsv[0]+= 0.12;
- if (seq->type == SEQ_ALPHAOVER) hsv[0]+= 0.16;
- if (seq->type == SEQ_ALPHAUNDER) hsv[0]+= 0.20;
- if (seq->type == SEQ_OVERDROP) hsv[0]+= 0.24;
- if (seq->type == SEQ_GLOW) hsv[0]+= 0.28;
- if (seq->type == SEQ_TRANSFORM) hsv[0]+= 0.36;
-
- if(hsv[0]>1.0) hsv[0]-=1.0; else if(hsv[0]<0.0) hsv[0]+= 1.0;
- hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2);
- col[0] = (char)(rgb[0]*255); col[1] = (char)(rgb[1]*255); col[2] = (char)(rgb[2]*255);
+ /* slightly offset hue to distinguish different effects */
+ if (seq->type == SEQ_ADD) rgb_byte_set_hue_float_offset(col,0.04);
+ if (seq->type == SEQ_SUB) rgb_byte_set_hue_float_offset(col,0.08);
+ if (seq->type == SEQ_MUL) rgb_byte_set_hue_float_offset(col,0.12);
+ if (seq->type == SEQ_ALPHAOVER) rgb_byte_set_hue_float_offset(col,0.16);
+ if (seq->type == SEQ_ALPHAUNDER) rgb_byte_set_hue_float_offset(col,0.20);
+ if (seq->type == SEQ_OVERDROP) rgb_byte_set_hue_float_offset(col,0.24);
+ if (seq->type == SEQ_GLOW) rgb_byte_set_hue_float_offset(col,0.28);
+ if (seq->type == SEQ_TRANSFORM) rgb_byte_set_hue_float_offset(col,0.36);
break;
+
case SEQ_COLOR:
if (colvars->col) {
- col[0]= (char)(colvars->col[0]*255);
- col[1]= (char)(colvars->col[1]*255);
- col[2]= (char)(colvars->col[2]*255);
+ rgb_float_to_byte(colvars->col, col);
} else {
col[0] = col[1] = col[2] = 128;
}
break;
+
case SEQ_PLUGIN:
UI_GetThemeColor3ubv(TH_SEQ_PLUGIN, col);
break;
+
case SEQ_SOUND:
UI_GetThemeColor3ubv(TH_SEQ_AUDIO, col);
blendcol[0] = blendcol[1] = blendcol[2] = 128;
if(seq->flag & SEQ_MUTE) UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.5, 20);
break;
+
default:
col[0] = 10; col[1] = 255; col[2] = 40;
}
@@ -597,8 +588,6 @@ so wave file sample drawing precision is zoom adjusted
*/
static void draw_seq_strip(Scene *scene, ARegion *ar, SpaceSeq *sseq, Sequence *seq, int outline_tint, float pixelx)
{
- // XXX
- extern void gl_round_box_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadetop, float shadedown);
View2D *v2d= &ar->v2d;
float x1, x2, y1, y2;
char col[3], background_col[3], is_single_image;
@@ -655,7 +644,7 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, SpaceSeq *sseq, Sequence *
glLineStipple(1, 0x8888);
}
- gl_round_box_shade(GL_LINE_LOOP, x1, y1, x2, y2, 0.0, 0.1, 0.0);
+ uiDrawBoxShade(GL_LINE_LOOP, x1, y1, x2, y2, 0.0, 0.1, 0.0);
if (seq->flag & SEQ_MUTE) {
glDisable(GL_LINE_STIPPLE);
@@ -694,7 +683,6 @@ void set_special_seq_update(int val)
void draw_image_seq(const bContext* C, Scene *scene, ARegion *ar, SpaceSeq *sseq, int cfra, int frame_ofs)
{
- extern void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad);
struct Main *bmain= CTX_data_main(C);
struct ImBuf *ibuf = 0;
struct ImBuf *scope = 0;
@@ -855,7 +843,7 @@ void draw_image_seq(const bContext* C, Scene *scene, ARegion *ar, SpaceSeq *sseq
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
uiSetRoundBox(15);
- gl_round_box(GL_LINE_LOOP, x1, y1, x2, y2, 12.0);
+ uiDrawBox(GL_LINE_LOOP, x1, y1, x2, y2, 12.0);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c
index 2f3abd3ba0c..de9c063f069 100644
--- a/source/blender/editors/space_time/space_time.c
+++ b/source/blender/editors/space_time/space_time.c
@@ -396,6 +396,7 @@ static void time_listener(ScrArea *sa, wmNotifier *wmn)
switch (wmn->category) {
case NC_OBJECT:
switch (wmn->data) {
+ case ND_BONE_ACTIVE:
case ND_POINTCACHE:
ED_area_tag_refresh(sa);
ED_area_tag_redraw(sa);
diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c
index adff6ffdc65..c6aa4656191 100644
--- a/source/blender/editors/space_view3d/drawarmature.c
+++ b/source/blender/editors/space_view3d/drawarmature.c
@@ -310,7 +310,7 @@ static void drawsolidcube_size(float xsize, float ysize, float zsize)
if(displist==0) {
displist= glGenLists(1);
- glNewList(displist, GL_COMPILE_AND_EXECUTE);
+ glNewList(displist, GL_COMPILE);
glBegin(GL_QUADS);
n[0]= -1.0;
@@ -340,19 +340,17 @@ static void drawsolidcube_size(float xsize, float ysize, float zsize)
glEndList();
}
- else glCallList(displist);
-
+
+ glCallList(displist);
}
static void drawcube_size(float xsize, float ysize, float zsize)
{
static GLuint displist=0;
- glScalef(xsize, ysize, zsize);
-
if(displist == 0) {
displist= glGenLists(1);
- glNewList(displist, GL_COMPILE_AND_EXECUTE);
+ glNewList(displist, GL_COMPILE);
glBegin(GL_LINE_STRIP);
glVertex3fv(cube[0]); glVertex3fv(cube[1]);glVertex3fv(cube[2]); glVertex3fv(cube[3]);
@@ -368,7 +366,9 @@ static void drawcube_size(float xsize, float ysize, float zsize)
glEndList();
}
- else glCallList(displist);
+
+ glScalef(xsize, ysize, zsize);
+ glCallList(displist);
}
@@ -381,7 +381,7 @@ static void draw_bonevert(void)
GLUquadricObj *qobj;
displist= glGenLists(1);
- glNewList(displist, GL_COMPILE_AND_EXECUTE);
+ glNewList(displist, GL_COMPILE);
glPushMatrix();
@@ -400,8 +400,8 @@ static void draw_bonevert(void)
glPopMatrix();
glEndList();
}
- else
- glCallList(displist);
+
+ glCallList(displist);
}
static void draw_bonevert_solid(void)
@@ -412,7 +412,7 @@ static void draw_bonevert_solid(void)
GLUquadricObj *qobj;
displist= glGenLists(1);
- glNewList(displist, GL_COMPILE_AND_EXECUTE);
+ glNewList(displist, GL_COMPILE);
qobj = gluNewQuadric();
gluQuadricDrawStyle(qobj, GLU_FILL);
@@ -423,8 +423,8 @@ static void draw_bonevert_solid(void)
glEndList();
}
- else
- glCallList(displist);
+
+ glCallList(displist);
}
static void draw_bone_octahedral()
@@ -435,7 +435,7 @@ static void draw_bone_octahedral()
float vec[6][3];
displist= glGenLists(1);
- glNewList(displist, GL_COMPILE_AND_EXECUTE);
+ glNewList(displist, GL_COMPILE);
vec[0][0]= vec[0][1]= vec[0][2]= 0.0f;
vec[5][0]= vec[5][2]= 0.0f; vec[5][1]= 1.0f;
@@ -467,8 +467,8 @@ static void draw_bone_octahedral()
glEndList();
}
- else
- glCallList(displist);
+
+ glCallList(displist);
}
static void draw_bone_solid_octahedral(void)
@@ -479,7 +479,7 @@ static void draw_bone_solid_octahedral(void)
float vec[6][3], nor[3];
displist= glGenLists(1);
- glNewList(displist, GL_COMPILE_AND_EXECUTE);
+ glNewList(displist, GL_COMPILE);
vec[0][0]= vec[0][1]= vec[0][2]= 0.0f;
vec[5][0]= vec[5][2]= 0.0f; vec[5][1]= 1.0f;
@@ -529,8 +529,8 @@ static void draw_bone_solid_octahedral(void)
glEndList();
}
- else
- glCallList(displist);
+
+ glCallList(displist);
}
/* *************** Armature drawing, bones ******************* */
@@ -655,6 +655,26 @@ static void draw_sphere_bone_dist(float smat[][4], float imat[][4], int boneflag
mul_mat3_m4_v3(smat, dirvec);
/* clear zcomp */
dirvec[2]= 0.0f;
+
+ if(head != tail) {
+ /* correcyion when viewing along the bones axis
+ * it pops in and out but better then artifacts, [#23841] */
+ float view_dist= len_v2(dirvec);
+
+ if(head - view_dist > tail) {
+ tailvec= headvec;
+ tail = head;
+ zero_v3(dirvec);
+ dirvec[0]= 0.00001; // XXX. weak but ok
+ }
+ else if(tail - view_dist > head) {
+ headvec= tailvec;
+ head = tail;
+ zero_v3(dirvec);
+ dirvec[0]= 0.00001; // XXX. weak but ok
+ }
+ }
+
/* move vector back */
mul_mat3_m4_v3(imat, dirvec);
@@ -1933,7 +1953,7 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, int dt)
if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
- for (eBone=arm->edbo->first, index=0; eBone; eBone=eBone->next, index++) {
+ for (eBone=arm->edbo->first; eBone; eBone=eBone->next) {
if (eBone->layer & arm->layer) {
if ((eBone->flag & (BONE_HIDDEN_A|BONE_NO_DEFORM))==0) {
if (eBone->flag & (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL))
@@ -1949,7 +1969,6 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, int dt)
/* if solid we draw it first */
if ((dt > OB_WIRE) && (arm->drawtype!=ARM_LINE)) {
- index= 0;
for (eBone=arm->edbo->first, index=0; eBone; eBone=eBone->next, index++) {
if (eBone->layer & arm->layer) {
if ((eBone->flag & BONE_HIDDEN_A)==0) {
@@ -2043,6 +2062,7 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, int dt)
}
/* restore */
+ if(index!=-1) glLoadName(-1);
if (arm->drawtype==ARM_LINE);
else if (dt>OB_WIRE) bglPolygonOffset(rv3d->dist, 0.0f);
@@ -2054,7 +2074,7 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, int dt)
if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
- for (eBone=arm->edbo->first, index=0; eBone; eBone=eBone->next, index++) {
+ for (eBone=arm->edbo->first; eBone; eBone=eBone->next) {
if(eBone->layer & arm->layer) {
if ((eBone->flag & BONE_HIDDEN_A)==0) {
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 17516f6a40c..fa394ff708a 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -974,7 +974,6 @@ static void drawviewborder_flymode(ARegion *ar)
static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
{
- extern void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad); // interface_panel.c
float fac, a;
float x1, x2, y1, y2;
float x1i, x2i, y1i, y2i;
@@ -1061,7 +1060,7 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0);
uiSetRoundBox(15);
- gl_round_box(GL_LINE_LOOP, x1, y1, x2, y2, 12.0);
+ uiDrawBox(GL_LINE_LOOP, x1, y1, x2, y2, 12.0);
}
setlinestyle(0);
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index 966fac1a3bd..cc1d26b136e 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -630,6 +630,7 @@ static void do_lasso_select_armature(ViewContext *vc, short mcords[][2], short m
EditBone *ebone;
float vec[3];
short sco1[2], sco2[2], didpoint;
+ int change= FALSE;
/* set editdata in vc */
@@ -645,20 +646,27 @@ static void do_lasso_select_armature(ViewContext *vc, short mcords[][2], short m
if(select) ebone->flag |= BONE_ROOTSEL;
else ebone->flag &= ~BONE_ROOTSEL;
didpoint= 1;
+ change= TRUE;
}
if(lasso_inside(mcords, moves, sco2[0], sco2[1])) {
if(select) ebone->flag |= BONE_TIPSEL;
else ebone->flag &= ~BONE_TIPSEL;
didpoint= 1;
+ change= TRUE;
}
/* if one of points selected, we skip the bone itself */
if(didpoint==0 && lasso_inside_edge(mcords, moves, sco1[0], sco1[1], sco2[0], sco2[1])) {
if(select) ebone->flag |= BONE_TIPSEL|BONE_ROOTSEL|BONE_SELECTED;
else ebone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
+ change= TRUE;
}
}
- ED_armature_sync_selection(arm->edbo);
- ED_armature_validate_active(arm);
+
+ if(change) {
+ ED_armature_sync_selection(arm->edbo);
+ ED_armature_validate_active(arm);
+ WM_main_add_notifier(NC_OBJECT|ND_BONE_SELECT, vc->obedit);
+ }
}
static void do_lasso_select_facemode(ViewContext *vc, short mcords[][2], short moves, short select)
@@ -1593,6 +1601,7 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op)
}
ED_armature_sync_selection(arm->edbo);
+ WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, vc.obedit);
}
else if(obedit->type==OB_LATTICE) {
do_lattice_box_select(&vc, &rect, selecting, extend);
@@ -1985,6 +1994,7 @@ static void armature_circle_select(ViewContext *vc, int selecting, short *mval,
struct {ViewContext *vc; short select, mval[2]; float radius; } data;
bArmature *arm= vc->obedit->data;
EditBone *ebone;
+ int change= FALSE;
/* set vc->edit data */
data.select = selecting;
@@ -2023,10 +2033,14 @@ static void armature_circle_select(ViewContext *vc, int selecting, short *mval,
ebone->flag |= BONE_TIPSEL|BONE_ROOTSEL|BONE_SELECTED;
else
ebone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
+ change= TRUE;
}
}
- ED_armature_validate_active(arm);
+ if(change) {
+ ED_armature_validate_active(arm);
+ WM_main_add_notifier(NC_OBJECT|ND_BONE_SELECT, vc->obedit);
+ }
}
/** Callbacks for circle selection in Editmode */
diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c
index b2d6fe4ea34..0187a3b3567 100644
--- a/source/blender/editors/transform/transform_ops.c
+++ b/source/blender/editors/transform/transform_ops.c
@@ -752,7 +752,7 @@ void TRANSFORM_OT_transform(struct wmOperatorType *ot)
{TFM_PUSHPULL, "PUSHPULL", 0, "Pushpull", ""},
{TFM_CREASE, "CREASE", 0, "Crease", ""},
{TFM_MIRROR, "MIRROR", 0, "Mirror", ""},
- {TFM_BONESIZE, "BONESIZE", 0, "Bonesize", ""},
+ {TFM_BONESIZE, "BONE_SIZE", 0, "Bonesize", ""},
{TFM_BONE_ENVELOPE, "BONE_ENVELOPE", 0, "Bone_Envelope", ""},
{TFM_CURVE_SHRINKFATTEN, "CURVE_SHRINKFATTEN", 0, "Curve_Shrinkfatten", ""},
{TFM_BONE_ROLL, "BONE_ROLL", 0, "Bone_Roll", ""},
diff --git a/source/blender/ikplugin/BIK_api.h b/source/blender/ikplugin/BIK_api.h
index 0f0703486a3..0f4fea89c37 100644
--- a/source/blender/ikplugin/BIK_api.h
+++ b/source/blender/ikplugin/BIK_api.h
@@ -73,7 +73,6 @@ int BIK_get_solver_param(struct bPose *pose, struct bPoseChannel *pchan, int id,
// number of solver available
// 0 = iksolver
// 1 = iTaSC
-#define BIK_SOLVER_COUNT 2
/* for use in BIK_get_constraint_param */
#define BIK_PARAM_CONSTRAINT_ERROR 0
diff --git a/source/blender/ikplugin/CMakeLists.txt b/source/blender/ikplugin/CMakeLists.txt
index ef1f4d450b9..79f33effb87 100644
--- a/source/blender/ikplugin/CMakeLists.txt
+++ b/source/blender/ikplugin/CMakeLists.txt
@@ -24,12 +24,27 @@
#
# ***** END GPL LICENSE BLOCK *****
-FILE(GLOB SRC intern/*.c intern/*.cpp)
+
+SET(SRC
+ ./intern/ikplugin_api.c
+ ./intern/iksolver_plugin.c
+)
SET(INC
- ../../../intern/guardedalloc ../../../intern/iksolver/extern
- ../../../intern/itasc ../../../extern/Eigen2
- ../blenlib ../makesdna ../blenkernel ../include ../ikplugin
+ ../blenlib
+ ../makesdna
+ ../blenkernel
+ ../include
+ ../ikplugin
+ ../../../intern/guardedalloc
+ ../../../intern/iksolver/extern
)
+IF(WITH_IK_ITASC)
+ ADD_DEFINITIONS(-DWITH_IK_ITASC)
+ LIST(APPEND INC ../../../extern/Eigen2)
+ LIST(APPEND INC ../../../intern/itasc)
+ LIST(APPEND SRC ./intern/itasc_plugin.cpp)
+ENDIF(WITH_IK_ITASC)
+
BLENDERLIB(bf_ikplugin "${SRC}" "${INC}")
diff --git a/source/blender/ikplugin/SConscript b/source/blender/ikplugin/SConscript
index a745a93077a..f60c42f8dc9 100644
--- a/source/blender/ikplugin/SConscript
+++ b/source/blender/ikplugin/SConscript
@@ -1,9 +1,11 @@
#!/usr/bin/python
Import ('env')
-
+defs = []
sources = env.Glob('intern/*.c') + env.Glob('intern/*.cpp')
incs = '#/intern/guardedalloc #/intern/iksolver/extern ../makesdna ../blenlib'
incs += ' ../blenkernel ../include ../ikplugin #/intern/itasc #/extern/Eigen2'
-env.BlenderLib ( 'bf_ikplugin', sources, Split(incs), [], libtype=['core','player'], priority=[180, 190] )
+defs.append('WITH_IK_ITASC')
+
+env.BlenderLib ( 'bf_ikplugin', sources, Split(incs), defs, libtype=['core','player'], priority=[180, 190] )
diff --git a/source/blender/ikplugin/intern/Makefile b/source/blender/ikplugin/intern/Makefile
index 352ab90df9d..12e2366b28e 100644
--- a/source/blender/ikplugin/intern/Makefile
+++ b/source/blender/ikplugin/intern/Makefile
@@ -30,6 +30,9 @@ DIR = $(OCGDIR)/blender/ikplugin
include nan_compile.mk
+CFLAGS += -DWITH_IK_ITASC
+CPPFLAGS += -DWITH_IK_ITASC
+
CFLAGS += $(LEVEL_1_C_WARNINGS)
CFLAGS += -I$(NAN_GUARDEDALLOC)/include
CFLAGS += -I../../makesdna
diff --git a/source/blender/ikplugin/intern/ikplugin_api.c b/source/blender/ikplugin/intern/ikplugin_api.c
index cdc4ee11518..c3310e77ad6 100644
--- a/source/blender/ikplugin/intern/ikplugin_api.c
+++ b/source/blender/ikplugin/intern/ikplugin_api.c
@@ -42,10 +42,12 @@
#include "ikplugin_api.h"
#include "iksolver_plugin.h"
-#include "itasc_plugin.h"
+#ifdef WITH_IK_ITASC
+#include "itasc_plugin.h"
+#endif
-static IKPlugin ikplugin_tab[BIK_SOLVER_COUNT] = {
+static IKPlugin ikplugin_tab[] = {
/* Legacy IK solver */
{
iksolver_initialize_tree,
@@ -55,6 +57,7 @@ static IKPlugin ikplugin_tab[BIK_SOLVER_COUNT] = {
NULL,
NULL,
NULL,
+#ifdef WITH_IK_ITASC
},
/* iTaSC IK solver */
{
@@ -65,13 +68,13 @@ static IKPlugin ikplugin_tab[BIK_SOLVER_COUNT] = {
itasc_clear_cache,
itasc_update_param,
itasc_test_constraint,
+#endif
}
};
-
static IKPlugin *get_plugin(bPose *pose)
{
- if (!pose || pose->iksolver < 0 || pose->iksolver >= BIK_SOLVER_COUNT)
+ if (!pose || pose->iksolver < 0 || pose->iksolver >= (sizeof(ikplugin_tab) / sizeof(IKPlugin)))
return NULL;
return &ikplugin_tab[pose->iksolver];
@@ -135,3 +138,4 @@ void BIK_test_constraint(struct Object *ob, struct bConstraint *cons)
if (plugin && plugin->test_constraint)
plugin->test_constraint(ob, cons);
}
+
diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp
index af69cb9a996..7bdc327afa1 100644
--- a/source/blender/ikplugin/intern/itasc_plugin.cpp
+++ b/source/blender/ikplugin/intern/itasc_plugin.cpp
@@ -32,6 +32,7 @@
#include <vector>
// iTaSC headers
+#ifdef WITH_IK_ITASC
#include "Armature.hpp"
#include "MovingFrame.hpp"
#include "CopyPose.hpp"
@@ -40,6 +41,7 @@
#include "Scene.hpp"
#include "Cache.hpp"
#include "Distance.hpp"
+#endif
#include "MEM_guardedalloc.h"
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h
index 07b99dddfa5..c39c5d31f80 100644
--- a/source/blender/imbuf/IMB_imbuf.h
+++ b/source/blender/imbuf/IMB_imbuf.h
@@ -93,7 +93,7 @@ void IMB_exit(void);
*
* @attention Defined in readimage.c
*/
-struct ImBuf *IMB_ibImageFromMemory(unsigned char *mem, int size, int flags);
+struct ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, int flags);
/**
*
diff --git a/source/blender/imbuf/intern/IMB_filetype.h b/source/blender/imbuf/intern/IMB_filetype.h
index 9fd4108bee9..8529c72c7ae 100644
--- a/source/blender/imbuf/intern/IMB_filetype.h
+++ b/source/blender/imbuf/intern/IMB_filetype.h
@@ -37,9 +37,9 @@ typedef struct ImFileType {
int (*is_a)(unsigned char *buf);
int (*ftype)(struct ImFileType *type, struct ImBuf *ibuf);
- struct ImBuf *(*load)(unsigned char *mem, int size, int flags);
+ struct ImBuf *(*load)(unsigned char *mem, size_t size, int flags);
int (*save)(struct ImBuf *ibuf, char *name, int flags);
- void (*load_tile)(struct ImBuf *ibuf, unsigned char *mem, int size, int tx, int ty, unsigned int *rect);
+ void (*load_tile)(struct ImBuf *ibuf, unsigned char *mem, size_t size, int tx, int ty, unsigned int *rect);
int flag;
int filetype;
@@ -60,59 +60,59 @@ void imb_tile_cache_tile_free(struct ImBuf *ibuf, int tx, int ty);
/* png */
int imb_is_a_png(unsigned char *buf);
-struct ImBuf *imb_loadpng(unsigned char *mem, int size, int flags);
+struct ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags);
int imb_savepng(struct ImBuf *ibuf, char *name, int flags);
/* targa */
int imb_is_a_targa(unsigned char *buf);
-struct ImBuf *imb_loadtarga(unsigned char *mem, int size, int flags);
+struct ImBuf *imb_loadtarga(unsigned char *mem, size_t size, int flags);
int imb_savetarga(struct ImBuf * ibuf, char *name, int flags);
/* iris */
int imb_is_a_iris(unsigned char *mem);
-struct ImBuf *imb_loadiris(unsigned char *mem, int size, int flags);
+struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags);
int imb_saveiris(struct ImBuf * ibuf, char *name, int flags);
/* jp2 */
int imb_is_a_jp2(unsigned char *buf);
-struct ImBuf *imb_jp2_decode(unsigned char *mem, int size, int flags);
+struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags);
int imb_savejp2(struct ImBuf *ibuf, char *name, int flags);
/* jpeg */
int imb_is_a_jpeg(unsigned char *mem);
int imb_savejpeg(struct ImBuf * ibuf, char * name, int flags);
struct ImBuf * imb_ibJpegImageFromFilename (const char * filename, int flags);
-struct ImBuf * imb_load_jpeg (unsigned char * buffer, int size, int flags);
+struct ImBuf * imb_load_jpeg (unsigned char * buffer, size_t size, int flags);
/* bmp */
int imb_is_a_bmp(unsigned char *buf);
-struct ImBuf *imb_bmp_decode(unsigned char *mem, int size, int flags);
+struct ImBuf *imb_bmp_decode(unsigned char *mem, size_t size, int flags);
int imb_savebmp(struct ImBuf *ibuf, char *name, int flags);
/* cocoa */
-struct ImBuf *imb_cocoaLoadImage(unsigned char *mem, int size, int flags);
+struct ImBuf *imb_cocoaLoadImage(unsigned char *mem, size_t size, int flags);
short imb_cocoaSaveImage(struct ImBuf *ibuf, char *name, int flags);
/* cineon */
int imb_savecineon(struct ImBuf *buf, char *myfil, int flags);
-struct ImBuf *imb_loadcineon(unsigned char *mem, int size, int flags);
+struct ImBuf *imb_loadcineon(unsigned char *mem, size_t size, int flags);
int imb_is_cineon(unsigned char *buf);
/* dpx */
int imb_save_dpx(struct ImBuf *buf, char *myfile, int flags);
-struct ImBuf *imb_loaddpx(unsigned char *mem, int size, int flags);
+struct ImBuf *imb_loaddpx(unsigned char *mem, size_t size, int flags);
int imb_is_dpx(unsigned char *buf);
/* hdr */
int imb_is_a_hdr(unsigned char *buf);
-struct ImBuf *imb_loadhdr(unsigned char *mem, int size, int flags);
+struct ImBuf *imb_loadhdr(unsigned char *mem, size_t size, int flags);
int imb_savehdr(struct ImBuf * ibuf, char *name, int flags);
/* tiff */
void imb_inittiff(void);
int imb_is_a_tiff(unsigned char *buf);
-struct ImBuf *imb_loadtiff(unsigned char *mem, int size, int flags);
-void imb_loadtiletiff(struct ImBuf *ibuf, unsigned char *mem, int size,
+struct ImBuf *imb_loadtiff(unsigned char *mem, size_t size, int flags);
+void imb_loadtiletiff(struct ImBuf *ibuf, unsigned char *mem, size_t size,
int tx, int ty, unsigned int *rect);
int imb_savetiff(struct ImBuf *ibuf, char *name, int flags);
void *libtiff_findsymbol(char *name);
diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c
index 3f440c0bf6f..02fc98f2d63 100644
--- a/source/blender/imbuf/intern/allocimbuf.c
+++ b/source/blender/imbuf/intern/allocimbuf.c
@@ -32,6 +32,8 @@
/* It's become a bit messy... Basically, only the IMB_ prefixed files
* should remain. */
+#include <stddef.h>
+
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
diff --git a/source/blender/imbuf/intern/bmp.c b/source/blender/imbuf/intern/bmp.c
index bdcf60090c3..450b09c923b 100644
--- a/source/blender/imbuf/intern/bmp.c
+++ b/source/blender/imbuf/intern/bmp.c
@@ -101,7 +101,7 @@ int imb_is_a_bmp(unsigned char *buf) {
return checkbmp(buf);
}
-struct ImBuf *imb_bmp_decode(unsigned char *mem, int size, int flags)
+struct ImBuf *imb_bmp_decode(unsigned char *mem, size_t size, int flags)
{
struct ImBuf *ibuf = 0;
BMPINFOHEADER bmi;
diff --git a/source/blender/imbuf/intern/dds/dds_api.cpp b/source/blender/imbuf/intern/dds/dds_api.cpp
index 9a106253397..2e224893271 100644
--- a/source/blender/imbuf/intern/dds/dds_api.cpp
+++ b/source/blender/imbuf/intern/dds/dds_api.cpp
@@ -22,6 +22,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
+#include <stddef.h>
#include <dds_api.h>
#include <Stream.h>
#include <DirectDrawSurface.h>
@@ -64,7 +65,7 @@ int imb_is_a_dds(unsigned char *mem) // note: use at most first 32 bytes
return(1);
}
-struct ImBuf *imb_load_dds(unsigned char *mem, int size, int flags)
+struct ImBuf *imb_load_dds(unsigned char *mem, size_t size, int flags)
{
struct ImBuf * ibuf = 0;
DirectDrawSurface dds(mem, size); /* reads header */
diff --git a/source/blender/imbuf/intern/dds/dds_api.h b/source/blender/imbuf/intern/dds/dds_api.h
index 6d9fa0839dd..384570ceb72 100644
--- a/source/blender/imbuf/intern/dds/dds_api.h
+++ b/source/blender/imbuf/intern/dds/dds_api.h
@@ -31,7 +31,7 @@ extern "C" {
int imb_save_dds(struct ImBuf *ibuf, char *name, int flags);
int imb_is_a_dds(unsigned char *mem); /* use only first 32 bytes of mem */
-struct ImBuf *imb_load_dds(unsigned char *mem, int size, int flags);
+struct ImBuf *imb_load_dds(unsigned char *mem, size_t size, int flags);
#ifdef __cplusplus
}
diff --git a/source/blender/imbuf/intern/filetype.c b/source/blender/imbuf/intern/filetype.c
index db2eef759dc..fb5d2f2e4d7 100644
--- a/source/blender/imbuf/intern/filetype.c
+++ b/source/blender/imbuf/intern/filetype.c
@@ -22,6 +22,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
+#include <stddef.h>
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
#include "IMB_filetype.h"
diff --git a/source/blender/imbuf/intern/iris.c b/source/blender/imbuf/intern/iris.c
index c676c401ccd..883de823745 100644
--- a/source/blender/imbuf/intern/iris.c
+++ b/source/blender/imbuf/intern/iris.c
@@ -244,7 +244,7 @@ int imb_is_a_iris(unsigned char *mem)
*
*/
-struct ImBuf *imb_loadiris(unsigned char *mem, int size, int flags)
+struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags)
{
unsigned int *base, *lptr = NULL;
float *fbase, *fptr = NULL;
diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c
index 558eaedf8b2..a70c154014a 100644
--- a/source/blender/imbuf/intern/jp2.c
+++ b/source/blender/imbuf/intern/jp2.c
@@ -90,7 +90,7 @@ void info_callback(const char *msg, void *client_data) {
-struct ImBuf *imb_jp2_decode(unsigned char *mem, int size, int flags)
+struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags)
{
struct ImBuf *ibuf = 0;
int use_float = 0; /* for precision higher then 8 use float */
diff --git a/source/blender/imbuf/intern/jpeg.c b/source/blender/imbuf/intern/jpeg.c
index 2bae7228220..855c0bf3433 100644
--- a/source/blender/imbuf/intern/jpeg.c
+++ b/source/blender/imbuf/intern/jpeg.c
@@ -58,7 +58,7 @@ static void init_source(j_decompress_ptr cinfo);
static boolean fill_input_buffer(j_decompress_ptr cinfo);
static void skip_input_data(j_decompress_ptr cinfo, long num_bytes);
static void term_source(j_decompress_ptr cinfo);
-static void memory_source(j_decompress_ptr cinfo, unsigned char *buffer, int size);
+static void memory_source(j_decompress_ptr cinfo, unsigned char *buffer, size_t size);
static boolean handle_app1 (j_decompress_ptr cinfo);
static ImBuf * ibJpegImageFromCinfo(struct jpeg_decompress_struct * cinfo, int flags);
@@ -167,7 +167,7 @@ static void term_source(j_decompress_ptr cinfo)
{
}
-static void memory_source(j_decompress_ptr cinfo, unsigned char *buffer, int size)
+static void memory_source(j_decompress_ptr cinfo, unsigned char *buffer, size_t size)
{
my_src_ptr src;
@@ -459,7 +459,7 @@ ImBuf * imb_ibJpegImageFromFilename (const char * filename, int flags)
return(ibuf);
}
-ImBuf * imb_load_jpeg (unsigned char * buffer, int size, int flags)
+ImBuf * imb_load_jpeg (unsigned char * buffer, size_t size, int flags)
{
struct jpeg_decompress_struct _cinfo, *cinfo = &_cinfo;
struct my_error_mgr jerr;
diff --git a/source/blender/imbuf/intern/module.c b/source/blender/imbuf/intern/module.c
index 5438066d164..f291c0de776 100644
--- a/source/blender/imbuf/intern/module.c
+++ b/source/blender/imbuf/intern/module.c
@@ -22,6 +22,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
+#include <stddef.h>
#include "IMB_imbuf.h"
#include "IMB_filetype.h"
diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp
index 9b68e0e45eb..4107f051d73 100644
--- a/source/blender/imbuf/intern/openexr/openexr_api.cpp
+++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp
@@ -93,7 +93,7 @@ class Mem_IStream: public IStream
{
public:
- Mem_IStream (unsigned char *exrbuf, int exrsize):
+ Mem_IStream (unsigned char *exrbuf, size_t exrsize):
IStream("dummy"), _exrpos (0), _exrsize(exrsize) { _exrbuf = exrbuf; }
virtual bool read (char c[], int n);
@@ -943,7 +943,7 @@ static int exr_is_renderresult(InputFile *file)
return 0;
}
-struct ImBuf *imb_load_openexr(unsigned char *mem, int size, int flags)
+struct ImBuf *imb_load_openexr(unsigned char *mem, size_t size, int flags)
{
struct ImBuf *ibuf = NULL;
InputFile *file = NULL;
diff --git a/source/blender/imbuf/intern/openexr/openexr_api.h b/source/blender/imbuf/intern/openexr/openexr_api.h
index c23b47d1480..c7e4c7d2f57 100644
--- a/source/blender/imbuf/intern/openexr/openexr_api.h
+++ b/source/blender/imbuf/intern/openexr/openexr_api.h
@@ -48,7 +48,7 @@ int imb_is_a_openexr (unsigned char *mem);
int imb_save_openexr (struct ImBuf *ibuf, char *name, int flags);
-struct ImBuf *imb_load_openexr (unsigned char *mem, int size, int flags);
+struct ImBuf *imb_load_openexr (unsigned char *mem, size_t size, int flags);
#ifdef __cplusplus
}
diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c
index 6344b227174..6b21f20b3fb 100644
--- a/source/blender/imbuf/intern/png.c
+++ b/source/blender/imbuf/intern/png.c
@@ -286,7 +286,7 @@ int imb_savepng(struct ImBuf *ibuf, char *name, int flags)
return(1);
}
-struct ImBuf *imb_loadpng(unsigned char *mem, int size, int flags)
+struct ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags)
{
struct ImBuf *ibuf = 0;
png_structp png_ptr;
@@ -317,7 +317,7 @@ struct ImBuf *imb_loadpng(unsigned char *mem, int size, int flags)
return 0;
}
- ps.size = size;
+ ps.size = size; /* XXX, 4gig limit! */
ps.data = mem;
ps.seek = 0;
diff --git a/source/blender/imbuf/intern/radiance_hdr.c b/source/blender/imbuf/intern/radiance_hdr.c
index c5122ebe46c..4064246c866 100644
--- a/source/blender/imbuf/intern/radiance_hdr.c
+++ b/source/blender/imbuf/intern/radiance_hdr.c
@@ -173,7 +173,7 @@ int imb_is_a_hdr(unsigned char *buf)
return 0;
}
-struct ImBuf *imb_loadhdr(unsigned char *mem, int size, int flags)
+struct ImBuf *imb_loadhdr(unsigned char *mem, size_t size, int flags)
{
struct ImBuf* ibuf;
RGBE* sline;
diff --git a/source/blender/imbuf/intern/readimage.c b/source/blender/imbuf/intern/readimage.c
index 3f4e177c78b..a56007f15f0 100644
--- a/source/blender/imbuf/intern/readimage.c
+++ b/source/blender/imbuf/intern/readimage.c
@@ -46,7 +46,7 @@
#include "IMB_imbuf.h"
#include "IMB_filetype.h"
-ImBuf *IMB_ibImageFromMemory(unsigned char *mem, int size, int flags)
+ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, int flags)
{
ImBuf *ibuf;
ImFileType *type;
@@ -79,7 +79,7 @@ ImBuf *IMB_loadifffile(int file, int flags)
{
ImBuf *ibuf;
unsigned char *mem;
- int size;
+ size_t size;
if(file == -1) return 0;
@@ -166,7 +166,7 @@ static void imb_loadtilefile(ImBuf *ibuf, int file, int tx, int ty, unsigned int
{
ImFileType *type;
unsigned char *mem;
- int size;
+ size_t size;
if(file == -1) return;
diff --git a/source/blender/imbuf/intern/targa.c b/source/blender/imbuf/intern/targa.c
index b5434b85b5a..ada1f448bfc 100644
--- a/source/blender/imbuf/intern/targa.c
+++ b/source/blender/imbuf/intern/targa.c
@@ -359,7 +359,7 @@ static void complete_partial_load(struct ImBuf *ibuf, unsigned int *rect)
}
}
-static void decodetarga(struct ImBuf *ibuf, unsigned char *mem, int mem_size, int psize)
+static void decodetarga(struct ImBuf *ibuf, unsigned char *mem, size_t mem_size, int psize)
{
unsigned char *mem_end = mem+mem_size;
int count, col, size;
@@ -470,7 +470,7 @@ partial_load:
complete_partial_load(ibuf, rect);
}
-static void ldtarga(struct ImBuf * ibuf,unsigned char * mem, int mem_size, int psize)
+static void ldtarga(struct ImBuf * ibuf,unsigned char * mem, size_t mem_size, int psize)
{
unsigned char *mem_end = mem+mem_size;
int col,size;
@@ -527,7 +527,7 @@ partial_load:
}
-struct ImBuf *imb_loadtarga(unsigned char *mem, int mem_size, int flags)
+struct ImBuf *imb_loadtarga(unsigned char *mem, size_t mem_size, int flags)
{
TARGA tga;
struct ImBuf * ibuf;
diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c
index 6b94583f17d..5b77c6c7c36 100644
--- a/source/blender/imbuf/intern/tiff.c
+++ b/source/blender/imbuf/intern/tiff.c
@@ -262,7 +262,7 @@ static toff_t imb_tiff_SizeProc(thandle_t handle)
return (toff_t)(mfile->size);
}
-static TIFF *imb_tiff_client_open(ImbTIFFMemFile *memFile, unsigned char *mem, int size)
+static TIFF *imb_tiff_client_open(ImbTIFFMemFile *memFile, unsigned char *mem, size_t size)
{
/* open the TIFF client layer interface to the in-memory file */
memFile->mem = mem;
@@ -464,7 +464,7 @@ void imb_inittiff(void)
*
* @return: A newly allocated ImBuf structure if successful, otherwise NULL.
*/
-ImBuf *imb_loadtiff(unsigned char *mem, int size, int flags)
+ImBuf *imb_loadtiff(unsigned char *mem, size_t size, int flags)
{
TIFF *image = NULL;
ImBuf *ibuf = NULL, *hbuf;
@@ -573,7 +573,7 @@ ImBuf *imb_loadtiff(unsigned char *mem, int size, int flags)
return ibuf;
}
-void imb_loadtiletiff(ImBuf *ibuf, unsigned char *mem, int size, int tx, int ty, unsigned int *rect)
+void imb_loadtiletiff(ImBuf *ibuf, unsigned char *mem, size_t size, int tx, int ty, unsigned int *rect)
{
TIFF *image = NULL;
uint32 width, height;
diff --git a/source/blender/makesdna/DNA_boid_types.h b/source/blender/makesdna/DNA_boid_types.h
index 8584b5f99e9..c4324612aff 100644
--- a/source/blender/makesdna/DNA_boid_types.h
+++ b/source/blender/makesdna/DNA_boid_types.h
@@ -187,8 +187,8 @@ typedef struct BoidState {
typedef struct BoidSettings {
int options, last_state_id;
- float landing_smoothness, rt;
- float banking, height;
+ float landing_smoothness, height;
+ float banking, pitch;
float health, aggression;
float strength, accuracy, range;
diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c
index f2abe690218..d42cf625898 100644
--- a/source/blender/makesrna/intern/rna_armature.c
+++ b/source/blender/makesrna/intern/rna_armature.c
@@ -24,6 +24,8 @@
#include <stdlib.h>
+#include "BLI_math.h"
+
#include "RNA_define.h"
#include "rna_internal.h"
@@ -37,8 +39,6 @@
#ifdef RNA_RUNTIME
-#include "BLI_math.h"
-
#include "BKE_context.h"
#include "BKE_depsgraph.h"
#include "BKE_idprop.h"
@@ -468,16 +468,18 @@ static void rna_def_bone_common(StructRNA *srna, int editbone)
RNA_def_property_ui_text(prop, "Envelope Deform Weight", "Bone deformation weight (for Envelope deform only)");
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
- prop= RNA_def_property(srna, "head_radius", PROP_FLOAT, PROP_NONE);
+ prop= RNA_def_property(srna, "head_radius", PROP_FLOAT, PROP_UNSIGNED);
if(editbone) RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update");
RNA_def_property_float_sdna(prop, NULL, "rad_head");
//RNA_def_property_range(prop, 0, 1000); // XXX range is 0 to lim, where lim= 10000.0f*MAX2(1.0, view3d->grid);
+ RNA_def_property_ui_range(prop, 0.01, 100, 0.1, 3);
RNA_def_property_ui_text(prop, "Envelope Head Radius", "Radius of head of bone (for Envelope deform only)");
- prop= RNA_def_property(srna, "tail_radius", PROP_FLOAT, PROP_NONE);
+ prop= RNA_def_property(srna, "tail_radius", PROP_FLOAT, PROP_UNSIGNED);
if(editbone) RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update");
RNA_def_property_float_sdna(prop, NULL, "rad_tail");
//RNA_def_property_range(prop, 0, 1000); // XXX range is 0 to lim, where lim= 10000.0f*MAX2(1.0, view3d->grid);
+ RNA_def_property_ui_range(prop, 0.01, 100, 0.1, 3);
RNA_def_property_ui_text(prop, "Envelope Tail Radius", "Radius of tail of bone (for Envelope deform only)");
/* b-bones deform settings */
@@ -538,6 +540,16 @@ static void rna_def_bone(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_SELECTED);
RNA_def_property_ui_text(prop, "Select", "");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
+
+ prop= RNA_def_property(srna, "select_head", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_ROOTSEL);
+ RNA_def_property_ui_text(prop, "Select Head", "");
+ RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
+
+ prop= RNA_def_property(srna, "select_tail", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_TIPSEL);
+ RNA_def_property_ui_text(prop, "Select Tail", "");
+ RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
/* XXX better matrix descriptions possible (Arystan) */
prop= RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX);
@@ -569,6 +581,8 @@ static void rna_def_bone(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "arm_head");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Armature-Relative Head", "Location of head end of the bone relative to armature");
+
+ RNA_api_bone(srna);
}
static void rna_def_edit_bone(BlenderRNA *brna)
@@ -591,8 +605,9 @@ static void rna_def_edit_bone(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Parent", "Parent edit bone (in same Armature)");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
- prop= RNA_def_property(srna, "roll", PROP_FLOAT, PROP_NONE);
+ prop= RNA_def_property(srna, "roll", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "roll");
+ RNA_def_property_ui_range(prop, -M_PI * 2, M_PI * 2, 0.1, 2);
RNA_def_property_ui_text(prop, "Roll", "Bone rotation around head-tail axis");
RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update");
diff --git a/source/blender/makesrna/intern/rna_armature_api.c b/source/blender/makesrna/intern/rna_armature_api.c
index cd78bd6e578..4e161e5b22e 100644
--- a/source/blender/makesrna/intern/rna_armature_api.c
+++ b/source/blender/makesrna/intern/rna_armature_api.c
@@ -36,7 +36,7 @@
#include <stddef.h>
#include "BLI_blenlib.h"
-
+#include "BKE_armature.h"
void rna_EditBone_align_roll(EditBone *ebo, float *no)
{
@@ -48,6 +48,12 @@ void rna_EditBone_align_roll(EditBone *ebo, float *no)
}
}
+float rna_Bone_do_envelope(Bone *bone, float *vec)
+{
+ float scale = (bone->flag & BONE_MULT_VG_ENV) == BONE_MULT_VG_ENV ? bone->weight : 1.0f;
+ return distfactor_to_bone(vec, bone->head, bone->tail, bone->rad_head * scale, bone->rad_tail * scale, bone->dist * scale);
+}
+
#else
void RNA_api_armature_edit_bone(StructRNA *srna)
@@ -61,4 +67,18 @@ void RNA_api_armature_edit_bone(StructRNA *srna)
RNA_def_property_flag(parm, PROP_REQUIRED);
}
+void RNA_api_bone(StructRNA *srna)
+{
+ PropertyRNA *parm;
+ FunctionRNA *func;
+
+ func= RNA_def_function(srna, "evaluate_envelope", "rna_Bone_do_envelope");
+ RNA_def_function_ui_description(func, "Calculate bone envelope at given point.");
+ parm= RNA_def_float_vector_xyz(func, "point", 3, NULL, -FLT_MAX, FLT_MAX, "Point", "Position in 3d space to evaluate", -FLT_MAX, FLT_MAX);
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+ /* return value */
+ parm= RNA_def_float(func, "factor", 0, -FLT_MAX, FLT_MAX, "Factor", "Envelope factor", -FLT_MAX, FLT_MAX);
+ RNA_def_function_return(func, parm);
+}
+
#endif
diff --git a/source/blender/makesrna/intern/rna_boid.c b/source/blender/makesrna/intern/rna_boid.c
index 3afa135d079..8cd6fcbeff9 100644
--- a/source/blender/makesrna/intern/rna_boid.c
+++ b/source/blender/makesrna/intern/rna_boid.c
@@ -480,6 +480,12 @@ static void rna_def_boid_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Banking", "Amount of rotation around velocity vector on turns");
RNA_def_property_update(prop, 0, "rna_Boids_reset");
+ prop= RNA_def_property(srna, "pitch", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "pitch");
+ RNA_def_property_range(prop, 0.0, 2.0);
+ RNA_def_property_ui_text(prop, "Pitch", "Amount of rotation around side vector");
+ RNA_def_property_update(prop, 0, "rna_Boids_reset");
+
prop= RNA_def_property(srna, "height", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0.0, 2.0);
RNA_def_property_ui_text(prop, "Height", "Boid height relative to particle size");
diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c
index 7dffa4aec74..ec089d69d91 100644
--- a/source/blender/makesrna/intern/rna_image.c
+++ b/source/blender/makesrna/intern/rna_image.c
@@ -242,13 +242,13 @@ static void rna_def_imageuser(BlenderRNA *brna)
prop= RNA_def_property(srna, "frame_offset", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "offset");
- RNA_def_property_range(prop, -MAXFRAMEF, MAXFRAMEF);
+ RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF);
RNA_def_property_ui_text(prop, "Offset", "Offsets the number of the frame to use in the animation");
RNA_def_property_update(prop, 0, "rna_ImageUser_update");
prop= RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME);
RNA_def_property_int_sdna(prop, NULL, "sfra");
- RNA_def_property_range(prop, 1.0f, MAXFRAMEF);
+ RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF);
RNA_def_property_ui_text(prop, "Start Frame", "Sets the global starting frame of the movie");
RNA_def_property_update(prop, 0, "rna_ImageUser_update");
diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h
index 6f72ae0f33b..76ee24a5608 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -225,6 +225,7 @@ char *rna_TextureSlot_path(struct PointerRNA *ptr);
void RNA_api_action(StructRNA *srna);
void RNA_api_armature_edit_bone(StructRNA *srna);
+void RNA_api_bone(StructRNA *srna);
void RNA_api_drivers(StructRNA *srna);
void RNA_api_image(struct StructRNA *srna);
void RNA_api_operator(struct StructRNA *srna);
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 5044518ca93..20e74ca5a72 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -593,7 +593,7 @@ static void def_group(StructRNA *srna)
{
PropertyRNA *prop;
- prop = RNA_def_property(srna, "nodetree", PROP_POINTER, PROP_NONE);
+ prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "id");
RNA_def_property_struct_type(prop, "NodeTree");
RNA_def_property_flag(prop, PROP_EDITABLE);
@@ -1063,7 +1063,7 @@ static void def_cmp_image(StructRNA *srna)
prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "sfra");
- RNA_def_property_range(prop, 1, MAXFRAMEF);
+ RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF);
RNA_def_property_ui_text(prop, "Start Frame", "");
RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index 3777005aaad..d354e152fce 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -1748,6 +1748,7 @@ static void rna_def_object(BlenderRNA *brna)
prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION);
RNA_def_property_float_sdna(prop, NULL, "loc");
RNA_def_property_editable_array_func(prop, "rna_Object_location_editable");
+ RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3);
RNA_def_property_ui_text(prop, "Location", "Location of the object");
RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
@@ -1785,6 +1786,7 @@ static void rna_def_object(BlenderRNA *brna)
prop= RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ);
RNA_def_property_float_sdna(prop, NULL, "size");
RNA_def_property_editable_array_func(prop, "rna_Object_scale_editable");
+ RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3);
RNA_def_property_float_array_default(prop, default_scale);
RNA_def_property_ui_text(prop, "Scale", "Scaling of the object");
RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
@@ -1792,6 +1794,7 @@ static void rna_def_object(BlenderRNA *brna)
prop= RNA_def_property(srna, "dimensions", PROP_FLOAT, PROP_XYZ_LENGTH);
RNA_def_property_array(prop, 3);
RNA_def_property_float_funcs(prop, "rna_Object_dimensions_get", "rna_Object_dimensions_set", NULL);
+ RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3);
RNA_def_property_ui_text(prop, "Dimensions", "Absolute bounding box dimensions of the object");
RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
diff --git a/source/blender/makesrna/intern/rna_pose_api.c b/source/blender/makesrna/intern/rna_pose_api.c
index 922fa285f84..48e8a1e6940 100644
--- a/source/blender/makesrna/intern/rna_pose_api.c
+++ b/source/blender/makesrna/intern/rna_pose_api.c
@@ -41,8 +41,16 @@
/* #include "DNA_anim_types.h" */
#include "DNA_action_types.h" /* bPose */
+#include "BKE_armature.h"
+static float rna_PoseBone_do_envelope(bPoseChannel *chan, float *vec)
+{
+ Bone *bone = chan->bone;
+
+ float scale = (bone->flag & BONE_MULT_VG_ENV) == BONE_MULT_VG_ENV ? bone->weight : 1.0f;
+ return distfactor_to_bone(vec, chan->pose_head, chan->pose_tail, bone->rad_head * scale, bone->rad_tail * scale, bone->dist * scale);
+}
#else
void RNA_api_pose(StructRNA *srna)
@@ -53,8 +61,16 @@ void RNA_api_pose(StructRNA *srna)
void RNA_api_pose_channel(StructRNA *srna)
{
-// FunctionRNA *func;
-// PropertyRNA *parm;
+ PropertyRNA *parm;
+ FunctionRNA *func;
+
+ func= RNA_def_function(srna, "envelope", "rna_PoseBone_do_envelope");
+ RNA_def_function_ui_description(func, "Calculate bone envelope at given point.");
+ parm= RNA_def_float_vector_xyz(func, "point", 3, NULL, -FLT_MAX, FLT_MAX, "Point", "Position in 3d space to evaluate", -FLT_MAX, FLT_MAX);
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+ /* return value */
+ parm= RNA_def_float(func, "factor", 0, -FLT_MAX, FLT_MAX, "Factor", "Envelope factor", -FLT_MAX, FLT_MAX);
+ RNA_def_function_return(func, parm);
}
diff --git a/source/blender/makesrna/intern/rna_sensor.c b/source/blender/makesrna/intern/rna_sensor.c
index d20e5aebcfb..6dddb042533 100644
--- a/source/blender/makesrna/intern/rna_sensor.c
+++ b/source/blender/makesrna/intern/rna_sensor.c
@@ -156,6 +156,8 @@ static void rna_Sensor_keyboard_key_set(struct PointerRNA *ptr, int value)
if (ISKEYBOARD(value))
ks->key = value;
+ else
+ ks->key = 0;
}
static void rna_Sensor_keyboard_modifier_set(struct PointerRNA *ptr, int value)
@@ -165,6 +167,8 @@ static void rna_Sensor_keyboard_modifier_set(struct PointerRNA *ptr, int value)
if (ISKEYBOARD(value))
ks->qual = value;
+ else
+ ks->qual = 0;
}
static void rna_Sensor_keyboard_modifier2_set(struct PointerRNA *ptr, int value)
@@ -174,6 +178,8 @@ static void rna_Sensor_keyboard_modifier2_set(struct PointerRNA *ptr, int value)
if (ISKEYBOARD(value))
ks->qual2 = value;
+ else
+ ks->qual2 = 0;
}
static void rna_Sensor_tap_set(struct PointerRNA *ptr, int value)
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 632d8c1be29..7459adc121f 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -2655,6 +2655,10 @@ static void rna_def_userdef_input(BlenderRNA *brna)
RNA_def_property_collection_sdna(prop, NULL, "keymaps", NULL);
RNA_def_property_struct_type(prop, "KeyMap");
RNA_def_property_ui_text(prop, "Edited Keymaps", "");
+
+ prop= RNA_def_property(srna, "active_keyconfig", PROP_STRING, PROP_DIRPATH);
+ RNA_def_property_string_sdna(prop, NULL, "keyconfigstr");
+ RNA_def_property_ui_text(prop, "Key Config", "The name of the active key configuration");
}
static void rna_def_userdef_filepaths(BlenderRNA *brna)
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index 900a1fd60cf..62d0c99f6c5 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -697,7 +697,7 @@ static int operator_poll(bContext *C, wmOperatorType *ot)
return visible;
}
-static int operator_exec(bContext *C, wmOperator *op)
+static int operator_execute(bContext *C, wmOperator *op)
{
PointerRNA opr;
ParameterList list;
@@ -720,6 +720,30 @@ static int operator_exec(bContext *C, wmOperator *op)
return result;
}
+/* same as execute() but no return value */
+static int operator_check(bContext *C, wmOperator *op)
+{
+ PointerRNA opr;
+ ParameterList list;
+ FunctionRNA *func;
+ void *ret;
+ int result;
+
+ RNA_pointer_create(&CTX_wm_screen(C)->id, op->type->ext.srna, op, &opr);
+ func= RNA_struct_find_function(&opr, "check");
+
+ RNA_parameter_list_create(&list, &opr, func);
+ RNA_parameter_set_lookup(&list, "context", &C);
+ op->type->ext.call(&opr, func, &list);
+
+ RNA_parameter_get_lookup(&list, "result", &ret);
+ result= *(int*)ret;
+
+ RNA_parameter_list_free(&list);
+
+ return result;
+}
+
static int operator_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
PointerRNA opr;
@@ -796,7 +820,7 @@ static StructRNA *rna_Operator_register(const bContext *C, ReportList *reports,
wmOperatorType dummyot = {0};
wmOperator dummyop= {0};
PointerRNA dummyotr;
- int have_function[5];
+ int have_function[6];
/* setup dummy operator & operator type to store static properties in */
dummyop.type= &dummyot;
@@ -846,11 +870,11 @@ static StructRNA *rna_Operator_register(const bContext *C, ReportList *reports,
dummyot.ext.free= free;
dummyot.pyop_poll= (have_function[0])? operator_poll: NULL;
- dummyot.exec= (have_function[1])? operator_exec: NULL;
- dummyot.invoke= (have_function[2])? operator_invoke: NULL;
- dummyot.modal= (have_function[3])? operator_modal: NULL;
- dummyot.ui= (have_function[4])? operator_draw: NULL;
-
+ dummyot.exec= (have_function[1])? operator_execute: NULL;
+ dummyot.check= (have_function[2])? operator_check: NULL;
+ dummyot.invoke= (have_function[3])? operator_invoke: NULL;
+ dummyot.modal= (have_function[4])? operator_modal: NULL;
+ dummyot.ui= (have_function[5])? operator_draw: NULL;
WM_operatortype_append_ptr(operator_wrapper, (void *)&dummyot);
/* update while blender is running */
diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c
index b13d7627a34..36dd6efc256 100644
--- a/source/blender/makesrna/intern/rna_wm_api.c
+++ b/source/blender/makesrna/intern/rna_wm_api.c
@@ -165,6 +165,15 @@ void RNA_api_operator(StructRNA *srna)
RNA_def_property_flag(parm, PROP_ENUM_FLAG);
RNA_def_function_return(func, parm);
+ /* check */
+ func= RNA_def_function(srna, "check", NULL);
+ RNA_def_function_ui_description(func, "Check the operator settings.");
+ RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
+ RNA_def_pointer(func, "context", "Context", "", "");
+
+ parm= RNA_def_boolean(func, "result", 0, "result", ""); // better name?
+ RNA_def_function_return(func, parm);
+
/* invoke */
func= RNA_def_function(srna, "invoke", NULL);
RNA_def_function_ui_description(func, "Invoke the operator.");
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index 77d0f4fa90a..997c5f4fce6 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -170,15 +170,7 @@ void BPY_start_python_path(void)
/* cmake/MSVC debug build crashes without this, why only
in this case is unknown.. */
{
- char *envpath = getenv("PYTHONPATH");
-
- if(envpath && envpath[0]) {
- char *newenvpath = BLI_sprintfN("%s;%s", py_path_bundle, envpath);
- BLI_setenv("PYTHONPATH", newenvpath);
- MEM_freeN(newenvpath);
- }
- else
- BLI_setenv("PYTHONPATH", py_path_bundle);
+ BLI_setenv("PYTHONPATH", py_path_bundle);
}
#endif
diff --git a/source/blender/python/intern/bpy_operator_wrap.c b/source/blender/python/intern/bpy_operator_wrap.c
index 27da839960b..6d16896fb16 100644
--- a/source/blender/python/intern/bpy_operator_wrap.c
+++ b/source/blender/python/intern/bpy_operator_wrap.c
@@ -45,9 +45,6 @@ static void operator_properties_init(wmOperatorType *ot)
PyErr_Print(); /* failed to register operator props */
PyErr_Clear();
}
-
- // see bpy_types.py:Operator, May redo this some other way!
- PyObject_CallMethod(py_class, "easy_getsets", NULL);
}
void operator_wrapper(wmOperatorType *ot, void *userdata)
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index c20bb3deaee..d2234963927 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -5121,13 +5121,17 @@ static int bpy_class_call(PointerRNA *ptr, FunctionRNA *func, ParameterList *par
err= -1;
}
else {
- if(ret_len==1) {
+ if(ret_len==0 && ret != Py_None) {
+ PyErr_Format(PyExc_RuntimeError, "expected class %.200s, function %.200s to return None, got a %.200s type instead.", RNA_struct_identifier(ptr->type), RNA_function_identifier(func), Py_TYPE(ret)->tp_name);
+ err= -1;
+ }
+ else if(ret_len==1) {
err= pyrna_py_to_prop(&funcptr, pret_single, parms, retdata_single, ret, "calling class function:");
}
else if (ret_len > 1) {
if(PyTuple_Check(ret)==0) {
- PyErr_Format(PyExc_RuntimeError, "expected class %.200s, function %.200s to return a tuple of size %d.", RNA_struct_identifier(ptr->type), RNA_function_identifier(func), ret_len);
+ PyErr_Format(PyExc_RuntimeError, "expected class %.200s, function %.200s to return a tuple of size %d, got a %.200s type instead.", RNA_struct_identifier(ptr->type), RNA_function_identifier(func), ret_len, Py_TYPE(ret)->tp_name);
err= -1;
}
else if (PyTuple_GET_SIZE(ret) != ret_len) {
diff --git a/source/blender/readblenfile/intern/BLO_readblenfile.c b/source/blender/readblenfile/intern/BLO_readblenfile.c
index 7c876c96a86..dfcdaf756f7 100644
--- a/source/blender/readblenfile/intern/BLO_readblenfile.c
+++ b/source/blender/readblenfile/intern/BLO_readblenfile.c
@@ -132,7 +132,8 @@ blo_read_runtime(
ReportList *reports)
{
BlendFileData *bfd= NULL;
- int fd, actualsize, datastart;
+ size_t actualsize;
+ int fd, datastart;
char buf[8];
fd= open(path, O_BINARY|O_RDONLY, 0);
diff --git a/source/blender/render/intern/raytrace/reorganize.h b/source/blender/render/intern/raytrace/reorganize.h
index 7ef7296945c..1d923c92d6f 100644
--- a/source/blender/render/intern/raytrace/reorganize.h
+++ b/source/blender/render/intern/raytrace/reorganize.h
@@ -35,6 +35,7 @@
#include "BKE_global.h"
#ifdef _WIN32
+#undef INFINITY
#define INFINITY FLT_MAX // in mingw math.h: (1.0F/0.0F). This generates compile error, though.
#endif
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 9668b2e17c9..690d8ad0f75 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -52,6 +52,8 @@ typedef struct wmJob wmJob;
/* general API */
void WM_setprefsize (int stax, int stay, int sizx, int sizy);
+void WM_setinitialstate_fullscreen();
+void WM_setinitialstate_normal();
void WM_init (struct bContext *C, int argc, char **argv);
void WM_exit (struct bContext *C);
@@ -78,7 +80,7 @@ void WM_window_open_temp (struct bContext *C, struct rcti *position, int type);
int WM_read_homefile (struct bContext *C, struct wmOperator *op);
int WM_write_homefile (struct bContext *C, struct wmOperator *op);
void WM_read_file (struct bContext *C, char *name, struct ReportList *reports);
-int WM_write_file (struct bContext *C, char *target, int fileflags, struct ReportList *reports, int copy);
+int WM_write_file (struct bContext *C, const char *target, int fileflags, struct ReportList *reports, int copy);
void WM_read_autosavefile(struct bContext *C);
void WM_autosave_init (struct wmWindowManager *wm);
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index 807125765f7..a732524ca03 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -385,6 +385,12 @@ typedef struct wmOperatorType {
* any interface code or input device state.
* - see defines below for return values */
int (*exec)(struct bContext *, struct wmOperator *);
+
+ /* this callback executes on a running operator whenever as property
+ * is changed. It can correct its own properties or report errors for
+ * invalid settings in exceptional cases.
+ * Boolean return value, True denotes a change has been made and to redraw */
+ int (*check)(struct bContext *, struct wmOperator *);
/* for modal temporary operators, initially invoke is called. then
* any further events are handled in modal. if the operation is
diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c
index 5f386170c54..148932fa941 100644
--- a/source/blender/windowmanager/intern/wm.c
+++ b/source/blender/windowmanager/intern/wm.c
@@ -57,8 +57,10 @@
#include "MEM_guardedalloc.h"
#include "ED_screen.h"
-#include "BPY_extern.h"
+#ifndef DISABLE_PYTHON
+#include "BPY_extern.h"
+#endif
/* ****************************************************** */
@@ -229,7 +231,7 @@ void WM_check(bContext *C)
}
/* case: no open windows at all, for old file reads */
- wm_window_add_ghostwindows(wm);
+ wm_window_add_ghostwindows(C, wm);
/* case: fileread */
if((wm->initialized & WM_INIT_WINDOW) == 0) {
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 6e8ab87f640..9e7606a9f14 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -1224,23 +1224,27 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa
case EVT_FILESELECT_EXEC:
case EVT_FILESELECT_CANCEL:
+ case EVT_FILESELECT_EXTERNAL_CANCEL:
{
/* XXX validate area and region? */
bScreen *screen= CTX_wm_screen(C);
-
- if(screen != handler->filescreen)
- ED_screen_full_prevspace(C, CTX_wm_area(C));
- else
- ED_area_prevspace(C, CTX_wm_area(C));
-
- /* remlink now, for load file case */
+
+ /* remlink now, for load file case before removing*/
BLI_remlink(handlers, handler);
+ if(event->val!=EVT_FILESELECT_EXTERNAL_CANCEL)
+ if(screen != handler->filescreen)
+ ED_screen_full_prevspace(C, CTX_wm_area(C));
+ else
+ ED_area_prevspace(C, CTX_wm_area(C));
+
wm_handler_op_context(C, handler);
/* needed for uiPupMenuReports */
if(event->val==EVT_FILESELECT_EXEC) {
+#if 0 // use REDALERT now
+
/* a bit weak, might become arg for WM_event_fileselect? */
/* XXX also extension code in image-save doesnt work for this yet */
if (RNA_struct_find_property(handler->op->ptr, "check_existing") &&
@@ -1251,7 +1255,9 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa
if(path)
MEM_freeN(path);
}
- else {
+ else
+#endif
+ {
int retval;
if(handler->op->type->flag & OPTYPE_UNDO)
@@ -1820,6 +1826,12 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op)
BLI_addhead(&win->modalhandlers, handler);
+ /* check props once before invoking if check is available
+ * ensures initial properties are valid */
+ if(op->type->check) {
+ op->type->check(C, op); /* ignore return value */
+ }
+
WM_event_fileselect_event(C, op, full?EVT_FILESELECT_FULL_OPEN:EVT_FILESELECT_OPEN);
}
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 1264f496103..f0b8577be47 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -96,7 +96,9 @@
#include "GPU_draw.h"
+#ifndef DISABLE_PYTHON
#include "BPY_extern.h"
+#endif
#include "WM_api.h"
#include "WM_types.h"
@@ -403,6 +405,13 @@ int WM_read_homefile(bContext *C, wmOperator *op)
ED_editors_init(C);
DAG_on_load_update(CTX_data_main(C));
+
+#ifndef DISABLE_PYTHON
+ if(CTX_py_init_get(C)) {
+ /* sync addons, these may have changed from the defaults */
+ BPY_eval_string(C, "__import__('bpy').utils.addon_reset_all()");
+ }
+#endif
WM_event_add_notifier(C, NC_WM|ND_FILEREAD, NULL);
CTX_wm_window_set(C, NULL); /* exits queues */
@@ -576,7 +585,7 @@ int write_crash_blend(void)
}
}
-int WM_write_file(bContext *C, char *target, int fileflags, ReportList *reports, int copy)
+int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *reports, int copy)
{
Library *li;
int len;
@@ -597,25 +606,20 @@ int WM_write_file(bContext *C, char *target, int fileflags, ReportList *reports,
return -1;
}
+ BLI_strncpy(di, target, FILE_MAX);
+ BLI_replace_extension(di, FILE_MAX, ".blend");
+ /* dont use 'target' anymore */
+
/* send the OnSave event */
for (li= G.main->library.first; li; li= li->id.next) {
- if (BLI_streq(li->name, target)) {
- BKE_report(reports, RPT_ERROR, "Cannot overwrite used library");
+ if (strcmp(li->filepath, di) == 0) {
+ BKE_reportf(reports, RPT_ERROR, "Can't overwrite used library '%f'", di);
return -1;
}
}
-
- if (!BLO_has_bfile_extension(target) && (len+6 < FILE_MAX)) {
- sprintf(di, "%s.blend", target);
- } else {
- strcpy(di, target);
- }
-// if (BLI_exists(di)) {
-// XXX if(!saveover(di))
-// XXX return;
-// }
-
+ /* operator now handles overwrite checks */
+
if (G.fileflags & G_AUTOPACK) {
packAll(G.main, reports);
}
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 95ab84c9192..b84b7eab55f 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -928,6 +928,16 @@ static void dialog_exec_cb(bContext *C, void *arg1, void *arg2)
uiPupBlockClose(C, block);
}
+void dialog_check_cb(bContext *C, void *op_ptr, void *dummy2)
+{
+ wmOperator *op= op_ptr;
+ if(op->type->check) {
+ if(op->type->check(C, op)) {
+ /* refresh */
+ }
+ }
+}
+
/* Dialogs are popups that require user verification (click OK) before exec */
static uiBlock *wm_block_create_dialog(bContext *C, ARegion *ar, void *userData)
{
@@ -953,6 +963,8 @@ static uiBlock *wm_block_create_dialog(bContext *C, ARegion *ar, void *userData)
RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, data->width, data->height, style);
uiItemL(layout, op->type->name, 0);
+
+ uiBlockSetFunc(block, dialog_check_cb, op, NULL);
if (op->type->ui) {
op->layout= layout;
@@ -961,6 +973,8 @@ static uiBlock *wm_block_create_dialog(bContext *C, ARegion *ar, void *userData)
}
else
uiDefAutoButsRNA(C, layout, &ptr, columns);
+
+ uiBlockSetFunc(block, NULL, NULL, NULL);
/* Create OK button, the callback of which will execute op */
btn= uiDefBut(block, BUT, 0, "OK", 0, 0, 0, 20, NULL, 0, 0, 0, 0, "");
@@ -1799,6 +1813,18 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
+/* function used for WM_OT_save_mainfile too */
+static int blend_save_check(bContext *C, wmOperator *op)
+{
+ char filepath[FILE_MAX];
+ RNA_string_get(op->ptr, "filepath", filepath);
+ if(BLI_replace_extension(filepath, sizeof(filepath), ".blend")) {
+ RNA_string_set(op->ptr, "filepath", filepath);
+ return TRUE;
+ }
+ return FALSE;
+}
+
static void WM_OT_save_as_mainfile(wmOperatorType *ot)
{
ot->name= "Save As Blender File";
@@ -1807,6 +1833,7 @@ static void WM_OT_save_as_mainfile(wmOperatorType *ot)
ot->invoke= wm_save_as_mainfile_invoke;
ot->exec= wm_save_as_mainfile_exec;
+ ot->check= blend_save_check;
ot->poll= WM_operator_winactive;
WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH);
@@ -1857,6 +1884,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;
WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH);
@@ -1872,9 +1900,10 @@ static void WM_OT_save_mainfile(wmOperatorType *ot)
static int wm_collada_export_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
if(!RNA_property_is_set(op->ptr, "filepath")) {
- char *path = BLI_replacestr(G.sce, ".blend", ".dae");
- RNA_string_set(op->ptr, "filepath", path);
- MEM_freeN(path);
+ char *filepath[FILE_MAX];
+ BLI_strncpy(filepath, G.sce, sizeof(filepath));
+ BLI_replace_extension(filepath, sizeof(filepath), ".dae");
+ RNA_string_set(op->ptr, "filepath", filepath);
}
WM_event_add_fileselect(C, op);
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 45234464ef0..4baad110232 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -67,7 +67,7 @@
GHOST_SystemHandle g_system= NULL;
/* set by commandline */
-static int prefsizx= 0, prefsizy= 0, prefstax= 0, prefstay= 0;
+static int prefsizx= 0, prefsizy= 0, prefstax= 0, prefstay= 0, initialstate= GHOST_kWindowStateNormal;
/* ******** win open & close ************ */
@@ -289,19 +289,21 @@ void wm_window_title(wmWindowManager *wm, wmWindow *win)
}
/* belongs to below */
-static void wm_window_add_ghostwindow(wmWindowManager *wm, char *title, wmWindow *win)
+static void wm_window_add_ghostwindow(bContext *C, wmWindowManager *wm, char *title, wmWindow *win)
{
GHOST_WindowHandle ghostwin;
- GHOST_TWindowState inital_state;
int scr_w, scr_h, posy;
+ GHOST_TWindowState initial_state;
+
+ /* when there is no window open uses the initial state */
+ if(!CTX_wm_window(C))
+ initial_state= initialstate;
+ else
+ initial_state= GHOST_kWindowStateNormal;
wm_get_screensize(&scr_w, &scr_h);
posy= (scr_h - win->posy - win->sizey);
- // inital_state = GHOST_kWindowStateFullScreen;
- // inital_state = GHOST_kWindowStateMaximized;
- inital_state = GHOST_kWindowStateNormal;
-
#if defined(__APPLE__) && !defined(GHOST_COCOA)
{
extern int macPrefState; /* creator.c */
@@ -312,13 +314,16 @@ static void wm_window_add_ghostwindow(wmWindowManager *wm, char *title, wmWindow
doesn't work well when AA is initialized, even if not used. */
ghostwin= GHOST_CreateWindow(g_system, title,
win->posx, posy, win->sizex, win->sizey,
- inital_state,
+ initial_state,
GHOST_kDrawingContextTypeOpenGL,
0 /* no stereo */,
0 /* no AA */);
if (ghostwin) {
+ /* set the state*/
+ GHOST_SetWindowState(ghostwin, initial_state);
+
win->ghostwin= ghostwin;
GHOST_SetWindowUserData(ghostwin, win); /* pointer back */
@@ -342,7 +347,7 @@ static void wm_window_add_ghostwindow(wmWindowManager *wm, char *title, wmWindow
/* for wmWindows without ghostwin, open these and clear */
/* window size is read from window, if 0 it uses prefsize */
/* called in WM_check, also inits stuff after file read */
-void wm_window_add_ghostwindows(wmWindowManager *wm)
+void wm_window_add_ghostwindows(bContext* C, wmWindowManager *wm)
{
wmKeyMap *keymap;
wmWindow *win;
@@ -372,9 +377,9 @@ void wm_window_add_ghostwindows(wmWindowManager *wm)
win->posy= prefstay;
win->sizex= prefsizx;
win->sizey= prefsizy;
- win->windowstate= 0;
+ win->windowstate= initialstate;
}
- wm_window_add_ghostwindow(wm, "Blender", win);
+ wm_window_add_ghostwindow(C, wm, "Blender", win);
}
/* happens after fileread */
if(win->eventstate==NULL)
@@ -1106,6 +1111,17 @@ void WM_setprefsize(int stax, int stay, int sizx, int sizy)
prefsizy= sizy;
}
+/* for borderless and border windows set from command-line */
+void WM_setinitialstate_fullscreen()
+{
+ initialstate= GHOST_kWindowStateFullScreen;
+}
+
+void WM_setinitialstate_normal()
+{
+ initialstate= GHOST_kWindowStateNormal;
+}
+
/* This function requires access to the GHOST_SystemHandle (g_system) */
void WM_cursor_warp(wmWindow *win, int x, int y)
{
diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h
index 6cb3971bd21..e4b56080b03 100644
--- a/source/blender/windowmanager/wm_event_types.h
+++ b/source/blender/windowmanager/wm_event_types.h
@@ -269,10 +269,11 @@
#define EVT_FILESELECT 0x5020
/* event->val */
-#define EVT_FILESELECT_OPEN 1
-#define EVT_FILESELECT_FULL_OPEN 2
-#define EVT_FILESELECT_EXEC 3
-#define EVT_FILESELECT_CANCEL 4
+#define EVT_FILESELECT_OPEN 1
+#define EVT_FILESELECT_FULL_OPEN 2
+#define EVT_FILESELECT_EXEC 3
+#define EVT_FILESELECT_CANCEL 4
+#define EVT_FILESELECT_EXTERNAL_CANCEL 5
/* event->type */
#define EVT_BUT_OPEN 0x5021
diff --git a/source/blender/windowmanager/wm_window.h b/source/blender/windowmanager/wm_window.h
index d57fd0e75d8..5a425df01e1 100644
--- a/source/blender/windowmanager/wm_window.h
+++ b/source/blender/windowmanager/wm_window.h
@@ -43,7 +43,7 @@ void wm_window_free (bContext *C, wmWindowManager *wm, wmWindow *win);
void wm_window_close (bContext *C, wmWindowManager *wm, wmWindow *win);
void wm_window_title (wmWindowManager *wm, wmWindow *win);
-void wm_window_add_ghostwindows (wmWindowManager *wm);
+void wm_window_add_ghostwindows (bContext *C, wmWindowManager *wm);
void wm_window_process_events (const bContext *C);
void wm_window_process_events_nosleep(const bContext *C);