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:
authorTon Roosendaal <ton@blender.org>2005-11-30 16:58:01 +0300
committerTon Roosendaal <ton@blender.org>2005-11-30 16:58:01 +0300
commit1eab492c4ba988b1d27d5719c231e6ebf385f45c (patch)
treebbce8f413c91ce61f306793028183c174b28f445
parent77f5473da95d046123bdcac0a9808b127506b6bd (diff)
parentb7a4a6c8374e808837e45829ec85c48a409efd74 (diff)
Syncing Orange branch with bf-blender
-rw-r--r--source/blender/blenkernel/BKE_armature.h9
-rw-r--r--source/blender/blenkernel/BKE_image.h2
-rw-r--r--source/blender/blenkernel/BKE_object.h3
-rw-r--r--source/blender/blenkernel/intern/armature.c67
-rw-r--r--source/blender/blenkernel/intern/depsgraph.c9
-rw-r--r--source/blender/blenkernel/intern/displist.c2
-rw-r--r--source/blender/blenkernel/intern/effect.c10
-rw-r--r--source/blender/blenkernel/intern/image.c32
-rw-r--r--source/blender/blenkernel/intern/material.c2
-rw-r--r--source/blender/blenkernel/intern/object.c23
-rw-r--r--source/blender/blenloader/intern/readfile.c5
-rw-r--r--source/blender/imbuf/intern/dynlibtiff.c5
-rw-r--r--source/blender/include/BDR_drawobject.h11
-rw-r--r--source/blender/makesdna/DNA_material_types.h1
-rw-r--r--source/blender/python/BPY_interface.c37
-rw-r--r--source/blender/python/api2_2x/BGL.c4
-rw-r--r--source/blender/python/api2_2x/BezTriple.c147
-rw-r--r--source/blender/python/api2_2x/BezTriple.h2
-rw-r--r--source/blender/python/api2_2x/Blender.c18
-rw-r--r--source/blender/python/api2_2x/Curve.c27
-rw-r--r--source/blender/python/api2_2x/Draw.c10
-rw-r--r--source/blender/python/api2_2x/Effect.c6
-rw-r--r--source/blender/python/api2_2x/Ipocurve.c17
-rw-r--r--source/blender/python/api2_2x/Key.c155
-rw-r--r--source/blender/python/api2_2x/Lattice.c4
-rw-r--r--source/blender/python/api2_2x/MTex.c805
-rw-r--r--source/blender/python/api2_2x/Mesh.c2
-rw-r--r--source/blender/python/api2_2x/NMesh.c3
-rw-r--r--source/blender/python/api2_2x/Object.c6
-rw-r--r--source/blender/python/api2_2x/Particle.c2
-rw-r--r--source/blender/python/api2_2x/Sys.c4
-rw-r--r--source/blender/python/api2_2x/Texture.c58
-rw-r--r--source/blender/python/api2_2x/constant.c4
-rw-r--r--source/blender/python/api2_2x/doc/API_intro.py2
-rw-r--r--source/blender/python/api2_2x/doc/Key.py65
-rw-r--r--source/blender/python/api2_2x/doc/Texture.py79
-rw-r--r--source/blender/python/api2_2x/doc/Window.py4
-rw-r--r--source/blender/python/api2_2x/gen_utils.c13
-rw-r--r--source/blender/python/api2_2x/gen_utils.h3
-rw-r--r--source/blender/render/intern/source/imagetexture.c18
-rw-r--r--source/blender/render/intern/source/ray.c79
-rw-r--r--source/blender/render/intern/source/rendercore.c38
-rw-r--r--source/blender/render/intern/source/zbuf.c7
-rw-r--r--source/blender/renderconverter/intern/convertBlenderScene.c14
-rw-r--r--source/blender/src/buttons_object.c4
-rw-r--r--source/blender/src/buttons_shading.c4
-rw-r--r--source/blender/src/drawarmature.c4
-rw-r--r--source/blender/src/drawobject.c101
-rw-r--r--source/blender/src/drawtime.c13
-rw-r--r--source/blender/src/drawview.c71
-rw-r--r--source/blender/src/editmesh.c2
-rw-r--r--source/blender/src/editmesh_add.c12
-rw-r--r--source/blender/src/editmesh_lib.c4
-rw-r--r--source/blender/src/editmesh_tools.c1
-rw-r--r--source/blender/src/editobject.c19
-rw-r--r--source/blender/src/editscreen.c13
-rw-r--r--source/blender/src/ghostwinlay.c2
-rw-r--r--source/blender/src/header_image.c6
-rw-r--r--source/blender/src/header_view3d.c6
-rw-r--r--source/blender/src/meshtools.c13
-rw-r--r--source/blender/src/poseobject.c15
-rw-r--r--source/blender/src/pub/license_key.c8
-rw-r--r--source/blender/src/renderwin.c20
-rw-r--r--source/blender/src/sequence.c2
-rw-r--r--source/blender/src/space.c7
-rw-r--r--source/blender/src/transform_manipulator.c19
-rw-r--r--source/blender/src/view.c6
-rw-r--r--source/blender/src/vpaint.c25
68 files changed, 1516 insertions, 675 deletions
diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h
index 336ba823520..1ce5f7d0f03 100644
--- a/source/blender/blenkernel/BKE_armature.h
+++ b/source/blender/blenkernel/BKE_armature.h
@@ -95,19 +95,11 @@ void get_objectspace_bone_matrix (struct Bone* bone, float M_accumulatedMatrix[]
void vec_roll_to_mat3(float *vec, float roll, float mat[][3]);
void mat3_to_vec_roll(float mat[][3], float *vec, float *roll);
-
/* Animation functions */
-
struct PoseTree *ik_tree_to_posetree(struct Object *ob, struct Bone *bone);
void solve_posetree(PoseTree *tree);
void free_posetree(PoseTree *tree);
-/* Gameblender hacks */
-void GB_init_armature_deform(struct ListBase *defbase, float premat[][4], float postmat[][4]);
-void GB_calc_armature_deform (float *co, struct MDeformVert *dvert);
-void GB_build_mats (float parmat[][4], float obmat[][4], float premat[][4], float postmat[][4]);
-void GB_validate_defgroups (struct Mesh *mesh, struct ListBase *defbase);
-
/* B-Bone support */
typedef struct Mat4 {
float mat[4][4];
@@ -115,7 +107,6 @@ typedef struct Mat4 {
Mat4 *b_bone_spline_setup(struct bPoseChannel *pchan);
-
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h
index 1927ad9bb02..1ae5552104c 100644
--- a/source/blender/blenkernel/BKE_image.h
+++ b/source/blender/blenkernel/BKE_image.h
@@ -47,7 +47,7 @@ void free_image(struct Image *me);
void free_image_buffers(struct Image *ima);
struct Image *add_image(char *name);
void free_unused_animimages(void);
-struct Image *new_image(int width, int height, char *name);
+struct Image *new_image(int width, int height, char *name, short uvtestgrid);
void makepicstring(char *string, int frame);
void addImageExtension(char *string);
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index a7e37425da7..2e4e4917de2 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -50,8 +50,11 @@ void copy_baseflags(void);
void copy_objectflags(void);
struct SoftBody *copy_softbody(struct SoftBody *sb);
void update_base_layer(struct Object *ob);
+
void free_object(struct Object *ob);
+void object_free_display(struct Object *ob);
void object_free_modifiers(struct Object *ob);
+
void unlink_object(struct Object *ob);
int exist_object(struct Object *obtest);
void *add_camera(void);
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index 991370c798b..95a39c29a54 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -1642,70 +1642,3 @@ void where_is_pose (Object *ob)
}
}
}
-
-/* ****************** Game Blender functions, called by engine ************** */
-
-/* NOTE: doesn't work at the moment!!! (ton) */
-
-/* ugly Globals */
-static float g_premat[4][4];
-static float g_postmat[4][4];
-
-void GB_build_mats (float parmat[][4], float obmat[][4], float premat[][4], float postmat[][4])
-{
- float obinv[4][4];
-
- Mat4Invert(obinv, obmat);
- Mat4CpyMat4(premat, obmat);
- Mat4MulMat4(postmat, parmat, obinv);
-
- Mat4Invert (premat, postmat);
-}
-
-void GB_init_armature_deform(ListBase *defbase, float premat[][4], float postmat[][4])
-{
-// g_defbase = defbase;
- Mat4CpyMat4 (g_premat, premat);
- Mat4CpyMat4 (g_postmat, postmat);
-
-}
-
-void GB_validate_defgroups (Mesh *mesh, ListBase *defbase)
-{
- /* Should only be called when the mesh or armature changes */
-// int j, i;
-// MDeformVert *dvert;
-
-// for (j=0; j<mesh->totvert; j++){
-// dvert = mesh->dvert+j;
-// for (i=0; i<dvert->totweight; i++)
-// dvert->dw[i].data = ((bDeformGroup*)BLI_findlink (defbase, dvert->dw[i].def_nr))->data;
-// }
-}
-
-void GB_calc_armature_deform (float *co, MDeformVert *dvert)
-{
- float vec[3]={0, 0, 0};
- float contrib = 0;
- int i;
-// bPoseChannel *pchan;
-
- Mat4MulVecfl(g_premat, co);
-
- for (i=0; i<dvert->totweight; i++){
-// pchan = (bPoseChannel *)dvert->dw[i].data;
-// if (pchan) pchan_bone_deform(pchan, dvert->dw[i].weight, vec, co, &contrib);
- }
-
- if (contrib){
- vec[0]/=contrib;
- vec[1]/=contrib;
- vec[2]/=contrib;
- }
-
- VecAddf (co, vec, co);
- Mat4MulVecfl(g_postmat, co);
-}
-
-/* ****************** END Game Blender functions, called by engine ************** */
-
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index 617a3dcdb68..50ca6bc4fe6 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -67,6 +67,7 @@
#include "BKE_key.h"
#include "BKE_mball.h"
#include "BKE_modifier.h"
+#include "BKE_object.h"
#include "BKE_utildefines.h"
#include "MEM_guardedalloc.h"
@@ -1390,9 +1391,13 @@ static void flush_update_node(DagNode *node, unsigned int layer, int curtime)
}
}
/* even nicer, we can clear recalc flags... */
- if((all_layer & layer)==0)
+ if((all_layer & layer)==0) {
+ /* but existing displaylists or derivedmesh should be freed */
+ if(ob->recalc & OB_RECALC_DATA)
+ object_free_display(ob);
+
ob->recalc &= ~OB_RECALC;
-
+ }
}
/* check case where child changes and parent forcing obdata to change */
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index 34500bfeea9..4f62748e20e 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -260,7 +260,7 @@ int displist_has_faces(ListBase *lb)
dl= lb->first;
while(dl) {
- if ELEM4(dl->type, DL_INDEX3, DL_INDEX4, DL_SURF, DL_POLY)
+ if ELEM3(dl->type, DL_INDEX3, DL_INDEX4, DL_SURF)
return 1;
dl= dl->next;
}
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index d308976dc1f..b2b52cfda06 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -391,11 +391,13 @@ static void precalc_effectors(Object *ob, PartEff *paf, Particle *pa, ListBase *
pEffectorCache *ec;
for(ec= lb->first; ec; ec= ec->next) {
- if(ec->ob->type==OB_CURVE) {
+ PartDeflect *pd= ec->ob->pd;
+
+ ec->oldspeed[0]= ec->oldspeed[1]= ec->oldspeed[2]= 0.0f;
+
+ if(pd->forcefield==PFIELD_GUIDE && ec->ob->type==OB_CURVE) {
float vec[4], dir[3];
- ec->oldspeed[0]= ec->oldspeed[1]= ec->oldspeed[2]= 0.0f;
-
/* scale corrects speed vector to curve size */
if(paf->totkey>1) ec->scale= (paf->totkey-1)/pa->lifetime;
else ec->scale= 1.0f;
@@ -1868,7 +1870,7 @@ void build_particle_system(Object *ob)
if(folengths)
pa->lifetime*= folengths[curface];
-
+
make_particle_keys(rng, ob, 0, a, paf, pa, force, deform, mtexmove, effectorbase);
}
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 5be1c0ed48f..c09f68643ce 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -54,6 +54,7 @@
#include "DNA_userdef_types.h"
#include "BLI_blenlib.h"
+#include "BLI_arithb.h"
#include "BKE_bmfont.h"
#include "BKE_packedFile.h"
@@ -148,7 +149,7 @@ Image *add_image(char *name)
return ima;
}
-Image *new_image(int width, int height, char *name)
+Image *new_image(int width, int height, char *name, short uvtestgrid)
{
Image *ima;
@@ -159,6 +160,7 @@ Image *new_image(int width, int height, char *name)
ImBuf *ibuf;
unsigned char *rect;
int x, y;
+ float h=0.0, hoffs=0.0, s=0.9, v=0.6, r, g, b;
strcpy(ima->name, "Untitled");
@@ -167,10 +169,30 @@ Image *new_image(int width, int height, char *name)
ima->ibuf= ibuf;
rect= (unsigned char*)ibuf->rect;
- for(y=0; y<ibuf->y; y++) {
- for(x=0; x<ibuf->x; x++, rect+=4) {
- rect[0]= rect[1]= rect[2]= 0;
- rect[3]= 255;
+
+ if (uvtestgrid) {
+ for(y=0; y<ibuf->y; y++) {
+ if (y % 20 == 0) hoffs += 0.125;
+ if (y % 160 == 0) hoffs = 0.0;
+
+ for(x=0; x<ibuf->x; x++, rect+=4) {
+ if (x % 20 == 0) h += 0.125;
+ if (x % 160 == 0) h = 0.0;
+
+ hsv_to_rgb(fabs(h-hoffs), s, v, &r, &g, &b);
+
+ rect[0]= (char)(r * 255.0);
+ rect[1]= (char)(g * 255.0);
+ rect[2]= (char)(b * 255.0);
+ rect[3]= 255;
+ }
+ }
+ } else { /* blank image */
+ for(y=0; y<ibuf->y; y++) {
+ for(x=0; x<ibuf->x; x++, rect+=4) {
+ rect[0]= rect[1]= rect[2]= 0;
+ rect[3]= 255;
+ }
}
}
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index 08b4e0b7ea6..d303a7ed5bd 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -117,7 +117,7 @@ void init_material(Material *ma)
ma->rampfac_spec= 1.0;
ma->pr_lamp= 3; // two lamps, is bits
- ma->mode= MA_TRACEBLE|MA_SHADOW|MA_RADIO|MA_TANGENT_STR;
+ ma->mode= MA_TRACEBLE|MA_SHADBUF|MA_SHADOW|MA_RADIO|MA_TANGENT_STR;
}
Material *add_material(char *name)
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index d97211b3125..957d76d786b 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -161,14 +161,29 @@ void object_free_modifiers(Object *ob)
}
}
+/* here we will collect all local displist stuff */
+/* also (ab)used in depsgraph */
+void object_free_display(Object *ob)
+{
+ if(ob->derivedDeform) {
+ ob->derivedDeform->release(ob->derivedDeform);
+ ob->derivedDeform= NULL;
+ }
+ if(ob->derivedFinal) {
+ ob->derivedFinal->release(ob->derivedFinal);
+ ob->derivedFinal= NULL;
+ }
+
+ freedisplist(&ob->disp);
+}
+
/* do not free object itself */
void free_object(Object *ob)
{
int a;
- if(ob->derivedDeform) ob->derivedDeform->release(ob->derivedDeform);
- if(ob->derivedFinal) ob->derivedFinal->release(ob->derivedFinal);
-
+ object_free_display(ob);
+
/* disconnect specific data */
if(ob->data) {
ID *id= ob->data;
@@ -211,8 +226,6 @@ void free_object(Object *ob)
free_constraint_channels(&ob->constraintChannels);
free_nlastrips(&ob->nlastrips);
- freedisplist(&ob->disp);
-
BPY_free_scriptlink(&ob->scriptlink);
if(ob->pd) MEM_freeN(ob->pd);
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index e22df9d66d9..1fb00163644 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -5077,6 +5077,11 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
ma->strand_sta= ma->strand_end= 1.0f;
ma->mode |= MA_TANGENT_STR;
}
+ /* remove this test before 2.40 too! pad is set to denote check was done */
+ if(ma->pad==0) {
+ if(ma->mode & MA_TRACEBLE) ma->mode |= MA_SHADBUF;
+ ma->pad= 1;
+ }
}
}
diff --git a/source/blender/imbuf/intern/dynlibtiff.c b/source/blender/imbuf/intern/dynlibtiff.c
index 17aa0dfbf4f..7472764b7df 100644
--- a/source/blender/imbuf/intern/dynlibtiff.c
+++ b/source/blender/imbuf/intern/dynlibtiff.c
@@ -76,6 +76,9 @@ void libtiff_loadlibtiff(void)
char *filename;
libtiff = NULL;
+#ifndef __APPLE__ /* no standard location of libtiff in MacOS X */
+ /* declare env var if you want to use that */
+
/* Try to find libtiff in a couple of standard places */
libtiff = PIL_dynlib_open("libtiff.so");
if (libtiff != NULL) return;
@@ -91,6 +94,8 @@ void libtiff_loadlibtiff(void)
/* For solaris */
libtiff = PIL_dynlib_open("/usr/openwin/lib/libtiff.so");
if (libtiff != NULL) return;
+
+#endif
filename = getenv("BF_TIFF_LIB");
if (filename) libtiff = PIL_dynlib_open(filename);
diff --git a/source/blender/include/BDR_drawobject.h b/source/blender/include/BDR_drawobject.h
index 839c1f45f42..c9b3a357a97 100644
--- a/source/blender/include/BDR_drawobject.h
+++ b/source/blender/include/BDR_drawobject.h
@@ -49,9 +49,6 @@ struct BezTriple;
struct EditVert;
struct EditFace;
-void drawaxes(float size);
-void drawcamera(struct Object *ob);
-
void mesh_foreachScreenVert(void (*func)(void *userData, struct EditVert *eve, int x, int y, int index), void *userData, int clipVerts);
void mesh_foreachScreenEdge(void (*func)(void *userData, struct EditEdge *eed, int x0, int y0, int x1, int y1, int index), void *userData, int clipVerts);
void mesh_foreachScreenFace(void (*func)(void *userData, struct EditFace *efa, int x, int y, int index), void *userData);
@@ -61,7 +58,13 @@ void nurbs_foreachScreenVert(void (*func)(void *userData, struct Nurb *nu, struc
void drawcircball(int mode, float *cent, float rad, float tmat[][4]);
void get_local_bounds(struct Object *ob, float *centre, float *size);
-void draw_object(struct Base *base);
+
+/* drawing flags: */
+#define DRAW_PICKING 1
+#define DRAW_CONSTCOLOR 2
+void draw_object(struct Base *base, int flag);
+void drawaxes(float size, int flag);
+
void draw_object_ext(struct Base *base);
void drawsolidcube(float size);
extern void draw_object_backbufsel(struct Object *ob);
diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h
index 42c22d51536..5ef327502e1 100644
--- a/source/blender/makesdna/DNA_material_types.h
+++ b/source/blender/makesdna/DNA_material_types.h
@@ -155,6 +155,7 @@ typedef struct Material {
#define MA_RAYBIAS 0x400000
#define MA_FULL_OSA 0x800000
#define MA_TANGENT_STR 0x1000000
+#define MA_SHADBUF 0x2000000
/* diff_shader */
#define MA_DIFF_LAMBERT 0
diff --git a/source/blender/python/BPY_interface.c b/source/blender/python/BPY_interface.c
index e82c51aa208..3cdc0de4f52 100644
--- a/source/blender/python/BPY_interface.c
+++ b/source/blender/python/BPY_interface.c
@@ -223,7 +223,7 @@ void init_syspath( int first_time )
if( mod ) {
d = PyModule_GetDict( mod );
- PyDict_SetItemString( d, "progname", path );
+ EXPP_dict_set_item_str( d, "progname", path );
Py_DECREF( mod );
} else
printf( "Warning: could not set Blender.sys.progname\n" );
@@ -302,7 +302,7 @@ void init_syspath( int first_time )
if( mod ) {
d = PyModule_GetDict( mod ); /* borrowed ref */
- PyDict_SetItemString( d, "executable",
+ EXPP_dict_set_item_str( d, "executable",
Py_BuildValue( "s", bprogname ) );
Py_DECREF( mod );
}
@@ -545,7 +545,7 @@ int BPY_txt_do_python_Text( struct Text *text )
PyString_FromString( script->id.name + 2 ) );
Py_INCREF( Py_None );
PyConstant_Insert( info, "arg", Py_None );
- PyDict_SetItemString( py_dict, "__script__",
+ EXPP_dict_set_item_str( py_dict, "__script__",
( PyObject * ) info );
}
@@ -787,7 +787,7 @@ int BPY_menu_do_python( short menutype, int event )
PyConstant_Insert( info, "name",
PyString_FromString( script->id.name + 2 ) );
PyConstant_Insert( info, "arg", pyarg );
- PyDict_SetItemString( py_dict, "__script__",
+ EXPP_dict_set_item_str( py_dict, "__script__",
( PyObject * ) info );
}
@@ -1081,10 +1081,10 @@ void BPY_do_pyscript( ID * id, short event )
disable_where_scriptlink( (short)during_slink );
/* set globals in Blender module to identify scriptlink */
- PyDict_SetItemString( g_blenderdict, "bylink", EXPP_incr_ret_True() );
- PyDict_SetItemString( g_blenderdict, "link",
+ EXPP_dict_set_item_str( g_blenderdict, "bylink", EXPP_incr_ret_True() );
+ EXPP_dict_set_item_str( g_blenderdict, "link",
ID_asPyObject( id ) );
- PyDict_SetItemString( g_blenderdict, "event",
+ EXPP_dict_set_item_str( g_blenderdict, "event",
PyString_FromString( event_to_name
( event ) ) );
@@ -1123,10 +1123,9 @@ void BPY_do_pyscript( ID * id, short event )
/* cleanup bylink flag and clear link so PyObject
* can be released
*/
- PyDict_SetItemString( g_blenderdict, "bylink", EXPP_incr_ret_False() );
- Py_INCREF( Py_None );
+ EXPP_dict_set_item_str( g_blenderdict, "bylink", EXPP_incr_ret_False() );
PyDict_SetItemString( g_blenderdict, "link", Py_None );
- PyDict_SetItemString( g_blenderdict, "event",
+ EXPP_dict_set_item_str( g_blenderdict, "event",
PyString_FromString( "" ) );
}
}
@@ -1302,11 +1301,11 @@ int BPY_do_spacehandlers( ScrArea *sa, unsigned short event,
}
/* set globals in Blender module to identify space handler scriptlink */
- PyDict_SetItemString(g_blenderdict, "bylink", EXPP_incr_ret_True());
+ EXPP_dict_set_item_str(g_blenderdict, "bylink", EXPP_incr_ret_True());
/* unlike normal scriptlinks, here Blender.link is int (space event type) */
- PyDict_SetItemString(g_blenderdict, "link", PyInt_FromLong(space_event));
+ EXPP_dict_set_item_str(g_blenderdict, "link", PyInt_FromLong(space_event));
/* note: DRAW space_events set event to 0 */
- PyDict_SetItemString(g_blenderdict, "event", PyInt_FromLong(event));
+ EXPP_dict_set_item_str(g_blenderdict, "event", PyInt_FromLong(event));
/* now run all assigned space handlers for this space and space_event */
for( index = 0; index < scriptlink->totscript; index++ ) {
@@ -1362,9 +1361,9 @@ int BPY_do_spacehandlers( ScrArea *sa, unsigned short event,
}
- PyDict_SetItemString(g_blenderdict, "bylink", EXPP_incr_ret_False());
- PyDict_SetItemString(g_blenderdict, "link", EXPP_incr_ret(Py_None));
- PyDict_SetItemString(g_blenderdict, "event", PyString_FromString(""));
+ EXPP_dict_set_item_str(g_blenderdict, "bylink", EXPP_incr_ret_False());
+ PyDict_SetItemString(g_blenderdict, "link", Py_None );
+ EXPP_dict_set_item_str(g_blenderdict, "event", PyString_FromString(""));
}
/* retval:
@@ -1548,7 +1547,7 @@ PyObject *CreateGlobalDictionary( void )
PyObject *dict = PyDict_New( );
PyDict_SetItemString( dict, "__builtins__", PyEval_GetBuiltins( ) );
- PyDict_SetItemString( dict, "__name__",
+ EXPP_dict_set_item_str( dict, "__name__",
PyString_FromString( "__main__" ) );
return dict;
@@ -1672,7 +1671,7 @@ void init_ourImport( void )
m = PyImport_AddModule( "__builtin__" );
d = PyModule_GetDict( m );
- PyDict_SetItemString( d, "__import__", import );
+ EXPP_dict_set_item_str( d, "__import__", import );
}
/*
@@ -1772,5 +1771,5 @@ void init_ourReload( void )
m = PyImport_AddModule( "__builtin__" );
d = PyModule_GetDict( m );
- PyDict_SetItemString( d, "reload", reload );
+ EXPP_dict_set_item_str( d, "reload", reload );
}
diff --git a/source/blender/python/api2_2x/BGL.c b/source/blender/python/api2_2x/BGL.c
index 165f9055057..81f188e040c 100644
--- a/source/blender/python/api2_2x/BGL.c
+++ b/source/blender/python/api2_2x/BGL.c
@@ -1096,11 +1096,11 @@ PyObject *BGL_Init(void)
buffer_Type.ob_type = &PyType_Type;
-#define EXPP_ADDCONST(x) PyDict_SetItemString(dict, #x, PyInt_FromLong(x))
+#define EXPP_ADDCONST(x) EXPP_dict_set_item_str(dict, #x, PyInt_FromLong(x))
/* So, for example:
* EXPP_ADDCONST(GL_CURRENT_BIT) becomes
- * PyDict_SetItemString(dict, "GL_CURRENT_BIT", PyInt_FromLong(GL_CURRENT_BIT)) */
+ * EXPP_dict_set_item_str(dict, "GL_CURRENT_BIT", PyInt_FromLong(GL_CURRENT_BIT)) */
EXPP_ADDCONST(GL_CURRENT_BIT);
EXPP_ADDCONST(GL_POINT_BIT);
diff --git a/source/blender/python/api2_2x/BezTriple.c b/source/blender/python/api2_2x/BezTriple.c
index 46ea67728d6..324ba2958bb 100644
--- a/source/blender/python/api2_2x/BezTriple.c
+++ b/source/blender/python/api2_2x/BezTriple.c
@@ -134,19 +134,44 @@ PyTypeObject BezTriple_Type = {
static PyObject *M_BezTriple_New( PyObject* self, PyObject * args )
{
+ float numbuf[9];
+ int status, length;
PyObject* in_args = NULL;
- if( !PyArg_ParseTuple( args, "|O", &in_args) ) {
- return( EXPP_ReturnPyObjError
- ( PyExc_AttributeError,
- "expected sequence of 3 or 9 floats or nothing"));
- }
+ if( !PyArg_ParseTuple( args, "|O", &in_args) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected sequence of 3 or 9 floats or nothing" );
if( !in_args ) {
- in_args = Py_BuildValue( "(fff)", 0.0, 0.0, 0.0 );
- }
+ numbuf[0] = 0.0f; numbuf[1] = 0.0f; numbuf[2] = 0.0f;
+ numbuf[3] = 0.0f; numbuf[4] = 0.0f; numbuf[5] = 0.0f;
+ numbuf[6] = 0.0f; numbuf[7] = 0.0f; numbuf[8] = 0.0f;
+ } else {
+ if( !PySequence_Check( in_args ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected sequence of 3 or 9 floats or nothing" );
- return newBezTriple( in_args );
+ length = PySequence_Length( in_args );
+ if( length == 9 )
+ status = PyArg_ParseTuple( in_args, "fffffffff",
+ &numbuf[0], &numbuf[1], &numbuf[2],
+ &numbuf[3], &numbuf[4], &numbuf[5],
+ &numbuf[6], &numbuf[7], &numbuf[8]);
+ else if( length == 3 ) {
+ status = PyArg_ParseTuple( in_args, "fff",
+ &numbuf[0], &numbuf[1], &numbuf[2]);
+ numbuf[3] = numbuf[0]; numbuf[6] = numbuf[0];
+ numbuf[4] = numbuf[1]; numbuf[7] = numbuf[1];
+ numbuf[5] = numbuf[2]; numbuf[8] = numbuf[2];
+ } else
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "wrong number of points" );
+ if( !status )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "sequence item not number");
+ }
+
+ return newBezTriple( numbuf );
}
/****************************************************************************
@@ -436,99 +461,35 @@ BezTriple *BezTriple_FromPyObject( PyObject * pyobj )
input args is a sequence - either 3 or 9 floats
*/
-PyObject *newBezTriple( PyObject *args)
+PyObject *newBezTriple( float *numbuf )
{
- BPy_BezTriple *pybez = NULL;
- int length;
- float numbuf[9];
- int status;
-/*
- check input args:
- sequence of nine floats - x,y,z for h1, pt, h2
- sequence of 3 floats - x,y,z for pt with zero len handles in AUTO mode
-*/
-
- /* do we have a sequence of the right length? */
+ int i, j, num;
+ PyObject *pyobj = NULL;
+ BezTriple *bzt = NULL;
- if( ! PySequence_Check( args )) {
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected better stuff"));
- }
-
- length = PySequence_Length( args );
- if( length != 9 && length != 3 )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "wrong number of points");
- {
- if (length == 9)
- status = PyArg_ParseTuple( args, "fffffffff",
- &numbuf[0],
- &numbuf[1],
- &numbuf[2],
- &numbuf[3],
- &numbuf[4],
- &numbuf[5],
- &numbuf[6],
- &numbuf[7],
- &numbuf[8]);
-
- else if (length == 3)
- status = PyArg_ParseTuple( args, "fff",
- &numbuf[0],
- &numbuf[1],
- &numbuf[2]);
- else
- return EXPP_ReturnPyObjError
- ( PyExc_AttributeError,
- "wrong number of points");
- if ( !status )
- return EXPP_ReturnPyObjError
- ( PyExc_AttributeError,
- "sequence item not number");
- }
+ /* create our own beztriple data */
+ bzt = MEM_callocN( sizeof( BezTriple ), "new bpytriple");
- /* create our bpy object */
- pybez = ( BPy_BezTriple* ) PyObject_New( BPy_BezTriple,
- &BezTriple_Type );
- if( ! pybez )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "PyObject_New failed");
- pybez->beztriple = MEM_callocN( sizeof( BezTriple ), "new bpytriple");
/* check malloc */
+ if( !bzt )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "MEM_callocN failed");
- pybez->own_memory = 1; /* we own it. must free later */
-
- switch( length ) {
- case 9: {
- int i,j;
- int num = 0;
- for( i = 0; i < 3; i++ ){
- for( j = 0; j < 3; j++){
- pybez->beztriple->vec[i][j] = numbuf[num ++];
- }
- }
- }
- break;
- case 3: {
- int i;
- int num = 0;
- /* set h1, pt, and h2 to the same values. */
- for( i = 0; i < 3; i++ ) {
- pybez->beztriple->vec[0][i] = numbuf[num];
- pybez->beztriple->vec[1][i] = numbuf[num];
- pybez->beztriple->vec[2][i] = numbuf[num];
- ++num;
+ /* copy the data */
+ num = 0;
+ for( i = 0; i < 3; i++ ) {
+ for( j = 0; j < 3; j++) {
+ bzt->vec[i][j] = numbuf[num++];
}
}
- break;
- default:
- /* we should not be here! */
- break;
- }
+ bzt->h1 = HD_ALIGN;
+ bzt->h2 = HD_ALIGN;
+ /* wrap it */
+ pyobj = BezTriple_CreatePyObject( bzt );
- pybez->beztriple->h1 = HD_ALIGN;
- pybez->beztriple->h2 = HD_ALIGN;
+ /* we own it. must free later */
+ ( ( BPy_BezTriple * )pyobj)->own_memory = 1;
- return ( PyObject* ) pybez;
+ return pyobj;
}
diff --git a/source/blender/python/api2_2x/BezTriple.h b/source/blender/python/api2_2x/BezTriple.h
index e8fb4f2e543..a4e9b2e2db3 100644
--- a/source/blender/python/api2_2x/BezTriple.h
+++ b/source/blender/python/api2_2x/BezTriple.h
@@ -59,7 +59,7 @@ typedef struct {
PyObject *BezTriple_CreatePyObject( BezTriple * bzt );
int BezTriple_CheckPyObject( PyObject * pyobj );
BezTriple *BezTriple_FromPyObject( PyObject * pyobj );
-PyObject *newBezTriple( PyObject *args );
+PyObject *newBezTriple( float *args );
PyObject *BezTriple_Init( void );
#endif /* EXPP_BEZTRIPLE_H */
diff --git a/source/blender/python/api2_2x/Blender.c b/source/blender/python/api2_2x/Blender.c
index 7c7d07f52e1..e00d39ee4ff 100644
--- a/source/blender/python/api2_2x/Blender.c
+++ b/source/blender/python/api2_2x/Blender.c
@@ -416,13 +416,13 @@ static PyObject *Blender_Get( PyObject * self, PyObject * args )
else if( StringEqual( str, "vrmloptions" ) ) {
ret = PyDict_New( );
- PyDict_SetItemString( dict, "twoside",
+ EXPP_dict_set_item_str( ret, "twoside",
PyInt_FromLong( U.vrmlflag & USER_VRML_TWOSIDED ) );
- PyDict_SetItemString( dict, "layers",
+ EXPP_dict_set_item_str( ret, "layers",
PyInt_FromLong( U.vrmlflag & USER_VRML_LAYERS ) );
- PyDict_SetItemString( dict, "autoscale",
+ EXPP_dict_set_item_str( ret, "autoscale",
PyInt_FromLong( U.vrmlflag & USER_VRML_AUTOSCALE ) );
} /* End 'quick hack' part. */
@@ -678,8 +678,8 @@ static PyObject *Blender_ShowHelp(PyObject *self, PyObject *args)
return EXPP_ReturnPyObjError(PyExc_MemoryError,
"can't create py dictionary!");
- PyDict_SetItemString(rkeyd, "script", script);
- PyDict_SetItemString(bpy_registryDict, "__help_browser", rkeyd);
+ EXPP_dict_set_item_str(rkeyd, "script", script);
+ EXPP_dict_set_item_str(bpy_registryDict, "__help_browser", rkeyd);
arglist = Py_BuildValue("(s)", hspath);
Blender_Run(self, arglist);
@@ -798,10 +798,10 @@ void M_Blender_Init(void)
PyModule_AddIntConstant(module, "TRUE", 1);
PyModule_AddIntConstant( module, "FALSE", 0 );
- PyDict_SetItemString(dict, "bylink", EXPP_incr_ret_False());
- PyDict_SetItemString(dict, "link", EXPP_incr_ret (Py_None));
- PyDict_SetItemString(dict, "event", PyString_FromString(""));
- PyDict_SetItemString(dict, "mode", smode);
+ EXPP_dict_set_item_str(dict, "bylink", EXPP_incr_ret_False());
+ PyDict_SetItemString(dict, "link", Py_None);
+ EXPP_dict_set_item_str(dict, "event", PyString_FromString(""));
+ EXPP_dict_set_item_str(dict, "mode", smode);
PyDict_SetItemString(dict, "Armature", Armature_Init());
PyDict_SetItemString(dict, "BezTriple", BezTriple_Init());
diff --git a/source/blender/python/api2_2x/Curve.c b/source/blender/python/api2_2x/Curve.c
index 544ae9fb00a..2445e835dee 100644
--- a/source/blender/python/api2_2x/Curve.c
+++ b/source/blender/python/api2_2x/Curve.c
@@ -838,6 +838,7 @@ static PyObject *Curve_setControlPoint( BPy_Curve * self, PyObject * args )
static PyObject *Curve_getControlPoint( BPy_Curve * self, PyObject * args )
{
PyObject *liste = PyList_New( 0 ); /* return values */
+ PyObject *item;
Nurb *ptrnurb;
int i, j;
@@ -870,22 +871,18 @@ static PyObject *Curve_getControlPoint( BPy_Curve * self, PyObject * args )
"point index out of range" ) );
if( ptrnurb->bp ) { /* if we are a nurb curve, you get 4 values */
- for( i = 0; i < 4; i++ )
- PyList_Append( liste,
- PyFloat_FromDouble( ptrnurb->
- bp[numpoint].
- vec[i] ) );
- }
-
- if( ptrnurb->bezt ) { /* if we are a bezier, you get 9 values */
+ for( i = 0; i < 4; i++ ) {
+ item = PyFloat_FromDouble( ptrnurb->bp[numpoint].vec[i] );
+ PyList_Append( liste, item );
+ Py_DECREF(item);
+ }
+ } else if( ptrnurb->bezt ) { /* if we are a bezier, you get 9 values */
for( i = 0; i < 3; i++ )
- for( j = 0; j < 3; j++ )
- PyList_Append( liste,
- PyFloat_FromDouble( ptrnurb->
- bezt
- [numpoint].
- vec[i]
- [j] ) );
+ for( j = 0; j < 3; j++ ) {
+ item = PyFloat_FromDouble( ptrnurb->bezt[numpoint].vec[i][j] );
+ PyList_Append( liste, item );
+ Py_DECREF(item);
+ }
}
return liste;
diff --git a/source/blender/python/api2_2x/Draw.c b/source/blender/python/api2_2x/Draw.c
index e8c49dd71ff..57802c47746 100644
--- a/source/blender/python/api2_2x/Draw.c
+++ b/source/blender/python/api2_2x/Draw.c
@@ -534,12 +534,14 @@ void BPY_spacescript_do_pywin_event( SpaceScript * sc, unsigned short event,
int pass_ascii = 0;
if (ascii > 31 && ascii != 127) {
pass_ascii = 1;
- PyDict_SetItemString(g_blenderdict, "event", PyInt_FromLong((long)ascii));
+ EXPP_dict_set_item_str(g_blenderdict, "event",
+ PyInt_FromLong((long)ascii));
}
exec_callback( sc, sc->script->py_event,
Py_BuildValue( "(ii)", event, val ) );
if (pass_ascii)
- PyDict_SetItemString(g_blenderdict, "event", PyString_FromString(""));
+ EXPP_dict_set_item_str(g_blenderdict, "event",
+ PyString_FromString(""));
}
}
@@ -1392,11 +1394,11 @@ PyObject *Draw_Init( void )
dict = PyModule_GetDict( submodule );
#define EXPP_ADDCONST(x) \
- PyDict_SetItemString(dict, #x, PyInt_FromLong(x))
+ EXPP_dict_set_item_str(dict, #x, PyInt_FromLong(x))
/* So, for example:
* EXPP_ADDCONST(LEFTMOUSE) becomes
- * PyDict_SetItemString(dict, "LEFTMOUSE", PyInt_FromLong(LEFTMOUSE))
+ * EXPP_dict_set_item_str(dict, "LEFTMOUSE", PyInt_FromLong(LEFTMOUSE))
*/
EXPP_ADDCONST( LEFTMOUSE );
diff --git a/source/blender/python/api2_2x/Effect.c b/source/blender/python/api2_2x/Effect.c
index 2bf63abe3b3..fab16c7e8f3 100644
--- a/source/blender/python/api2_2x/Effect.c
+++ b/source/blender/python/api2_2x/Effect.c
@@ -734,7 +734,7 @@ PyObject *Effect_Init( void )
dict = PyModule_GetDict( submodule );
- PyDict_SetItemString( dict, "Particle", particle );
+ EXPP_dict_set_item_str( dict, "Particle", particle );
return ( submodule );
}
@@ -1339,7 +1339,7 @@ static int Effect_setVertGroup( BPy_Effect * self, PyObject * value )
dg = get_named_vertexgroup( self->object, self->effect->vgroupname );
if( dg )
- self->effect->vertgroup = get_defgroup_num( self->object, dg )+1;
+ self->effect->vertgroup = (short)get_defgroup_num( self->object, dg )+1;
else
self->effect->vertgroup = 0;
@@ -1372,7 +1372,7 @@ static int Effect_setSpeedVertGroup( BPy_Effect * self, PyObject * value )
dg = get_named_vertexgroup( self->object, self->effect->vgroupname_v );
if( dg )
- self->effect->vertgroup_v = get_defgroup_num( self->object, dg )+1;
+ self->effect->vertgroup_v = (short)get_defgroup_num( self->object, dg )+1;
else
self->effect->vertgroup_v = 0;
diff --git a/source/blender/python/api2_2x/Ipocurve.c b/source/blender/python/api2_2x/Ipocurve.c
index c89b3303188..6167223b1bd 100644
--- a/source/blender/python/api2_2x/Ipocurve.c
+++ b/source/blender/python/api2_2x/Ipocurve.c
@@ -83,7 +83,6 @@ static PyObject *IpoCurve_setExtrapolation( C_IpoCurve * self,
PyObject * args );
static PyObject *IpoCurve_getExtrapolation( C_IpoCurve * self );
static PyObject *IpoCurve_getPoints( C_IpoCurve * self );
-static int IpoCurve_setPoints( C_IpoCurve * self, PyObject * value );
static PyObject *IpoCurve_evaluate( C_IpoCurve * self, PyObject * args );
static PyObject *IpoCurve_getDriver( C_IpoCurve * self );
@@ -565,20 +564,6 @@ static PyObject *IpoCurve_getPoints( C_IpoCurve * self )
return list;
}
-
-static int IpoCurve_setPoints( C_IpoCurve * self, PyObject * value )
-{
- struct BezTriple *bezt;
- PyObject *l = PyList_New( 0 );
- int i;
- for( i = 0; i < self->ipocurve->totvert; i++ ) {
- bezt = self->ipocurve->bezt + i;
- PyList_Append( l, BezTriple_CreatePyObject( bezt ) );
- }
- return 0;
-}
-
-
/*****************************************************************************/
/* Function: IpoCurveRepr */
/* Description: This is a callback function for the C_IpoCurve type. It */
@@ -587,7 +572,7 @@ static int IpoCurve_setPoints( C_IpoCurve * self, PyObject * value )
static PyObject *IpoCurveRepr( C_IpoCurve * self )
{
char s[100];
- sprintf( s, "[IpoCurve \"%s\"]\n", getIpoCurveName( self->ipocurve ) );
+ sprintf( s, "[IpoCurve \"%s\"]", getIpoCurveName( self->ipocurve ) );
return PyString_FromString( s );
}
diff --git a/source/blender/python/api2_2x/Key.c b/source/blender/python/api2_2x/Key.c
index f1b8c5e2388..e71602ad6b4 100644
--- a/source/blender/python/api2_2x/Key.c
+++ b/source/blender/python/api2_2x/Key.c
@@ -25,7 +25,7 @@
*
* This is a new part of Blender.
*
- * Contributor(s): Pontus Lidman, Johnny Matthews
+ * Contributor(s): Pontus Lidman, Johnny Matthews, Ken Hughes
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
@@ -35,6 +35,7 @@
#include <BLI_blenlib.h>
#include <BKE_global.h>
#include <BKE_main.h>
+#include <BKE_curve.h>
#include "Ipocurve.h"
#include "Key.h"
@@ -79,6 +80,8 @@ static PyGetSetDef BPy_Key_getsetters[] = {
"Key value",NULL},
{"ipo",(getter)Key_getIpo, (setter)Key_setIpo,
"ipo linked to key",NULL},
+ {"blocks",(getter)Key_getBlocks, (setter)NULL,
+ "blocks linked to the key",NULL},
{NULL,NULL,NULL,NULL,NULL} /* Sentinel */
};
@@ -97,12 +100,9 @@ static int KeyBlock_setVgroup( BPy_KeyBlock *, PyObject * args );
static int KeyBlock_setSlidermin( BPy_KeyBlock *, PyObject * args );
static int KeyBlock_setSlidermax( BPy_KeyBlock *, PyObject * args );
-
-
static struct PyMethodDef KeyBlock_methods[] = {
{ "getData", (PyCFunction) KeyBlock_getData, METH_NOARGS,
"Get keyblock data" },
-
{ 0, 0, 0, 0 }
};
@@ -117,8 +117,10 @@ static PyGetSetDef BPy_KeyBlock_getsetters[] = {
"Keyblock Slider Maximum",NULL},
{"vgroup",(getter)KeyBlock_getVgroup, (setter)KeyBlock_setVgroup,
"Keyblock VGroup",NULL},
+ {"data",(getter)KeyBlock_getData, (setter)NULL,
+ "Keyblock VGroup",NULL},
{NULL,NULL,NULL,NULL,NULL} /* Sentinel */
- };
+};
PyTypeObject Key_Type = {
PyObject_HEAD_INIT( NULL ) 0, /*ob_size */
@@ -197,9 +199,6 @@ PyTypeObject Key_Type = {
NULL
};
-
-
-
PyTypeObject KeyBlock_Type = {
PyObject_HEAD_INIT( NULL ) 0, /*ob_size */
"Blender KeyBlock", /*tp_name */
@@ -277,8 +276,6 @@ PyTypeObject KeyBlock_Type = {
NULL
};
-
-
static void Key_dealloc( PyObject * self )
{
PyObject_DEL( self );
@@ -365,7 +362,6 @@ static int Key_setIpo( PyObject * self, PyObject * value )
return 0;
}
-
static PyObject *Key_getType( PyObject * self )
{
BPy_Key *k = ( BPy_Key * ) self;
@@ -406,7 +402,6 @@ static PyObject *Key_getBlocks( PyObject * self )
return l;
}
-
static PyObject *Key_getValue( PyObject * self )
{
BPy_Key *k = ( BPy_Key * ) self;
@@ -414,10 +409,7 @@ static PyObject *Key_getValue( PyObject * self )
return PyFloat_FromDouble( k->key->curval );
}
-
-
-
-// ------------ Key Block Functions --------------//
+/* ------------ Key Block Functions -------------- */
static void KeyBlock_dealloc( PyObject * self )
{
@@ -445,33 +437,33 @@ PyObject *KeyBlock_CreatePyObject( KeyBlock * kb, Key *parentKey )
return ( PyObject * ) keyBlock;
}
-
static PyObject *KeyBlock_getName( BPy_KeyBlock * self ) {
BPy_KeyBlock *kb = ( BPy_KeyBlock * ) self;
PyObject *name = Py_BuildValue( "s", kb->keyblock->name);
return name;
}
+
static PyObject *KeyBlock_getPos( BPy_KeyBlock * self ){
BPy_KeyBlock *kb = ( BPy_KeyBlock * ) self;
return PyFloat_FromDouble( kb->keyblock->pos );
}
+
static PyObject *KeyBlock_getSlidermin( BPy_KeyBlock * self ){
BPy_KeyBlock *kb = ( BPy_KeyBlock * ) self;
return PyFloat_FromDouble( kb->keyblock->slidermin );
}
+
static PyObject *KeyBlock_getSlidermax( BPy_KeyBlock * self ){
BPy_KeyBlock *kb = ( BPy_KeyBlock * ) self;
return PyFloat_FromDouble( kb->keyblock->slidermax );
}
+
static PyObject *KeyBlock_getVgroup( BPy_KeyBlock * self ){
BPy_KeyBlock *kb = ( BPy_KeyBlock * ) self;
PyObject *name = Py_BuildValue( "s", kb->keyblock->vgroup);
return name;
}
-
-
-
static int KeyBlock_setName( BPy_KeyBlock * self, PyObject * args ){
char* text = NULL;
BPy_KeyBlock *kb = ( BPy_KeyBlock * ) self;
@@ -508,38 +500,50 @@ static int KeyBlock_setSlidermax( BPy_KeyBlock * self, PyObject * args ){
10.0f );
}
+static Curve *find_curve( Key *key )
+{
+ Curve *cu;
+ if( !key )
+ return NULL;
-
-
-
+ for( cu = G.main->curve.first; cu; cu = cu->id.next ) {
+ if( cu->key == key )
+ break;
+ }
+ return cu;
+}
static PyObject *KeyBlock_getData( PyObject * self )
{
- /* If this is a mesh key, data is an array of MVert.
- If lattice, data is an array of BPoint
- If curve, data is an array of BezTriple */
+ /* If this is a mesh key, data is an array of MVert coords.
+ If lattice, data is an array of BPoint coords
+ If curve, data is an array of BezTriple or BPoint */
- BPy_KeyBlock *kb = ( BPy_KeyBlock * ) self;
- Key *key = kb->key;
char *datap;
int datasize;
int idcode;
int i;
+ Curve *cu;
+ Nurb* nu;
+ PyObject *l;
+ BPy_KeyBlock *kb = ( BPy_KeyBlock * ) self;
+ Key *key = kb->key;
- PyObject *l = PyList_New( kb->keyblock->totelem );
+ if( !kb->keyblock->data ) {
+ Py_RETURN_NONE;
+ }
- idcode = GS( key->from->name );
+ l = PyList_New( kb->keyblock->totelem );
+ if( !l )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "PyList_New() failed" );
- if (!kb->keyblock->data) {
- return EXPP_incr_ret( Py_None );
- }
+ idcode = GS( key->from->name );
switch(idcode) {
case ID_ME:
- datasize = sizeof(MVert);
-
for (i=0, datap = kb->keyblock->data; i<kb->keyblock->totelem; i++) {
BPy_NMVert *mv = PyObject_NEW( BPy_NMVert, &NMVert_Type );
@@ -548,9 +552,9 @@ static PyObject *KeyBlock_getData( PyObject * self )
mv->co[0]=vert->co[0];
mv->co[1]=vert->co[1];
mv->co[2]=vert->co[2];
- mv->no[0] = (float)(vert->no[0] / 32767.0);
- mv->no[1] = (float)(vert->no[1] / 32767.0);
- mv->no[2] = (float)(vert->no[2] / 32767.0);
+ mv->no[0] = 0.0;
+ mv->no[1] = 0.0;
+ mv->no[2] = 0.0;
mv->uvco[0] = mv->uvco[1] = mv->uvco[2] = 0.0;
mv->index = i;
@@ -558,42 +562,60 @@ static PyObject *KeyBlock_getData( PyObject * self )
PyList_SetItem(l, i, ( PyObject * ) mv);
- datap += datasize;
+ datap += kb->key->elemsize;
}
break;
case ID_CU:
-
- datasize = sizeof(BezTriple);
-
- for (i=0, datap = kb->keyblock->data; i<kb->keyblock->totelem; i++) {
-
- BezTriple *bt = (BezTriple *) datap;
- PyObject *pybt = BezTriple_CreatePyObject( bt );
-
- PyList_SetItem( l, i, pybt );
-
- datap += datasize;
+ cu = find_curve ( key );
+ if( !cu )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "key is no linked to any curve!" );
+ datasize = count_curveverts(&cu->nurb);
+ nu = cu->nurb.first;
+ if( nu->bezt ) {
+ datasize /= 3;
+ Py_DECREF (l);
+ l = PyList_New( datasize );
+ for( i = 0, datap = kb->keyblock->data; i < datasize;
+ i++, datap += sizeof(float)*12 ) {
+ /*
+ * since the key only stores the control point and not the
+ * other BezTriple attributes, build a Py_NEW BezTriple
+ */
+ PyObject *pybt = newBezTriple( (float *)datap );
+ PyList_SetItem( l, i, pybt );
+ }
+ } else {
+ for( i = 0, datap = kb->keyblock->data; i < datasize;
+ i++, datap += kb->key->elemsize ) {
+ PyObject *pybt;
+ float *fp = (float *)datap;
+ pybt = Py_BuildValue( "[f,f,f]", fp[0],fp[1],fp[2]);
+ if( !pybt ) {
+ Py_DECREF( l );
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "Py_BuildValue() failed" );
+ }
+ PyList_SetItem( l, i, pybt );
+ }
}
break;
case ID_LT:
- datasize = sizeof(BPoint);
-
- for (i=0, datap = kb->keyblock->data; i<kb->keyblock->totelem; i++) {
- /* Lacking a python class for BPoint, use a list of four floats */
- BPoint *bp = (BPoint *) datap;
- PyObject *bpoint = PyList_New( 4 );
-
- PyList_SetItem( bpoint, 0, PyFloat_FromDouble( bp->vec[0] ) );
- PyList_SetItem( bpoint, 1, PyFloat_FromDouble( bp->vec[1] ) );
- PyList_SetItem( bpoint, 2, PyFloat_FromDouble( bp->vec[2] ) );
- PyList_SetItem( bpoint, 3, PyFloat_FromDouble( bp->vec[3] ) );
-
- PyList_SetItem( l, i, bpoint );
-
- datap += datasize;
+ for( i = 0, datap = kb->keyblock->data; i < kb->keyblock->totelem;
+ i++, datap += kb->key->elemsize ) {
+ /* Lacking a python class for BPoint, use a list of three floats */
+ PyObject *pybt;
+ float *fp = (float *)datap;
+ pybt = Py_BuildValue( "[f,f,f]", fp[0],fp[1],fp[2]);
+ if( !pybt ) {
+ Py_DECREF( l );
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "Py_BuildValue() failed" );
+ }
+ PyList_SetItem( l, i, pybt );
}
break;
}
@@ -638,7 +660,6 @@ static PyObject *M_Key_Get( PyObject * self, PyObject * args )
}
}
-
struct PyMethodDef M_Key_methods[] = {
{"Get", M_Key_Get, METH_VARARGS, "Get a key or all key names"},
{NULL, NULL, 0, NULL}
@@ -652,10 +673,8 @@ PyObject *Key_Init( void )
return NULL;
Key_Type.ob_type = &PyType_Type;
- //KeyBlock_Type.ob_type = &PyType_Type;
PyType_Ready( &KeyBlock_Type );
-
submodule =
Py_InitModule3( "Blender.Key", M_Key_methods, "Key module" );
diff --git a/source/blender/python/api2_2x/Lattice.c b/source/blender/python/api2_2x/Lattice.c
index 415eb6c7be2..739d9d3733d 100644
--- a/source/blender/python/api2_2x/Lattice.c
+++ b/source/blender/python/api2_2x/Lattice.c
@@ -369,12 +369,12 @@ PyObject *Lattice_Init( void )
Lattice_Type.ob_type = &PyType_Type;
//Module dictionary
-#define EXPP_ADDCONST(x) PyDict_SetItemString(dict, #x, PyInt_FromLong(LT_##x))
+#define EXPP_ADDCONST(x) EXPP_dict_set_item_str(dict, #x, PyInt_FromLong(LT_##x))
EXPP_ADDCONST( GRID );
EXPP_ADDCONST( OUTSIDE );
#undef EXPP_ADDCONST
-#define EXPP_ADDCONST(x) PyDict_SetItemString(dict, #x, PyInt_FromLong(KEY_##x))
+#define EXPP_ADDCONST(x) EXPP_dict_set_item_str(dict, #x, PyInt_FromLong(KEY_##x))
EXPP_ADDCONST( LINEAR );
EXPP_ADDCONST( CARDINAL );
EXPP_ADDCONST( BSPLINE );
diff --git a/source/blender/python/api2_2x/MTex.c b/source/blender/python/api2_2x/MTex.c
index 6b058361951..848d28edfa0 100644
--- a/source/blender/python/api2_2x/MTex.c
+++ b/source/blender/python/api2_2x/MTex.c
@@ -25,7 +25,7 @@
*
* This is a new part of Blender.
*
- * Contributor(s): Alex Mole
+ * Contributor(s): Alex Mole, Yehoshua Sapir
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
@@ -33,13 +33,15 @@
#include "BKE_utildefines.h"
#include "Texture.h"
+#include "Object.h"
#include "gen_utils.h"
+#include <DNA_material_types.h>
/*****************************************************************************/
/* Python BPy_MTex methods declarations: */
/*****************************************************************************/
-static PyObject *MTex_setTex( BPy_MTex * self, PyObject * args );
+static PyObject *MTex_setTexMethod( BPy_MTex * self, PyObject * args );
/*****************************************************************************/
/* Python method structure definition for Blender.Texture.MTex module: */
@@ -53,7 +55,7 @@ struct PyMethodDef M_MTex_methods[] = {
/*****************************************************************************/
static PyMethodDef BPy_MTex_methods[] = {
/* name, method, flags, doc */
- {"setTex", ( PyCFunction ) MTex_setTex, METH_VARARGS,
+ {"setTex", ( PyCFunction ) MTex_setTexMethod, METH_VARARGS,
"(i) - Set MTex Texture"},
{NULL, NULL, 0, NULL}
};
@@ -62,15 +64,126 @@ static PyMethodDef BPy_MTex_methods[] = {
/* Python MTex_Type callback function prototypes: */
/*****************************************************************************/
static void MTex_dealloc( BPy_MTex * self );
-static int MTex_setAttr( BPy_MTex * self, char *name, PyObject * v );
static int MTex_compare( BPy_MTex * a, BPy_MTex * b );
-static PyObject *MTex_getAttr( BPy_MTex * self, char *name );
static PyObject *MTex_repr( BPy_MTex * self );
+#define MTEXGET(x) \
+ static PyObject *MTex_get##x( BPy_MTex *self, void *closure );
+#define MTEXSET(x) \
+ static int MTex_set##x( BPy_MTex *self, PyObject *value, void *closure);
+#define MTEXGETSET(x) \
+ MTEXGET(x) \
+ MTEXSET(x)
+
+MTEXGETSET(Tex)
+MTEXGETSET(TexCo)
+MTEXGETSET(Object)
+MTEXGETSET(MapTo)
+MTEXGETSET(Col)
+MTEXGETSET(DVar)
+MTEXGETSET(BlendMode)
+MTEXGETSET(ColFac)
+MTEXGETSET(NorFac)
+MTEXGETSET(VarFac)
+MTEXGETSET(DispFac)
+MTEXGETSET(WarpFac)
+MTEXGETSET(Ofs)
+MTEXGETSET(Size)
+MTEXGETSET(Mapping)
+MTEXGETSET(Flag)
+MTEXGETSET(ProjX)
+MTEXGETSET(ProjY)
+MTEXGETSET(ProjZ)
+MTEXGETSET(MapToFlag)
+
+/*****************************************************************************/
+/* Python get/set methods table */
+/*****************************************************************************/
+
+static PyGetSetDef MTex_getseters[] = {
+ { "tex", (getter) MTex_getTex, (setter) MTex_setTex,
+ "Texture whose mapping this MTex describes", NULL },
+ { "texco", (getter) MTex_getTexCo, (setter) MTex_setTexCo,
+ "Texture coordinate space (UV, Global, etc.)", NULL },
+ { "object", (getter) MTex_getObject, (setter) MTex_setObject,
+ "Object whose space to use when texco is Object", NULL },
+ { "mapto", (getter) MTex_getMapTo, (setter) MTex_setMapTo,
+ "What values the texture affects", NULL },
+ { "col", (getter) MTex_getCol, (setter) MTex_setCol,
+ "Color that the texture blends with", NULL },
+ { "dvar", (getter) MTex_getDVar, (setter) MTex_setDVar,
+ "Value that the texture blends with when not blending colors", NULL },
+ { "blendmode", (getter) MTex_getBlendMode, (setter) MTex_setBlendMode,
+ "Texture blending mode", NULL },
+ { "colfac", (getter) MTex_getColFac, (setter) MTex_setColFac,
+ "Factor by which texture affects color", NULL },
+ { "norfac", (getter) MTex_getNorFac, (setter) MTex_setNorFac,
+ "Factor by which texture affects normal", NULL },
+ { "varfac", (getter) MTex_getVarFac, (setter) MTex_setVarFac,
+ "Factor by which texture affects most variables", NULL },
+ { "dispfac", (getter) MTex_getDispFac, (setter) MTex_setDispFac,
+ "Factor by which texture affects displacement", NULL },
+ { "warpfac", (getter) MTex_getWarpFac, (setter) MTex_setWarpFac,
+ "Factor by which texture affects warp", NULL },
+ { "ofs", (getter) MTex_getOfs, (setter) MTex_setOfs,
+ "Offset to adjust texture space", NULL },
+ { "size", (getter) MTex_getSize, (setter) MTex_setSize,
+ "Size to scale texture space", NULL },
+ { "mapping", (getter) MTex_getMapping, (setter) MTex_setMapping,
+ "Mapping of texture coordinates (flat, cube, etc.)", NULL },
+ { "stencil", (getter) MTex_getFlag, (setter) MTex_setFlag,
+ "Stencil mode", (void*) MTEX_STENCIL },
+ { "neg", (getter) MTex_getFlag, (setter) MTex_setFlag,
+ "Negate texture values mode", (void*) MTEX_NEGATIVE },
+ { "noRGB", (getter) MTex_getFlag, (setter) MTex_setFlag,
+ "Convert texture RGB values to intensity values",
+ (void*) MTEX_RGBTOINT },
+ { "correctNor", (getter) MTex_getFlag, (setter) MTex_setFlag,
+ "Correct normal mapping for Texture space and Object space",
+ (void*) MTEX_VIEWSPACE },
+ { "xproj", (getter) MTex_getProjX, (setter) MTex_setProjX,
+ "Projection of X axis to Texture space", NULL },
+ { "yproj", (getter) MTex_getProjY, (setter) MTex_setProjY,
+ "Projection of Y axis to Texture space", NULL },
+ { "zproj", (getter) MTex_getProjZ, (setter) MTex_setProjZ,
+ "Projection of Z axis to Texture space", NULL },
+ { "mtCol", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
+ "How texture maps to color", (void*) MAP_COL },
+ { "mtNor", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
+ "How texture maps to normals", (void*) MAP_NORM },
+ { "mtCsp", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
+ "How texture maps to specularity color", (void*) MAP_COLSPEC },
+ { "mtCmir", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
+ "How texture maps to mirror color", (void*) MAP_COLMIR },
+ { "mtRef", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
+ "How texture maps to reflectivity", (void*) MAP_REF },
+ { "mtSpec", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
+ "How texture maps to specularity", (void*) MAP_SPEC },
+ { "mtEmit", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
+ "How texture maps to emit value", (void*) MAP_EMIT },
+ { "mtAlpha", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
+ "How texture maps to alpha value", (void*) MAP_ALPHA },
+ { "mtHard", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
+ "How texture maps to hardness", (void*) MAP_HAR },
+ { "mtRayMir", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
+ "How texture maps to RayMir value", (void*) MAP_RAYMIRR },
+ { "mtTranslu", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
+ "How texture maps to translucency", (void*) MAP_TRANSLU },
+ { "mtAmb", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
+ "How texture maps to ambient value", (void*) MAP_AMB },
+ { "mtDisp", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
+ "How texture maps to displacement", (void*) MAP_DISPLACE },
+ { "mtWarp", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
+ "How texture maps to warp", (void*) MAP_WARP },
+ { NULL, NULL, NULL, NULL, NULL }
+};
+
+
/*****************************************************************************/
/* Python MTex_Type structure definition: */
/*****************************************************************************/
+
PyTypeObject MTex_Type = {
PyObject_HEAD_INIT( NULL )
0, /* ob_size */
@@ -80,27 +193,55 @@ PyTypeObject MTex_Type = {
/* methods */
( destructor ) MTex_dealloc, /* tp_dealloc */
0, /* tp_print */
- ( getattrfunc ) MTex_getAttr, /* tp_getattr */
- ( setattrfunc ) MTex_setAttr, /* tp_setattr */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
( cmpfunc ) MTex_compare, /* tp_compare */
( reprfunc ) MTex_repr, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_as_hash */
- 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ /*** Flags to define presence of optional/expanded features ***/
+ Py_TPFLAGS_DEFAULT, /* long tp_flags; */
0, /* tp_doc */
0, 0, 0, 0, 0, 0,
- 0, /* tp_methods */
+ BPy_MTex_methods, /* tp_methods */
0, /* tp_members */
+ MTex_getseters, /* struct PyGetSetDef *tp_getset; */
+ 0, /* struct _typeobject *tp_base; */
+ 0, /* PyObject *tp_dict; */
+ 0, /* descrgetfunc tp_descr_get; */
+ 0, /* descrsetfunc tp_descr_set; */
+ 0, /* long tp_dictoffset; */
+ 0, /* initproc tp_init; */
+ 0, /* allocfunc tp_alloc; */
+ 0, /* newfunc tp_new; */
+ /* Low-level free-memory routine */
+ 0, /* freefunc tp_free; */
+ /* For PyObject_IS_GC */
+ 0, /* inquiry tp_is_gc; */
+ 0, /* PyObject *tp_bases; */
+ /* method resolution order */
+ 0, /* PyObject *tp_mro; */
+ 0, /* PyObject *tp_cache; */
+ 0, /* PyObject *tp_subclasses; */
+ 0, /* PyObject *tp_weaklist; */
+ 0
};
PyObject *MTex_Init( void )
{
PyObject *submodule;
+/* PyObject *dict; */
- MTex_Type.ob_type = &PyType_Type;
+ /* call PyType_Ready() to init dictionaries & such */
+ if( PyType_Ready( &MTex_Type) < 0)
+ return NULL;
+
+ /* So do we need this? */
+/* MTex_Type.ob_type = &PyType_Type;*/
submodule = Py_InitModule( "Blender.Texture.MTex", M_MTex_methods );
@@ -136,17 +277,27 @@ int MTex_CheckPyObject( PyObject * pyobj )
/* Python BPy_MTex methods: */
/*****************************************************************************/
-static PyObject *MTex_setTex( BPy_MTex * self, PyObject * args )
+static PyObject *MTex_setTexMethod( BPy_MTex * self, PyObject * args )
{
- BPy_Texture *pytex = NULL;
- if( !PyArg_ParseTuple( args, "O!", &Texture_Type, &pytex ) )
+ Tex *tex;
+
+ if( args == Py_None )
+ {
+ tex = NULL;
+ } else if( Texture_CheckPyObject( args ) ) {
+ tex = Texture_FromPyObject( args );
+ } else {
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected Texture argument" );
-
+ }
+
if( self->mtex->tex )
self->mtex->tex->id.us--;
- self->mtex->tex = Texture_FromPyObject( ( PyObject * ) pytex );
+ self->mtex->tex = tex;
+
+ if( self->mtex->tex )
+ self->mtex->tex->id.us++;
Py_INCREF( Py_None );
return Py_None;
@@ -157,83 +308,581 @@ static void MTex_dealloc( BPy_MTex * self )
PyObject_DEL( self );
}
-static PyObject *MTex_getAttr( BPy_MTex * self, char *name )
+static int MTex_compare( BPy_MTex * a, BPy_MTex * b )
{
- if( STREQ( name, "tex" ) ) {
- if( self->mtex->tex )
- return Texture_CreatePyObject( self->mtex->tex );
- else {
- Py_INCREF( Py_None );
- return Py_None;
- }
- } else if( STREQ( name, "texco" ) )
- return PyInt_FromLong( self->mtex->texco );
- else if( STREQ( name, "mapto" ) )
- return PyInt_FromLong( self->mtex->mapto );
-
- else if( STREQ( name, "__members__" ) )
- return Py_BuildValue( "[s,s,s]", "tex", "texco", "mapto" );
-
- /* not an attribute, search the methods table */
- return Py_FindMethod( BPy_MTex_methods, ( PyObject * ) self, name );
-}
-
-static int MTex_setAttr( BPy_MTex * self, char *name, PyObject * value )
-{
- PyObject *valtuple;
- PyObject *error = NULL;
-
- /* Put "value" in a tuple, because we want to pass it to functions *
- * that only accept PyTuples. */
- valtuple = Py_BuildValue( "(O)", value );
- if( !valtuple )
- return EXPP_ReturnIntError( PyExc_MemoryError,
- "MTex_setAttr: couldn't create PyTuple" );
-
- if( STREQ( name, "tex" ) )
- error = MTex_setTex( self, valtuple );
- else if( STREQ( name, "texco" ) ) {
- if( PyInt_Check( value ) ) {
- int texco = PyInt_AsLong( value );
- /* TODO: sanity-check this input! */
- self->mtex->texco = (short)texco;
- Py_INCREF( Py_None ); /* because we decref it below */
- error = Py_None;
- }
- } else if( STREQ( name, "mapto" ) ) {
- if( PyInt_Check( value ) ) {
- int mapto = PyInt_AsLong( value );
- /* TODO: sanity-check this input! */
- self->mtex->mapto = (short)mapto;
- Py_INCREF( Py_None ); /* because we decref it below */
- error = Py_None;
- }
+ return ( a->mtex == b->mtex ) ? 0 : -1;
+}
+
+static PyObject *MTex_repr( BPy_MTex * self )
+{
+ return PyString_FromFormat( "[MTex]" );
+}
+
+
+/*****************************************************************************/
+/* Python BPy_MTex get and set functions: */
+/*****************************************************************************/
+
+static PyObject *MTex_getTex( BPy_MTex *self, void *closure )
+{
+ if( self->mtex->tex )
+ return Texture_CreatePyObject( self->mtex->tex );
+ else {
+ Py_INCREF( Py_None );
+ return Py_None;
}
+}
+static int MTex_setTex( BPy_MTex *self, PyObject *value, void *closure)
+{
+ Tex *tex;
+
+ if( value == Py_None )
+ {
+ tex = NULL;
+ } else if( Texture_CheckPyObject( value ) ) {
+ tex = Texture_FromPyObject( value );
+ } else {
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected Texture argument" );
+ }
+
+ if( self->mtex->tex )
+ self->mtex->tex->id.us--;
+
+ self->mtex->tex = tex;
+
+ if( self->mtex->tex )
+ self->mtex->tex->id.us++;
+
+ return 0;
+}
+
+static PyObject *MTex_getTexCo( BPy_MTex *self, void *closure )
+{
+ return PyInt_FromLong( self->mtex->texco );
+}
+
+static int MTex_setTexCo( BPy_MTex *self, PyObject *value, void *closure)
+{
+ int texco;
+
+ if( !PyInt_Check( value ) ) {
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "Value must be a member of Texture.TexCo dictionary" );
+ }
+
+ texco = PyInt_AsLong( value ) ;
+
+ if (texco != TEXCO_ORCO && texco != TEXCO_REFL && texco != TEXCO_NORM &&
+ texco != TEXCO_GLOB && texco != TEXCO_UV && texco != TEXCO_OBJECT &&
+ texco != TEXCO_WINDOW && texco != TEXCO_VIEW && texco != TEXCO_STICKY )
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "Value must be a member of Texture.TexCo dictionary" );
+
+ self->mtex->texco = (short)texco;
+
+ return 0;
+}
+
+static PyObject *MTex_getObject( BPy_MTex *self, void *closure )
+{
+ if( self->mtex->object )
+ return Object_CreatePyObject( self->mtex->object );
else {
- /* Error */
- Py_DECREF( valtuple );
- return EXPP_ReturnIntError( PyExc_KeyError,
- "attribute not found" );
+ Py_INCREF( Py_None );
+ return Py_None;
}
+}
- Py_DECREF( valtuple );
+static int MTex_setObject( BPy_MTex *self, PyObject *value, void *closure)
+{
+ Object *obj;
+
+ if( value == Py_None )
+ {
+ obj = NULL;
+ } else if( Object_CheckPyObject( value ) ) {
+ obj = Object_FromPyObject( value );
+ } else {
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected Object argument" );
+ }
+
+ if( self->mtex->object )
+ self->mtex->object->id.us--;
- if( error != Py_None )
- return -1;
+ self->mtex->object = obj;
- /* Py_None was INCREF'd by the set*() function, so we need to DECREF it */
- Py_DECREF( Py_None );
+ if( self->mtex->object )
+ self->mtex->object->id.us++;
return 0;
}
-static int MTex_compare( BPy_MTex * a, BPy_MTex * b )
+static PyObject *MTex_getMapTo( BPy_MTex *self, void *closure )
{
- return ( a->mtex == b->mtex ) ? 0 : -1;
+ return PyInt_FromLong( self->mtex->mapto );
}
-static PyObject *MTex_repr( BPy_MTex * self )
+static int MTex_setMapTo( BPy_MTex *self, PyObject *value, void *closure)
{
- return PyString_FromFormat( "[MTex]" );
+ int mapto;
+
+ if( !PyInt_Check( value ) ) {
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected an int" );
+ }
+
+ mapto = PyInt_AsLong( value );
+
+ /* This method is deprecated anyway. */
+ if ( mapto < 0 || mapto > 16383 ) {
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "Value must be a sum of values from Texture.MapTo dictionary" );
+ }
+
+ self->mtex->mapto = (short)mapto;
+
+ return 0;
+}
+
+static PyObject *MTex_getCol( BPy_MTex *self, void *closure )
+{
+ return Py_BuildValue( "(f,f,f)", self->mtex->r, self->mtex->g,
+ self->mtex->b );
+}
+
+static int MTex_setCol( BPy_MTex *self, PyObject *value, void *closure)
+{
+ float rgb[3];
+ int i;
+
+ if( !PyArg_ParseTuple( value, "fff",
+ &rgb[0], &rgb[1], &rgb[2] ) )
+
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected tuple of 3 floats" );
+
+ for( i = 0; i < 3; ++i )
+ if( rgb[i] < 0 || rgb[i] > 1 )
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "values must be in range [0,1]" );
+
+ self->mtex->r = rgb[0];
+ self->mtex->g = rgb[1];
+ self->mtex->b = rgb[2];
+
+ return 0;
+}
+
+static PyObject *MTex_getDVar( BPy_MTex *self, void *closure )
+{
+ return PyFloat_FromDouble(self->mtex->def_var);
+}
+
+static int MTex_setDVar( BPy_MTex *self, PyObject *value, void *closure)
+{
+ float f;
+
+ if ( !PyFloat_Check( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected a float" );
+
+ f = (float)PyFloat_AsDouble(value);
+
+ if (f < 0 || f > 1)
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "values must be in range [0,1]" );
+
+ self->mtex->def_var = f;
+
+ return 0;
+}
+
+static PyObject *MTex_getBlendMode( BPy_MTex *self, void *closure )
+{
+ return PyInt_FromLong(self->mtex->blendtype);
+}
+
+static int MTex_setBlendMode( BPy_MTex *self, PyObject *value, void *closure)
+{
+ int n;
+
+ if ( !PyInt_Check( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "Value must be member of Texture.BlendModes dictionary" );
+
+ n = PyInt_AsLong(value);
+
+/* if (n != MTEX_BLEND && n != MTEX_MUL && n != MTEX_ADD &&
+ n != MTEX_SUB && n != MTEX_DIV && n != MTEX_DARK &&
+ n != MTEX_DIFF && n != MTEX_LIGHT && n != MTEX_SCREEN)*/
+ if (n < 0 || n > 8)
+ {
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "Value must be member of Texture.BlendModes dictionary" );
+ }
+
+ self->mtex->blendtype = (short)n;
+
+ return 0;
+}
+
+static PyObject *MTex_getColFac( BPy_MTex *self, void *closure )
+{
+ return PyFloat_FromDouble(self->mtex->colfac);
+}
+
+static int MTex_setColFac( BPy_MTex *self, PyObject *value, void *closure)
+{
+ float f;
+
+ if ( !PyFloat_Check( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected a float" );
+
+ f = (float)PyFloat_AsDouble(value);
+
+ if (f < 0 || f > 1)
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "values must be in range [0,1]" );
+
+ self->mtex->colfac = f;
+
+ return 0;
+}
+
+static PyObject *MTex_getNorFac( BPy_MTex *self, void *closure )
+{
+ return PyFloat_FromDouble(self->mtex->norfac);
+}
+
+static int MTex_setNorFac( BPy_MTex *self, PyObject *value, void *closure)
+{
+ float f;
+
+ if ( !PyFloat_Check( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected a float" );
+
+ f = (float)PyFloat_AsDouble(value);
+
+ if (f < 0 || f > 25)
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "values must be in range [0,25]" );
+
+ self->mtex->norfac = f;
+
+ return 0;
+}
+
+static PyObject *MTex_getVarFac( BPy_MTex *self, void *closure )
+{
+ return PyFloat_FromDouble(self->mtex->varfac);
+}
+
+static int MTex_setVarFac( BPy_MTex *self, PyObject *value, void *closure)
+{
+ float f;
+
+ if ( !PyFloat_Check( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected a float" );
+
+ f = (float)PyFloat_AsDouble(value);
+
+ if (f < 0 || f > 1)
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "values must be in range [0,1]" );
+
+ self->mtex->varfac = f;
+
+ return 0;
+}
+
+static PyObject *MTex_getDispFac( BPy_MTex *self, void *closure )
+{
+ return PyFloat_FromDouble(self->mtex->dispfac);
+}
+
+static int MTex_setDispFac( BPy_MTex *self, PyObject *value, void *closure)
+{
+ float f;
+
+ if ( !PyFloat_Check( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected a float" );
+
+ f = (float)PyFloat_AsDouble(value);
+
+ if (f < 0 || f > 1)
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "values must be in range [0,1]" );
+
+ self->mtex->dispfac = f;
+
+ return 0;
+}
+
+static PyObject *MTex_getWarpFac( BPy_MTex *self, void *closure )
+{
+ return PyFloat_FromDouble(self->mtex->warpfac);
+}
+
+static int MTex_setWarpFac( BPy_MTex *self, PyObject *value, void *closure)
+{
+ float f;
+
+ if ( !PyFloat_Check( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected a float" );
+
+ f = (float)PyFloat_AsDouble(value);
+
+ if (f < 0 || f > 1)
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "values must be in range [0,1]" );
+
+ self->mtex->warpfac = f;
+
+ return 0;
+}
+
+static PyObject *MTex_getOfs( BPy_MTex *self, void *closure )
+{
+ return Py_BuildValue( "(f,f,f)", self->mtex->ofs[0], self->mtex->ofs[1],
+ self->mtex->ofs[2] );
+}
+
+static int MTex_setOfs( BPy_MTex *self, PyObject *value, void *closure)
+{
+ float f[3];
+ int i;
+
+ if( !PyArg_ParseTuple( value, "fff", &f[0], &f[1], &f[2] ) )
+
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected tuple of 3 floats" );
+
+ for( i = 0; i < 3; ++i )
+ if( f[i] < -10 || f[i] > 10 )
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "values must be in range [-10,10]" );
+
+ self->mtex->ofs[0] = f[0];
+ self->mtex->ofs[1] = f[1];
+ self->mtex->ofs[2] = f[2];
+
+ return 0;
+}
+
+static PyObject *MTex_getSize( BPy_MTex *self, void *closure )
+{
+ return Py_BuildValue( "(f,f,f)", self->mtex->size[0], self->mtex->size[1],
+ self->mtex->size[2] );
+}
+
+static int MTex_setSize( BPy_MTex *self, PyObject *value, void *closure)
+{
+ float f[3];
+ int i;
+
+ if( !PyArg_ParseTuple( value, "fff", &f[0], &f[1], &f[2] ) )
+
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected tuple of 3 floats" );
+
+ for( i = 0; i < 3; ++i )
+ if( f[i] < -100 || f[i] > 100 )
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "values must be in range [-100,100]" );
+
+ self->mtex->size[0] = f[0];
+ self->mtex->size[1] = f[1];
+ self->mtex->size[2] = f[2];
+
+ return 0;
+}
+
+static PyObject *MTex_getMapping( BPy_MTex *self, void *closure )
+{
+ return PyInt_FromLong( self->mtex->mapping );
+}
+
+static int MTex_setMapping( BPy_MTex *self, PyObject *value, void *closure)
+{
+ int n;
+
+ if ( !PyInt_Check( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "Value must be member of Texture.Mappings dictionary" );
+
+ n = PyInt_AsLong(value);
+
+/* if (n != MTEX_FLAT && n != MTEX_TUBE && n != MTEX_CUBE &&
+ n != MTEX_SPHERE) */
+ if (n < 0 || n > 3)
+ {
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "Value must be member of Texture.Mappings dictionary" );
+ }
+
+ self->mtex->mapping = (char)n;
+
+ return 0;
+}
+
+static PyObject *MTex_getFlag( BPy_MTex *self, void *closure )
+{
+ return PyBool_FromLong( self->mtex->texflag & ((int) closure) );
+}
+
+static int MTex_setFlag( BPy_MTex *self, PyObject *value, void *closure)
+{
+ if ( !PyBool_Check( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected a bool");
+
+ if ( value == Py_True )
+ self->mtex->texflag |= (int)closure;
+ else
+ self->mtex->texflag &= ~((int) closure);
+
+ return 0;
+}
+
+static PyObject *MTex_getProjX( BPy_MTex *self, void *closure )
+{
+ return PyInt_FromLong( self->mtex->projx );
+}
+
+static int MTex_setProjX( BPy_MTex *self, PyObject *value, void *closure)
+{
+ int proj;
+
+ if( !PyInt_Check( value ) ) {
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "Value must be a member of Texture.Proj dictionary" );
+ }
+
+ proj = PyInt_AsLong( value ) ;
+
+ /* valid values are from PROJ_N to PROJ_Z = 0 to 3 */
+ if (proj < 0 || proj > 3)
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "Value must be a member of Texture.Proj dictionary" );
+
+ self->mtex->projx = (char)proj;
+
+ return 0;
+}
+
+static PyObject *MTex_getProjY( BPy_MTex *self, void *closure )
+{
+ return PyInt_FromLong( self->mtex->projy );
+}
+
+static int MTex_setProjY( BPy_MTex *self, PyObject *value, void *closure )
+{
+ int proj;
+
+ if( !PyInt_Check( value ) ) {
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "Value must be a member of Texture.Proj dictionary" );
+ }
+
+ proj = PyInt_AsLong( value ) ;
+
+ /* valid values are from PROJ_N to PROJ_Z = 0 to 3 */
+ if (proj < 0 || proj > 3)
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "Value must be a member of Texture.Proj dictionary" );
+
+ self->mtex->projy = (char)proj;
+
+ return 0;
+}
+
+static PyObject *MTex_getProjZ( BPy_MTex *self, void *closure )
+{
+ return PyInt_FromLong( self->mtex->projz );
+}
+
+static int MTex_setProjZ( BPy_MTex *self, PyObject *value, void *closure)
+{
+ int proj;
+
+ if( !PyInt_Check( value ) ) {
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "Value must be a member of Texture.Proj dictionary" );
+ }
+
+ proj = PyInt_AsLong( value ) ;
+
+ /* valid values are from PROJ_N to PROJ_Z = 0 to 3 */
+ if (proj < 0 || proj > 3)
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "Value must be a member of Texture.Proj dictionary" );
+
+ self->mtex->projz = (char)proj;
+
+ return 0;
+}
+
+static PyObject *MTex_getMapToFlag( BPy_MTex *self, void *closure )
+{
+ int flag = (int) closure;
+
+ if ( self->mtex->mapto & flag )
+ {
+ return PyInt_FromLong( ( self->mtex->maptoneg & flag ) ? -1 : 1 );
+ } else {
+ return PyInt_FromLong( 0 );
+ }
+}
+
+static int MTex_setMapToFlag( BPy_MTex *self, PyObject *value, void *closure)
+{
+ int flag = (int) closure;
+ int intVal;
+
+ if ( !PyInt_Check( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected an int");
+
+ intVal = PyInt_AsLong( value );
+
+ if (flag == MAP_COL || flag == MAP_COLSPEC || flag == MAP_COLMIR ||
+ flag == MAP_WARP) {
+ if (intVal < 0 || intVal > 1) {
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "value for that mapping must be 0 or 1" );
+ }
+ } else {
+ if (intVal < -1 || intVal > 1) {
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "value for that mapping must be -1, 0 or 1" );
+ }
+ }
+
+ switch (intVal)
+ {
+ case 0:
+ self->mtex->mapto &= ~flag;
+ self->mtex->maptoneg &= ~flag;
+ break;
+
+ case 1:
+ self->mtex->mapto |= flag;
+ self->mtex->maptoneg &= ~flag;
+ break;
+
+ case -1:
+ self->mtex->mapto |= flag;
+ self->mtex->maptoneg |= flag;
+ break;
+ }
+
+ return 0;
}
diff --git a/source/blender/python/api2_2x/Mesh.c b/source/blender/python/api2_2x/Mesh.c
index 3aed4695ca1..ab286b20761 100644
--- a/source/blender/python/api2_2x/Mesh.c
+++ b/source/blender/python/api2_2x/Mesh.c
@@ -5528,7 +5528,7 @@ static struct PyMethodDef BPy_Mesh_methods[] = {
"Convert selected triangles to quads (experimental)"},
{"quadToTriangle", (PyCFunction)Mesh_quad2tri, METH_VARARGS,
"Convert selected quads to triangles (experimental)"},
- {"subdivide", (PyCFunction)Mesh_subdivide, METH_NOARGS,
+ {"subdivide", (PyCFunction)Mesh_subdivide, METH_VARARGS,
"Subdivide selected edges in a mesh (experimental)"},
{"remDoubles", (PyCFunction)Mesh_removeDoubles, METH_VARARGS,
"Removes duplicates from selected vertices (experimental)"},
diff --git a/source/blender/python/api2_2x/NMesh.c b/source/blender/python/api2_2x/NMesh.c
index e842b01eb82..a614dbaa3d4 100644
--- a/source/blender/python/api2_2x/NMesh.c
+++ b/source/blender/python/api2_2x/NMesh.c
@@ -1373,6 +1373,9 @@ static PyObject *NMesh_update( PyObject *self, PyObject *a, PyObject *kwd )
}
base = base->next;
}
+
+ /* recalculate the derived mesh before trying to use it */
+ makeDispListMesh (nmesh->object);
make_vertexcol();
countall();
diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c
index 619c8f0c53b..9ed4768eede 100644
--- a/source/blender/python/api2_2x/Object.c
+++ b/source/blender/python/api2_2x/Object.c
@@ -1786,6 +1786,7 @@ static PyObject *internal_makeParent(Object *parent, PyObject *py_child,
child->parent = parent;
//py_obj_child = (BPy_Object *) py_child;
if( noninverse == 1 ) {
+ Mat4One(child->parentinv);
/* Parent inverse = unity */
child->loc[0] = 0.0;
child->loc[1] = 0.0;
@@ -2759,8 +2760,9 @@ static PyObject *Object_getAttr( BPy_Object * obj, char *name )
if( StringEqual( name, "parent" ) ) {
if( object->parent )
return Object_CreatePyObject( object->parent );
- else
+ else {
Py_RETURN_NONE;
+ }
}
if( StringEqual( name, "parentbonename" ) ) {
if( object->parent && object->parsubstr[0] )
@@ -3075,7 +3077,7 @@ static int Object_setAttr( BPy_Object * obj, char *name, PyObject * value )
OB_LOCK_ROTX | OB_LOCK_ROTY | OB_LOCK_ROTZ |
OB_LOCK_SIZEX | OB_LOCK_SIZEY | OB_LOCK_SIZEZ;
- object->protectflag = flag;
+ object->protectflag = (short)flag;
return 0;
}
diff --git a/source/blender/python/api2_2x/Particle.c b/source/blender/python/api2_2x/Particle.c
index ed448e2f631..d744204991b 100644
--- a/source/blender/python/api2_2x/Particle.c
+++ b/source/blender/python/api2_2x/Particle.c
@@ -298,7 +298,7 @@ PyObject *M_Particle_New( PyObject * self, PyObject * args )
"couldn't create Effect Data in Blender" );
}
- pyeffect->effect = bleffect;
+ pyeffect->effect = (PartEff *)bleffect;
BLI_addtail( &ob->effect, bleffect );
return ( PyObject * ) pyeffect;
diff --git a/source/blender/python/api2_2x/Sys.c b/source/blender/python/api2_2x/Sys.c
index 39258f43595..305ed0a0653 100644
--- a/source/blender/python/api2_2x/Sys.c
+++ b/source/blender/python/api2_2x/Sys.c
@@ -158,8 +158,8 @@ PyObject *sys_Init( void )
if( sep ) {
Py_INCREF( sep );
- PyDict_SetItemString( dict, "dirsep", sep );
- PyDict_SetItemString( dict, "sep", sep );
+ EXPP_dict_set_item_str( dict, "dirsep", sep );
+ EXPP_dict_set_item_str( dict, "sep", sep );
}
return submodule;
diff --git a/source/blender/python/api2_2x/Texture.c b/source/blender/python/api2_2x/Texture.c
index 30cb602416b..7f576069795 100644
--- a/source/blender/python/api2_2x/Texture.c
+++ b/source/blender/python/api2_2x/Texture.c
@@ -1044,7 +1044,7 @@ static PyObject *M_Texture_STypesDict( void )
PyInt_FromLong(TEX_BLENDER));
PyConstant_Insert(d, "DN_PERLIN",
PyInt_FromLong(TEX_STDPERLIN));
- PyConstant_Insert(d, "DN_IMPROVEPERLIN",
+ PyConstant_Insert(d, "DN_IMPROVEDPERLIN",
PyInt_FromLong(TEX_NEWPERLIN));
PyConstant_Insert(d, "DN_VORONOIF1",
PyInt_FromLong(TEX_VORONOI_F1));
@@ -1123,6 +1123,7 @@ static PyObject *M_Texture_MapToDict( void )
PyConstant_Insert(d, "AMB", PyInt_FromLong(MAP_AMB));
PyConstant_Insert(d, "TRANSLU", PyInt_FromLong(MAP_TRANSLU));
PyConstant_Insert(d, "DISP", PyInt_FromLong(MAP_DISPLACE));
+ PyConstant_Insert(d, "WARP", PyInt_FromLong(MAP_WARP));
}
return MapTo;
}
@@ -1183,7 +1184,7 @@ static PyObject *M_Texture_NoiseDict( void )
PyConstant_Insert(d, "TRI", PyInt_FromLong(EXPP_TEX_NOISE_TRI));
PyConstant_Insert(d, "BLENDER", PyInt_FromLong(TEX_BLENDER));
PyConstant_Insert(d, "PERLIN", PyInt_FromLong(TEX_STDPERLIN));
- PyConstant_Insert(d, "IMPROVEPERLIN", PyInt_FromLong(TEX_NEWPERLIN));
+ PyConstant_Insert(d, "IMPROVEDPERLIN", PyInt_FromLong(TEX_NEWPERLIN));
PyConstant_Insert(d, "VORONOIF1", PyInt_FromLong(TEX_VORONOI_F1));
PyConstant_Insert(d, "VORONOIF2", PyInt_FromLong(TEX_VORONOI_F2));
PyConstant_Insert(d, "VORONOIF3", PyInt_FromLong(TEX_VORONOI_F3));
@@ -1196,6 +1197,50 @@ static PyObject *M_Texture_NoiseDict( void )
return Noise;
}
+static PyObject *M_Texture_BlendModesDict( void )
+{
+ PyObject *BlendModes = PyConstant_New( );
+ if( BlendModes ) {
+ BPy_constant *d = ( BPy_constant * ) BlendModes;
+ PyConstant_Insert(d, "MIX", PyInt_FromLong(MTEX_BLEND));
+ PyConstant_Insert(d, "MULTIPLY", PyInt_FromLong(MTEX_MUL));
+ PyConstant_Insert(d, "ADD", PyInt_FromLong(MTEX_ADD));
+ PyConstant_Insert(d, "SUBTRACT", PyInt_FromLong(MTEX_SUB));
+ PyConstant_Insert(d, "DIVIDE", PyInt_FromLong(MTEX_DIV));
+ PyConstant_Insert(d, "DARKEN", PyInt_FromLong(MTEX_DARK));
+ PyConstant_Insert(d, "DIFFERENCE", PyInt_FromLong(MTEX_DIFF));
+ PyConstant_Insert(d, "LIGHTEN", PyInt_FromLong(MTEX_LIGHT));
+ PyConstant_Insert(d, "SCREEN", PyInt_FromLong(MTEX_SCREEN));
+ }
+ return BlendModes;
+}
+
+static PyObject *M_Texture_MappingsDict( void )
+{
+ PyObject *Mappings = PyConstant_New( );
+ if( Mappings ) {
+ BPy_constant *d = ( BPy_constant * ) Mappings;
+ PyConstant_Insert(d, "FLAT", PyInt_FromLong(MTEX_FLAT));
+ PyConstant_Insert(d, "CUBE", PyInt_FromLong(MTEX_CUBE));
+ PyConstant_Insert(d, "TUBE", PyInt_FromLong(MTEX_TUBE));
+ PyConstant_Insert(d, "SPHERE", PyInt_FromLong(MTEX_SPHERE));
+ }
+ return Mappings;
+}
+
+static PyObject *M_Texture_ProjDict( void )
+{
+ PyObject *Proj = PyConstant_New( );
+ if( Proj ) {
+ BPy_constant *d = ( BPy_constant * ) Proj;
+ PyConstant_Insert(d, "NONE", PyInt_FromLong(PROJ_N));
+ PyConstant_Insert(d, "X", PyInt_FromLong(PROJ_X));
+ PyConstant_Insert(d, "Y", PyInt_FromLong(PROJ_Y));
+ PyConstant_Insert(d, "Z", PyInt_FromLong(PROJ_Z));
+ }
+ return Proj;
+}
+
PyObject *Texture_Init( void )
{
PyObject *submodule;
@@ -1210,6 +1255,9 @@ PyObject *Texture_Init( void )
PyObject *ExtendModes = M_Texture_ExtendModesDict( );
PyObject *ImageFlags = M_Texture_ImageFlagsDict( );
PyObject *Noise = M_Texture_NoiseDict( );
+ PyObject *BlendModes = M_Texture_BlendModesDict( );
+ PyObject *Mappings = M_Texture_MappingsDict( );
+ PyObject *Proj = M_Texture_ProjDict( );
if( PyType_Ready( &Texture_Type ) < 0)
return NULL;
@@ -1233,6 +1281,12 @@ PyObject *Texture_Init( void )
PyModule_AddObject( submodule, "ImageFlags", ImageFlags );
if( Noise )
PyModule_AddObject( submodule, "Noise", Noise );
+ if ( BlendModes )
+ PyModule_AddObject( submodule, "BlendModes", BlendModes );
+ if ( Mappings )
+ PyModule_AddObject( submodule, "Mappings", Mappings );
+ if ( Proj )
+ PyModule_AddObject( submodule, "Proj", Proj );
/* Add the MTex submodule to this module */
dict = PyModule_GetDict( submodule );
diff --git a/source/blender/python/api2_2x/constant.c b/source/blender/python/api2_2x/constant.c
index 41a845184d4..1ebf50ffa55 100644
--- a/source/blender/python/api2_2x/constant.c
+++ b/source/blender/python/api2_2x/constant.c
@@ -74,7 +74,7 @@ static PyObject *new_const(void)
"couldn't create constant object's dictionary"));
}
- return EXPP_incr_ret((PyObject *)constant);
+ return (PyObject *)constant;
}
//------------------------tp_doc
//The __doc__ string for this object
@@ -230,7 +230,7 @@ PyObject *PyConstant_New(void)
//Inserts a key:value pair into the constant and then returns 0/1
int PyConstant_Insert(BPy_constant *self, char *name, PyObject *value)
{
- return PyDict_SetItemString(self->dict, name, value);
+ return EXPP_dict_set_item_str(self->dict, name, value);
}
//This is a helper function for generating constants......
PyObject *PyConstant_NewInt(char *name, int value)
diff --git a/source/blender/python/api2_2x/doc/API_intro.py b/source/blender/python/api2_2x/doc/API_intro.py
index 999d692ae0c..31ab333f231 100644
--- a/source/blender/python/api2_2x/doc/API_intro.py
+++ b/source/blender/python/api2_2x/doc/API_intro.py
@@ -41,7 +41,7 @@ The Blender Python API Reference
- L{Text}
- L{Text3d}
- L{Font}
- - L{Texture}
+ - L{Texture} (*)
- L{TimeLine}
- L{Types}
- L{Window}
diff --git a/source/blender/python/api2_2x/doc/Key.py b/source/blender/python/api2_2x/doc/Key.py
index 491ae8011f5..6d3c8316a0e 100644
--- a/source/blender/python/api2_2x/doc/Key.py
+++ b/source/blender/python/api2_2x/doc/Key.py
@@ -9,11 +9,12 @@ This module provides access to B{Key} objects in Blender.
@var Types: The type of a key, indicating the type of data in the
data blocks.
- MESH - the key is a Mesh key; data blocks contain
- L{NMesh.NMVert} vertices.
- - CURVE - the key is a Curve key; data blocks contain
- L{Ipo.BezTriple} points.
+ L{NMVert<NMesh.NMVert>} vertices.
+ - CURVE - the key is a Curve key; data blocks contains either
+ L{BezTriples<Ipo.BezTriple>} or points (represented by a list of
+ 3 floating point numbers).
- LATTICE - the key is a Lattice key; data blocks contain
- BPoints, each point represented as a list of 4 floating point numbers.
+ BPoints, each point represented by a list of 3 floating point numbers.
"""
@@ -32,26 +33,25 @@ class Key:
"""
The Key object
==============
- An object with keyframes (L{Lattice.Lattice}, L{NMesh.NMesh} or
- L{Curve.Curve}) will contain a Key object representing the
+ An object with keyframes (L{Lattice}, L{NMesh} or
+ L{Curve}) will contain a Key object representing the
keyframe data.
- @ivar ipo: Key Ipo.
- Contains the Ipo if one is assigned to the object, B{None} otherwise. Setting to B{None} clears the current Ipo..
+ @ivar ipo: Key Ipo. Contains the Ipo if one is assigned to the
+ object, B{None} otherwise. Setting to B{None} clears the current Ipo..
@type ipo: Blender Ipo
- @ivar value: The Value of the Key - Read Only
+ @ivar value: The value of the key. Read-only.
@type value: float
@ivar type: An integer from the L{Types} dictionary
- representing the Key type.
+ representing the Key type. Read-only.
@type type: int
-
- @cvar blocks: A list of KeyBlocks.
- @cvar ipo: The L{Ipo.Ipo} object associated with this key.
+ @ivar blocks: A list of KeyBlocks for the key. Read-only.
+ @type blocks: Blender KeyBlock.
"""
def getIpo():
"""
- Get the L{Ipo.Ipo} object associated with this key.
+ Get the L{Ipo} object associated with this key.
"""
def getBlocks():
"""
@@ -59,7 +59,6 @@ class Key:
this Key.
"""
-
class KeyBlock:
"""
The KeyBlock object
@@ -67,34 +66,36 @@ class KeyBlock:
Each Key object has a list of KeyBlocks attached, each KeyBlock
representing a keyframe.
- @ivar name: The Name of the Keyblock
- Truncated to 32 Characters
+ @ivar name: The name of the Keyblock. Truncated to 32 characters.
@type name: string
- @ivar pos: The position of the keyframe
+ @ivar pos: The position of the keyframe.
@type pos: float
- @ivar slidermin: The minimum value for the action slider
+ @ivar slidermin: The minimum value for the action slider.
+ Value is clamped to the range [-10.0,10.0].
@type slidermin: float
- @ivar slidermax: The maximum value for the action slider
+ @ivar slidermax: The maximum value for the action slider.
+ Value is clamped to the range [-10.0,10.0].
@type slidermax: float
- @ivar vgroup: The assigned VGroup for the Key Block
+ @ivar vgroup: The assigned VGroup for the Key Block.
@type vgroup: string
-
- @cvar data: The data of the KeyBlock (see L{getData}). This
+ @ivar data: The data of the KeyBlock (see L{getData}). This
attribute is read-only.
+ @type data: varies
"""
+
def getData():
"""
Get the data of a KeyBlock, as a list of data items. Each item
will have a different data type depending on the type of this
Key.
- Mesh keys have a list of L{NMesh.NMVert} objects in the data
- block.
-
- Lattice keys have a list of BPoints in the data block. These
- don't have corresponding Python objects yet, so each BPoint is
- represented using a list of four floating-point numbers.
-
- Curve keys have a list of L{Ipo.BezTriple} objects in the data
- block.
+ - Mesh keys have a list of L{NMVert<NMesh.NMVert>} objects in the data
+ block.
+ - Lattice keys have a list of BPoints in the data block. These
+ don't have corresponding Python objects yet, so each BPoint is
+ represented using a list of three floating-point numbers (the
+ coordinate for each lattice vertex).
+ - Curve keys return either a list of L{BezTriple<Ipo.BezTriple>}
+ objects in the data if the curve is a Bezier curve, otherwise it
+ returns lists of three floats for each NURB or poly coordinate.
"""
diff --git a/source/blender/python/api2_2x/doc/Texture.py b/source/blender/python/api2_2x/doc/Texture.py
index 454a6efa40d..18b0be4ccb1 100644
--- a/source/blender/python/api2_2x/doc/Texture.py
+++ b/source/blender/python/api2_2x/doc/Texture.py
@@ -7,6 +7,10 @@
"""
The Blender.Texture submodule.
+B{New}:
+ - many new attributes in L{MTex} submodule
+ - new dictionaries (L{Texture.BlendModes}, L{Texture.Mappings}, L{Texture.Proj}) to use for the values of some of the new L{MTex} attributes.
+
Texture
=======
@@ -88,7 +92,7 @@ Example::
- TRI - Produce bands using triangle wave (marble, wood textures)
- BLENDER - Original Blender algorithm
- PERLIN - Ken Perlin's original (1985) algorithm
- - IMPROVEPERLIN - Ken Perlin's newer (2002) algorithm
+ - IMPROVEDPERLIN - Ken Perlin's newer (2002) algorithm
- VORONOIF1 - none
- VORONOIF2 - none
- VORONOIF3 - none
@@ -97,6 +101,32 @@ Example::
- VORONOICRACKLE - none
- CELLNOISE - Steven Worley's cellular basis algorithm (1996)
+@type BlendModes: readonly dictionary
+@var BlendModes: The available texture blending modes:
+ - MIX - mix texture with value
+ - MULTIPLY - multiply texture with value
+ - ADD - add texture to value
+ - SUBTRACT - subtract texture from value
+ - DIVIDE - divide value by texture
+ - DARKEN - replace value with texture if texture is darker
+ - DIFFERENCE - difference of texture from value
+ - LIGHTEN - replace value with texture if texture is lighter
+ - SCREEN - 'screen' mode
+
+@type Mappings: readonly dictionary
+@var Mappings: The available 2D texture coordinate mappings for images:
+ - FLAT - flat projection
+ - CUBE - cube projection
+ - TUBE - cylindrical projection
+ - SPHERE - spherical projection
+
+@type Proj: readonly dictionary
+@var Proj: The available projections per axis:
+ - NONE - axis isn't used
+ - X - axis is used as final x axis
+ - Y - axis is used as final y axis
+ - Z - axis is used as final z axis
+
@type STypes: readonly dictionary
@var STypes: Texture-type specific data. Depending on the value of
Texture.type, certain groups will make sense. For instance, when a texture
@@ -151,7 +181,7 @@ Example::
13. Distorted noise type
- DN_BLENDER - Original Blender algorithm
- DN_PERLIN - Ken Perlin's original (1985) algorithm
- - DN_IMPROVEPERLIN - Ken Perlin's newer (2002) algorithm
+ - DN_IMPROVEDPERLIN - Ken Perlin's newer (2002) algorithm
- DN_VORONOIF1 - none
- DN_VORONOIF2 - none
- DN_VORONOIF3 - none
@@ -177,11 +207,16 @@ Example::
- NOR - Make the texture affect the rendered normal
- CSP - Make the texture affect the specularity colour
- CMIR - Make the texture affect the mirror colour
- - REF - Make the texture affect the value of the material's reflectivity
- - SPEC - Make the texture affect the value of specularity
+ - REF - Make the texture affect the diffuse reflectivity value
+ - SPEC - Make the texture affect the specularity value
- HARD - Make the texture affect the hardness value
- ALPHA - Make the texture affect the alpha value
- - EMIT - Make the texture affext the emit value
+ - EMIT - Make the texture affect the emit value
+ - RAYMIR - Make the texture affect the mirror reflectivity value
+ - DISP - Make the texture displace the mesh
+ - TRANSLU - Make the texture affect the translucency value
+ - AMB - Make the texture affect the ambient value
+ - WARP - Make the texture affect texture coordinates for the following textures
@type MapTo: readonly dictionary
"""
@@ -449,6 +484,40 @@ class MTex:
@type tex: Blender Texture
@ivar texco: Texture coordinates ("Map input"). See L{TexCo}
@ivar mapto: "Map to" field of texture. OR'd values of L{MapTo}
+ @ivar object: Object whose space to use when texco is Object
+ @type object: Blender Object
+ @ivar col: Color that the texture blends with
+ @ivar dvar: Value that the texture blends with when not blending colors
+ @ivar blendmode: Texture blending mode. L{BlendModes}
+ @ivar colfac: Factor by which texture affects color
+ @ivar norfac: Factor by which texture affects normal
+ @ivar varfac: Factor by which texture affects most variables
+ @ivar dispfac: Factor by which texture affects displacement
+ @ivar warpfac: Factor by which texture affects warp
+ @ivar ofs: Offset to adjust texture space
+ @ivar size: Size to scale texture space
+ @ivar mapping: Mapping of texture coordinates (flat, cube, etc.). L{Mappings}
+ @ivar stencil: Stencil mode
+ @ivar neg: Negate texture values mode
+ @ivar noRGB: Convert texture RGB values to intensity values
+ @ivar correctNor: Correct normal mapping for Texture space and Object space
+ @ivar xproj: Projection of X axis to Texture space. L{Proj}
+ @ivar yproj: Projection of Y axis to Texture space. L{Proj}
+ @ivar zproj: Projection of Z axis to Texture space. L{Proj}
+ @ivar mtCol: How texture maps to color
+ @ivar mtNor: How texture maps to normals
+ @ivar mtCsp: How texture maps to specularity color
+ @ivar mtCmir: How texture maps to mirror color
+ @ivar mtRef: How texture maps to reflectivity
+ @ivar mtSpec: How texture maps to specularity
+ @ivar mtEmit: How texture maps to emit value
+ @ivar mtAlpha: How texture maps to alpha value
+ @ivar mtHard: How texture maps to hardness
+ @ivar mtRayMir: How texture maps to RayMir value
+ @ivar mtTranslu: How texture maps to translucency
+ @ivar mtAmb: How texture maps to ambient value
+ @ivar mtDisp: How texture maps to displacement
+ @ivar mtWarp: How texture maps to warp
"""
def getIpo():
diff --git a/source/blender/python/api2_2x/doc/Window.py b/source/blender/python/api2_2x/doc/Window.py
index 99d2fe9464d..64775654054 100644
--- a/source/blender/python/api2_2x/doc/Window.py
+++ b/source/blender/python/api2_2x/doc/Window.py
@@ -318,8 +318,8 @@ def CameraView (camtov3d = 0):
def QTest ():
"""
Check if there are pending events in the event queue.
- @rtype: bool
- @return: 1 if there are pending events, 0 otherwise.
+ @rtype: int
+ @return: 0 if there are no pending events, non-zero otherwise.
"""
def QRead ():
diff --git a/source/blender/python/api2_2x/gen_utils.c b/source/blender/python/api2_2x/gen_utils.c
index de29e4ba001..25d3a7912b8 100644
--- a/source/blender/python/api2_2x/gen_utils.c
+++ b/source/blender/python/api2_2x/gen_utils.c
@@ -904,3 +904,16 @@ PyObject *EXPP_setterWrapperTuple ( PyObject * self, PyObject * args,
return NULL;
}
+/*
+ * Helper to keep dictionaries from causing memory leaks. When some object
+ * is just created to be added to the dictionary, its reference count needs
+ * to be decremented so it can be reclaimed.
+ */
+
+int EXPP_dict_set_item_str( PyObject *dict, char *key, PyObject *value)
+{
+ /* add value to dictionary */
+ int ret = PyDict_SetItemString(dict, key, value);
+ Py_DECREF( value ); /* delete original */
+ return ret;
+}
diff --git a/source/blender/python/api2_2x/gen_utils.h b/source/blender/python/api2_2x/gen_utils.h
index d0e618635a5..a4debf87d35 100644
--- a/source/blender/python/api2_2x/gen_utils.h
+++ b/source/blender/python/api2_2x/gen_utils.h
@@ -142,5 +142,8 @@ PyObject *EXPP_clearScriptLinks(ScriptLink *slink, PyObject *args);
/* this queues redraws if we're not in background mode: */
void EXPP_allqueue(unsigned short event, short val);
+/* helper to keep dictionaries from causing memory leaks */
+int EXPP_dict_set_item_str( PyObject *dict, char *key, PyObject *value);
+
#endif /* EXPP_gen_utils_h */
diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c
index 2a7d7942490..2ddf08b29cc 100644
--- a/source/blender/render/intern/source/imagetexture.c
+++ b/source/blender/render/intern/source/imagetexture.c
@@ -83,7 +83,8 @@ int imagewrap(Tex *tex, Image *ima, float *texvec, TexResult *texres)
texres->tin= texres->ta= texres->tr= texres->tg= texres->tb= 0.0;
if(ima==NULL || ima->ok== 0) {
- return 0;
+ if(texres->nor) return 3;
+ else return 1;
}
if(ima->ibuf==NULL) {
@@ -483,6 +484,7 @@ static void boxsample(ImBuf *ibuf, float minx, float miny, float maxx, float max
* If global variable 'imaprepeat' has been set, the
* clipped-away parts are sampled as well.
*/
+ /* note: actually minx etc isnt in the proper range... this due to filter size and offset vectors for bump */
TexResult texr;
rctf *rf, stack[8];
float opp, tot, alphaclip= 1.0;
@@ -494,7 +496,10 @@ static void boxsample(ImBuf *ibuf, float minx, float miny, float maxx, float max
rf->ymin= miny*(ibuf->y);
rf->ymax= maxy*(ibuf->y);
- if(imapextend);
+ if(imapextend) {
+ CLAMP(rf->xmin, 0.0f, ibuf->x-1);
+ CLAMP(rf->xmax, 0.0f, ibuf->x-1);
+ }
else if(imaprepeat) clipx_rctf_swap(stack, &count, 0.0, (float)(ibuf->x));
else {
alphaclip= clipx_rctf(rf, 0.0, (float)(ibuf->x));
@@ -505,7 +510,10 @@ static void boxsample(ImBuf *ibuf, float minx, float miny, float maxx, float max
}
}
- if(imapextend);
+ if(imapextend) {
+ CLAMP(rf->ymin, 0.0f, ibuf->y-1);
+ CLAMP(rf->ymax, 0.0f, ibuf->y-1);
+ }
else if(imaprepeat) clipy_rctf_swap(stack, &count, 0.0, (float)(ibuf->y));
else {
alphaclip*= clipy_rctf(rf, 0.0, (float)(ibuf->y));
@@ -586,7 +594,8 @@ int imagewraposa(Tex *tex, Image *ima, float *texvec, float *dxt, float *dyt, Te
texres->tin= texres->ta= texres->tr= texres->tg= texres->tb= 0.0;
if(ima==NULL || ima->ok== 0) {
- return 0;
+ if(texres->nor) return 3;
+ else return 1;
}
if(ima->ibuf==NULL) {
@@ -871,7 +880,6 @@ int imagewraposa(Tex *tex, Image *ima, float *texvec, float *dxt, float *dyt, Te
val2= texr.tr + texr.tg + texr.tb;
boxsample(ibuf, fx-minx+dyt[0], fy-miny+dyt[1], fx+minx+dyt[0], fy+miny+dyt[1], &texr);
val3= texr.tr + texr.tg + texr.tb;
-
/* don't switch x or y! */
texres->nor[0]= (val1-val2);
texres->nor[1]= (val1-val3);
diff --git a/source/blender/render/intern/source/ray.c b/source/blender/render/intern/source/ray.c
index 0dce37bc8e2..d9f94c0be60 100644
--- a/source/blender/render/intern/source/ray.c
+++ b/source/blender/render/intern/source/ray.c
@@ -632,7 +632,7 @@ void makeoctree(void)
/* ************ raytracer **************** */
/* only for self-intersecting test with current render face (where ray left) */
-static short intersection2(VlakRen *vlr, float r0, float r1, float r2, float rx1, float ry1, float rz1)
+static int intersection2(VlakRen *vlr, float r0, float r1, float r2, float rx1, float ry1, float rz1)
{
VertRen *v1,*v2,*v3,*v4=NULL;
float x0,x1,x2,t00,t01,t02,t10,t11,t12,t20,t21,t22;
@@ -705,12 +705,83 @@ static short intersection2(VlakRen *vlr, float r0, float r1, float r2, float rx1
return 0;
}
-static short intersection(Isect *is)
+#if 0
+/* ray - line intersection */
+/* disabled until i got real & fast cylinder checking, this code doesnt work proper
+for faster strands */
+
+static int intersection_strand(Isect *is)
+{
+ float v1[3], v2[3]; /* length of strand */
+ float axis[3], rc[3], nor[3], radline, dist, len;
+
+ /* radius strand */
+ radline= 0.5f*VecLenf(is->vlr->v1->co, is->vlr->v2->co);
+
+ VecMidf(v1, is->vlr->v1->co, is->vlr->v2->co);
+ VecMidf(v2, is->vlr->v3->co, is->vlr->v4->co);
+
+ VECSUB(rc, v1, is->start); /* vector from base ray to base cylinder */
+ VECSUB(axis, v2, v1); /* cylinder axis */
+
+ CROSS(nor, is->vec, axis);
+ len= VecLength(nor);
+
+ if(len<FLT_EPSILON)
+ return 0;
+
+ dist= INPR(rc, nor)/len; /* distance between ray and axis cylinder */
+
+ if(dist<radline && dist>-radline) {
+ float dot1, dot2, dot3, rlen, alen, div;
+ float labda;
+
+ /* calculating the intersection point of shortest distance */
+ dot1 = INPR(rc, is->vec);
+ dot2 = INPR(is->vec, axis);
+ dot3 = INPR(rc, axis);
+ rlen = INPR(is->vec, is->vec);
+ alen = INPR(axis, axis);
+
+ div = alen * rlen - dot2 * dot2;
+ if (ABS(div) < FLT_EPSILON)
+ return 0;
+
+ labda = (dot1*dot2 - dot3*rlen)/div;
+
+ radline/= sqrt(alen);
+
+ /* labda: where on axis do we have closest intersection? */
+ if(labda >= -radline && labda <= 1.0f+radline) {
+ VlakRen *vlr= is->vlrorig;
+ VertRen *v1= is->vlr->v1, *v2= is->vlr->v2, *v3= is->vlr->v3, *v4= is->vlr->v4;
+ /* but we dont do shadows from faces sharing edge */
+
+ if(v1==vlr->v1 || v2==vlr->v1 || v3==vlr->v1 || v4==vlr->v1) return 0;
+ if(v1==vlr->v2 || v2==vlr->v2 || v3==vlr->v2 || v4==vlr->v2) return 0;
+ if(v1==vlr->v3 || v2==vlr->v3 || v3==vlr->v3 || v4==vlr->v3) return 0;
+ if(vlr->v4) {
+ if(v1==vlr->v4 || v2==vlr->v4 || v3==vlr->v4 || v4==vlr->v4) return 0;
+ }
+ return 1;
+ }
+ }
+ return 0;
+}
+#endif
+
+/* ray - triangle or quad intersection */
+static int intersection(Isect *is)
{
VertRen *v1,*v2,*v3,*v4=NULL;
float x0,x1,x2,t00,t01,t02,t10,t11,t12,t20,t21,t22,r0,r1,r2;
float m0, m1, m2, divdet, det1;
short ok=0;
+
+ /* disabled until i got real & fast cylinder checking, this code doesnt work proper
+ for faster strands */
+// if(is->mode==DDA_SHADOW && is->vlr->flag & R_STRAND)
+// return intersection_strand(is);
v1= is->vlr->v1;
v2= is->vlr->v2;
@@ -986,7 +1057,7 @@ static Node *ocread(int x, int y, int z)
return NULL;
}
-static short cliptest(float p, float q, float *u1, float *u2)
+static int cliptest(float p, float q, float *u1, float *u2)
{
float r;
@@ -1017,7 +1088,7 @@ static short cliptest(float p, float q, float *u1, float *u2)
/*
-in top: static short coh_nodes[16*16*16][6];
+in top: static int coh_nodes[16*16*16][6];
in makeoctree: memset(coh_nodes, 0, sizeof(coh_nodes));
static void add_coherence_test(int ocx1, int ocx2, int ocy1, int ocy2, int ocz1, int ocz2)
diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c
index 303d83cde14..98c82019fa4 100644
--- a/source/blender/render/intern/source/rendercore.c
+++ b/source/blender/render/intern/source/rendercore.c
@@ -665,7 +665,6 @@ static float area_lamp_energy(float *co, float *vn, LampRen *lar)
return pow(fac*lar->areasize, lar->k); // corrected for buttons size and lar->dist^2
}
-
float spec(float inp, int hard)
{
float b1;
@@ -717,7 +716,7 @@ float Phong_Spec( float *n, float *l, float *v, int hard, int tangent )
Normalise(h);
rslt = h[0]*n[0] + h[1]*n[1] + h[2]*n[2];
- if(tangent) rslt= sqrt(1.0 - rslt*rslt);
+ if(tangent) rslt= sasqrt(1.0 - rslt*rslt);
if( rslt > 0.0 ) rslt= spec(rslt, hard);
else rslt = 0.0;
@@ -737,11 +736,11 @@ float CookTorr_Spec(float *n, float *l, float *v, int hard, int tangent)
Normalise(h);
nh= n[0]*h[0]+n[1]*h[1]+n[2]*h[2];
- if(tangent) nh= sqrt(1.0 - nh*nh);
+ if(tangent) nh= sasqrt(1.0 - nh*nh);
else if(nh<0.0) return 0.0;
nv= n[0]*v[0]+n[1]*v[1]+n[2]*v[2];
- if(tangent) nv= sqrt(1.0 - nv*nv);
+ if(tangent) nv= sasqrt(1.0 - nv*nv);
else if(nv<0.0) nv= 0.0;
i= spec(nh, hard);
@@ -770,15 +769,15 @@ float Blinn_Spec(float *n, float *l, float *v, float refrac, float spec_power, i
Normalise(h);
nh= n[0]*h[0]+n[1]*h[1]+n[2]*h[2]; /* Dot product between surface normal and half-way vector */
- if(tangent) nh= sqrt(1.0f - nh*nh);
+ if(tangent) nh= sasqrt(1.0f - nh*nh);
else if(nh<0.0) return 0.0;
nv= n[0]*v[0]+n[1]*v[1]+n[2]*v[2]; /* Dot product between surface normal and view vector */
- if(tangent) nv= sqrt(1.0f - nv*nv);
+ if(tangent) nv= sasqrt(1.0f - nv*nv);
if(nv<=0.0) nv= 0.01; /* hrms... */
nl= n[0]*l[0]+n[1]*l[1]+n[2]*l[2]; /* Dot product between surface normal and light vector */
- if(tangent) nl= sqrt(1.0f - nl*nl);
+ if(tangent) nl= sasqrt(1.0f - nl*nl);
if(nl<=0.0) {
return 0.0;
}
@@ -817,7 +816,7 @@ float Toon_Spec( float *n, float *l, float *v, float size, float smooth, int tan
Normalise(h);
rslt = h[0]*n[0] + h[1]*n[1] + h[2]*n[2];
- if(tangent) rslt = sqrt(1.0f - rslt*rslt);
+ if(tangent) rslt = sasqrt(1.0f - rslt*rslt);
ang = saacos( rslt );
@@ -841,15 +840,15 @@ float WardIso_Spec( float *n, float *l, float *v, float rms, int tangent)
Normalise(h);
nh = n[0]*h[0]+n[1]*h[1]+n[2]*h[2]; /* Dot product between surface normal and half-way vector */
- if(tangent) nh = sqrt(1.0f - nh*nh);
+ if(tangent) nh = sasqrt(1.0f - nh*nh);
if(nh<=0.0) nh = 0.001f;
nv = n[0]*v[0]+n[1]*v[1]+n[2]*v[2]; /* Dot product between surface normal and view vector */
- if(tangent) nv = sqrt(1.0f - nv*nv);
+ if(tangent) nv = sasqrt(1.0f - nv*nv);
if(nv<=0.0) nv = 0.001f;
nl = n[0]*l[0]+n[1]*l[1]+n[2]*l[2]; /* Dot product between surface normal and light vector */
- if(tangent) nl = sqrt(1.0f - nl*nl);
+ if(tangent) nl = sasqrt(1.0f - nl*nl);
if(nl<=0.0) nl = 0.001;
angle = tan(saacos(nh));
@@ -1506,7 +1505,7 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr)
x= MAX2(fabs(lvrot[0]/lvrot[2]) , fabs(lvrot[1]/lvrot[2]));
/* 1.0/(sqrt(1+x*x)) is equivalent to cos(atan(x)) */
- inpr= 1.0/(sqrt(1+x*x));
+ inpr= 1.0f/(sqrt(1.0f+x*x));
}
else inpr= 0.0;
}
@@ -2007,7 +2006,20 @@ void shade_input_set_coords(ShadeInput *shi, float u, float v, int i1, int i2, i
shi->dyuv[0]= 2.0*(dl*uv3[0]-duv[0]*uv1[0]-duv[1]*uv2[0]);
shi->dyuv[1]= 2.0*(dl*uv3[1]-duv[0]*uv1[1]-duv[1]*uv2[1]);
}
-
+#if 0
+ { /* tangent derived from UV, comes back later! (ton) */
+ //float s1= uv2[0] - uv1[0];
+ //float s2= uv3[0] - uv1[0];
+ float t1= uv2[1] - uv1[1];
+ float t2= uv3[1] - uv1[1];
+
+ shi->vn[0]= (t2 * (v2->co[0]-v1->co[0]) - t1 * (v3->co[0]-v1->co[0]));
+ shi->vn[1]= (t2 * (v2->co[1]-v1->co[1]) - t1 * (v3->co[1]-v1->co[1]));
+ shi->vn[2]= (t2 * (v2->co[2]-v1->co[2]) - t1 * (v3->co[2]-v1->co[2]));
+ Normalise(shi->vn);
+ vlr->flag |= R_TANGENT;
+ }
+#endif
if(mode & MA_FACETEXTURE) {
if((mode & (MA_VERTEXCOL|MA_VERTEXCOLP))==0) {
shi->vcol[0]= 1.0;
diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c
index 298a86b6f76..b99f4d8e768 100644
--- a/source/blender/render/intern/source/zbuf.c
+++ b/source/blender/render/intern/source/zbuf.c
@@ -2451,7 +2451,7 @@ void zbuffershad(LampRen *lar)
if(vlr->mat!= ma) {
ma= vlr->mat;
ok= 1;
- if((ma->mode & MA_TRACEBLE)==0) ok= 0;
+ if((ma->mode & MA_SHADBUF)==0) ok= 0;
}
if(ok && (vlr->flag & R_VISIBLE) && (vlr->lay & lay)) {
@@ -2752,13 +2752,14 @@ static int addtosampcol(float *sampcol, float *fcol, int mask)
* renders when needed the Abuffer with faces stored in pixels, returns 1 scanline rendered
*/
+#define MAX_ZROW 1000
void abufsetrow(float *acolrow, int y)
{
extern SDL_mutex *render_abuf_lock; // initrender.c
APixstr *ap, *apn;
float *col, fcol[4], tempcol[4], sampcol[16*4], *scol, accumcol[4];
float ys, fac, alpha[32];
- int x, part, a, zrow[200][3], totface, nr;
+ int x, part, a, zrow[MAX_ZROW][3], totface, nr;
int sval;
if(y<0) return;
@@ -2814,7 +2815,7 @@ void abufsetrow(float *acolrow, int y)
zrow[totface][1]= apn->p[a];
zrow[totface][2]= apn->mask[a];
totface++;
- if(totface>199) totface= 199;
+ if(totface>=MAX_ZROW) totface= MAX_ZROW-1;
}
else break;
}
diff --git a/source/blender/renderconverter/intern/convertBlenderScene.c b/source/blender/renderconverter/intern/convertBlenderScene.c
index e0ee3f831ca..07ae6dbcdd2 100644
--- a/source/blender/renderconverter/intern/convertBlenderScene.c
+++ b/source/blender/renderconverter/intern/convertBlenderScene.c
@@ -979,7 +979,7 @@ static void static_particle_strand(Object *ob, Material *ma, float *orco, float
VECCOPY(v1->co, vec);
VecAddf(v1->co, v1->co, cross);
VECCOPY(v1->n, nor);
- v2->orco= orco;
+ v1->orco= orco;
v1->accum= -1.0f; // accum abuse for strand texco
VECCOPY(v2->co, vec);
@@ -1030,7 +1030,7 @@ static void render_static_particle_system(Object *ob, PartEff *paf)
VlakRen *vlr;
float xn, yn, zn, imat[3][3], mat[4][4], hasize;
float mtime, ptime, ctime, vec[3], vec1[3], view[3], nor[3];
- float *orco= NULL;
+ float *orco= NULL, loc_tex[3], size_tex[3];
int a, mat_nr=1, seed, totvlako, totverto, first;
pa= paf->keys;
@@ -1060,6 +1060,8 @@ static void render_static_particle_system(Object *ob, PartEff *paf)
BLI_ghash_insert(g_orco_hash, paf, orco); /* pointer is particles, otherwise object uses it */
}
+ mesh_get_texspace(ob->data, loc_tex, NULL, size_tex);
+
if(ob->ipoflag & OB_OFFS_PARTICLE) ptime= ob->sf;
else ptime= 0.0;
ctime= bsystem_time(ob, 0, (float)G.scene->r.cfra, ptime);
@@ -1068,9 +1070,11 @@ static void render_static_particle_system(Object *ob, PartEff *paf)
for(a=0; a<paf->totpart; a++, pa+=paf->totkey) {
where_is_particle(paf, pa, pa->time, vec1);
- if(orco) VECCOPY(orco, vec1);
- MTC_Mat4MulVecfl(mat, vec1);
-
+ if(orco) {
+ orco[0] = (vec1[0]-loc_tex[0])/size_tex[0];
+ orco[1] = (vec1[1]-loc_tex[1])/size_tex[1];
+ orco[2] = (vec1[2]-loc_tex[2])/size_tex[2];
+ }
mtime= pa->time+pa->lifetime+paf->staticstep-1;
first= 1;
diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c
index 1864b9c2b1e..b3d84eb18ed 100644
--- a/source/blender/src/buttons_object.c
+++ b/source/blender/src/buttons_object.c
@@ -1704,7 +1704,7 @@ static void object_panel_fields(Object *ob)
uiBlock *block;
block= uiNewBlock(&curarea->uiblocks, "object_panel_fields", UI_EMBOSS, UI_HELV, curarea->win);
- if(uiNewPanel(curarea, block, "Fields and Defection", "Physics", 0, 0, 318, 204)==0) return;
+ if(uiNewPanel(curarea, block, "Fields and Deflection", "Physics", 0, 0, 318, 204)==0) return;
/* should become button, option? */
if(ob->pd==NULL) {
@@ -1958,7 +1958,7 @@ static void object_panel_particles_motion(Object *ob)
uiDefBut(block, LABEL, 0, "Texture Emission", 0,30,150,20, NULL, 0.0, 0, 0, 0, "");
uiBlockBeginAlign(block);
uiDefButBitS(block, TOG3, PAF_TEXTIME, B_CALCEFFECT, "TexEmit", 0,10,75,20, &(paf->flag2), 0, 0, 0, 0, "Use a texture to define emission of particles");
- uiDefButS(block, NUM, B_CALCEFFECT, "Tex:", 75,10,75,20, &paf->timetex, 1.0, 8.0, 0, 0, "Specify texture used for the texture emission");
+ uiDefButS(block, NUM, B_CALCEFFECT, "Tex:", 75,10,75,20, &paf->timetex, 1.0, 10.0, 0, 0, "Specify texture used for the texture emission");
/* right collumn */
uiBlockBeginAlign(block);
diff --git a/source/blender/src/buttons_shading.c b/source/blender/src/buttons_shading.c
index 9599f4e0ae9..98d4d5d537f 100644
--- a/source/blender/src/buttons_shading.c
+++ b/source/blender/src/buttons_shading.c
@@ -3065,7 +3065,9 @@ static void material_panel_shading(Material *ma)
uiBlockEndAlign(block);
uiBlockSetCol(block, TH_BUT_SETTING1);
- uiDefButBitI(block, TOG, MA_TRACEBLE, 0, "Traceable", 245,150,65,19, &(ma->mode), 0, 0, 0, 0, "Makes material to cast shadows or being detected by ray tracing");
+ uiBlockBeginAlign(block);
+ uiDefButBitI(block, TOG, MA_TRACEBLE, 0,"Traceable", 245,160,65,18, &(ma->mode), 0, 0, 0, 0, "Makes material to being detected by ray tracing");
+ uiDefButBitI(block, TOG, MA_SHADBUF, 0, "Shadbuf", 245,142,65,18, &(ma->mode), 0, 0, 0, 0, "Makes material to cast shadows with shadow buffers");
uiBlockBeginAlign(block);
uiDefButBitI(block, TOG, MA_SHADOW, 0, "Shadow", 245,120,65,19, &(ma->mode), 0, 0, 0, 0, "Makes material receive shadows");
diff --git a/source/blender/src/drawarmature.c b/source/blender/src/drawarmature.c
index e2edf634d30..b4c31179e2d 100644
--- a/source/blender/src/drawarmature.c
+++ b/source/blender/src/drawarmature.c
@@ -1486,7 +1486,7 @@ static void draw_pose_channels(Base *base, int dt)
glPushMatrix();
glMultMatrixf(pchan->pose_mat);
glTranslatef(0.0f, pchan->bone->length, 0.0f);
- drawaxes(0.25f*pchan->bone->length);
+ drawaxes(0.25f*pchan->bone->length, 0);
glPopMatrix();
}
}
@@ -1663,7 +1663,7 @@ static void draw_ebones(Object *ob, int dt)
glPushMatrix();
set_matrix_editbone(eBone);
glTranslatef(0.0f, eBone->length, 0.0f);
- drawaxes(eBone->length*0.25f);
+ drawaxes(eBone->length*0.25f, 0);
glPopMatrix();
}
diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c
index 3801d9c8fff..3261c884ca6 100644
--- a/source/blender/src/drawobject.c
+++ b/source/blender/src/drawobject.c
@@ -238,7 +238,8 @@ static float cube[8][3] = {
{ 1.0, 1.0, -1.0},
};
-void drawaxes(float size)
+/* flag is same as for draw_object */
+void drawaxes(float size, int flag)
{
int axis;
@@ -268,7 +269,7 @@ void drawaxes(float size)
glRasterPos3fv(v2);
// patch for 3d cards crashing on glSelect for text drawing (IBM)
- if((G.f & G_PICKSEL) == 0) {
+ if((flag & DRAW_PICKING) == 0) {
if (axis==0)
BMF_DrawString(G.font, "x");
else if (axis==1)
@@ -288,7 +289,8 @@ static void drawcentercircle(float *vec, int selstate, int special_color)
size= v3d->persmat[0][3]*vec[0]+ v3d->persmat[1][3]*vec[1]+ v3d->persmat[2][3]*vec[2]+ v3d->persmat[3][3];
size*= v3d->pixsize*((float)U.obcenter_dia*0.5f);
- if(v3d->zbuf) glDisable(GL_DEPTH_TEST);
+ /* using gldepthfunc guarantees that it does write z values, but not checks for it, so centers remain visible independt order of drawing */
+ if(v3d->zbuf) glDepthFunc(GL_ALWAYS);
glEnable(GL_BLEND);
if(special_color) {
@@ -296,18 +298,17 @@ static void drawcentercircle(float *vec, int selstate, int special_color)
else glColor4ub(0x55, 0xCC, 0xCC, 155);
}
else {
- if (selstate == ACTIVE) BIF_ThemeColorShadeAlpha(TH_ACTIVE, 0, -100);
- else if (selstate == SELECT) BIF_ThemeColorShadeAlpha(TH_SELECT, 0, -100);
- else if (selstate == DESELECT) BIF_ThemeColorShadeAlpha(TH_WIRE, 0, -100);
+ if (selstate == ACTIVE) BIF_ThemeColorShadeAlpha(TH_ACTIVE, 0, -80);
+ else if (selstate == SELECT) BIF_ThemeColorShadeAlpha(TH_SELECT, 0, -80);
+ else if (selstate == DESELECT) BIF_ThemeColorShadeAlpha(TH_TRANSFORM, 0, -80);
}
drawcircball(GL_POLYGON, vec, size, v3d->viewinv);
- if (selstate == ACTIVE) glColor4ub(255, 255, 255, 80);
- else if ((selstate == SELECT) || (selstate == DESELECT)) glColor4ub(0, 0, 0, 80);
+ BIF_ThemeColorShadeAlpha(TH_WIRE, 0, -30);
drawcircball(GL_LINE_LOOP, vec, size, v3d->viewinv);
glDisable(GL_BLEND);
- if(v3d->zbuf) glEnable(GL_DEPTH_TEST);
+ if(v3d->zbuf) glDepthFunc(GL_LEQUAL);
}
@@ -552,9 +553,9 @@ static void drawlamp(Object *ob)
/* Inner Circle */
VECCOPY(vec, ob->obmat[3]);
glEnable(GL_BLEND);
- drawcircball(GL_LINE_LOOP, vec, lampsize, imat);
+ drawcircball(GL_LINE_LOOP, vec, lampsize/2, imat);
glDisable(GL_BLEND);
- drawcircball(GL_POLYGON, vec, lampsize, imat);
+ drawcircball(GL_POLYGON, vec, lampsize/2, imat);
/* restore */
if(ob->id.us>1)
@@ -800,7 +801,8 @@ static void draw_focus_cross(float dist, float size)
glEnd();
}
-void drawcamera(Object *ob)
+/* flag similar to draw_object() */
+static void drawcamera(Object *ob, int flag)
{
/* a standing up pyramid with (0,0,0) as top */
Camera *cam;
@@ -880,26 +882,28 @@ void drawcamera(Object *ob)
glEnd();
}
- if(cam->flag & (CAM_SHOWLIMITS+CAM_SHOWMIST)) {
- myloadmatrix(G.vd->viewmat);
- Mat4CpyMat4(vec, ob->obmat);
- Mat4Ortho(vec);
- mymultmatrix(vec);
+ if(flag==0) {
+ if(cam->flag & (CAM_SHOWLIMITS+CAM_SHOWMIST)) {
+ myloadmatrix(G.vd->viewmat);
+ Mat4CpyMat4(vec, ob->obmat);
+ Mat4Ortho(vec);
+ mymultmatrix(vec);
- MTC_Mat4SwapMat4(G.vd->persmat, tmat);
- mygetsingmatrix(G.vd->persmat);
+ MTC_Mat4SwapMat4(G.vd->persmat, tmat);
+ mygetsingmatrix(G.vd->persmat);
- if(cam->flag & CAM_SHOWLIMITS) {
- draw_limit_line(cam->clipsta, cam->clipend, 0x77FFFF);
- /* yafray: dof focus point */
- if (G.scene->r.renderer==R_YAFRAY) draw_focus_cross(cam->YF_dofdist, cam->drawsize);
- }
+ if(cam->flag & CAM_SHOWLIMITS) {
+ draw_limit_line(cam->clipsta, cam->clipend, 0x77FFFF);
+ /* yafray: dof focus point */
+ if (G.scene->r.renderer==R_YAFRAY) draw_focus_cross(cam->YF_dofdist, cam->drawsize);
+ }
- wrld= G.scene->world;
- if(cam->flag & CAM_SHOWMIST)
- if(wrld) draw_limit_line(wrld->miststa, wrld->miststa+wrld->mistdist, 0xFFFFFF);
-
- MTC_Mat4SwapMat4(G.vd->persmat, tmat);
+ wrld= G.scene->world;
+ if(cam->flag & CAM_SHOWMIST)
+ if(wrld) draw_limit_line(wrld->miststa, wrld->miststa+wrld->mistdist, 0xFFFFFF);
+
+ MTC_Mat4SwapMat4(G.vd->persmat, tmat);
+ }
}
}
@@ -3472,7 +3476,8 @@ static void draw_hooks(Object *ob)
}
}
-void draw_object(Base *base)
+/* flag can be DRAW_PICKING and/or DRAW_CONSTCOLOR */
+void draw_object(Base *base, int flag)
{
static int warning_recursive= 0;
Object *ob;
@@ -3490,7 +3495,8 @@ void draw_object(Base *base)
ob= base->object;
/* xray delay? */
- if(!(G.f & G_PICKSEL)) {
+ if((flag & DRAW_PICKING)==0) {
+ /* xray and transp are set when it is drawing the 2nd/3rd pass */
if(!G.vd->xray && !G.vd->transp && (ob->dtx & OB_DRAWXRAY)) {
add_view3d_after(G.vd, base, V3D_XRAY);
return;
@@ -3499,7 +3505,7 @@ void draw_object(Base *base)
/* draw keys? */
if(base==(G.scene->basact) || (base->flag & (SELECT+BA_WAS_SEL))) {
- if(warning_recursive==0 && ob!=G.obedit) {
+ if(flag==0 && warning_recursive==0 && ob!=G.obedit) {
if(ob->ipo && ob->ipo->showkey && (ob->ipoflag & OB_DRAWKEY)) {
ListBase elems;
CfraElem *ce;
@@ -3531,7 +3537,7 @@ void draw_object(Base *base)
base->flag= 0;
where_is_object_time(ob, (G.scene->r.cfra));
- draw_object(base);
+ draw_object(base, 0);
}
ce= ce->next;
}
@@ -3545,7 +3551,7 @@ void draw_object(Base *base)
base->flag= SELECT;
where_is_object_time(ob, (G.scene->r.cfra));
- draw_object(base);
+ draw_object(base, 0);
}
ce= ce->next;
}
@@ -3576,7 +3582,7 @@ void draw_object(Base *base)
mymultmatrix(ob->obmat);
/* which wire color */
- if((G.f & G_PICKSEL) == 0) {
+ if((flag & DRAW_CONSTCOLOR) == 0) {
project_short(ob->obmat[3], &base->sx);
if((G.moving & G_TRANSFORM_OBJ) && (base->flag & (SELECT+BA_WAS_SEL))) BIF_ThemeColor(TH_TRANSFORM);
@@ -3653,7 +3659,7 @@ void draw_object(Base *base)
/* draw outline for selected solid objects, mesh does itself */
if((G.vd->flag & V3D_SELECT_OUTLINE) && ob->type!=OB_MESH) {
if(dt>OB_WIRE && dt<OB_TEXTURE && ob!=G.obedit) {
- if (!(ob->dtx&OB_DRAWWIRE) && (ob->flag&SELECT) && !(G.f&G_PICKSEL)) {
+ if (!(ob->dtx&OB_DRAWWIRE) && (ob->flag&SELECT) && !(flag&DRAW_PICKING)) {
drawSolidSelect(base);
}
}
@@ -3671,7 +3677,7 @@ void draw_object(Base *base)
if(paf) {
if(col || (ob->flag & SELECT)) cpack(0xFFFFFF); /* for visibility, also while wpaint */
if(paf->flag & PAF_STATIC) draw_static_particle_system(ob, paf, dt);
- else if((G.f & G_PICKSEL) == 0) draw_particle_system(ob, paf); // selection errors happen to easy
+ else if((flag & DRAW_PICKING) == 0) draw_particle_system(ob, paf); // selection errors happen to easy
if(col) cpack(col);
}
}
@@ -3792,14 +3798,14 @@ void draw_object(Base *base)
empty_object= drawmball(ob, dt);
break;
case OB_EMPTY:
- drawaxes(1.0);
+ drawaxes(1.0, flag);
break;
case OB_LAMP:
drawlamp(ob);
if(dtx || (base->flag & SELECT)) mymultmatrix(ob->obmat);
break;
case OB_CAMERA:
- drawcamera(ob);
+ drawcamera(ob, flag);
break;
case OB_LATTICE:
drawlattice(ob);
@@ -3809,7 +3815,7 @@ void draw_object(Base *base)
empty_object= draw_armature(base, dt);
break;
default:
- drawaxes(1.0);
+ drawaxes(1.0, flag);
}
if(ob->pd && ob->pd->forcefield) draw_forcefield(ob);
@@ -3818,13 +3824,14 @@ void draw_object(Base *base)
if(dtx) {
if(G.f & G_SIMULATION);
else if(dtx & OB_AXIS) {
- drawaxes(1.0f);
+ drawaxes(1.0f, flag);
}
if(dtx & OB_BOUNDBOX) draw_bounding_volume(ob);
if(dtx & OB_TEXSPACE) drawtexspace(ob);
if(dtx & OB_DRAWNAME) {
- // patch for several 3d cards (IBM mostly) that crash on glSelect with text drawing
- if((G.f & G_PICKSEL) == 0) {
+ /* patch for several 3d cards (IBM mostly) that crash on glSelect with text drawing */
+ /* but, we also dont draw names for sets or duplicators */
+ if(flag == 0) {
glRasterPos3f(0.0, 0.0, 0.0);
BMF_DrawString(G.font, " ");
@@ -3859,7 +3866,8 @@ void draw_object(Base *base)
/* object centers, need to be drawn in viewmat space for speed, but OK for picking select */
if((G.f & (G_VERTEXPAINT|G_FACESELECT|G_TEXTUREPAINT|G_WEIGHTPAINT))==0) {
- if(ob->type!=OB_LAMP) {
+ /* we don't draw centers for duplicators and sets */
+ if((flag & DRAW_CONSTCOLOR)==0) {
if((G.scene->basact)==base)
drawcentercircle(ob->obmat[3], ACTIVE, ob->id.lib || ob->id.us>1);
else if(base->flag & SELECT)
@@ -3869,7 +3877,8 @@ void draw_object(Base *base)
}
}
- if((G.f & (G_PICKSEL))==0) {
+ /* not for sets, duplicators or picking */
+ if(flag==0) {
ListBase *list;
/* draw hook center and offset line */
@@ -3934,7 +3943,7 @@ void draw_object_ext(Base *base)
if(G.vd->flag & V3D_CLIPPING)
view3d_set_clipping(G.vd);
- draw_object(base);
+ draw_object(base, 0);
if(G.vd->flag & V3D_CLIPPING)
view3d_clr_clipping();
diff --git a/source/blender/src/drawtime.c b/source/blender/src/drawtime.c
index 2eb19db36fb..9ec0f864cdb 100644
--- a/source/blender/src/drawtime.c
+++ b/source/blender/src/drawtime.c
@@ -123,8 +123,7 @@ static void draw_cfra_time(SpaceTime *stime)
static void draw_marker(TimeMarker *marker)
{
- float xpos, col[3];
- float xspace, yspace, xpixels, ypixels;
+ float xpos, xspace, yspace, xpixels, ypixels;
xpos = marker->frame;
/* no time correction for framelen! space is drawn with old values */
@@ -134,16 +133,14 @@ static void draw_marker(TimeMarker *marker)
xpixels= G.v2d->mask.xmax-G.v2d->mask.xmin;
ypixels= G.v2d->mask.ymax-G.v2d->mask.ymin;
- BIF_GetThemeColor3fv(TH_BACK, col);
-
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
/* 5 px to offset icon to align properly, space / pixels corrects for zoom */
if(marker->flag & SELECT)
- BIF_draw_icon_blended(xpos-(5.0*(xspace/xpixels)), 12.0*yspace/ypixels, ICON_MARKER_HLT, (int)col, 0);
+ BIF_draw_icon_blended(xpos-(5.0*(xspace/xpixels)), 12.0*yspace/ypixels, ICON_MARKER_HLT, TH_BACK, 0);
else
- BIF_draw_icon_blended(xpos-(5.0*(xspace/xpixels)), 12.0*yspace/ypixels, ICON_MARKER, (int)col, 0);
+ BIF_draw_icon_blended(xpos-(5.0*(xspace/xpixels)), 12.0*yspace/ypixels, ICON_MARKER, TH_BACK, 0);
glBlendFunc(GL_ONE, GL_ZERO);
glDisable(GL_BLEND);
@@ -167,7 +164,7 @@ static void draw_marker(TimeMarker *marker)
}
}
-static void draw_markers_time(SpaceTime *stime)
+static void draw_markers_time( void )
{
TimeMarker *marker;
@@ -308,7 +305,7 @@ void drawtimespace(ScrArea *sa, void *spacedata)
draw_cfra_time(spacedata);
draw_ob_keys();
- draw_markers_time(spacedata);
+ draw_markers_time();
/* restore viewport */
mywinset(curarea->win);
diff --git a/source/blender/src/drawview.c b/source/blender/src/drawview.c
index 7ded0b5b66c..b470d2ab6af 100644
--- a/source/blender/src/drawview.c
+++ b/source/blender/src/drawview.c
@@ -2053,7 +2053,7 @@ void add_view3d_after(View3D *v3d, Base *base, int type)
}
/* clears zbuffer and draws it over */
-static void view3d_draw_xray(View3D *v3d)
+static void view3d_draw_xray(View3D *v3d, int flag)
{
View3DAfter *v3da, *next;
int doit= 0;
@@ -2068,7 +2068,7 @@ static void view3d_draw_xray(View3D *v3d)
for(v3da= v3d->afterdraw.first; v3da; v3da= next) {
next= v3da->next;
if(v3da->type==V3D_XRAY) {
- draw_object(v3da->base);
+ draw_object(v3da->base, flag);
BLI_remlink(&v3d->afterdraw, v3da);
MEM_freeN(v3da);
}
@@ -2078,7 +2078,7 @@ static void view3d_draw_xray(View3D *v3d)
}
/* disables write in zbuffer and draws it over */
-static void view3d_draw_transp(View3D *v3d)
+static void view3d_draw_transp(View3D *v3d, int flag)
{
View3DAfter *v3da, *next;
@@ -2088,7 +2088,7 @@ static void view3d_draw_transp(View3D *v3d)
for(v3da= v3d->afterdraw.first; v3da; v3da= next) {
next= v3da->next;
if(v3da->type==V3D_TRANSP) {
- draw_object(v3da->base);
+ draw_object(v3da->base, flag);
BLI_remlink(&v3d->afterdraw, v3da);
MEM_freeN(v3da);
}
@@ -2195,14 +2195,8 @@ void drawview3dspace(ScrArea *sa, void *spacedata)
object_handle_update(base->object);
- /* patch: color remains constant, only set it for wire, so transparant works */
- if(v3d->zbuf==0 || base->object->dt<=OB_WIRE)
- G.f |= G_PICKSEL;
- else
- G.f &= ~G_PICKSEL;
-
BIF_ThemeColorBlend(TH_WIRE, TH_BACK, 0.6f);
- draw_object(base);
+ draw_object(base, DRAW_CONSTCOLOR);
if(base->object->transflag & OB_DUPLI) {
extern ListBase duplilist;
@@ -2215,7 +2209,7 @@ void drawview3dspace(ScrArea *sa, void *spacedata)
ob= duplilist.first;
while(ob) {
tbase.object= ob;
- draw_object(&tbase);
+ draw_object(&tbase, DRAW_CONSTCOLOR);
ob= ob->id.next;
}
free_duplilist();
@@ -2224,12 +2218,10 @@ void drawview3dspace(ScrArea *sa, void *spacedata)
}
base= base->next;
}
-
- G.f &= ~G_PICKSEL;
/* Transp and X-ray afterdraw stuff */
- view3d_draw_xray(v3d); // clears zbuffer if it is used!
- view3d_draw_transp(v3d);
+ view3d_draw_xray(v3d, DRAW_CONSTCOLOR); // clears zbuffer if it is used!
+ view3d_draw_transp(v3d, DRAW_CONSTCOLOR);
}
/* update all objects, ipos, matrices, displists, etc. Flags set by depgraph or manual, no layer check here, gets correct flushed */
@@ -2246,8 +2238,6 @@ void drawview3dspace(ScrArea *sa, void *spacedata)
extern ListBase duplilist;
Base tbase;
- /* patch: color remains constant */
- G.f |= G_PICKSEL;
BIF_ThemeColorBlend(TH_BACK, TH_WIRE, 0.5);
tbase.flag= OB_FROMDUPLI;
@@ -2256,15 +2246,13 @@ void drawview3dspace(ScrArea *sa, void *spacedata)
ob= duplilist.first;
while(ob) {
tbase.object= ob;
- draw_object(&tbase);
+ draw_object(&tbase, DRAW_CONSTCOLOR);
ob= ob->id.next;
}
free_duplilist();
-
- G.f &= ~G_PICKSEL;
}
if((base->flag & SELECT)==0) {
- if(base->object!=G.obedit) draw_object(base);
+ if(base->object!=G.obedit) draw_object(base, 0);
}
}
}
@@ -2272,7 +2260,7 @@ void drawview3dspace(ScrArea *sa, void *spacedata)
for(base= G.scene->base.first; base; base= base->next) {
if(v3d->lay & base->lay) {
if (base->object==G.obedit || ( base->flag & SELECT) )
- draw_object(base);
+ draw_object(base, 0);
}
}
@@ -2284,8 +2272,8 @@ void drawview3dspace(ScrArea *sa, void *spacedata)
if(G.scene->radio) RAD_drawall(v3d->drawtype>=OB_SOLID);
/* Transp and X-ray afterdraw stuff */
- view3d_draw_xray(v3d); // clears zbuffer if it is used!
- view3d_draw_transp(v3d);
+ view3d_draw_xray(v3d, 0); // clears zbuffer if it is used!
+ view3d_draw_transp(v3d, 0);
if(v3d->flag & V3D_CLIPPING)
view3d_clr_clipping();
@@ -2402,14 +2390,8 @@ void drawview3d_render(struct View3D *v3d)
else {
where_is_object(base->object);
- /* patch: color remains constant, only set it for wire, so transparant works */
- if(v3d->zbuf==0 || base->object->dt<=OB_WIRE)
- G.f |= G_PICKSEL;
- else
- G.f &= ~G_PICKSEL;
-
BIF_ThemeColorBlend(TH_WIRE, TH_BACK, 0.6f);
- draw_object(base);
+ draw_object(base, DRAW_CONSTCOLOR);
if(base->object->transflag & OB_DUPLI) {
extern ListBase duplilist;
@@ -2420,7 +2402,7 @@ void drawview3d_render(struct View3D *v3d)
ob= duplilist.first;
while(ob) {
tbase.object= ob;
- draw_object(&tbase);
+ draw_object(&tbase, DRAW_CONSTCOLOR);
ob= ob->id.next;
}
free_duplilist();
@@ -2431,10 +2413,8 @@ void drawview3d_render(struct View3D *v3d)
}
/* Transp and X-ray afterdraw stuff */
- view3d_draw_xray(v3d); // clears zbuffer if it is used!
- view3d_draw_transp(v3d);
-
- G.f &= ~G_PICKSEL;
+ view3d_draw_xray(v3d, DRAW_CONSTCOLOR); // clears zbuffer if it is used!
+ view3d_draw_transp(v3d, DRAW_CONSTCOLOR);
}
/* first not selected and duplis */
@@ -2449,11 +2429,8 @@ void drawview3d_render(struct View3D *v3d)
extern ListBase duplilist;
Base tbase;
- /* always draw original first because of make_displist */
- draw_object(base);
+ draw_object(base, 0);
- /* patch: color remains constant */
- G.f |= G_PICKSEL;
BIF_ThemeColorBlend(TH_WIRE, TH_BACK, 0.5f);
tbase.flag= OB_FROMDUPLI;
@@ -2461,15 +2438,13 @@ void drawview3d_render(struct View3D *v3d)
ob= duplilist.first;
while(ob) {
tbase.object= ob;
- draw_object(&tbase);
+ draw_object(&tbase, DRAW_CONSTCOLOR);
ob= ob->id.next;
}
free_duplilist();
-
- G.f &= ~G_PICKSEL;
}
else if((base->flag & SELECT)==0) {
- draw_object(base);
+ draw_object(base, 0);
}
}
}
@@ -2483,7 +2458,7 @@ void drawview3d_render(struct View3D *v3d)
if ( ((base)->flag & SELECT) && ((base)->lay & v3d->lay) ) {
if ELEM3(base->object->type, OB_LAMP, OB_CAMERA, OB_LATTICE);
- else draw_object(base);
+ else draw_object(base, 0);
}
base= base->next;
@@ -2492,8 +2467,8 @@ void drawview3d_render(struct View3D *v3d)
if(G.scene->radio) RAD_drawall(v3d->drawtype>=OB_SOLID);
/* Transp and X-ray afterdraw stuff */
- view3d_draw_xray(v3d); // clears zbuffer if it is used!
- view3d_draw_transp(v3d);
+ view3d_draw_xray(v3d, 0); // clears zbuffer if it is used!
+ view3d_draw_transp(v3d, 0);
if(v3d->flag & V3D_CLIPPING)
view3d_clr_clipping();
diff --git a/source/blender/src/editmesh.c b/source/blender/src/editmesh.c
index 5a354b5e002..2eb59c146f2 100644
--- a/source/blender/src/editmesh.c
+++ b/source/blender/src/editmesh.c
@@ -782,7 +782,7 @@ void make_editMesh()
if(medge->flag & SELECT) eed->f |= SELECT;
if(medge->flag & ME_FGON) eed->h= EM_FGON; // 2 different defines!
if(medge->flag & ME_HIDE) eed->h |= 1;
- if(G.scene->selectmode & SCE_SELECT_EDGE)
+ if(G.scene->selectmode==SCE_SELECT_EDGE)
EM_select_edge(eed, eed->f & SELECT); // force edge selection to vertices, seems to be needed ...
}
diff --git a/source/blender/src/editmesh_add.c b/source/blender/src/editmesh_add.c
index 13860329cf7..6e82e82134e 100644
--- a/source/blender/src/editmesh_add.c
+++ b/source/blender/src/editmesh_add.c
@@ -633,7 +633,7 @@ void addedgeface_mesh(void)
/* if 4 edges exist, we just create the face, convex or not */
efa= addface_from_edges();
if(efa==NULL) {
- /* the order of vertices can be anything, three cases to check */
+ /* the order of vertices can be anything, 6 cases to check */
if( convex(neweve[0]->co, neweve[1]->co, neweve[2]->co, neweve[3]->co) ) {
efa= addfacelist(neweve[0], neweve[1], neweve[2], neweve[3], NULL, NULL);
}
@@ -643,6 +643,16 @@ void addedgeface_mesh(void)
else if( convex(neweve[0]->co, neweve[2]->co, neweve[1]->co, neweve[3]->co) ) {
efa= addfacelist(neweve[0], neweve[2], neweve[1], neweve[3], NULL, NULL);
}
+
+ else if( convex(neweve[1]->co, neweve[2]->co, neweve[3]->co, neweve[0]->co) ) {
+ efa= addfacelist(neweve[1], neweve[2], neweve[3], neweve[0], NULL, NULL);
+ }
+ else if( convex(neweve[1]->co, neweve[3]->co, neweve[0]->co, neweve[2]->co) ) {
+ efa= addfacelist(neweve[1], neweve[3], neweve[0], neweve[2], NULL, NULL);
+ }
+ else if( convex(neweve[1]->co, neweve[3]->co, neweve[2]->co, neweve[0]->co) ) {
+ efa= addfacelist(neweve[1], neweve[3], neweve[2], neweve[0], NULL, NULL);
+ }
else error("The selected vertices form a concave quad");
}
}
diff --git a/source/blender/src/editmesh_lib.c b/source/blender/src/editmesh_lib.c
index e9289fb2e5b..153a6b1b945 100644
--- a/source/blender/src/editmesh_lib.c
+++ b/source/blender/src/editmesh_lib.c
@@ -401,14 +401,14 @@ void EM_selectmode_set(void)
EditEdge *eed;
EditFace *efa;
- if(G.scene->selectmode & SCE_SELECT_VERTEX) {
+ if(G.scene->selectmode == SCE_SELECT_VERTEX) {
/* vertices -> edges -> faces */
for (eed= em->edges.first; eed; eed= eed->next) eed->f &= ~SELECT;
for (efa= em->faces.first; efa; efa= efa->next) efa->f &= ~SELECT;
EM_select_flush();
}
- else if(G.scene->selectmode & SCE_SELECT_EDGE) {
+ else if(G.scene->selectmode == SCE_SELECT_EDGE) {
/* deselect vertices, and select again based on edge select */
for(eve= em->verts.first; eve; eve= eve->next) eve->f &= ~SELECT;
for(eed= em->edges.first; eed; eed= eed->next)
diff --git a/source/blender/src/editmesh_tools.c b/source/blender/src/editmesh_tools.c
index e38bb8998ff..1ecf44bd71a 100644
--- a/source/blender/src/editmesh_tools.c
+++ b/source/blender/src/editmesh_tools.c
@@ -646,6 +646,7 @@ void split_mesh(void)
adduplicateflag(SELECT);
/* old faces have flag 128 set, delete them */
delfaceflag(128);
+ recalc_editnormals();
waitcursor(0);
diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c
index 088a66f378a..a7a8ba0c5a6 100644
--- a/source/blender/src/editobject.c
+++ b/source/blender/src/editobject.c
@@ -120,14 +120,6 @@
#include "BKE_utildefines.h"
#include "BKE_modifier.h"
-#include "BIF_gl.h"
-#include "BIF_graphics.h"
-#include "BIF_interface.h"
-#include "BIF_mywindow.h"
-#include "BIF_toolbox.h"
-#include "BIF_screen.h"
-#include "BIF_space.h"
-#include "BIF_toets.h"
#include "BIF_butspace.h"
#include "BIF_editconstraint.h"
#include "BIF_editdeform.h"
@@ -137,7 +129,16 @@
#include "BIF_editoops.h"
#include "BIF_editview.h"
#include "BIF_editarmature.h"
+#include "BIF_gl.h"
+#include "BIF_graphics.h"
+#include "BIF_interface.h"
+#include "BIF_meshtools.h"
+#include "BIF_mywindow.h"
#include "BIF_resources.h"
+#include "BIF_screen.h"
+#include "BIF_space.h"
+#include "BIF_toolbox.h"
+#include "BIF_toets.h"
#include "BSE_edit.h"
#include "BSE_editipo.h"
@@ -1504,6 +1505,8 @@ void exit_editmode(int freedata) /* freedata==0 at render, 1= freedata, 2= do un
set_seamtface();
allqueue(REDRAWIMAGE, 0);
}
+ if(G.f & G_WEIGHTPAINT)
+ mesh_octree_table(G.obedit, NULL, 'e');
}
else if (G.obedit->type==OB_ARMATURE){
load_editArmature();
diff --git a/source/blender/src/editscreen.c b/source/blender/src/editscreen.c
index ea1e0fb5da1..b95fc9f11bd 100644
--- a/source/blender/src/editscreen.c
+++ b/source/blender/src/editscreen.c
@@ -1488,24 +1488,13 @@ void setprefsize(int stax, int stay, int sizx, int sizy)
winlay_get_screensize(&scrwidth, &scrheight);
-// if(stax<0) stax= 0;
-// if(stay<0) stay= 0;
if(sizx<320) sizx= 320;
if(sizy<256) sizy= 256;
-// if(stax+sizx>scrwidth) {
-// fprintf(stderr," width prob \n");
-// sizx= scrwidth-stax;
-// }
-
if(stay+sizy>scrheight) {
fprintf(stderr," height prob \n");
sizy= scrheight-stay;
- }
-
-/* #ifdef __APPLE__ */
-/* if(stay+sizy>scrheight-22) sizy= scrheight-22-stay; // 22 = topbar */
-/* #endif*/
+ }
if(sizx<320 || sizy<256) {
printf("ERROR: illegal prefsize\n");
diff --git a/source/blender/src/ghostwinlay.c b/source/blender/src/ghostwinlay.c
index 7a83dbcb2f5..88beb6ea874 100644
--- a/source/blender/src/ghostwinlay.c
+++ b/source/blender/src/ghostwinlay.c
@@ -359,6 +359,8 @@ Window *window_open(char *title, int posx, int posy, int sizex, int sizey, int s
win->lmouse[0]= win->size[0]/2;
win->lmouse[1]= win->size[1]/2;
+
+
} else {
GHOST_DisposeWindow(g_system, ghostwin);
}
diff --git a/source/blender/src/header_image.c b/source/blender/src/header_image.c
index 8a4603ec532..e0571e94e45 100644
--- a/source/blender/src/header_image.c
+++ b/source/blender/src/header_image.c
@@ -731,6 +731,7 @@ static void do_image_imagemenu(void *arg, int event)
case 7: /* New Image */
{
static int width= 256, height= 256;
+ static short uvtestgrid=0;
char name[256];
strcpy(name, "Image");
@@ -738,10 +739,11 @@ static void do_image_imagemenu(void *arg, int event)
add_numbut(0, TEX, "Name:", 0, 255, name, NULL);
add_numbut(1, NUM|INT, "Width:", 1, 5000, &width, NULL);
add_numbut(2, NUM|INT, "Height:", 1, 5000, &height, NULL);
- if (!do_clever_numbuts("New Image", 3, REDRAW))
+ add_numbut(3, TOG|SHO, "UV Test Grid", 0, 0, &uvtestgrid, NULL);
+ if (!do_clever_numbuts("New Image", 4, REDRAW))
return;
- G.sima->image= new_image(width, height, name);
+ G.sima->image= new_image(width, height, name, uvtestgrid);
image_changed(G.sima, 0);
allqueue(REDRAWIMAGE, 0);
diff --git a/source/blender/src/header_view3d.c b/source/blender/src/header_view3d.c
index 05a792e4690..2b448348034 100644
--- a/source/blender/src/header_view3d.c
+++ b/source/blender/src/header_view3d.c
@@ -3881,7 +3881,11 @@ void do_view3d_buttons(short event)
case B_LOCALVIEW:
if(G.vd->localview) initlocalview();
- else endlocalview(curarea);
+ else {
+ endlocalview(curarea);
+ /* new layers might need unflushed events events */
+ DAG_scene_update_flags(G.scene, G.vd->lay); // tags all that moves and flushes
+ }
scrarea_queue_headredraw(curarea);
break;
diff --git a/source/blender/src/meshtools.c b/source/blender/src/meshtools.c
index 2a8ee7570af..1ef7320763c 100644
--- a/source/blender/src/meshtools.c
+++ b/source/blender/src/meshtools.c
@@ -598,7 +598,7 @@ void sort_faces(void)
#define MOC_RES 8
#define MOC_NODE_RES 8
-#define MOC_THRESH 0.0001f
+#define MOC_THRESH 0.0002f
typedef struct MocNode {
struct MocNode *next;
@@ -735,6 +735,9 @@ int mesh_octree_table(Object *ob, float *co, char mode)
static float offs[3], div[3];
if(mode=='u') { /* use table */
+ if(basetable==NULL)
+ mesh_octree_table(ob, NULL, 's');
+
if(basetable) {
Mesh *me= ob->data;
bt= basetable + mesh_octree_get_base_offs(co, offs, div);
@@ -751,7 +754,15 @@ int mesh_octree_table(Object *ob, float *co, char mode)
/* for quick unit coordinate calculus */
VECCOPY(offs, bb->vec[0]);
+ offs[0]+= MOC_THRESH; /* we offset it 1 threshold unit extra */
+ offs[1]+= MOC_THRESH;
+ offs[2]+= MOC_THRESH;
+
VecSubf(div, bb->vec[6], offs);
+ div[0]+= MOC_THRESH; /* and divide with 1 threshold unit more extra (try 8x8 unit grid on paint) */
+ div[1]+= MOC_THRESH;
+ div[2]+= MOC_THRESH;
+
VecMulf(div, 1.0f/MOC_RES);
if(div[0]==0.0f) div[0]= 1.0f;
if(div[1]==0.0f) div[1]= 1.0f;
diff --git a/source/blender/src/poseobject.c b/source/blender/src/poseobject.c
index 077d6f520b4..5a2276736b6 100644
--- a/source/blender/src/poseobject.c
+++ b/source/blender/src/poseobject.c
@@ -525,17 +525,18 @@ void paste_posebuf (int flip)
if (G.flags & G_RECORDKEYS){
ID *id= &ob->id;
+
/* Set keys on pose */
if (chan->flag & POSE_ROT){
- insertkey(id, ID_PO, chan->name, NULL, AC_QUAT_X);
- insertkey(id, ID_PO, chan->name, NULL, AC_QUAT_Y);
- insertkey(id, ID_PO, chan->name, NULL, AC_QUAT_Z);
- insertkey(id, ID_PO, chan->name, NULL, AC_QUAT_W);
+ insertkey(id, ID_PO, pchan->name, NULL, AC_QUAT_X);
+ insertkey(id, ID_PO, pchan->name, NULL, AC_QUAT_Y);
+ insertkey(id, ID_PO, pchan->name, NULL, AC_QUAT_Z);
+ insertkey(id, ID_PO, pchan->name, NULL, AC_QUAT_W);
}
if (chan->flag & POSE_SIZE){
- insertkey(id, ID_PO, chan->name, NULL, AC_SIZE_X);
- insertkey(id, ID_PO, chan->name, NULL, AC_SIZE_Y);
- insertkey(id, ID_PO, chan->name, NULL, AC_SIZE_Z);
+ insertkey(id, ID_PO, pchan->name, NULL, AC_SIZE_X);
+ insertkey(id, ID_PO, pchan->name, NULL, AC_SIZE_Y);
+ insertkey(id, ID_PO, pchan->name, NULL, AC_SIZE_Z);
}
if (chan->flag & POSE_LOC){
insertkey(id, ID_PO, pchan->name, NULL, AC_LOC_X);
diff --git a/source/blender/src/pub/license_key.c b/source/blender/src/pub/license_key.c
index 72977e591b4..07e8296a185 100644
--- a/source/blender/src/pub/license_key.c
+++ b/source/blender/src/pub/license_key.c
@@ -234,8 +234,7 @@ static void insertname(PyObject *m,PyObject *p, char *name)
{
PyObject *d = PyModule_GetDict(m);
- PyDict_SetItemString(d, name, p);
- Py_DECREF(p);
+ EXPP_dict_set_item_str(d, name, p);
}
/* initialisation */
@@ -243,8 +242,6 @@ static void initprot()
{
PyObject *m, *d;
PyObject *capi1;
- PyObject *ErrorObject;
-
init_ftable();
g_main = PyImport_AddModule("__main__");
@@ -254,8 +251,7 @@ static void initprot()
(PyObject*)NULL,PYTHON_API_VERSION);
g_module_self = m;
d = PyModule_GetDict(m);
- ErrorObject = PyString_FromString("prot.error");
- PyDict_SetItemString(d, "error", ErrorObject);
+ EXPP_dict_set_item_str(d, "error", PyString_FromString("prot.error");
/* add global object */
diff --git a/source/blender/src/renderwin.c b/source/blender/src/renderwin.c
index 15d7b8aef76..5483d8e27cf 100644
--- a/source/blender/src/renderwin.c
+++ b/source/blender/src/renderwin.c
@@ -604,12 +604,8 @@ void calc_renderwin_rectangle(int posmask, int renderpos_r[2], int rendersize_r[
int scr_w, scr_h, x, y, div= 0;
float ndc_x= 0.0, ndc_y= 0.0;
- /* XXX, we temporarily hack the screen size and position so
- * the window is always 60 pixels away from a side, really need
- * a GHOST_GetMaxWindowBounds or so - zr
- */
winlay_get_screensize(&scr_w, &scr_h);
-
+
rendersize_r[0]= (G.scene->r.size*G.scene->r.xsch)/100;
rendersize_r[1]= (G.scene->r.size*G.scene->r.ysch)/100;
@@ -623,9 +619,6 @@ void calc_renderwin_rectangle(int posmask, int renderpos_r[2], int rendersize_r[
rendersize_r[0]*= G.scene->r.xparts;
rendersize_r[1]*= G.scene->r.yparts;
}
- /* increased size of clipping for OSX, should become an option instead */
- rendersize_r[0]= CLAMPIS(rendersize_r[0], 100, scr_w-120);
- rendersize_r[1]= CLAMPIS(rendersize_r[1], 100, scr_h-120);
for (y=-1; y<=1; y++) {
for (x=-1; x<=1; x++) {
@@ -641,9 +634,14 @@ void calc_renderwin_rectangle(int posmask, int renderpos_r[2], int rendersize_r[
ndc_x/= div;
ndc_y/= div;
}
-
- renderpos_r[0]= 60 + (scr_w-90-rendersize_r[0])*(ndc_x*0.5 + 0.5);
- renderpos_r[1]= 30 + (scr_h-90-rendersize_r[1])*(ndc_y*0.5 + 0.5);
+
+ renderpos_r[0]= (scr_w-rendersize_r[0])*(ndc_x*0.5 + 0.5);
+#ifdef __APPLE__
+ /* 44 pixels is topbar and window header... awaiting better fixes in ghost :) */
+ renderpos_r[1]= -44-RW_HEADERY+(scr_h-rendersize_r[1])*(ndc_y*0.5 + 0.5);
+#else
+ renderpos_r[1]= (scr_h-rendersize_r[1])*(ndc_y*0.5 + 0.5);
+#endif
}
/* init renderwin, alloc/open/resize */
diff --git a/source/blender/src/sequence.c b/source/blender/src/sequence.c
index 1564dbce14a..17b6e4d90b0 100644
--- a/source/blender/src/sequence.c
+++ b/source/blender/src/sequence.c
@@ -1486,11 +1486,13 @@ void RVIsolateHighlights (unsigned char* in, unsigned char* out, int width, int
out[index+GlowR]=MIN2(255*clamp, (in[index+GlowR]*boost*intensity)/255);
out[index+GlowG]=MIN2(255*clamp, (in[index+GlowG]*boost*intensity)/255);
out[index+GlowB]=MIN2(255*clamp, (in[index+GlowB]*boost*intensity)/255);
+ out[index+GlowA]=MIN2(255*clamp, (in[index+GlowA]*boost*intensity)/255);
}
else{
out[index+GlowR]=0;
out[index+GlowG]=0;
out[index+GlowB]=0;
+ out[index+GlowA]=0;
}
}
}
diff --git a/source/blender/src/space.c b/source/blender/src/space.c
index 9e655d0628c..47c3b8e4004 100644
--- a/source/blender/src/space.c
+++ b/source/blender/src/space.c
@@ -3297,6 +3297,7 @@ void extern_set_butspace(int fkey)
{
ScrArea *sa;
SpaceButs *sbuts;
+ Object *ob= OBACT;
/* when a f-key pressed: 'closest' button window is initialized */
if(curarea->spacetype==SPACE_BUTS) sa= curarea;
@@ -3336,12 +3337,12 @@ void extern_set_butspace(int fkey)
}
/* if we're coming in from texture buttons,
or from outside the shading context, just go to the 'default' */
- else if ((OBACT && sbuts->mainb!= CONTEXT_SHADING) || (sbuts->oldkeypress == F6KEY)) {
+ else if (ob && ((sbuts->mainb!= CONTEXT_SHADING) || (sbuts->oldkeypress == F6KEY)) ) {
sbuts->mainb= CONTEXT_SHADING;
- if(OBACT->type==OB_CAMERA)
+ if(ob->type==OB_CAMERA)
sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_WORLD;
- else if(OBACT->type==OB_LAMP)
+ else if(ob->type==OB_LAMP)
sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_LAMP;
else
sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_MAT;
diff --git a/source/blender/src/transform_manipulator.c b/source/blender/src/transform_manipulator.c
index ef7b15427d4..7e41008700d 100644
--- a/source/blender/src/transform_manipulator.c
+++ b/source/blender/src/transform_manipulator.c
@@ -245,18 +245,13 @@ int calc_manipulator_stats(ScrArea *sa)
else if (G.obedit->type==OB_ARMATURE){
EditBone *ebo;
for (ebo=G.edbo.first;ebo;ebo=ebo->next){
-
- // If this is a connected child and it's parent is being moved, don't count as selected
- if ((ebo->flag & BONE_CONNECTED)&& (ebo->flag & BONE_ROOTSEL) && ebo->parent && (ebo->parent->flag & BONE_TIPSEL));
- else {
- if (ebo->flag & BONE_TIPSEL) {
- calc_tw_center(ebo->tail);
- totsel++;
- }
- if (ebo->flag & BONE_ROOTSEL) {
- calc_tw_center(ebo->head);
- totsel++;
- }
+ if (ebo->flag & BONE_TIPSEL) {
+ calc_tw_center(ebo->tail);
+ totsel++;
+ }
+ if (ebo->flag & BONE_ROOTSEL) {
+ calc_tw_center(ebo->head);
+ totsel++;
}
}
}
diff --git a/source/blender/src/view.c b/source/blender/src/view.c
index c421f34a838..e13a23691f9 100644
--- a/source/blender/src/view.c
+++ b/source/blender/src/view.c
@@ -998,10 +998,10 @@ short view3d_opengl_select(unsigned int *buffer, unsigned int bufsize, short x1
code= 1;
if(G.obedit && G.obedit->type==OB_MBALL) {
- draw_object(BASACT);
+ draw_object(BASACT, DRAW_PICKING|DRAW_CONSTCOLOR);
}
else if ((G.obedit && G.obedit->type==OB_ARMATURE)) {
- draw_object(BASACT);
+ draw_object(BASACT, DRAW_PICKING|DRAW_CONSTCOLOR);
}
else {
Base *base;
@@ -1011,7 +1011,7 @@ short view3d_opengl_select(unsigned int *buffer, unsigned int bufsize, short x1
if(base->lay & G.vd->lay) {
base->selcol= code;
glLoadName(code);
- draw_object(base);
+ draw_object(base, DRAW_PICKING|DRAW_CONSTCOLOR);
code++;
}
}
diff --git a/source/blender/src/vpaint.c b/source/blender/src/vpaint.c
index ec73a3c5ec6..ad62f6c0dc0 100644
--- a/source/blender/src/vpaint.c
+++ b/source/blender/src/vpaint.c
@@ -969,13 +969,15 @@ static void do_weight_paint_vertex(Object *ob, int index, int alpha, float paint
wpaint_blend(dw, uw, (float)alpha/255.0, paintweight);
if(Gwp.flag & VP_MIRROR_X) { /* x mirror painting */
- if(vgroup_mirror != -1) {
- int j= mesh_get_x_mirror_vert(ob, index);
- if(j>=0) {
- /* copy, not paint again */
+ int j= mesh_get_x_mirror_vert(ob, index);
+ if(j>=0) {
+ /* copy, not paint again */
+ if(vgroup_mirror != -1)
uw= verify_defweight(me->dvert+j, vgroup_mirror);
- uw->weight= dw->weight;
- }
+ else
+ uw= verify_defweight(me->dvert+j, vgroup);
+
+ uw->weight= dw->weight;
}
}
}
@@ -1020,7 +1022,7 @@ void weight_paint(void)
vertexcosnos= mesh_get_mapped_verts_nors(ob);
/* this happens on a Bone select, when no vgroup existed yet */
- if(ob->actdef==0) {
+ if(ob->actdef<=0) {
Object *modob;
if((modob = modifiers_isDeformedByArmature(ob))) {
bPoseChannel *pchan;
@@ -1075,14 +1077,19 @@ void weight_paint(void)
bDeformGroup *curdef;
int actdef= 0;
char name[32];
-
+
BLI_strncpy(name, defgroup->name, 32);
bone_flip_name(name, 0); // 0 = don't strip off number extensions
for (curdef = ob->defbase.first; curdef; curdef=curdef->next, actdef++)
if (!strcmp(curdef->name, name))
break;
-
+ if(curdef==NULL) {
+ int olddef= ob->actdef; /* tsk, add_defgroup sets the active defgroup */
+ curdef= add_defgroup_name (ob, name);
+ ob->actdef= olddef;
+ }
+
if(curdef && curdef!=defgroup)
vgroup_mirror= actdef;
}