From 5627e1b33fda416711b5daf1c14fe3f007f5fc23 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 23 Dec 2011 12:56:48 +0000 Subject: Fix #29652: operator tab can not be maximised Clamp region's size on expand to max allowed size, so it wouldn't be automatically hidden just after expand. --- source/blender/editors/screen/screen_ops.c | 67 +++++++++++++++++++++++------- 1 file changed, 53 insertions(+), 14 deletions(-) (limited to 'source/blender') diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 1c34df5393a..7e17592f67c 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -1666,6 +1666,47 @@ static int region_scale_invoke(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_FINISHED; } +static int region_scale_get_maxsize(RegionMoveData *rmd) +{ + int maxsize= 0; + + if(rmd->edge==AE_LEFT_TO_TOPRIGHT || rmd->edge==AE_RIGHT_TO_TOPLEFT) { + return rmd->sa->winx - UI_UNIT_X; + } + + if(rmd->ar->regiontype == RGN_TYPE_TOOL_PROPS) { + /* this calculation seems overly verbose + * can someone explain why this method is necessary? - campbell */ + maxsize = rmd->maxsize - ((rmd->sa->headertype==HEADERTOP)?UI_UNIT_Y*2:UI_UNIT_Y) - (UI_UNIT_Y/4); + } + + return maxsize; +} + +static void region_scale_validate_size(RegionMoveData *rmd) +{ + if((rmd->ar->flag & RGN_FLAG_HIDDEN)==0) { + short *size, maxsize= -1; + + + if(rmd->edge==AE_LEFT_TO_TOPRIGHT || rmd->edge==AE_RIGHT_TO_TOPLEFT) + size= &rmd->ar->sizex; + else + size= &rmd->ar->sizey; + + maxsize= region_scale_get_maxsize(rmd); + + if(*size > maxsize && maxsize > 0) + *size= maxsize; + } +} + +static void region_scale_toggle_hidden(bContext *C, RegionMoveData *rmd) +{ + ED_region_toggle_hidden(C, rmd->ar); + region_scale_validate_size(rmd); +} + static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event) { RegionMoveData *rmd= op->customdata; @@ -1685,35 +1726,29 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event) if(rmd->ar->sizex < UI_UNIT_X) { rmd->ar->sizex= rmd->origval; if(!(rmd->ar->flag & RGN_FLAG_HIDDEN)) - ED_region_toggle_hidden(C, rmd->ar); + region_scale_toggle_hidden(C, rmd); } else if(rmd->ar->flag & RGN_FLAG_HIDDEN) - ED_region_toggle_hidden(C, rmd->ar); + region_scale_toggle_hidden(C, rmd); } else { - int maxsize=0; + int maxsize= region_scale_get_maxsize(rmd); delta= event->y - rmd->origy; if(rmd->edge==AE_BOTTOM_TO_TOPLEFT) delta= -delta; rmd->ar->sizey= rmd->origval + delta; CLAMP(rmd->ar->sizey, 0, rmd->maxsize); - if(rmd->ar->regiontype == RGN_TYPE_TOOL_PROPS) { - /* this calculation seems overly verbose - * can someone explain why this method is necessary? - campbell */ - maxsize = rmd->maxsize - ((rmd->sa->headertype==HEADERTOP)?UI_UNIT_Y*2:UI_UNIT_Y) - (UI_UNIT_Y/4); - } - /* note, 'UI_UNIT_Y/4' means you need to drag the header almost * all the way down for it to become hidden, this is done * otherwise its too easy to do this by accident */ if(rmd->ar->sizey < UI_UNIT_Y/4 || (maxsize > 0 && (rmd->ar->sizey > maxsize)) ) { rmd->ar->sizey= rmd->origval; if(!(rmd->ar->flag & RGN_FLAG_HIDDEN)) - ED_region_toggle_hidden(C, rmd->ar); + region_scale_toggle_hidden(C, rmd); } else if(rmd->ar->flag & RGN_FLAG_HIDDEN) - ED_region_toggle_hidden(C, rmd->ar); + region_scale_toggle_hidden(C, rmd); } ED_area_tag_redraw(rmd->sa); WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); @@ -1725,10 +1760,14 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event) if(ABS(event->x - rmd->origx) < 2 && ABS(event->y - rmd->origy) < 2) { if(rmd->ar->flag & RGN_FLAG_HIDDEN) { - ED_region_toggle_hidden(C, rmd->ar); - ED_area_tag_redraw(rmd->sa); - WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); + region_scale_toggle_hidden(C, rmd); + } + else if(rmd->ar->flag & RGN_FLAG_TOO_SMALL) { + region_scale_validate_size(rmd); } + + ED_area_tag_redraw(rmd->sa); + WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); } MEM_freeN(op->customdata); op->customdata = NULL; -- cgit v1.2.3 From 46d23ae7676d6c17c787cecd33a54f601a8f3cc3 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 23 Dec 2011 13:36:07 +0000 Subject: Moving back sr locales to sr_RS (else, with recent changes (42830), loading sr was no more working). My mistake, using only sr wasn't useful here (unlike spanish, we only have one version of serbian, in cyrilic and latin forms...)! --- source/blender/blenfont/intern/blf_lang.c | 4 ++-- source/blender/makesrna/intern/rna_userdef.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenfont/intern/blf_lang.c b/source/blender/blenfont/intern/blf_lang.c index 71e4fba94f6..6fd868cd074 100644 --- a/source/blender/blenfont/intern/blf_lang.c +++ b/source/blender/blenfont/intern/blf_lang.c @@ -85,7 +85,7 @@ static const char *locales[] = { "Chinese (Traditional)_China.1252", "zh_TW", "russian", "ru_RU", "croatian", "hr_HR", - "serbian", "sr", + "serbian", "sr_RS", "ukrainian", "uk_UA", "polish", "pl_PL", "romanian", "ro_RO", @@ -96,7 +96,7 @@ static const char *locales[] = { "nepali", "ne_NP", "persian", "fa_PE", "indonesian", "id_ID", - "serbian (latin)", "sr@latin", + "serbian (latin)", "sr_RS@latin", }; void BLF_lang_init(void) diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index c0a644f5758..164f8e4f0d0 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -2639,8 +2639,8 @@ static void rna_def_userdef_system(BlenderRNA *brna) {26, "PERSIAN", 0, "Persian (ﯽﺳﺭﺎﻓ)", "fa_PE"}, {19, "POLISH", 0, "Polish (Polski)", "pl_PL"}, {20, "ROMANIAN", 0, "Romanian (Român)", "ro_RO"}, - {17, "SERBIAN", 0, "Serbian (Српски)", "sr"}, - {28, "SERBIAN_LATIN", 0, "Serbian latin (Srpski latinica)", "sr@latin"}, + {17, "SERBIAN", 0, "Serbian (Српски)", "sr_RS"}, + {28, "SERBIAN_LATIN", 0, "Serbian latin (Srpski latinica)", "sr_RS@latin"}, { 7, "SWEDISH", 0, "Swedish (Svenska)", "sv_SE"}, {18, "UKRAINIAN", 0, "Ukrainian (Український)", "uk_UA"}, { 0, NULL, 0, NULL, NULL}}; -- cgit v1.2.3 From 217a7d1829a36343792ef4114e5e032b22bac8af Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 23 Dec 2011 13:53:21 +0000 Subject: UI: small further tweak to last region expand/collapse fix, when moving the operator redo panel up now it no longer hides the region, just stops it at max size. --- source/blender/editors/screen/screen_ops.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source/blender') diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 7e17592f67c..ffdfea7fde5 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -1742,11 +1742,13 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event) /* note, 'UI_UNIT_Y/4' means you need to drag the header almost * all the way down for it to become hidden, this is done * otherwise its too easy to do this by accident */ - if(rmd->ar->sizey < UI_UNIT_Y/4 || (maxsize > 0 && (rmd->ar->sizey > maxsize)) ) { + if(rmd->ar->sizey < UI_UNIT_Y/4) { rmd->ar->sizey= rmd->origval; if(!(rmd->ar->flag & RGN_FLAG_HIDDEN)) region_scale_toggle_hidden(C, rmd); } + else if(maxsize > 0 && (rmd->ar->sizey > maxsize)) + rmd->ar->sizey= maxsize; else if(rmd->ar->flag & RGN_FLAG_HIDDEN) region_scale_toggle_hidden(C, rmd); } -- cgit v1.2.3 From 5df049f390047d6cf3badca0277b2724979db515 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 23 Dec 2011 20:26:37 +0000 Subject: fix [#29683] OpenEXR Output Appears to be broken own error with moving image settings. --- source/blender/blenfont/intern/blf_translation.c | 1 + source/blender/blenkernel/intern/image.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender') diff --git a/source/blender/blenfont/intern/blf_translation.c b/source/blender/blenfont/intern/blf_translation.c index 1d82abcf32d..0ddb6549717 100644 --- a/source/blender/blenfont/intern/blf_translation.c +++ b/source/blender/blenfont/intern/blf_translation.c @@ -131,6 +131,7 @@ const char *BLF_pgettext(const char *context, const char *message) return translation; #else + (void)context; return message; #endif } diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 25ff7b5fa04..354a5265f90 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1544,7 +1544,7 @@ int BKE_write_ibuf(ImBuf *ibuf, const char *name, ImageFormatData *imf) ibuf->ftype= OPENEXR; if(imf->depth == R_IMF_CHAN_DEPTH_16) ibuf->ftype |= OPENEXR_HALF; - ibuf->ftype |= (quality & OPENEXR_COMPRESS); + ibuf->ftype |= (imf->exr_codec & OPENEXR_COMPRESS); if(!(imf->flag & R_IMF_FLAG_ZBUF)) ibuf->zbuf_float = NULL; /* signal for exr saving */ -- cgit v1.2.3 From ddcf56366d47c08ebfb6bb9e6d1cbd54b1db706c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 23 Dec 2011 20:30:23 +0000 Subject: change customdata mask from an 'unsigned int' to an 'u_int64_t', since BMesh branch has run out of bits --- source/blender/blenkernel/BKE_customdata.h | 4 +++- source/blender/blenkernel/depsgraph_private.h | 2 +- source/blender/blenkernel/intern/customdata.c | 14 +++++++------- source/blender/blenkernel/intern/mesh_validate.c | 2 +- source/blender/blenkernel/intern/object.c | 2 +- source/blender/editors/include/ED_view3d.h | 4 ++-- source/blender/makesdna/DNA_defs.h | 3 +++ source/blender/makesdna/DNA_genfile.h | 7 ++++--- source/blender/makesdna/DNA_object_types.h | 4 ++-- source/blender/makesdna/DNA_scene_types.h | 5 +++-- source/blender/makesdna/intern/dna_genfile.c | 10 +++++++++- source/blender/makesdna/intern/makesdna.c | 1 + source/blender/modifiers/intern/MOD_multires.c | 4 ++-- source/blender/modifiers/intern/MOD_shrinkwrap.c | 4 ++-- source/blender/windowmanager/intern/wm_event_system.c | 2 +- 15 files changed, 42 insertions(+), 26 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h index 1d344c6e810..fea706c45a5 100644 --- a/source/blender/blenkernel/BKE_customdata.h +++ b/source/blender/blenkernel/BKE_customdata.h @@ -41,7 +41,7 @@ extern "C" { struct ID; struct CustomData; struct CustomDataLayer; -typedef unsigned int CustomDataMask; +typedef u_int64_t CustomDataMask; extern const CustomDataMask CD_MASK_BAREMESH; extern const CustomDataMask CD_MASK_MESH; @@ -65,6 +65,8 @@ extern const CustomDataMask CD_MASK_FACECORNERS; #define CD_DUPLICATE 4 /* do a full copy of all layers, only allowed if source has same number of elements */ +#define CD_TYPE_AS_MASK(_type) (CustomDataMask)(1 << (CustomDataMask)(_type)) + /* initialises a CustomData object with the same layer setup as source. * mask is a bitfield where (mask & (1 << (layer type))) indicates * if a layer should be copied or not. alloctype must be one of the above. */ diff --git a/source/blender/blenkernel/depsgraph_private.h b/source/blender/blenkernel/depsgraph_private.h index 2dd14281253..1c4d423131f 100644 --- a/source/blender/blenkernel/depsgraph_private.h +++ b/source/blender/blenkernel/depsgraph_private.h @@ -69,7 +69,7 @@ typedef struct DagNode int ancestor_count; unsigned int lay; // accumulated layers of its relations + itself unsigned int scelay; // layers due to being in scene - unsigned int customdata_mask; // customdata mask + u_int64_t customdata_mask; // customdata mask int lasttime; // if lasttime != DagForest->time, this node was not evaluated yet for flushing int BFS_dist; // BFS distance int DFS_dist; // DFS distance diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 5305372402b..289faaa0095 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -943,7 +943,7 @@ void CustomData_merge(const struct CustomData *source, struct CustomData *dest, number++; if(lastflag & CD_FLAG_NOCOPY) continue; - else if(!((int)mask & (int)(1 << (int)type))) continue; + else if(!(mask & CD_TYPE_AS_MASK(type))) continue; else if(number < CustomData_number_of_layers(dest, type)) continue; if((alloctype == CD_ASSIGN) && (lastflag & CD_FLAG_NOFREE)) @@ -1500,7 +1500,7 @@ void CustomData_set_only_copy(const struct CustomData *data, int i; for(i = 0; i < data->totlayer; ++i) - if(!((int)mask & (int)(1 << (int)data->layers[i].type))) + if(!(mask & CD_TYPE_AS_MASK(data->layers[i].type))) data->layers[i].flag |= CD_FLAG_NOCOPY; } @@ -2441,7 +2441,7 @@ void CustomData_external_reload(CustomData *data, ID *UNUSED(id), CustomDataMask layer = &data->layers[i]; typeInfo = layerType_getInfo(layer->type); - if(!(mask & (1<type))); + if(!(mask & CD_TYPE_AS_MASK(layer->type))); else if((layer->flag & CD_FLAG_EXTERNAL) && (layer->flag & CD_FLAG_IN_MEMORY)) { if(typeInfo->free) typeInfo->free(layer->data, totelem, typeInfo->size); @@ -2467,7 +2467,7 @@ void CustomData_external_read(CustomData *data, ID *id, CustomDataMask mask, int layer = &data->layers[i]; typeInfo = layerType_getInfo(layer->type); - if(!(mask & (1<type))); + if(!(mask & CD_TYPE_AS_MASK(layer->type))); else if(layer->flag & CD_FLAG_IN_MEMORY); else if((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->read) update= 1; @@ -2488,7 +2488,7 @@ void CustomData_external_read(CustomData *data, ID *id, CustomDataMask mask, int layer = &data->layers[i]; typeInfo = layerType_getInfo(layer->type); - if(!(mask & (1<type))); + if(!(mask & CD_TYPE_AS_MASK(layer->type))); else if(layer->flag & CD_FLAG_IN_MEMORY); else if((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->read) { blay= cdf_layer_find(cdf, layer->type, layer->name); @@ -2527,7 +2527,7 @@ void CustomData_external_write(CustomData *data, ID *id, CustomDataMask mask, in layer = &data->layers[i]; typeInfo = layerType_getInfo(layer->type); - if(!(mask & (1<type))); + if(!(mask & CD_TYPE_AS_MASK(layer->type))); else if((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->write) update= 1; } @@ -2641,7 +2641,7 @@ void CustomData_external_remove(CustomData *data, ID *id, int type, int totelem) if(layer->flag & CD_FLAG_EXTERNAL) { if(!(layer->flag & CD_FLAG_IN_MEMORY)) - CustomData_external_read(data, id, (1<type), totelem); + CustomData_external_read(data, id, CD_TYPE_AS_MASK(layer->type), totelem); layer->flag &= ~CD_FLAG_EXTERNAL; diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c index 5a53d953f1b..a1bf9cb9481 100644 --- a/source/blender/blenkernel/intern/mesh_validate.c +++ b/source/blender/blenkernel/intern/mesh_validate.c @@ -395,7 +395,7 @@ static int mesh_validate_customdata(CustomData *data, short do_verbose, const sh while(itotlayer) { CustomDataLayer *layer= &data->layers[i]; - int mask= 1 << layer->type; + CustomDataMask mask= CD_TYPE_AS_MASK(layer->type); int ok= 1; if((mask&CD_MASK_MESH)==0) { diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 28c1aacdec5..76f11b7e87f 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2563,7 +2563,7 @@ void object_handle_update(Scene *scene, Object *ob) #else /* ensure CD_MASK_BAREMESH for now */ EditMesh *em = (ob == scene->obedit)? BKE_mesh_get_editmesh(ob->data): NULL; - unsigned int data_mask= scene->customdata_mask | ob->customdata_mask | CD_MASK_BAREMESH; + u_int64_t data_mask= scene->customdata_mask | ob->customdata_mask | CD_MASK_BAREMESH; if(em) { makeDerivedMesh(scene, ob, em, data_mask); /* was CD_MASK_BAREMESH */ BKE_mesh_end_editmesh(ob->data, em); diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 476cf2ac109..fb41b2f7fb6 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -286,8 +286,8 @@ Base *ED_view3d_give_base_under_cursor(struct bContext *C, const int mval[2]); void ED_view3d_quadview_update(struct ScrArea *sa, struct ARegion *ar, short do_clip); int ED_view3d_lock(struct RegionView3D *rv3d); -unsigned int ED_view3d_datamask(struct Scene *scene, struct View3D *v3d); -unsigned int ED_viewedit_datamask(struct bScreen *screen); +u_int64_t ED_view3d_datamask(struct Scene *scene, struct View3D *v3d); +u_int64_t ED_viewedit_datamask(struct bScreen *screen); /* camera lock functions */ int ED_view3d_camera_lock_check(struct View3D *v3d, struct RegionView3D *rv3d); diff --git a/source/blender/makesdna/DNA_defs.h b/source/blender/makesdna/DNA_defs.h index 88401d3d2d4..25d95419605 100644 --- a/source/blender/makesdna/DNA_defs.h +++ b/source/blender/makesdna/DNA_defs.h @@ -42,4 +42,7 @@ # endif #endif +/* hrmf, we need a better include then this */ +#include "../blenloader/BLO_sys_types.h" /* needed for int64_t only! */ + #endif /* DNA_DEFS_H */ diff --git a/source/blender/makesdna/DNA_genfile.h b/source/blender/makesdna/DNA_genfile.h index 83292d3d8f8..be13c8bba4f 100644 --- a/source/blender/makesdna/DNA_genfile.h +++ b/source/blender/makesdna/DNA_genfile.h @@ -48,12 +48,13 @@ typedef enum eSDNA_Type { SDNA_TYPE_ULONG = 6, SDNA_TYPE_FLOAT = 7, SDNA_TYPE_DOUBLE = 8, - SDNA_TYPE_INT64 = 9 - /* ,SDNA_TYPE_VOID = 10 */ /* nothing uses yet */ + SDNA_TYPE_INT64 = 9, + SDNA_TYPE_UINT64 = 10 + /* ,SDNA_TYPE_VOID = 11 */ /* nothing uses yet */ } eSDNA_Type; /* define so switch statements don't complain */ -#define SDNA_TYPE_VOID 10 +#define SDNA_TYPE_VOID 11 struct SDNA *DNA_sdna_from_data(void *data, int datalen, int do_endian_swap); void DNA_sdna_free(struct SDNA *sdna); diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index 8707ae038c3..fcce21c936d 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -250,8 +250,8 @@ typedef struct Object { struct FluidsimSettings *fluidsimSettings; /* if fluidsim enabled, store additional settings */ struct DerivedMesh *derivedDeform, *derivedFinal; - unsigned int lastDataMask; /* the custom data layer mask that was last used to calculate derivedDeform and derivedFinal */ - unsigned int customdata_mask; /* (extra) custom data layer mask to use for creating derivedmesh, set by depsgraph */ + u_int64_t lastDataMask; /* the custom data layer mask that was last used to calculate derivedDeform and derivedFinal */ + u_int64_t customdata_mask; /* (extra) custom data layer mask to use for creating derivedmesh, set by depsgraph */ unsigned int state; /* bit masks of game controllers that are active */ unsigned int init_state; /* bit masks of initial state as recorded by the users */ diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 345e78d70c9..1288e8a0cca 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -915,8 +915,6 @@ typedef struct Scene { unsigned int lay; /* bitflags for layer visibility */ int layact; /* active layer */ unsigned int lay_updated; /* runtime flag, has layer ever been updated since load? */ - unsigned int customdata_mask; /* XXX. runtime flag for drawing, actually belongs in the window, only used by object_handle_update() */ - unsigned int customdata_mask_modal; /* XXX. same as above but for temp operator use (gl renders) */ short flag; /* various settings */ @@ -971,6 +969,9 @@ typedef struct Scene { /* Movie Tracking */ struct MovieClip *clip; /* active movie clip */ + + u_int64_t customdata_mask; /* XXX. runtime flag for drawing, actually belongs in the window, only used by object_handle_update() */ + u_int64_t customdata_mask_modal; /* XXX. same as above but for temp operator use (gl renders) */ } Scene; diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c index db0c2bc0e2d..d493083db8b 100644 --- a/source/blender/makesdna/intern/dna_genfile.c +++ b/source/blender/makesdna/intern/dna_genfile.c @@ -667,6 +667,7 @@ static eSDNA_Type sdna_type_nr(const char *dna_type) else if( strcmp(dna_type, "float")==0) return SDNA_TYPE_FLOAT; else if( strcmp(dna_type, "double")==0) return SDNA_TYPE_DOUBLE; else if( strcmp(dna_type, "int64_t")==0) return SDNA_TYPE_INT64; + else if( strcmp(dna_type, "u_int64_t")==0) return SDNA_TYPE_UINT64; else return -1; /* invalid! */ } @@ -711,6 +712,8 @@ static void cast_elem(const char *ctype, const char *otype, const char *name, ch val= *( (double *)olddata); break; case SDNA_TYPE_INT64: val= *( (int64_t *)olddata); break; + case SDNA_TYPE_UINT64: + val= *( (u_int64_t *)olddata); break; } switch(ctypenr) { @@ -736,6 +739,8 @@ static void cast_elem(const char *ctype, const char *otype, const char *name, ch *( (double *)curdata)= val; break; case SDNA_TYPE_INT64: *( (int64_t *)curdata)= val; break; + case SDNA_TYPE_UINT64: + *( (u_int64_t *)curdata)= val; break; } olddata+= oldlen; @@ -1093,7 +1098,9 @@ void DNA_struct_switch_endian(SDNA *oldsdna, int oldSDNAnr, char *data) cpo+= 4; } } - else if ( (spc[0]==SDNA_TYPE_INT64)) { + else if ( (spc[0]==SDNA_TYPE_INT64) || + (spc[0]==SDNA_TYPE_UINT64)) + { mul= DNA_elem_array_size(name, strlen(name)); cpo= cur; while(mul--) { @@ -1170,6 +1177,7 @@ int DNA_elem_type_size(const eSDNA_Type elem_nr) return 4; case SDNA_TYPE_DOUBLE: case SDNA_TYPE_INT64: + case SDNA_TYPE_UINT64: return 8; } diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c index 0c417e9f884..31f52866367 100644 --- a/source/blender/makesdna/intern/makesdna.c +++ b/source/blender/makesdna/intern/makesdna.c @@ -939,6 +939,7 @@ static int make_structDNA(char *baseDirectory, FILE *file) add_type("float", 4); /* SDNA_TYPE_FLOAT */ add_type("double", 8); /* SDNA_TYPE_DOUBLE */ add_type("int64_t", 8); /* SDNA_TYPE_INT64 */ + add_type("u_int64_t", 8); /* SDNA_TYPE_UINT64 */ add_type("void", 0); /* SDNA_TYPE_VOID */ // the defines above shouldn't be output in the padding file... diff --git a/source/blender/modifiers/intern/MOD_multires.c b/source/blender/modifiers/intern/MOD_multires.c index 8bcaf8802b5..55f29137eb9 100644 --- a/source/blender/modifiers/intern/MOD_multires.c +++ b/source/blender/modifiers/intern/MOD_multires.c @@ -35,14 +35,14 @@ #include +#include "DNA_mesh_types.h" + #include "BKE_cdderivedmesh.h" #include "BKE_multires.h" #include "BKE_modifier.h" #include "BKE_paint.h" #include "BKE_particle.h" -#include "DNA_mesh_types.h" - #include "MOD_util.h" static void initData(ModifierData *md) diff --git a/source/blender/modifiers/intern/MOD_shrinkwrap.c b/source/blender/modifiers/intern/MOD_shrinkwrap.c index 6c047a81fa5..e8f099785f9 100644 --- a/source/blender/modifiers/intern/MOD_shrinkwrap.c +++ b/source/blender/modifiers/intern/MOD_shrinkwrap.c @@ -35,6 +35,8 @@ #include +#include "DNA_object_types.h" + #include "BLI_string.h" #include "BLI_utildefines.h" @@ -42,8 +44,6 @@ #include "BKE_modifier.h" #include "BKE_shrinkwrap.h" -#include "DNA_object_types.h" - #include "depsgraph_private.h" #include "MOD_util.h" diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 1593f14a76c..064c98b7f8a 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -186,7 +186,7 @@ void wm_event_do_notifiers(bContext *C) wmWindowManager *wm= CTX_wm_manager(C); wmNotifier *note, *next; wmWindow *win; - unsigned int win_combine_v3d_datamask= 0; + u_int64_t win_combine_v3d_datamask= 0; if(wm==NULL) return; -- cgit v1.2.3 From 9bb030322138dbfee7385e5066146a74cc057268 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Fri, 23 Dec 2011 22:07:34 +0000 Subject: Bugfix for [#29684] Output video presets messed up * This was caused ny the ImageType refactor. * Problem persisted with Quicktime too, could not test that, but should fix presets there too. --- source/blender/blenkernel/BKE_writeffmpeg.h | 2 +- source/blender/blenkernel/intern/writeffmpeg.c | 10 +++++----- source/blender/makesrna/intern/rna_scene.c | 4 ++-- source/blender/quicktime/apple/qtkit_export.m | 4 ++-- source/blender/quicktime/apple/quicktime_export.c | 4 ++-- source/blender/quicktime/quicktime_export.h | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_writeffmpeg.h b/source/blender/blenkernel/BKE_writeffmpeg.h index 3263a1659f3..257ed0ba15f 100644 --- a/source/blender/blenkernel/BKE_writeffmpeg.h +++ b/source/blender/blenkernel/BKE_writeffmpeg.h @@ -72,7 +72,7 @@ extern int append_ffmpeg(struct RenderData *rd, int frame, int *pixels, int rect void filepath_ffmpeg(char* string, struct RenderData* rd); extern void ffmpeg_set_preset(struct RenderData *rd, int preset); -extern void ffmpeg_verify_image_type(struct RenderData *rd); +extern void ffmpeg_verify_image_type(struct RenderData *rd, struct ImageFormatData *imf); extern struct IDProperty *ffmpeg_property_add(struct RenderData *Rd, const char *type, int opt_index, int parent_index); extern int ffmpeg_property_add_string(struct RenderData *rd, const char *type, const char *str); diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index aa7d71b1577..bf547584b9e 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -1333,11 +1333,11 @@ void ffmpeg_set_preset(RenderData *rd, int preset) } } -void ffmpeg_verify_image_type(RenderData *rd) +void ffmpeg_verify_image_type(RenderData *rd, ImageFormatData *imf) { int audio= 0; - if(rd->imtype == R_IMF_IMTYPE_FFMPEG) { + if(imf->imtype == R_IMF_IMTYPE_FFMPEG) { if(rd->ffcodecdata.type <= 0 || rd->ffcodecdata.codec <= 0 || rd->ffcodecdata.audio_codec <= 0 || @@ -1353,19 +1353,19 @@ void ffmpeg_verify_image_type(RenderData *rd) audio= 1; } - else if(rd->imtype == R_IMF_IMTYPE_H264) { + else if(imf->imtype == R_IMF_IMTYPE_H264) { if(rd->ffcodecdata.codec != CODEC_ID_H264) { ffmpeg_set_preset(rd, FFMPEG_PRESET_H264); audio= 1; } } - else if(rd->imtype == R_IMF_IMTYPE_XVID) { + else if(imf->imtype == R_IMF_IMTYPE_XVID) { if(rd->ffcodecdata.codec != CODEC_ID_MPEG4) { ffmpeg_set_preset(rd, FFMPEG_PRESET_XVID); audio= 1; } } - else if(rd->imtype == R_IMF_IMTYPE_THEORA) { + else if(imf->imtype == R_IMF_IMTYPE_THEORA) { if(rd->ffcodecdata.codec != CODEC_ID_THEORA) { ffmpeg_set_preset(rd, FFMPEG_PRESET_THEORA); audio= 1; diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 2a5e815591a..54267725fe2 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -659,10 +659,10 @@ static void rna_ImageFormatSettings_file_format_set(PointerRNA *ptr, int value) Scene *scene= ptr->id.data; RenderData *rd= &scene->r; #ifdef WITH_FFMPEG - ffmpeg_verify_image_type(rd); + ffmpeg_verify_image_type(rd, imf); #endif #ifdef WITH_QUICKTIME - quicktime_verify_image_type(rd); + quicktime_verify_image_type(rd, imf); #endif (void)rd; } diff --git a/source/blender/quicktime/apple/qtkit_export.m b/source/blender/quicktime/apple/qtkit_export.m index 75c7d890ddd..8fd04026233 100644 --- a/source/blender/quicktime/apple/qtkit_export.m +++ b/source/blender/quicktime/apple/qtkit_export.m @@ -777,9 +777,9 @@ void end_qt(void) void free_qtcomponentdata(void) { } -void quicktime_verify_image_type(RenderData *rd) +void quicktime_verify_image_type(RenderData *rd, ImageFormatData *imf) { - if (rd->im_format.imtype == R_IMF_IMTYPE_QUICKTIME) { + if (imf->imtype == R_IMF_IMTYPE_QUICKTIME) { if ((rd->qtcodecsettings.codecType<= 0) || (rd->qtcodecsettings.codecSpatialQuality <0) || (rd->qtcodecsettings.codecSpatialQuality > 100)) { diff --git a/source/blender/quicktime/apple/quicktime_export.c b/source/blender/quicktime/apple/quicktime_export.c index 937e1b6be46..5dfce9d3e80 100644 --- a/source/blender/quicktime/apple/quicktime_export.c +++ b/source/blender/quicktime/apple/quicktime_export.c @@ -687,9 +687,9 @@ static void check_renderbutton_framerate(RenderData *rd, ReportList *reports) } } -void quicktime_verify_image_type(RenderData *rd) +void quicktime_verify_image_type(RenderData *rd, ImageFormatData *imf) { - if (rd->im_format.imtype == R_IMF_IMTYPE_QUICKTIME) { + if (imf->imtype == R_IMF_IMTYPE_QUICKTIME) { if ((rd->qtcodecsettings.codecType== 0) || (rd->qtcodecsettings.codecSpatialQuality <0) || (rd->qtcodecsettings.codecSpatialQuality > 100)) { diff --git a/source/blender/quicktime/quicktime_export.h b/source/blender/quicktime/quicktime_export.h index 517e0c8c0f6..f64521bda35 100644 --- a/source/blender/quicktime/quicktime_export.h +++ b/source/blender/quicktime/quicktime_export.h @@ -61,7 +61,7 @@ void end_qt(void); void filepath_qt(char *string, struct RenderData *rd); /*RNA helper functions */ -void quicktime_verify_image_type(struct RenderData *rd); //used by RNA for defaults values init, if needed +void quicktime_verify_image_type(struct RenderData *rd, struct ImageFormatData *imf); //used by RNA for defaults values init, if needed /*Video codec type*/ int quicktime_get_num_videocodecs(void); QuicktimeCodecTypeDesc* quicktime_get_videocodecType_desc(int indexValue); -- cgit v1.2.3 From b21a0f4fa1c4c5f2ad20e8ddd48ae3657ad941ef Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 24 Dec 2011 02:37:42 +0000 Subject: formatting edits 120 line length --- source/blender/blenkernel/intern/writeavi.c | 3 -- source/blender/editors/interface/view2d.c | 3 +- source/blender/editors/sculpt_paint/paint_stroke.c | 34 ++++++++++++---------- .../blender/python/generic/bpy_internal_import.c | 7 +++-- 4 files changed, 25 insertions(+), 22 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c index 8cd30912840..da64c464dce 100644 --- a/source/blender/blenkernel/intern/writeavi.c +++ b/source/blender/blenkernel/intern/writeavi.c @@ -159,9 +159,6 @@ static int start_avi(Scene *scene, RenderData *rd, int rectx, int recty, ReportL avi = MEM_mallocN (sizeof(AviMovie), "avimovie"); - /* RPW 11-21-2002 - if (rd->imtype != AVI_FORMAT_MJPEG) format = AVI_FORMAT_AVI_RGB; - */ if (rd->im_format.imtype != R_IMF_IMTYPE_AVIJPEG ) format = AVI_FORMAT_AVI_RGB; else format = AVI_FORMAT_MJPEG; diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index c2c482b0a2c..57d46de9cb7 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -177,7 +177,8 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy) /* see eView2D_CommonViewTypes in UI_view2d.h for available view presets */ switch (type) { - /* 'standard view' - optimum setup for 'standard' view behaviour, that should be used new views as basis for their + /* 'standard view' - optimum setup for 'standard' view behaviour, + * that should be used new views as basis for their * own unique View2D settings, which should be used instead of this in most cases... */ case V2D_COMMONVIEW_STANDARD: diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index 0e65383861b..7cff37e8814 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -123,19 +123,19 @@ static int same_snap(Snapshot* snap, Brush* brush, ViewContext* vc) { MTex* mtex = &brush->mtex; - return - (mtex->tex && - mtex->ofs[0] == snap->ofs[0] && - mtex->ofs[1] == snap->ofs[1] && - mtex->ofs[2] == snap->ofs[2] && - mtex->size[0] == snap->size[0] && - mtex->size[1] == snap->size[1] && - mtex->size[2] == snap->size[2] && - mtex->rot == snap->rot) && - ((mtex->brush_map_mode == MTEX_MAP_MODE_FIXED && brush_size(brush) <= snap->brush_size) || (brush_size(brush) == snap->brush_size)) && // make brush smaller shouldn't cause a resample - mtex->brush_map_mode == snap->brush_map_mode && - vc->ar->winx == snap->winx && - vc->ar->winy == snap->winy; + return ( (mtex->tex) && + equals_v3v3(mtex->ofs, snap->ofs) && + equals_v3v3(mtex->size, snap->size) && + mtex->rot == snap->rot + ) && + + /* make brush smaller shouldn't cause a resample */ + ( (mtex->brush_map_mode == MTEX_MAP_MODE_FIXED && (brush_size(brush) <= snap->brush_size)) || + (brush_size(brush) == snap->brush_size)) && + + (mtex->brush_map_mode == snap->brush_map_mode) && + (vc->ar->winx == snap->winx) && + (vc->ar->winy == snap->winy); } static void make_snap(Snapshot* snap, Brush* brush, ViewContext* vc) @@ -869,7 +869,10 @@ int paint_stroke_modal(bContext *C, wmOperator *op, wmEvent *event) MEM_freeN(stroke); return OPERATOR_FINISHED; } - else if(first || ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE) || (event->type == TIMER && (event->customdata == stroke->timer))) { + else if( (first) || + (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) || + (event->type == TIMER && (event->customdata == stroke->timer)) ) + { if(stroke->stroke_started) { if(paint_smooth_stroke(stroke, mouse, event)) { if(paint_space_stroke_enabled(stroke->brush)) { @@ -887,7 +890,8 @@ int paint_stroke_modal(bContext *C, wmOperator *op, wmEvent *event) } } - /* we want the stroke to have the first daub at the start location instead of waiting till we have moved the space distance */ + /* we want the stroke to have the first daub at the start location + * instead of waiting till we have moved the space distance */ if(first && stroke->stroke_started && paint_space_stroke_enabled(stroke->brush) && diff --git a/source/blender/python/generic/bpy_internal_import.c b/source/blender/python/generic/bpy_internal_import.c index 88e2da16eb5..d9183261329 100644 --- a/source/blender/python/generic/bpy_internal_import.c +++ b/source/blender/python/generic/bpy_internal_import.c @@ -141,9 +141,10 @@ PyObject *bpy_text_import_name(const char *name, int *found) printf("ERROR: bpy_import_main_set() was not called before running python. this is a bug.\n"); return NULL; } - - if (namelen >= (MAX_ID_NAME-2) - 3) return NULL; /* we know this cant be importable, the name is too long for blender! */ - + + /* we know this cant be importable, the name is too long for blender! */ + if (namelen >= (MAX_ID_NAME-2) - 3) return NULL; + memcpy(txtname, name, namelen); memcpy(&txtname[namelen], ".py", 4); -- cgit v1.2.3 From 33bd38ebc74f42694f063fd7937d7b457a141727 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 24 Dec 2011 02:47:13 +0000 Subject: minor edits to cycles c/python module - rename 'bcycles' --> '_cycles', since this is the python convention when a py module uses a C module internally. - use macros for returning None - make with_osl an attribute rather then a function. - changes methods METH_VARARGS --> METH_O when single args are used. --- source/blender/python/intern/bpy_interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender') diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 14d74bcf5d0..90d5cccc85a 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -189,7 +189,7 @@ static struct _inittab bpy_internal_modules[]= { {(char *)"aud", AUD_initPython}, #endif #ifdef WITH_CYCLES - {(char *)"bcycles", CYCLES_initPython}, + {(char *)"_cycles", CYCLES_initPython}, #endif {(char *)"gpu", GPU_initPython}, {NULL, NULL} -- cgit v1.2.3 From eb3beca8d4a1c5073992d3f8a30d4e87e4f29430 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 24 Dec 2011 03:03:42 +0000 Subject: replace u_int64_t with cc99's uint64_t as suggested by Nicholas Bishop. --- source/blender/blenkernel/BKE_customdata.h | 2 +- source/blender/blenkernel/depsgraph_private.h | 2 +- source/blender/blenkernel/intern/object.c | 2 +- source/blender/blenloader/BLO_sys_types.h | 8 ++++++++ source/blender/editors/include/ED_view3d.h | 4 ++-- source/blender/makesdna/DNA_object_types.h | 4 ++-- source/blender/makesdna/DNA_scene_types.h | 4 ++-- source/blender/makesdna/intern/dna_genfile.c | 6 +++--- source/blender/makesdna/intern/makesdna.c | 2 +- source/blender/modifiers/intern/MOD_decimate.c | 4 ++-- source/blender/modifiers/intern/MOD_edgesplit.c | 2 +- source/blender/modifiers/intern/MOD_smooth.c | 5 ++--- source/blender/modifiers/intern/MOD_solidify.c | 4 ++-- source/blender/windowmanager/intern/wm_event_system.c | 2 +- 14 files changed, 29 insertions(+), 22 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h index fea706c45a5..c648cbb8493 100644 --- a/source/blender/blenkernel/BKE_customdata.h +++ b/source/blender/blenkernel/BKE_customdata.h @@ -41,7 +41,7 @@ extern "C" { struct ID; struct CustomData; struct CustomDataLayer; -typedef u_int64_t CustomDataMask; +typedef uint64_t CustomDataMask; extern const CustomDataMask CD_MASK_BAREMESH; extern const CustomDataMask CD_MASK_MESH; diff --git a/source/blender/blenkernel/depsgraph_private.h b/source/blender/blenkernel/depsgraph_private.h index 1c4d423131f..0338d10a66d 100644 --- a/source/blender/blenkernel/depsgraph_private.h +++ b/source/blender/blenkernel/depsgraph_private.h @@ -69,7 +69,7 @@ typedef struct DagNode int ancestor_count; unsigned int lay; // accumulated layers of its relations + itself unsigned int scelay; // layers due to being in scene - u_int64_t customdata_mask; // customdata mask + uint64_t customdata_mask; // customdata mask int lasttime; // if lasttime != DagForest->time, this node was not evaluated yet for flushing int BFS_dist; // BFS distance int DFS_dist; // DFS distance diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 76f11b7e87f..8251c4796ea 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2563,7 +2563,7 @@ void object_handle_update(Scene *scene, Object *ob) #else /* ensure CD_MASK_BAREMESH for now */ EditMesh *em = (ob == scene->obedit)? BKE_mesh_get_editmesh(ob->data): NULL; - u_int64_t data_mask= scene->customdata_mask | ob->customdata_mask | CD_MASK_BAREMESH; + uint64_t data_mask= scene->customdata_mask | ob->customdata_mask | CD_MASK_BAREMESH; if(em) { makeDerivedMesh(scene, ob, em, data_mask); /* was CD_MASK_BAREMESH */ BKE_mesh_end_editmesh(ob->data, em); diff --git a/source/blender/blenloader/BLO_sys_types.h b/source/blender/blenloader/BLO_sys_types.h index e7f7a7e23bc..800ae834b59 100644 --- a/source/blender/blenloader/BLO_sys_types.h +++ b/source/blender/blenloader/BLO_sys_types.h @@ -86,6 +86,14 @@ typedef unsigned long uintptr_t; /* Linux-i386, Linux-Alpha, Linux-ppc */ #include +/* XXX */ +#ifndef uint64_t +typedef uint8_t u_int8_t; +typedef uint16_t u_int16_t; +typedef uint32_t u_int32_t; +typedef uint64_t u_int64_t; +#endif + #elif defined (__APPLE__) #include diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index fb41b2f7fb6..cf109768a43 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -286,8 +286,8 @@ Base *ED_view3d_give_base_under_cursor(struct bContext *C, const int mval[2]); void ED_view3d_quadview_update(struct ScrArea *sa, struct ARegion *ar, short do_clip); int ED_view3d_lock(struct RegionView3D *rv3d); -u_int64_t ED_view3d_datamask(struct Scene *scene, struct View3D *v3d); -u_int64_t ED_viewedit_datamask(struct bScreen *screen); +uint64_t ED_view3d_datamask(struct Scene *scene, struct View3D *v3d); +uint64_t ED_viewedit_datamask(struct bScreen *screen); /* camera lock functions */ int ED_view3d_camera_lock_check(struct View3D *v3d, struct RegionView3D *rv3d); diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index fcce21c936d..46b971e8e0d 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -250,8 +250,8 @@ typedef struct Object { struct FluidsimSettings *fluidsimSettings; /* if fluidsim enabled, store additional settings */ struct DerivedMesh *derivedDeform, *derivedFinal; - u_int64_t lastDataMask; /* the custom data layer mask that was last used to calculate derivedDeform and derivedFinal */ - u_int64_t customdata_mask; /* (extra) custom data layer mask to use for creating derivedmesh, set by depsgraph */ + uint64_t lastDataMask; /* the custom data layer mask that was last used to calculate derivedDeform and derivedFinal */ + uint64_t customdata_mask; /* (extra) custom data layer mask to use for creating derivedmesh, set by depsgraph */ unsigned int state; /* bit masks of game controllers that are active */ unsigned int init_state; /* bit masks of initial state as recorded by the users */ diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 1288e8a0cca..64b5bda3fc8 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -970,8 +970,8 @@ typedef struct Scene { /* Movie Tracking */ struct MovieClip *clip; /* active movie clip */ - u_int64_t customdata_mask; /* XXX. runtime flag for drawing, actually belongs in the window, only used by object_handle_update() */ - u_int64_t customdata_mask_modal; /* XXX. same as above but for temp operator use (gl renders) */ + uint64_t customdata_mask; /* XXX. runtime flag for drawing, actually belongs in the window, only used by object_handle_update() */ + uint64_t customdata_mask_modal; /* XXX. same as above but for temp operator use (gl renders) */ } Scene; diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c index d493083db8b..5b115a404ce 100644 --- a/source/blender/makesdna/intern/dna_genfile.c +++ b/source/blender/makesdna/intern/dna_genfile.c @@ -667,7 +667,7 @@ static eSDNA_Type sdna_type_nr(const char *dna_type) else if( strcmp(dna_type, "float")==0) return SDNA_TYPE_FLOAT; else if( strcmp(dna_type, "double")==0) return SDNA_TYPE_DOUBLE; else if( strcmp(dna_type, "int64_t")==0) return SDNA_TYPE_INT64; - else if( strcmp(dna_type, "u_int64_t")==0) return SDNA_TYPE_UINT64; + else if( strcmp(dna_type, "uint64_t")==0) return SDNA_TYPE_UINT64; else return -1; /* invalid! */ } @@ -713,7 +713,7 @@ static void cast_elem(const char *ctype, const char *otype, const char *name, ch case SDNA_TYPE_INT64: val= *( (int64_t *)olddata); break; case SDNA_TYPE_UINT64: - val= *( (u_int64_t *)olddata); break; + val= *( (uint64_t *)olddata); break; } switch(ctypenr) { @@ -740,7 +740,7 @@ static void cast_elem(const char *ctype, const char *otype, const char *name, ch case SDNA_TYPE_INT64: *( (int64_t *)curdata)= val; break; case SDNA_TYPE_UINT64: - *( (u_int64_t *)curdata)= val; break; + *( (uint64_t *)curdata)= val; break; } olddata+= oldlen; diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c index 31f52866367..2fa52776453 100644 --- a/source/blender/makesdna/intern/makesdna.c +++ b/source/blender/makesdna/intern/makesdna.c @@ -939,7 +939,7 @@ static int make_structDNA(char *baseDirectory, FILE *file) add_type("float", 4); /* SDNA_TYPE_FLOAT */ add_type("double", 8); /* SDNA_TYPE_DOUBLE */ add_type("int64_t", 8); /* SDNA_TYPE_INT64 */ - add_type("u_int64_t", 8); /* SDNA_TYPE_UINT64 */ + add_type("uint64_t", 8); /* SDNA_TYPE_UINT64 */ add_type("void", 0); /* SDNA_TYPE_VOID */ // the defines above shouldn't be output in the padding file... diff --git a/source/blender/modifiers/intern/MOD_decimate.c b/source/blender/modifiers/intern/MOD_decimate.c index aba68dc9edc..d1092345930 100644 --- a/source/blender/modifiers/intern/MOD_decimate.c +++ b/source/blender/modifiers/intern/MOD_decimate.c @@ -38,13 +38,13 @@ #include "BLI_math.h" #include "BLI_utildefines.h" +#include "MEM_guardedalloc.h" -#include "BKE_cdderivedmesh.h" #include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_particle.h" +#include "BKE_cdderivedmesh.h" -#include "MEM_guardedalloc.h" #ifdef WITH_MOD_DECIMATE #include "LOD_decimation.h" diff --git a/source/blender/modifiers/intern/MOD_edgesplit.c b/source/blender/modifiers/intern/MOD_edgesplit.c index a4097d8967b..32ab2c82f90 100644 --- a/source/blender/modifiers/intern/MOD_edgesplit.c +++ b/source/blender/modifiers/intern/MOD_edgesplit.c @@ -47,12 +47,12 @@ #include "BLI_utildefines.h" #include "BLI_linklist.h" +#include "MEM_guardedalloc.h" #include "BKE_cdderivedmesh.h" #include "BKE_modifier.h" #include "BKE_particle.h" -#include "MEM_guardedalloc.h" #include "MOD_util.h" diff --git a/source/blender/modifiers/intern/MOD_smooth.c b/source/blender/modifiers/intern/MOD_smooth.c index 6edd8921c79..1bd5b2e78dd 100644 --- a/source/blender/modifiers/intern/MOD_smooth.c +++ b/source/blender/modifiers/intern/MOD_smooth.c @@ -39,13 +39,12 @@ #include "BLI_utildefines.h" #include "BLI_string.h" +#include "MEM_guardedalloc.h" + #include "BKE_cdderivedmesh.h" #include "BKE_particle.h" #include "BKE_deform.h" - -#include "MEM_guardedalloc.h" - #include "MOD_modifiertypes.h" #include "MOD_util.h" diff --git a/source/blender/modifiers/intern/MOD_solidify.c b/source/blender/modifiers/intern/MOD_solidify.c index 067d66fc82c..d11d10eb71b 100644 --- a/source/blender/modifiers/intern/MOD_solidify.c +++ b/source/blender/modifiers/intern/MOD_solidify.c @@ -40,16 +40,16 @@ #include "BLI_utildefines.h" #include "BLI_string.h" +#include "MEM_guardedalloc.h" + #include "BKE_cdderivedmesh.h" #include "BKE_mesh.h" #include "BKE_particle.h" #include "BKE_deform.h" - #include "MOD_modifiertypes.h" #include "MOD_util.h" -#include "MEM_guardedalloc.h" typedef struct EdgeFaceRef { int f1; /* init as -1 */ diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 064c98b7f8a..43a691770c9 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -186,7 +186,7 @@ void wm_event_do_notifiers(bContext *C) wmWindowManager *wm= CTX_wm_manager(C); wmNotifier *note, *next; wmWindow *win; - u_int64_t win_combine_v3d_datamask= 0; + uint64_t win_combine_v3d_datamask= 0; if(wm==NULL) return; -- cgit v1.2.3 From b42497b46031b4960d1efb79faf5a1fedd3546bb Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 24 Dec 2011 04:58:01 +0000 Subject: mathutils get/set function rename + minor changes to matrix functions (no functional changes) --- source/blender/python/mathutils/mathutils.c | 8 +- source/blender/python/mathutils/mathutils.h | 8 +- source/blender/python/mathutils/mathutils_Color.c | 30 +- source/blender/python/mathutils/mathutils_Euler.c | 20 +- source/blender/python/mathutils/mathutils_Matrix.c | 49 +- source/blender/python/mathutils/mathutils_Matrix.h | 4 +- .../python/mathutils/mathutils_Quaternion.c | 32 +- source/blender/python/mathutils/mathutils_Vector.c | 704 ++++++++++----------- 8 files changed, 427 insertions(+), 428 deletions(-) (limited to 'source/blender') diff --git a/source/blender/python/mathutils/mathutils.c b/source/blender/python/mathutils/mathutils.c index 1147930ff65..5ff163379a7 100644 --- a/source/blender/python/mathutils/mathutils.c +++ b/source/blender/python/mathutils/mathutils.c @@ -358,16 +358,16 @@ int _BaseMathObject_WriteIndexCallback(BaseMathObject *self, int index) } /* BaseMathObject generic functions for all mathutils types */ -char BaseMathObject_Owner_doc[] = "The item this is wrapping or None (readonly)."; -PyObject *BaseMathObject_getOwner(BaseMathObject *self, void *UNUSED(closure)) +char BaseMathObject_owner_doc[] = "The item this is wrapping or None (readonly)."; +PyObject *BaseMathObject_owner_get(BaseMathObject *self, void *UNUSED(closure)) { PyObject *ret= self->cb_user ? self->cb_user : Py_None; Py_INCREF(ret); return ret; } -char BaseMathObject_Wrapped_doc[] = "True when this object wraps external data (readonly).\n\n:type: boolean"; -PyObject *BaseMathObject_getWrapped(BaseMathObject *self, void *UNUSED(closure)) +char BaseMathObject_is_wrapped_doc[] = "True when this object wraps external data (readonly).\n\n:type: boolean"; +PyObject *BaseMathObject_is_wrapped_get(BaseMathObject *self, void *UNUSED(closure)) { return PyBool_FromLong((self->wrapped == Py_WRAP) ? 1:0); } diff --git a/source/blender/python/mathutils/mathutils.h b/source/blender/python/mathutils/mathutils.h index 2454e953949..220ae61f47d 100644 --- a/source/blender/python/mathutils/mathutils.h +++ b/source/blender/python/mathutils/mathutils.h @@ -39,8 +39,8 @@ struct DynStr; -extern char BaseMathObject_Wrapped_doc[]; -extern char BaseMathObject_Owner_doc[]; +extern char BaseMathObject_is_wrapped_doc[]; +extern char BaseMathObject_owner_doc[]; #define BASE_MATH_MEMBERS(_data) \ PyObject_VAR_HEAD \ @@ -67,8 +67,8 @@ typedef struct { #include "mathutils_geometry.h" #include "mathutils_noise.h" -PyObject *BaseMathObject_getOwner( BaseMathObject * self, void * ); -PyObject *BaseMathObject_getWrapped( BaseMathObject *self, void * ); +PyObject *BaseMathObject_owner_get( BaseMathObject * self, void * ); +PyObject *BaseMathObject_is_wrapped_get( BaseMathObject *self, void * ); int BaseMathObject_traverse(BaseMathObject *self, visitproc visit, void *arg); int BaseMathObject_clear(BaseMathObject *self); diff --git a/source/blender/python/mathutils/mathutils_Color.c b/source/blender/python/mathutils/mathutils_Color.c index e0a0deb9a0e..59fc656a380 100644 --- a/source/blender/python/mathutils/mathutils_Color.c +++ b/source/blender/python/mathutils/mathutils_Color.c @@ -670,18 +670,18 @@ static PyNumberMethods Color_NumMethods = { }; /* color channel, vector.r/g/b */ -static PyObject *Color_getChannel(ColorObject * self, void *type) +static PyObject *Color_channel_get(ColorObject * self, void *type) { return Color_item(self, GET_INT_FROM_POINTER(type)); } -static int Color_setChannel(ColorObject * self, PyObject *value, void * type) +static int Color_channel_set(ColorObject * self, PyObject *value, void * type) { return Color_ass_item(self, GET_INT_FROM_POINTER(type), value); } /* color channel (HSV), color.h/s/v */ -static PyObject *Color_getChannelHSV(ColorObject * self, void *type) +static PyObject *Color_channel_hsv_get(ColorObject * self, void *type) { float hsv[3]; int i= GET_INT_FROM_POINTER(type); @@ -694,7 +694,7 @@ static PyObject *Color_getChannelHSV(ColorObject * self, void *type) return PyFloat_FromDouble(hsv[i]); } -static int Color_setChannelHSV(ColorObject * self, PyObject *value, void * type) +static int Color_channel_hsv_set(ColorObject * self, PyObject *value, void * type) { float hsv[3]; int i= GET_INT_FROM_POINTER(type); @@ -722,7 +722,7 @@ static int Color_setChannelHSV(ColorObject * self, PyObject *value, void * type) } /* color channel (HSV), color.h/s/v */ -static PyObject *Color_getHSV(ColorObject * self, void *UNUSED(closure)) +static PyObject *Color_hsv_get(ColorObject * self, void *UNUSED(closure)) { float hsv[3]; PyObject *ret; @@ -739,7 +739,7 @@ static PyObject *Color_getHSV(ColorObject * self, void *UNUSED(closure)) return ret; } -static int Color_setHSV(ColorObject * self, PyObject *value, void *UNUSED(closure)) +static int Color_hsv_set(ColorObject * self, PyObject *value, void *UNUSED(closure)) { float hsv[3]; @@ -762,18 +762,18 @@ static int Color_setHSV(ColorObject * self, PyObject *value, void *UNUSED(closur /* Python attributes get/set structure: */ /*****************************************************************************/ static PyGetSetDef Color_getseters[] = { - {(char *)"r", (getter)Color_getChannel, (setter)Color_setChannel, (char *)"Red color channel.\n\n:type: float", (void *)0}, - {(char *)"g", (getter)Color_getChannel, (setter)Color_setChannel, (char *)"Green color channel.\n\n:type: float", (void *)1}, - {(char *)"b", (getter)Color_getChannel, (setter)Color_setChannel, (char *)"Blue color channel.\n\n:type: float", (void *)2}, + {(char *)"r", (getter)Color_channel_get, (setter)Color_channel_set, (char *)"Red color channel.\n\n:type: float", (void *)0}, + {(char *)"g", (getter)Color_channel_get, (setter)Color_channel_set, (char *)"Green color channel.\n\n:type: float", (void *)1}, + {(char *)"b", (getter)Color_channel_get, (setter)Color_channel_set, (char *)"Blue color channel.\n\n:type: float", (void *)2}, - {(char *)"h", (getter)Color_getChannelHSV, (setter)Color_setChannelHSV, (char *)"HSV Hue component in [0, 1].\n\n:type: float", (void *)0}, - {(char *)"s", (getter)Color_getChannelHSV, (setter)Color_setChannelHSV, (char *)"HSV Saturation component in [0, 1].\n\n:type: float", (void *)1}, - {(char *)"v", (getter)Color_getChannelHSV, (setter)Color_setChannelHSV, (char *)"HSV Value component in [0, 1].\n\n:type: float", (void *)2}, + {(char *)"h", (getter)Color_channel_hsv_get, (setter)Color_channel_hsv_set, (char *)"HSV Hue component in [0, 1].\n\n:type: float", (void *)0}, + {(char *)"s", (getter)Color_channel_hsv_get, (setter)Color_channel_hsv_set, (char *)"HSV Saturation component in [0, 1].\n\n:type: float", (void *)1}, + {(char *)"v", (getter)Color_channel_hsv_get, (setter)Color_channel_hsv_set, (char *)"HSV Value component in [0, 1].\n\n:type: float", (void *)2}, - {(char *)"hsv", (getter)Color_getHSV, (setter)Color_setHSV, (char *)"HSV Values in [0, 1].\n\n:type: float triplet", (void *)0}, + {(char *)"hsv", (getter)Color_hsv_get, (setter)Color_hsv_set, (char *)"HSV Values in [0, 1].\n\n:type: float triplet", (void *)0}, - {(char *)"is_wrapped", (getter)BaseMathObject_getWrapped, (setter)NULL, BaseMathObject_Wrapped_doc, NULL}, - {(char *)"owner", (getter)BaseMathObject_getOwner, (setter)NULL, BaseMathObject_Owner_doc, NULL}, + {(char *)"is_wrapped", (getter)BaseMathObject_is_wrapped_get, (setter)NULL, BaseMathObject_is_wrapped_doc, NULL}, + {(char *)"owner", (getter)BaseMathObject_owner_get, (setter)NULL, BaseMathObject_owner_doc, NULL}, {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; diff --git a/source/blender/python/mathutils/mathutils_Euler.c b/source/blender/python/mathutils/mathutils_Euler.c index 443e77c3798..08e5018b789 100644 --- a/source/blender/python/mathutils/mathutils_Euler.c +++ b/source/blender/python/mathutils/mathutils_Euler.c @@ -571,18 +571,18 @@ static PyMappingMethods Euler_AsMapping = { /* * euler axis, euler.x/y/z */ -static PyObject *Euler_getAxis(EulerObject *self, void *type) +static PyObject *Euler_axis_get(EulerObject *self, void *type) { return Euler_item(self, GET_INT_FROM_POINTER(type)); } -static int Euler_setAxis(EulerObject *self, PyObject *value, void *type) +static int Euler_axis_set(EulerObject *self, PyObject *value, void *type) { return Euler_ass_item(self, GET_INT_FROM_POINTER(type), value); } /* rotation order */ -static PyObject *Euler_getOrder(EulerObject *self, void *UNUSED(closure)) +static PyObject *Euler_order_get(EulerObject *self, void *UNUSED(closure)) { if (BaseMath_ReadCallback(self) == -1) /* can read order too */ return NULL; @@ -590,7 +590,7 @@ static PyObject *Euler_getOrder(EulerObject *self, void *UNUSED(closure)) return PyUnicode_FromString(euler_order_str(self)); } -static int Euler_setOrder(EulerObject *self, PyObject *value, void *UNUSED(closure)) +static int Euler_order_set(EulerObject *self, PyObject *value, void *UNUSED(closure)) { const char *order_str= _PyUnicode_AsString(value); short order= euler_order_from_string(order_str, "euler.order"); @@ -607,13 +607,13 @@ static int Euler_setOrder(EulerObject *self, PyObject *value, void *UNUSED(closu /* Python attributes get/set structure: */ /*****************************************************************************/ static PyGetSetDef Euler_getseters[] = { - {(char *)"x", (getter)Euler_getAxis, (setter)Euler_setAxis, (char *)"Euler X axis in radians.\n\n:type: float", (void *)0}, - {(char *)"y", (getter)Euler_getAxis, (setter)Euler_setAxis, (char *)"Euler Y axis in radians.\n\n:type: float", (void *)1}, - {(char *)"z", (getter)Euler_getAxis, (setter)Euler_setAxis, (char *)"Euler Z axis in radians.\n\n:type: float", (void *)2}, - {(char *)"order", (getter)Euler_getOrder, (setter)Euler_setOrder, (char *)"Euler rotation order.\n\n:type: string in ['XYZ', 'XZY', 'YXZ', 'YZX', 'ZXY', 'ZYX']", (void *)NULL}, + {(char *)"x", (getter)Euler_axis_get, (setter)Euler_axis_set, (char *)"Euler X axis in radians.\n\n:type: float", (void *)0}, + {(char *)"y", (getter)Euler_axis_get, (setter)Euler_axis_set, (char *)"Euler Y axis in radians.\n\n:type: float", (void *)1}, + {(char *)"z", (getter)Euler_axis_get, (setter)Euler_axis_set, (char *)"Euler Z axis in radians.\n\n:type: float", (void *)2}, + {(char *)"order", (getter)Euler_order_get, (setter)Euler_order_set, (char *)"Euler rotation order.\n\n:type: string in ['XYZ', 'XZY', 'YXZ', 'YZX', 'ZXY', 'ZYX']", (void *)NULL}, - {(char *)"is_wrapped", (getter)BaseMathObject_getWrapped, (setter)NULL, (char *)BaseMathObject_Wrapped_doc, NULL}, - {(char *)"owner", (getter)BaseMathObject_getOwner, (setter)NULL, (char *)BaseMathObject_Owner_doc, NULL}, + {(char *)"is_wrapped", (getter)BaseMathObject_is_wrapped_get, (setter)NULL, (char *)BaseMathObject_is_wrapped_doc, NULL}, + {(char *)"owner", (getter)BaseMathObject_owner_get, (setter)NULL, (char *)BaseMathObject_owner_doc, NULL}, {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index de098ce8bd8..690a8d1b616 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -389,15 +389,12 @@ PyDoc_STRVAR(C_Matrix_Translation_doc, ); static PyObject *C_Matrix_Translation(PyObject *cls, PyObject *value) { - float mat[16], tvec[3]; + float mat[4][4]= MAT4_UNITY; - if (mathutils_array_parse(tvec, 3, 4, value, "mathutils.Matrix.Translation(vector), invalid vector arg") == -1) + if (mathutils_array_parse(mat[3], 3, 4, value, "mathutils.Matrix.Translation(vector), invalid vector arg") == -1) return NULL; - /* create a identity matrix and add translation */ - unit_m4((float(*)[4]) mat); - copy_v3_v3(mat + 12, tvec); /* 12, 13, 14 */ - return Matrix_CreatePyObject(mat, 4, 4, Py_NEW, (PyTypeObject *)cls); + return Matrix_CreatePyObject(&mat[0][0], 4, 4, Py_NEW, (PyTypeObject *)cls); } //----------------------------------mathutils.Matrix.Scale() ------------- //mat is a 1D array of floats - row[0][0], row[0][1], row[1][0], etc. @@ -583,19 +580,19 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args) } if (matSize == 2) { mat[0] = 1 - (tvec[0] * tvec[0]); - mat[1] = -(tvec[0] * tvec[1]); - mat[2] = -(tvec[0] * tvec[1]); + mat[1] = - (tvec[0] * tvec[1]); + mat[2] = - (tvec[0] * tvec[1]); mat[3] = 1 - (tvec[1] * tvec[1]); } else if (matSize > 2) { mat[0] = 1 - (tvec[0] * tvec[0]); - mat[1] = -(tvec[0] * tvec[1]); - mat[2] = -(tvec[0] * tvec[2]); - mat[3] = -(tvec[0] * tvec[1]); + mat[1] = - (tvec[0] * tvec[1]); + mat[2] = - (tvec[0] * tvec[2]); + mat[3] = - (tvec[0] * tvec[1]); mat[4] = 1 - (tvec[1] * tvec[1]); - mat[5] = -(tvec[1] * tvec[2]); - mat[6] = -(tvec[0] * tvec[2]); - mat[7] = -(tvec[1] * tvec[2]); + mat[5] = - (tvec[1] * tvec[2]); + mat[6] = - (tvec[0] * tvec[2]); + mat[7] = - (tvec[1] * tvec[2]); mat[8] = 1 - (tvec[2] * tvec[2]); } } @@ -846,7 +843,7 @@ PyDoc_STRVAR(Matrix_resize_4x4_doc, ); static PyObject *Matrix_resize_4x4(MatrixObject *self) { - float mat[16]; + float mat[4][4]= MAT4_UNITY; int col; if (self->wrapped==Py_WRAP) { @@ -870,10 +867,8 @@ static PyObject *Matrix_resize_4x4(MatrixObject *self) return NULL; } - unit_m4((float (*)[4])mat); - for (col = 0; col < self->num_col; col++) { - memcpy(mat + (4 * col), MATRIX_COL_PTR(self, col), self->num_row * sizeof(float)); + memcpy(mat[col], MATRIX_COL_PTR(self, col), self->num_row * sizeof(float)); } copy_m4_m4((float (*)[4])self->matrix, (float (*)[4])mat); @@ -1896,12 +1891,12 @@ static PyNumberMethods Matrix_NumMethods = { NULL, /* nb_index */ }; -static PyObject *Matrix_getRowSize(MatrixObject *self, void *UNUSED(closure)) +static PyObject *Matrix_row_size_get(MatrixObject *self, void *UNUSED(closure)) { return PyLong_FromLong((long) self->num_col); } -static PyObject *Matrix_getColSize(MatrixObject *self, void *UNUSED(closure)) +static PyObject *Matrix_col_size_get(MatrixObject *self, void *UNUSED(closure)) { return PyLong_FromLong((long) self->num_row); } @@ -2011,14 +2006,14 @@ static PyObject *Matrix_is_orthogonal_get(MatrixObject *self, void *UNUSED(closu /* Python attributes get/set structure: */ /*****************************************************************************/ static PyGetSetDef Matrix_getseters[] = { - {(char *)"row_size", (getter)Matrix_getRowSize, (setter)NULL, (char *)"The row size of the matrix (readonly).\n\n:type: int", NULL}, - {(char *)"col_size", (getter)Matrix_getColSize, (setter)NULL, (char *)"The column size of the matrix (readonly).\n\n:type: int", NULL}, + {(char *)"row_size", (getter)Matrix_row_size_get, (setter)NULL, (char *)"The row size of the matrix (readonly).\n\n:type: int", NULL}, + {(char *)"col_size", (getter)Matrix_col_size_get, (setter)NULL, (char *)"The column size of the matrix (readonly).\n\n:type: int", NULL}, {(char *)"median_scale", (getter)Matrix_median_scale_get, (setter)NULL, (char *)"The average scale applied to each axis (readonly).\n\n:type: float", NULL}, {(char *)"translation", (getter)Matrix_translation_get, (setter)Matrix_translation_set, (char *)"The translation component of the matrix.\n\n:type: Vector", NULL}, {(char *)"is_negative", (getter)Matrix_is_negative_get, (setter)NULL, (char *)"True if this matrix results in a negative scale, 3x3 and 4x4 only, (readonly).\n\n:type: bool", NULL}, {(char *)"is_orthogonal", (getter)Matrix_is_orthogonal_get, (setter)NULL, (char *)"True if this matrix is orthogonal, 3x3 and 4x4 only, (readonly).\n\n:type: bool", NULL}, - {(char *)"is_wrapped", (getter)BaseMathObject_getWrapped, (setter)NULL, (char *)BaseMathObject_Wrapped_doc, NULL}, - {(char *)"owner",(getter)BaseMathObject_getOwner, (setter)NULL, (char *)BaseMathObject_Owner_doc, NULL}, + {(char *)"is_wrapped", (getter)BaseMathObject_is_wrapped_get, (setter)NULL, (char *)BaseMathObject_is_wrapped_doc, NULL}, + {(char *)"owner",(getter)BaseMathObject_owner_get, (setter)NULL, (char *)BaseMathObject_owner_doc, NULL}, {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; @@ -2180,9 +2175,11 @@ PyObject *Matrix_CreatePyObject(float *mat, return (PyObject *) self; } -PyObject *Matrix_CreatePyObject_cb(PyObject *cb_user, int rowSize, int colSize, int cb_type, int cb_subtype) +PyObject *Matrix_CreatePyObject_cb(PyObject *cb_user, + const unsigned short num_col, const unsigned short num_row, + int cb_type, int cb_subtype) { - MatrixObject *self= (MatrixObject *)Matrix_CreatePyObject(NULL, rowSize, colSize, Py_NEW, NULL); + MatrixObject *self= (MatrixObject *)Matrix_CreatePyObject(NULL, num_col, num_row, Py_NEW, NULL); if (self) { Py_INCREF(cb_user); self->cb_user= cb_user; diff --git a/source/blender/python/mathutils/mathutils_Matrix.h b/source/blender/python/mathutils/mathutils_Matrix.h index e7bfc06b98b..05c822b0330 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.h +++ b/source/blender/python/mathutils/mathutils_Matrix.h @@ -68,7 +68,9 @@ typedef struct { PyObject *Matrix_CreatePyObject(float *mat, const unsigned short num_col, const unsigned short num_row, int type, PyTypeObject *base_type); -PyObject *Matrix_CreatePyObject_cb(PyObject *user, int num_col, int num_row, int cb_type, int cb_subtype); +PyObject *Matrix_CreatePyObject_cb(PyObject *user, + const unsigned short num_col, const unsigned short num_row, + int cb_type, int cb_subtype); extern int mathutils_matrix_vector_cb_index; extern int mathutils_matrix_column_cb_index; diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c b/source/blender/python/mathutils/mathutils_Quaternion.c index 7c339807ee9..2dd266d83fb 100644 --- a/source/blender/python/mathutils/mathutils_Quaternion.c +++ b/source/blender/python/mathutils/mathutils_Quaternion.c @@ -922,17 +922,17 @@ static PyNumberMethods Quaternion_NumMethods = { NULL, /* nb_index */ }; -static PyObject *Quaternion_getAxis(QuaternionObject *self, void *type) +static PyObject *Quaternion_axis_get(QuaternionObject *self, void *type) { return Quaternion_item(self, GET_INT_FROM_POINTER(type)); } -static int Quaternion_setAxis(QuaternionObject *self, PyObject *value, void *type) +static int Quaternion_axis_set(QuaternionObject *self, PyObject *value, void *type) { return Quaternion_ass_item(self, GET_INT_FROM_POINTER(type), value); } -static PyObject *Quaternion_getMagnitude(QuaternionObject *self, void *UNUSED(closure)) +static PyObject *Quaternion_magnitude_get(QuaternionObject *self, void *UNUSED(closure)) { if (BaseMath_ReadCallback(self) == -1) return NULL; @@ -940,7 +940,7 @@ static PyObject *Quaternion_getMagnitude(QuaternionObject *self, void *UNUSED(cl return PyFloat_FromDouble(sqrt(dot_qtqt(self->quat, self->quat))); } -static PyObject *Quaternion_getAngle(QuaternionObject *self, void *UNUSED(closure)) +static PyObject *Quaternion_angle_get(QuaternionObject *self, void *UNUSED(closure)) { float tquat[4]; float angle; @@ -957,7 +957,7 @@ static PyObject *Quaternion_getAngle(QuaternionObject *self, void *UNUSED(closur return PyFloat_FromDouble(angle); } -static int Quaternion_setAngle(QuaternionObject *self, PyObject *value, void *UNUSED(closure)) +static int Quaternion_angle_set(QuaternionObject *self, PyObject *value, void *UNUSED(closure)) { float tquat[4]; float len; @@ -992,7 +992,7 @@ static int Quaternion_setAngle(QuaternionObject *self, PyObject *value, void *UN return 0; } -static PyObject *Quaternion_getAxisVec(QuaternionObject *self, void *UNUSED(closure)) +static PyObject *Quaternion_axis_vector_get(QuaternionObject *self, void *UNUSED(closure)) { float tquat[4]; @@ -1010,7 +1010,7 @@ static PyObject *Quaternion_getAxisVec(QuaternionObject *self, void *UNUSED(clos return Vector_CreatePyObject(axis, 3, Py_NEW, NULL); } -static int Quaternion_setAxisVec(QuaternionObject *self, PyObject *value, void *UNUSED(closure)) +static int Quaternion_axis_vector_set(QuaternionObject *self, PyObject *value, void *UNUSED(closure)) { float tquat[4]; float len; @@ -1151,15 +1151,15 @@ static struct PyMethodDef Quaternion_methods[] = { /* Python attributes get/set structure: */ /*****************************************************************************/ static PyGetSetDef Quaternion_getseters[] = { - {(char *)"w", (getter)Quaternion_getAxis, (setter)Quaternion_setAxis, (char *)"Quaternion W value.\n\n:type: float", (void *)0}, - {(char *)"x", (getter)Quaternion_getAxis, (setter)Quaternion_setAxis, (char *)"Quaternion X axis.\n\n:type: float", (void *)1}, - {(char *)"y", (getter)Quaternion_getAxis, (setter)Quaternion_setAxis, (char *)"Quaternion Y axis.\n\n:type: float", (void *)2}, - {(char *)"z", (getter)Quaternion_getAxis, (setter)Quaternion_setAxis, (char *)"Quaternion Z axis.\n\n:type: float", (void *)3}, - {(char *)"magnitude", (getter)Quaternion_getMagnitude, (setter)NULL, (char *)"Size of the quaternion (readonly).\n\n:type: float", NULL}, - {(char *)"angle", (getter)Quaternion_getAngle, (setter)Quaternion_setAngle, (char *)"angle of the quaternion.\n\n:type: float", NULL}, - {(char *)"axis",(getter)Quaternion_getAxisVec, (setter)Quaternion_setAxisVec, (char *)"quaternion axis as a vector.\n\n:type: :class:`Vector`", NULL}, - {(char *)"is_wrapped", (getter)BaseMathObject_getWrapped, (setter)NULL, (char *)BaseMathObject_Wrapped_doc, NULL}, - {(char *)"owner", (getter)BaseMathObject_getOwner, (setter)NULL, (char *)BaseMathObject_Owner_doc, NULL}, + {(char *)"w", (getter)Quaternion_axis_get, (setter)Quaternion_axis_set, (char *)"Quaternion W value.\n\n:type: float", (void *)0}, + {(char *)"x", (getter)Quaternion_axis_get, (setter)Quaternion_axis_set, (char *)"Quaternion X axis.\n\n:type: float", (void *)1}, + {(char *)"y", (getter)Quaternion_axis_get, (setter)Quaternion_axis_set, (char *)"Quaternion Y axis.\n\n:type: float", (void *)2}, + {(char *)"z", (getter)Quaternion_axis_get, (setter)Quaternion_axis_set, (char *)"Quaternion Z axis.\n\n:type: float", (void *)3}, + {(char *)"magnitude", (getter)Quaternion_magnitude_get, (setter)NULL, (char *)"Size of the quaternion (readonly).\n\n:type: float", NULL}, + {(char *)"angle", (getter)Quaternion_angle_get, (setter)Quaternion_angle_set, (char *)"angle of the quaternion.\n\n:type: float", NULL}, + {(char *)"axis",(getter)Quaternion_axis_vector_get, (setter)Quaternion_axis_vector_set, (char *)"quaternion axis as a vector.\n\n:type: :class:`Vector`", NULL}, + {(char *)"is_wrapped", (getter)BaseMathObject_is_wrapped_get, (setter)NULL, (char *)BaseMathObject_is_wrapped_doc, NULL}, + {(char *)"owner", (getter)BaseMathObject_owner_get, (setter)NULL, (char *)BaseMathObject_owner_doc, NULL}, {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c index c31835cf7b5..69e51832bda 100644 --- a/source/blender/python/mathutils/mathutils_Vector.c +++ b/source/blender/python/mathutils/mathutils_Vector.c @@ -2028,18 +2028,18 @@ static PyNumberMethods Vector_NumMethods = { * vector axis, vector.x/y/z/w */ -static PyObject *Vector_getAxis(VectorObject *self, void *type) +static PyObject *Vector_axis_get(VectorObject *self, void *type) { return vector_item_internal(self, GET_INT_FROM_POINTER(type), TRUE); } -static int Vector_setAxis(VectorObject *self, PyObject *value, void *type) +static int Vector_axis_set(VectorObject *self, PyObject *value, void *type) { return vector_ass_item_internal(self, GET_INT_FROM_POINTER(type), value, TRUE); } /* vector.length */ -static PyObject *Vector_getLength(VectorObject *self, void *UNUSED(closure)) +static PyObject *Vector_length_get(VectorObject *self, void *UNUSED(closure)) { if (BaseMath_ReadCallback(self) == -1) return NULL; @@ -2047,7 +2047,7 @@ static PyObject *Vector_getLength(VectorObject *self, void *UNUSED(closure)) return PyFloat_FromDouble(sqrt(dot_vn_vn(self->vec, self->vec, self->size))); } -static int Vector_setLength(VectorObject *self, PyObject *value) +static int Vector_length_set(VectorObject *self, PyObject *value) { double dot = 0.0f, param; @@ -2090,7 +2090,7 @@ static int Vector_setLength(VectorObject *self, PyObject *value) } /* vector.length_squared */ -static PyObject *Vector_getLengthSquared(VectorObject *self, void *UNUSED(closure)) +static PyObject *Vector_length_squared_get(VectorObject *self, void *UNUSED(closure)) { if (BaseMath_ReadCallback(self) == -1) return NULL; @@ -2101,7 +2101,7 @@ static PyObject *Vector_getLengthSquared(VectorObject *self, void *UNUSED(closur /* Get a new Vector according to the provided swizzle. This function has little error checking, as we are in control of the inputs: the closure is set by us in Vector_createSwizzleGetSeter. */ -static PyObject *Vector_getSwizzle(VectorObject *self, void *closure) +static PyObject *Vector_swizzle_get(VectorObject *self, void *closure) { size_t axis_to; size_t axis_from; @@ -2142,7 +2142,7 @@ static PyObject *Vector_getSwizzle(VectorObject *self, void *closure) Returns 0 on success and -1 on failure. On failure, the vector will be unchanged. */ -static int Vector_setSwizzle(VectorObject *self, PyObject *value, void *closure) +static int Vector_swizzle_set(VectorObject *self, PyObject *value, void *closure) { size_t size_from; float scalarVal; @@ -2219,353 +2219,353 @@ static int Vector_setSwizzle(VectorObject *self, PyObject *value, void *closure) /* Python attributes get/set structure: */ /*****************************************************************************/ static PyGetSetDef Vector_getseters[] = { - {(char *)"x", (getter)Vector_getAxis, (setter)Vector_setAxis, (char *)"Vector X axis.\n\n:type: float", (void *)0}, - {(char *)"y", (getter)Vector_getAxis, (setter)Vector_setAxis, (char *)"Vector Y axis.\n\n:type: float", (void *)1}, - {(char *)"z", (getter)Vector_getAxis, (setter)Vector_setAxis, (char *)"Vector Z axis (3D Vectors only).\n\n:type: float", (void *)2}, - {(char *)"w", (getter)Vector_getAxis, (setter)Vector_setAxis, (char *)"Vector W axis (4D Vectors only).\n\n:type: float", (void *)3}, - {(char *)"length", (getter)Vector_getLength, (setter)Vector_setLength, (char *)"Vector Length.\n\n:type: float", NULL}, - {(char *)"length_squared", (getter)Vector_getLengthSquared, (setter)NULL, (char *)"Vector length squared (v.dot(v)).\n\n:type: float", NULL}, - {(char *)"magnitude", (getter)Vector_getLength, (setter)Vector_setLength, (char *)"Vector Length.\n\n:type: float", NULL}, - {(char *)"is_wrapped", (getter)BaseMathObject_getWrapped, (setter)NULL, (char *)BaseMathObject_Wrapped_doc, NULL}, - {(char *)"owner", (getter)BaseMathObject_getOwner, (setter)NULL, (char *)BaseMathObject_Owner_doc, NULL}, + {(char *)"x", (getter)Vector_axis_get, (setter)Vector_axis_set, (char *)"Vector X axis.\n\n:type: float", (void *)0}, + {(char *)"y", (getter)Vector_axis_get, (setter)Vector_axis_set, (char *)"Vector Y axis.\n\n:type: float", (void *)1}, + {(char *)"z", (getter)Vector_axis_get, (setter)Vector_axis_set, (char *)"Vector Z axis (3D Vectors only).\n\n:type: float", (void *)2}, + {(char *)"w", (getter)Vector_axis_get, (setter)Vector_axis_set, (char *)"Vector W axis (4D Vectors only).\n\n:type: float", (void *)3}, + {(char *)"length", (getter)Vector_length_get, (setter)Vector_length_set, (char *)"Vector Length.\n\n:type: float", NULL}, + {(char *)"length_squared", (getter)Vector_length_squared_get, (setter)NULL, (char *)"Vector length squared (v.dot(v)).\n\n:type: float", NULL}, + {(char *)"magnitude", (getter)Vector_length_get, (setter)Vector_length_set, (char *)"Vector Length.\n\n:type: float", NULL}, + {(char *)"is_wrapped", (getter)BaseMathObject_is_wrapped_get, (setter)NULL, (char *)BaseMathObject_is_wrapped_doc, NULL}, + {(char *)"owner", (getter)BaseMathObject_owner_get, (setter)NULL, (char *)BaseMathObject_owner_doc, NULL}, /* autogenerated swizzle attrs, see python script below */ - {(char *)"xx", (getter)Vector_getSwizzle, (setter)NULL, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)< Date: Sat, 24 Dec 2011 06:13:58 +0000 Subject: fix for error with matrix access and negative indices with recent row/col swap. --- source/blender/python/mathutils/mathutils.c | 4 ++-- source/blender/python/mathutils/mathutils_Matrix.c | 22 +++++++++++----------- source/blender/python/mathutils/mathutils_Matrix.h | 8 ++++---- 3 files changed, 17 insertions(+), 17 deletions(-) (limited to 'source/blender') diff --git a/source/blender/python/mathutils/mathutils.c b/source/blender/python/mathutils/mathutils.c index 5ff163379a7..1a7a1dbbe8e 100644 --- a/source/blender/python/mathutils/mathutils.c +++ b/source/blender/python/mathutils/mathutils.c @@ -455,8 +455,8 @@ PyMODINIT_FUNC PyInit_mathutils(void) PyDict_SetItemString(sys_modules, "mathutils.noise", item); Py_INCREF(item); - mathutils_matrix_vector_cb_index= Mathutils_RegisterCallback(&mathutils_matrix_vector_cb); - mathutils_matrix_column_cb_index= Mathutils_RegisterCallback(&mathutils_matrix_column_cb); + mathutils_matrix_row_cb_index= Mathutils_RegisterCallback(&mathutils_matrix_row_cb); + mathutils_matrix_col_cb_index= Mathutils_RegisterCallback(&mathutils_matrix_col_cb); return submodule; } diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index 690a8d1b616..4464a57ce0b 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -43,7 +43,7 @@ static int Matrix_ass_slice(MatrixObject *self, int begin, int end, PyObject *va static PyObject *matrix__apply_to_copy(PyNoArgsFunction matrix_func, MatrixObject *self); /* matrix row callbacks */ -int mathutils_matrix_vector_cb_index= -1; +int mathutils_matrix_row_cb_index= -1; static int mathutils_matrix_vector_check(BaseMathObject *bmo) { @@ -106,7 +106,7 @@ static int mathutils_matrix_vector_set_index(BaseMathObject *bmo, int row, int c return 0; } -Mathutils_Callback mathutils_matrix_vector_cb = { +Mathutils_Callback mathutils_matrix_row_cb = { mathutils_matrix_vector_check, mathutils_matrix_vector_get, mathutils_matrix_vector_set, @@ -116,7 +116,7 @@ Mathutils_Callback mathutils_matrix_vector_cb = { /* matrix vector callbacks, this is so you can do matrix[i][j] = val */ /* matrix row callbacks */ -int mathutils_matrix_column_cb_index= -1; +int mathutils_matrix_col_cb_index= -1; static int mathutils_matrix_column_check(BaseMathObject *bmo) { @@ -187,7 +187,7 @@ static int mathutils_matrix_column_set_index(BaseMathObject *bmo, int col, int r return 0; } -Mathutils_Callback mathutils_matrix_column_cb = { +Mathutils_Callback mathutils_matrix_col_cb = { mathutils_matrix_column_check, mathutils_matrix_column_get, mathutils_matrix_column_set, @@ -1483,7 +1483,7 @@ static PyObject *Matrix_item(MatrixObject *self, int row) "array index out of range"); return NULL; } - return Vector_CreatePyObject_cb((PyObject *)self, self->num_col, mathutils_matrix_vector_cb_index, row); + return Vector_CreatePyObject_cb((PyObject *)self, self->num_col, mathutils_matrix_row_cb_index, row); } /*----------------------------object[]------------------------- sequence accessor (set) */ @@ -1532,7 +1532,7 @@ static PyObject *Matrix_slice(MatrixObject *self, int begin, int end) tuple= PyTuple_New(end - begin); for (count= begin; count < end; count++) { PyTuple_SET_ITEM(tuple, count - begin, - Vector_CreatePyObject_cb((PyObject *)self, self->num_col, mathutils_matrix_vector_cb_index, count)); + Vector_CreatePyObject_cb((PyObject *)self, self->num_col, mathutils_matrix_row_cb_index, count)); } @@ -1786,13 +1786,13 @@ static PyObject *Matrix_subscript(MatrixObject* self, PyObject* item) if (i == -1 && PyErr_Occurred()) return NULL; if (i < 0) - i += self->num_col; + i += self->num_row; return Matrix_item(self, i); } else if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelength; - if (PySlice_GetIndicesEx((void *)item, self->num_col, &start, &stop, &step, &slicelength) < 0) + if (PySlice_GetIndicesEx((void *)item, self->num_row, &start, &stop, &step, &slicelength) < 0) return NULL; if (slicelength <= 0) { @@ -1822,13 +1822,13 @@ static int Matrix_ass_subscript(MatrixObject* self, PyObject* item, PyObject* va if (i == -1 && PyErr_Occurred()) return -1; if (i < 0) - i += self->num_col; + i += self->num_row; return Matrix_ass_item(self, i, value); } else if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelength; - if (PySlice_GetIndicesEx((void *)item, self->num_col, &start, &stop, &step, &slicelength) < 0) + if (PySlice_GetIndicesEx((void *)item, self->num_row, &start, &stop, &step, &slicelength) < 0) return -1; if (step == 1) @@ -1916,7 +1916,7 @@ static PyObject *Matrix_translation_get(MatrixObject *self, void *UNUSED(closure return NULL; } - ret = (PyObject *)Vector_CreatePyObject_cb((PyObject *)self, 3, mathutils_matrix_column_cb_index, 3); + ret = (PyObject *)Vector_CreatePyObject_cb((PyObject *)self, 3, mathutils_matrix_col_cb_index, 3); return ret; } diff --git a/source/blender/python/mathutils/mathutils_Matrix.h b/source/blender/python/mathutils/mathutils_Matrix.h index 05c822b0330..73b786ef6aa 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.h +++ b/source/blender/python/mathutils/mathutils_Matrix.h @@ -72,10 +72,10 @@ PyObject *Matrix_CreatePyObject_cb(PyObject *user, const unsigned short num_col, const unsigned short num_row, int cb_type, int cb_subtype); -extern int mathutils_matrix_vector_cb_index; -extern int mathutils_matrix_column_cb_index; -extern struct Mathutils_Callback mathutils_matrix_vector_cb; -extern struct Mathutils_Callback mathutils_matrix_column_cb; +extern int mathutils_matrix_row_cb_index; /* default */ +extern int mathutils_matrix_col_cb_index; +extern struct Mathutils_Callback mathutils_matrix_row_cb; /* default */ +extern struct Mathutils_Callback mathutils_matrix_col_cb; void matrix_as_3x3(float mat[3][3], MatrixObject *self); -- cgit v1.2.3 From 2a803680054506fd0e1edec73fa4f184df3a3bc8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 24 Dec 2011 07:03:19 +0000 Subject: mathtils, convenience attributes added 'row' and 'col', this makes the row/col swap a lot easier to deal with, since now you can still use column access previously... mat[2] = 1, 2, 3 needed to be converted into... mat[0][2] = 1 mat[1][2] = 2 mat[2][2] = 3 but with column access you can do... mat.col[2] = 1, 2, 3 Having 'row' attribute is a bit redundant since direct indexing on a matrix uses row but included for completeness. --- source/blender/python/mathutils/mathutils.c | 4 +- source/blender/python/mathutils/mathutils_Matrix.c | 220 ++++++++++++++++++++- source/blender/python/mathutils/mathutils_Matrix.h | 1 + 3 files changed, 218 insertions(+), 7 deletions(-) (limited to 'source/blender') diff --git a/source/blender/python/mathutils/mathutils.c b/source/blender/python/mathutils/mathutils.c index 1a7a1dbbe8e..45fe0092b39 100644 --- a/source/blender/python/mathutils/mathutils.c +++ b/source/blender/python/mathutils/mathutils.c @@ -425,7 +425,9 @@ PyMODINIT_FUNC PyInit_mathutils(void) if (PyType_Ready(&vector_Type) < 0) return NULL; if (PyType_Ready(&matrix_Type) < 0) - return NULL; + return NULL; + if (PyType_Ready(&matrix_access_Type) < 0) + return NULL; if (PyType_Ready(&euler_Type) < 0) return NULL; if (PyType_Ready(&quaternion_Type) < 0) diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index 4464a57ce0b..07abed20ec7 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -38,9 +38,15 @@ #include "BLI_string.h" #include "BLI_dynstr.h" +typedef enum eMatrixAccess_t { + MAT_ACCESS_ROW, + MAT_ACCESS_COL +} eMatrixAccess_t; + static PyObject *Matrix_copy(MatrixObject *self); static int Matrix_ass_slice(MatrixObject *self, int begin, int end, PyObject *value); static PyObject *matrix__apply_to_copy(PyNoArgsFunction matrix_func, MatrixObject *self); +static PyObject *MatrixAccess_CreatePyObject(MatrixObject *matrix, const eMatrixAccess_t type); /* matrix row callbacks */ int mathutils_matrix_row_cb_index= -1; @@ -1472,7 +1478,7 @@ static int Matrix_len(MatrixObject *self) /*----------------------------object[]--------------------------- sequence accessor (get) the wrapped vector gives direct access to the matrix data*/ -static PyObject *Matrix_item(MatrixObject *self, int row) +static PyObject *Matrix_item_row(MatrixObject *self, int row) { if (BaseMath_ReadCallback(self) == -1) return NULL; @@ -1485,10 +1491,25 @@ static PyObject *Matrix_item(MatrixObject *self, int row) } return Vector_CreatePyObject_cb((PyObject *)self, self->num_col, mathutils_matrix_row_cb_index, row); } +/* same but column access */ +static PyObject *Matrix_item_col(MatrixObject *self, int col) +{ + if (BaseMath_ReadCallback(self) == -1) + return NULL; + + if (col < 0 || col >= self->num_col) { + PyErr_SetString(PyExc_IndexError, + "matrix[attribute]: " + "array index out of range"); + return NULL; + } + return Vector_CreatePyObject_cb((PyObject *)self, self->num_row, mathutils_matrix_col_cb_index, col); +} + /*----------------------------object[]------------------------- sequence accessor (set) */ -static int Matrix_ass_item(MatrixObject *self, int row, PyObject *value) +static int Matrix_ass_item_row(MatrixObject *self, int row, PyObject *value) { int col; float vec[4]; @@ -1513,6 +1534,32 @@ static int Matrix_ass_item(MatrixObject *self, int row, PyObject *value) (void)BaseMath_WriteCallback(self); return 0; } +static int Matrix_ass_item_col(MatrixObject *self, int col, PyObject *value) +{ + int row; + float vec[4]; + if (BaseMath_ReadCallback(self) == -1) + return -1; + + if (col >= self->num_col || col < 0) { + PyErr_SetString(PyExc_IndexError, + "matrix[attribute] = x: bad col"); + return -1; + } + + if (mathutils_array_parse(vec, self->num_row, self->num_row, value, "matrix[i] = value assignment") < 0) { + return -1; + } + + /* Since we are assigning a row we cannot memcpy */ + for (row = 0; row < self->num_row; row++) { + MATRIX_ITEM(self, row, col) = vec[row]; + } + + (void)BaseMath_WriteCallback(self); + return 0; +} + /*----------------------------object[z:y]------------------------ sequence slice (get)*/ @@ -1768,9 +1815,9 @@ static PySequenceMethods Matrix_SeqMethods = { (lenfunc) Matrix_len, /* sq_length */ (binaryfunc) NULL, /* sq_concat */ (ssizeargfunc) NULL, /* sq_repeat */ - (ssizeargfunc) Matrix_item, /* sq_item */ + (ssizeargfunc) Matrix_item_row, /* sq_item */ (ssizessizeargfunc) NULL, /* sq_slice, deprecated */ - (ssizeobjargproc) Matrix_ass_item, /* sq_ass_item */ + (ssizeobjargproc) Matrix_ass_item_row, /* sq_ass_item */ (ssizessizeobjargproc) NULL, /* sq_ass_slice, deprecated */ (objobjproc) NULL, /* sq_contains */ (binaryfunc) NULL, /* sq_inplace_concat */ @@ -1787,7 +1834,7 @@ static PyObject *Matrix_subscript(MatrixObject* self, PyObject* item) return NULL; if (i < 0) i += self->num_row; - return Matrix_item(self, i); + return Matrix_item_row(self, i); } else if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelength; @@ -1823,7 +1870,7 @@ static int Matrix_ass_subscript(MatrixObject* self, PyObject* item, PyObject* va return -1; if (i < 0) i += self->num_row; - return Matrix_ass_item(self, i, value); + return Matrix_ass_item_row(self, i, value); } else if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelength; @@ -1921,6 +1968,15 @@ static PyObject *Matrix_translation_get(MatrixObject *self, void *UNUSED(closure return ret; } +static PyObject *Matrix_row_get(MatrixObject *self, void *UNUSED(closure)) +{ + return MatrixAccess_CreatePyObject(self, MAT_ACCESS_ROW); +} +static PyObject *Matrix_col_get(MatrixObject *self, void *UNUSED(closure)) +{ + return MatrixAccess_CreatePyObject(self, MAT_ACCESS_COL); +} + static int Matrix_translation_set(MatrixObject *self, PyObject *value, void *UNUSED(closure)) { float tvec[3]; @@ -2010,6 +2066,9 @@ static PyGetSetDef Matrix_getseters[] = { {(char *)"col_size", (getter)Matrix_col_size_get, (setter)NULL, (char *)"The column size of the matrix (readonly).\n\n:type: int", NULL}, {(char *)"median_scale", (getter)Matrix_median_scale_get, (setter)NULL, (char *)"The average scale applied to each axis (readonly).\n\n:type: float", NULL}, {(char *)"translation", (getter)Matrix_translation_get, (setter)Matrix_translation_set, (char *)"The translation component of the matrix.\n\n:type: Vector", NULL}, + /* MatrixAccess_CreatePyObject*/ + {(char *)"row", (getter)Matrix_row_get, (setter)NULL, (char *)"Access the matix by rows (default), (readonly).\n\n:type: Matrix Access", NULL}, + {(char *)"col", (getter)Matrix_col_get, (setter)NULL, (char *)"Access the matix by colums, 3x3 and 4x4 only, (readonly).\n\n:type: Matrix Access", NULL}, {(char *)"is_negative", (getter)Matrix_is_negative_get, (setter)NULL, (char *)"True if this matrix results in a negative scale, 3x3 and 4x4 only, (readonly).\n\n:type: bool", NULL}, {(char *)"is_orthogonal", (getter)Matrix_is_orthogonal_get, (setter)NULL, (char *)"True if this matrix is orthogonal, 3x3 and 4x4 only, (readonly).\n\n:type: bool", NULL}, {(char *)"is_wrapped", (getter)BaseMathObject_is_wrapped_get, (setter)NULL, (char *)BaseMathObject_is_wrapped_doc, NULL}, @@ -2189,3 +2248,152 @@ PyObject *Matrix_CreatePyObject_cb(PyObject *cb_user, } return (PyObject *) self; } + + +/* ---------------------------------------------------------------------------- + * special type for alaternate access */ + +typedef struct { + PyObject_HEAD /* required python macro */ + MatrixObject *matrix_user; + eMatrixAccess_t type; +} MatrixAccessObject; + +static int MatrixAccess_traverse(MatrixAccessObject *self, visitproc visit, void *arg) +{ + Py_VISIT(self->matrix_user); + return 0; +} + +int MatrixAccess_clear(MatrixAccessObject *self) +{ + Py_CLEAR(self->matrix_user); + return 0; +} + +void MatrixAccess_dealloc(MatrixAccessObject *self) +{ + if (self->matrix_user) { + PyObject_GC_UnTrack(self); + MatrixAccess_clear(self); + } + + Py_TYPE(self)->tp_free(self); +} + +/* sequence access */ + +static int MatrixAccess_len(MatrixAccessObject *self) +{ + return (self->type == MAT_ACCESS_ROW) ? + self->matrix_user->num_row : + self->matrix_user->num_col; +} + +static PyObject *MatrixAccess_subscript(MatrixAccessObject* self, PyObject* item) +{ + MatrixObject *matrix_user= self->matrix_user; + + if (PyIndex_Check(item)) { + Py_ssize_t i; + i = PyNumber_AsSsize_t(item, PyExc_IndexError); + if (i == -1 && PyErr_Occurred()) + return NULL; + if (self->type == MAT_ACCESS_ROW) { + if (i < 0) + i += matrix_user->num_row; + return Matrix_item_row(matrix_user, i); + } + else { /* MAT_ACCESS_ROW */ + if (i < 0) + i += matrix_user->num_col; + return Matrix_item_col(matrix_user, i); + } + } + /* TODO, slice */ + else { + PyErr_Format(PyExc_TypeError, + "matrix indices must be integers, not %.200s", + Py_TYPE(item)->tp_name); + return NULL; + } +} + +static int MatrixAccess_ass_subscript(MatrixAccessObject* self, PyObject* item, PyObject* value) +{ + MatrixObject *matrix_user= self->matrix_user; + + if (PyIndex_Check(item)) { + Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError); + if (i == -1 && PyErr_Occurred()) + return -1; + + if (self->type == MAT_ACCESS_ROW) { + if (i < 0) + i += matrix_user->num_row; + return Matrix_ass_item_row(matrix_user, i, value); + } + else { /* MAT_ACCESS_ROW */ + if (i < 0) + i += matrix_user->num_col; + return Matrix_ass_item_col(matrix_user, i, value); + } + + } + /* TODO, slice */ + else { + PyErr_Format(PyExc_TypeError, + "matrix indices must be integers, not %.200s", + Py_TYPE(item)->tp_name); + return -1; + } +} + + +static PyMappingMethods MatrixAccess_AsMapping = { + (lenfunc)MatrixAccess_len, + (binaryfunc)MatrixAccess_subscript, + (objobjargproc) MatrixAccess_ass_subscript +}; + +PyTypeObject matrix_access_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "MatrixAccess", /*tp_name*/ + sizeof(MatrixAccessObject), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + (destructor)MatrixAccess_dealloc, /*tp_dealloc*/ + NULL, /*tp_print*/ + NULL, /*tp_getattr*/ + NULL, /*tp_setattr*/ + NULL, /*tp_compare*/ + NULL, /*tp_repr*/ + NULL, /*tp_as_number*/ + NULL /*&MatrixAccess_SeqMethods*/ /* TODO */, /*tp_as_sequence*/ + &MatrixAccess_AsMapping, /*tp_as_mapping*/ + NULL, /*tp_hash*/ + NULL, /*tp_call*/ + NULL, /*tp_str*/ + NULL, /*tp_getattro*/ + NULL, /*tp_setattro*/ + NULL, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + NULL, /*tp_doc*/ + (traverseproc)MatrixAccess_traverse, //tp_traverse + (inquiry)MatrixAccess_clear, //tp_clear + NULL /* (richcmpfunc)MatrixAccess_richcmpr */ /* TODO*/, /*tp_richcompare*/ +}; + +static PyObject *MatrixAccess_CreatePyObject(MatrixObject *matrix, const eMatrixAccess_t type) +{ + MatrixAccessObject *matrix_access= (MatrixAccessObject *)PyObject_GC_New(MatrixObject, &matrix_access_Type); + + matrix_access->matrix_user= matrix; + Py_INCREF(matrix); + + matrix_access->type= type; + + return (PyObject *)matrix_access; +} + +/* end special access + * -------------------------------------------------------------------------- */ diff --git a/source/blender/python/mathutils/mathutils_Matrix.h b/source/blender/python/mathutils/mathutils_Matrix.h index 73b786ef6aa..7602f98dea4 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.h +++ b/source/blender/python/mathutils/mathutils_Matrix.h @@ -35,6 +35,7 @@ #define MATHUTILS_MATRIX_H extern PyTypeObject matrix_Type; +extern PyTypeObject matrix_access_Type; #define MatrixObject_Check(_v) PyObject_TypeCheck((_v), &matrix_Type) #define MATRIX_MAX_DIM 4 -- cgit v1.2.3 From 856208dba292e7841710d89889ecf3898743e4c8 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Sat, 24 Dec 2011 08:03:43 +0000 Subject: OSX/gcc-4.6, fix for typedef uin64_t --- source/blender/blenkernel/BKE_customdata.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h index c648cbb8493..7e2dfa2eefc 100644 --- a/source/blender/blenkernel/BKE_customdata.h +++ b/source/blender/blenkernel/BKE_customdata.h @@ -34,6 +34,10 @@ #ifndef BKE_CUSTOMDATA_H #define BKE_CUSTOMDATA_H +#if defined(__APPLE__) && (__GNUC__ == 4) && (__GNUC_MINOR__ >= 6) +#include +#endif + #ifdef __cplusplus extern "C" { #endif -- cgit v1.2.3 From f3ac865cc0031d775f67e3fcaa389e6f06d1954e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 24 Dec 2011 13:26:30 +0000 Subject: picky formatting of mathutils --- source/blender/python/mathutils/mathutils.c | 64 ++--- source/blender/python/mathutils/mathutils_Color.c | 102 ++++---- source/blender/python/mathutils/mathutils_Euler.c | 74 +++--- source/blender/python/mathutils/mathutils_Euler.h | 2 +- source/blender/python/mathutils/mathutils_Matrix.c | 258 ++++++++++---------- .../python/mathutils/mathutils_Quaternion.c | 104 ++++---- source/blender/python/mathutils/mathutils_Vector.c | 201 ++++++++-------- .../blender/python/mathutils/mathutils_geometry.c | 262 ++++++++++----------- source/blender/python/mathutils/mathutils_noise.c | 58 ++--- 9 files changed, 562 insertions(+), 563 deletions(-) (limited to 'source/blender') diff --git a/source/blender/python/mathutils/mathutils.c b/source/blender/python/mathutils/mathutils.c index 45fe0092b39..42fa46207f3 100644 --- a/source/blender/python/mathutils/mathutils.c +++ b/source/blender/python/mathutils/mathutils.c @@ -49,10 +49,10 @@ static int mathutils_array_parse_fast(float *array, int i; - i= size; + i = size; do { i--; - if ( ((array[i]= PyFloat_AsDouble((item= PySequence_Fast_GET_ITEM(value_fast, i)))) == -1.0f) && + if ( ((array[i] = PyFloat_AsDouble((item = PySequence_Fast_GET_ITEM(value_fast, i)))) == -1.0f) && PyErr_Occurred()) { PyErr_Format(PyExc_TypeError, @@ -75,10 +75,10 @@ int mathutils_array_parse(float *array, int array_min, int array_max, PyObject * #if 1 /* approx 6x speedup for mathutils types */ - if ( (size= VectorObject_Check(value) ? ((VectorObject *)value)->size : 0) || - (size= EulerObject_Check(value) ? 3 : 0) || - (size= QuaternionObject_Check(value) ? 4 : 0) || - (size= ColorObject_Check(value) ? 3 : 0)) + if ( (size = VectorObject_Check(value) ? ((VectorObject *)value)->size : 0) || + (size = EulerObject_Check(value) ? 3 : 0) || + (size = QuaternionObject_Check(value) ? 4 : 0) || + (size = ColorObject_Check(value) ? 3 : 0)) { if (BaseMath_ReadCallback((BaseMathObject *)value) == -1) { return -1; @@ -104,15 +104,15 @@ int mathutils_array_parse(float *array, int array_min, int array_max, PyObject * else #endif { - PyObject *value_fast= NULL; + PyObject *value_fast = NULL; /* non list/tuple cases */ - if (!(value_fast=PySequence_Fast(value, error_prefix))) { + if (!(value_fast = PySequence_Fast(value, error_prefix))) { /* PySequence_Fast sets the error */ return -1; } - size= PySequence_Fast_GET_SIZE(value_fast); + size = PySequence_Fast_GET_SIZE(value_fast); if (size > array_max || size < array_min) { if (array_max == array_min) { @@ -139,10 +139,10 @@ int mathutils_array_parse_alloc(float **array, int array_min, PyObject *value, c #if 1 /* approx 6x speedup for mathutils types */ - if ( (size= VectorObject_Check(value) ? ((VectorObject *)value)->size : 0) || - (size= EulerObject_Check(value) ? 3 : 0) || - (size= QuaternionObject_Check(value) ? 4 : 0) || - (size= ColorObject_Check(value) ? 3 : 0)) + if ( (size = VectorObject_Check(value) ? ((VectorObject *)value)->size : 0) || + (size = EulerObject_Check(value) ? 3 : 0) || + (size = QuaternionObject_Check(value) ? 4 : 0) || + (size = ColorObject_Check(value) ? 3 : 0)) { if (BaseMath_ReadCallback((BaseMathObject *)value) == -1) { return -1; @@ -155,23 +155,23 @@ int mathutils_array_parse_alloc(float **array, int array_min, PyObject *value, c return -1; } - *array= PyMem_Malloc(size * sizeof(float)); + *array = PyMem_Malloc(size * sizeof(float)); memcpy(*array, ((BaseMathObject *)value)->data, size * sizeof(float)); return size; } else #endif { - PyObject *value_fast= NULL; - //*array= NULL; + PyObject *value_fast = NULL; + //*array = NULL; /* non list/tuple cases */ - if (!(value_fast=PySequence_Fast(value, error_prefix))) { + if (!(value_fast = PySequence_Fast(value, error_prefix))) { /* PySequence_Fast sets the error */ return -1; } - size= PySequence_Fast_GET_SIZE(value_fast); + size = PySequence_Fast_GET_SIZE(value_fast); if (size < array_min) { PyErr_Format(PyExc_ValueError, @@ -180,7 +180,7 @@ int mathutils_array_parse_alloc(float **array, int array_min, PyObject *value, c return -1; } - *array= PyMem_Malloc(size * sizeof(float)); + *array = PyMem_Malloc(size * sizeof(float)); return mathutils_array_parse_fast(*array, size, value_fast, error_prefix); } @@ -261,7 +261,7 @@ int EXPP_FloatsAreEqual(float af, float bf, int maxDiff) int EXPP_VectorsAreEqual(float *vecA, float *vecB, int size, int floatSteps) { int x; - for (x=0; x< size; x++) { + for (x = 0; x < size; x++) { if (EXPP_FloatsAreEqual(vecA[x], vecB[x], floatSteps) == 0) return 0; } @@ -291,8 +291,8 @@ int Mathutils_RegisterCallback(Mathutils_Callback *cb) int i; /* find the first free slot */ - for (i= 0; mathutils_callbacks[i]; i++) { - if (mathutils_callbacks[i]==cb) /* already registered? */ + for (i = 0; mathutils_callbacks[i]; i++) { + if (mathutils_callbacks[i] == cb) /* already registered? */ return i; } @@ -303,7 +303,7 @@ int Mathutils_RegisterCallback(Mathutils_Callback *cb) /* use macros to check for NULL */ int _BaseMathObject_ReadCallback(BaseMathObject *self) { - Mathutils_Callback *cb= mathutils_callbacks[self->cb_type]; + Mathutils_Callback *cb = mathutils_callbacks[self->cb_type]; if (cb->get(self, self->cb_subtype) != -1) return 0; @@ -317,7 +317,7 @@ int _BaseMathObject_ReadCallback(BaseMathObject *self) int _BaseMathObject_WriteCallback(BaseMathObject *self) { - Mathutils_Callback *cb= mathutils_callbacks[self->cb_type]; + Mathutils_Callback *cb = mathutils_callbacks[self->cb_type]; if (cb->set(self, self->cb_subtype) != -1) return 0; @@ -331,7 +331,7 @@ int _BaseMathObject_WriteCallback(BaseMathObject *self) int _BaseMathObject_ReadIndexCallback(BaseMathObject *self, int index) { - Mathutils_Callback *cb= mathutils_callbacks[self->cb_type]; + Mathutils_Callback *cb = mathutils_callbacks[self->cb_type]; if (cb->get_index(self, self->cb_subtype, index) != -1) return 0; @@ -345,7 +345,7 @@ int _BaseMathObject_ReadIndexCallback(BaseMathObject *self, int index) int _BaseMathObject_WriteIndexCallback(BaseMathObject *self, int index) { - Mathutils_Callback *cb= mathutils_callbacks[self->cb_type]; + Mathutils_Callback *cb = mathutils_callbacks[self->cb_type]; if (cb->set_index(self, self->cb_subtype, index) != -1) return 0; @@ -361,7 +361,7 @@ int _BaseMathObject_WriteIndexCallback(BaseMathObject *self, int index) char BaseMathObject_owner_doc[] = "The item this is wrapping or None (readonly)."; PyObject *BaseMathObject_owner_get(BaseMathObject *self, void *UNUSED(closure)) { - PyObject *ret= self->cb_user ? self->cb_user : Py_None; + PyObject *ret = self->cb_user ? self->cb_user : Py_None; Py_INCREF(ret); return ret; } @@ -420,7 +420,7 @@ PyMODINIT_FUNC PyInit_mathutils(void) { PyObject *submodule; PyObject *item; - PyObject *sys_modules= PyThreadState_GET()->interp->modules; + PyObject *sys_modules = PyThreadState_GET()->interp->modules; if (PyType_Ready(&vector_Type) < 0) return NULL; @@ -445,7 +445,7 @@ PyMODINIT_FUNC PyInit_mathutils(void) PyModule_AddObject(submodule, "Color", (PyObject *)&color_Type); /* submodule */ - PyModule_AddObject(submodule, "geometry", (item=PyInit_mathutils_geometry())); + PyModule_AddObject(submodule, "geometry", (item = PyInit_mathutils_geometry())); /* XXX, python doesnt do imports with this usefully yet * 'from mathutils.geometry import PolyFill' * ...fails without this. */ @@ -453,12 +453,12 @@ PyMODINIT_FUNC PyInit_mathutils(void) Py_INCREF(item); /* Noise submodule */ - PyModule_AddObject(submodule, "noise", (item=PyInit_mathutils_noise())); + PyModule_AddObject(submodule, "noise", (item = PyInit_mathutils_noise())); PyDict_SetItemString(sys_modules, "mathutils.noise", item); Py_INCREF(item); - mathutils_matrix_row_cb_index= Mathutils_RegisterCallback(&mathutils_matrix_row_cb); - mathutils_matrix_col_cb_index= Mathutils_RegisterCallback(&mathutils_matrix_col_cb); + mathutils_matrix_row_cb_index = Mathutils_RegisterCallback(&mathutils_matrix_row_cb); + mathutils_matrix_col_cb_index = Mathutils_RegisterCallback(&mathutils_matrix_col_cb); return submodule; } diff --git a/source/blender/python/mathutils/mathutils_Color.c b/source/blender/python/mathutils/mathutils_Color.c index 59fc656a380..c85380fb245 100644 --- a/source/blender/python/mathutils/mathutils_Color.c +++ b/source/blender/python/mathutils/mathutils_Color.c @@ -40,7 +40,7 @@ //makes a new color for you to play with static PyObject *Color_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - float col[3]= {0.0f, 0.0f, 0.0f}; + float col[3] = {0.0f, 0.0f, 0.0f}; if (kwds && PyDict_Size(kwds)) { PyErr_SetString(PyExc_TypeError, @@ -73,15 +73,15 @@ static PyObject *Color_ToTupleExt(ColorObject *self, int ndigits) PyObject *ret; int i; - ret= PyTuple_New(COLOR_SIZE); + ret = PyTuple_New(COLOR_SIZE); if (ndigits >= 0) { - for (i= 0; i < COLOR_SIZE; i++) { + for (i = 0; i < COLOR_SIZE; i++) { PyTuple_SET_ITEM(ret, i, PyFloat_FromDouble(double_round((double)self->col[i], ndigits))); } } else { - for (i= 0; i < COLOR_SIZE; i++) { + for (i = 0; i < COLOR_SIZE; i++) { PyTuple_SET_ITEM(ret, i, PyFloat_FromDouble(self->col[i])); } } @@ -118,9 +118,9 @@ static PyObject *Color_repr(ColorObject * self) if (BaseMath_ReadCallback(self) == -1) return NULL; - tuple= Color_ToTupleExt(self, -1); + tuple = Color_ToTupleExt(self, -1); - ret= PyUnicode_FromFormat("Color(%R)", tuple); + ret = PyUnicode_FromFormat("Color(%R)", tuple); Py_DECREF(tuple); return ret; @@ -133,7 +133,7 @@ static PyObject *Color_str(ColorObject * self) if (BaseMath_ReadCallback(self) == -1) return NULL; - ds= BLI_dynstr_new(); + ds = BLI_dynstr_new(); BLI_dynstr_appendf(ds, "", self->col[0], self->col[1], self->col[2]); @@ -143,19 +143,19 @@ static PyObject *Color_str(ColorObject * self) //------------------------tp_richcmpr //returns -1 execption, 0 false, 1 true -static PyObject* Color_richcmpr(PyObject *a, PyObject *b, int op) +static PyObject *Color_richcmpr(PyObject *a, PyObject *b, int op) { PyObject *res; - int ok= -1; /* zero is true */ + int ok = -1; /* zero is true */ if (ColorObject_Check(a) && ColorObject_Check(b)) { - ColorObject *colA= (ColorObject*)a; - ColorObject *colB= (ColorObject*)b; + ColorObject *colA = (ColorObject *)a; + ColorObject *colB = (ColorObject *)b; if (BaseMath_ReadCallback(colA) == -1 || BaseMath_ReadCallback(colB) == -1) return NULL; - ok= EXPP_VectorsAreEqual(colA->col, colB->col, COLOR_SIZE, 1) ? 0 : -1; + ok = EXPP_VectorsAreEqual(colA->col, colB->col, COLOR_SIZE, 1) ? 0 : -1; } switch (op) { @@ -190,7 +190,7 @@ static int Color_len(ColorObject *UNUSED(self)) //sequence accessor (get) static PyObject *Color_item(ColorObject * self, int i) { - if (i<0) i= COLOR_SIZE-i; + if (i < 0) i = COLOR_SIZE - i; if (i < 0 || i >= COLOR_SIZE) { PyErr_SetString(PyExc_IndexError, @@ -218,7 +218,7 @@ static int Color_ass_item(ColorObject * self, int i, PyObject *value) return -1; } - if (i<0) i= COLOR_SIZE-i; + if (i < 0) i= COLOR_SIZE - i; if (i < 0 || i >= COLOR_SIZE) { PyErr_SetString(PyExc_IndexError, "color[attribute] = x: " @@ -244,12 +244,12 @@ static PyObject *Color_slice(ColorObject * self, int begin, int end) return NULL; CLAMP(begin, 0, COLOR_SIZE); - if (end<0) end= (COLOR_SIZE + 1) + end; + if (end < 0) end = (COLOR_SIZE + 1) + end; CLAMP(end, 0, COLOR_SIZE); - begin= MIN2(begin, end); + begin = MIN2(begin, end); - tuple= PyTuple_New(end - begin); - for (count= begin; count < end; count++) { + tuple = PyTuple_New(end - begin); + for (count = begin; count < end; count++) { PyTuple_SET_ITEM(tuple, count - begin, PyFloat_FromDouble(self->col[count])); } @@ -266,11 +266,11 @@ static int Color_ass_slice(ColorObject *self, int begin, int end, PyObject *seq) return -1; CLAMP(begin, 0, COLOR_SIZE); - if (end<0) end= (COLOR_SIZE + 1) + end; + if (end < 0) end = (COLOR_SIZE + 1) + end; CLAMP(end, 0, COLOR_SIZE); begin = MIN2(begin, end); - if ((size=mathutils_array_parse(col, 0, COLOR_SIZE, seq, "mathutils.Color[begin:end] = []")) == -1) + if ((size = mathutils_array_parse(col, 0, COLOR_SIZE, seq, "mathutils.Color[begin:end] = []")) == -1) return -1; if (size != (end - begin)) { @@ -280,7 +280,7 @@ static int Color_ass_slice(ColorObject *self, int begin, int end, PyObject *seq) return -1; } - for (i= 0; i < COLOR_SIZE; i++) + for (i = 0; i < COLOR_SIZE; i++) self->col[begin + i] = col[i]; (void)BaseMath_WriteCallback(self); @@ -392,8 +392,8 @@ static PyObject *Color_add(PyObject *v1, PyObject *v2) Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name); return NULL; } - color1 = (ColorObject*)v1; - color2 = (ColorObject*)v2; + color1 = (ColorObject *)v1; + color2 = (ColorObject *)v2; if (BaseMath_ReadCallback(color1) == -1 || BaseMath_ReadCallback(color2) == -1) return NULL; @@ -415,8 +415,8 @@ static PyObject *Color_iadd(PyObject *v1, PyObject *v2) Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name); return NULL; } - color1 = (ColorObject*)v1; - color2 = (ColorObject*)v2; + color1 = (ColorObject *)v1; + color2 = (ColorObject *)v2; if (BaseMath_ReadCallback(color1) == -1 || BaseMath_ReadCallback(color2) == -1) return NULL; @@ -441,8 +441,8 @@ static PyObject *Color_sub(PyObject *v1, PyObject *v2) Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name); return NULL; } - color1 = (ColorObject*)v1; - color2 = (ColorObject*)v2; + color1 = (ColorObject *)v1; + color2 = (ColorObject *)v2; if (BaseMath_ReadCallback(color1) == -1 || BaseMath_ReadCallback(color2) == -1) return NULL; @@ -455,7 +455,7 @@ static PyObject *Color_sub(PyObject *v1, PyObject *v2) /* subtraction in-place: obj -= obj */ static PyObject *Color_isub(PyObject *v1, PyObject *v2) { - ColorObject *color1= NULL, *color2= NULL; + ColorObject *color1 = NULL, *color2 = NULL; if (!ColorObject_Check(v1) || !ColorObject_Check(v2)) { PyErr_Format(PyExc_TypeError, @@ -464,8 +464,8 @@ static PyObject *Color_isub(PyObject *v1, PyObject *v2) Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name); return NULL; } - color1 = (ColorObject*)v1; - color2 = (ColorObject*)v2; + color1 = (ColorObject *)v1; + color2 = (ColorObject *)v2; if (BaseMath_ReadCallback(color1) == -1 || BaseMath_ReadCallback(color2) == -1) return NULL; @@ -491,12 +491,12 @@ static PyObject *Color_mul(PyObject *v1, PyObject *v2) float scalar; if ColorObject_Check(v1) { - color1= (ColorObject *)v1; + color1 = (ColorObject *)v1; if (BaseMath_ReadCallback(color1) == -1) return NULL; } if ColorObject_Check(v2) { - color2= (ColorObject *)v2; + color2 = (ColorObject *)v2; if (BaseMath_ReadCallback(color2) == -1) return NULL; } @@ -507,12 +507,12 @@ static PyObject *Color_mul(PyObject *v1, PyObject *v2) /* col * col, dont support yet! */ } else if (color1) { - if (((scalar= PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred())==0) { /* COLOR * FLOAT */ + if (((scalar = PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) == 0) { /* COLOR * FLOAT */ return color_mul_float(color1, scalar); } } else if (color2) { - if (((scalar= PyFloat_AsDouble(v1)) == -1.0f && PyErr_Occurred())==0) { /* FLOAT * COLOR */ + if (((scalar = PyFloat_AsDouble(v1)) == -1.0f && PyErr_Occurred()) == 0) { /* FLOAT * COLOR */ return color_mul_float(color2, scalar); } } @@ -533,7 +533,7 @@ static PyObject *Color_div(PyObject *v1, PyObject *v2) float scalar; if ColorObject_Check(v1) { - color1= (ColorObject *)v1; + color1 = (ColorObject *)v1; if (BaseMath_ReadCallback(color1) == -1) return NULL; } @@ -544,8 +544,8 @@ static PyObject *Color_div(PyObject *v1, PyObject *v2) } /* make sure v1 is always the vector */ - if (((scalar= PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred())==0) { /* COLOR * FLOAT */ - if (scalar==0.0f) { + if (((scalar = PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) == 0) { /* COLOR * FLOAT */ + if (scalar == 0.0f) { PyErr_SetString(PyExc_ZeroDivisionError, "Color division: divide by zero error"); return NULL; @@ -570,7 +570,7 @@ static PyObject *Color_imul(PyObject *v1, PyObject *v2) return NULL; /* only support color *= float */ - if (((scalar= PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred())==0) { /* COLOR *= FLOAT */ + if (((scalar = PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) == 0) { /* COLOR *= FLOAT */ mul_vn_fl(color->col, COLOR_SIZE, scalar); } else { @@ -596,8 +596,8 @@ static PyObject *Color_idiv(PyObject *v1, PyObject *v2) return NULL; /* only support color /= float */ - if (((scalar= PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred())==0) { /* COLOR /= FLOAT */ - if (scalar==0.0f) { + if (((scalar = PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) == 0) { /* COLOR /= FLOAT */ + if (scalar == 0.0f) { PyErr_SetString(PyExc_ZeroDivisionError, "Color division: divide by zero error"); return NULL; @@ -619,7 +619,7 @@ static PyObject *Color_idiv(PyObject *v1, PyObject *v2) } /* -obj - returns the negative of this object*/ + returns the negative of this object */ static PyObject *Color_neg(ColorObject *self) { float tcol[COLOR_SIZE]; @@ -684,7 +684,7 @@ static int Color_channel_set(ColorObject * self, PyObject *value, void * type) static PyObject *Color_channel_hsv_get(ColorObject * self, void *type) { float hsv[3]; - int i= GET_INT_FROM_POINTER(type); + int i = GET_INT_FROM_POINTER(type); if (BaseMath_ReadCallback(self) == -1) return NULL; @@ -697,7 +697,7 @@ static PyObject *Color_channel_hsv_get(ColorObject * self, void *type) static int Color_channel_hsv_set(ColorObject * self, PyObject *value, void * type) { float hsv[3]; - int i= GET_INT_FROM_POINTER(type); + int i = GET_INT_FROM_POINTER(type); float f = PyFloat_AsDouble(value); if (f == -1 && PyErr_Occurred()) { @@ -732,7 +732,7 @@ static PyObject *Color_hsv_get(ColorObject * self, void *UNUSED(closure)) rgb_to_hsv(self->col[0], self->col[1], self->col[2], &(hsv[0]), &(hsv[1]), &(hsv[2])); - ret= PyTuple_New(3); + ret = PyTuple_New(3); PyTuple_SET_ITEM(ret, 0, PyFloat_FromDouble(hsv[0])); PyTuple_SET_ITEM(ret, 1, PyFloat_FromDouble(hsv[1])); PyTuple_SET_ITEM(ret, 2, PyFloat_FromDouble(hsv[2])); @@ -847,13 +847,13 @@ PyObject *Color_CreatePyObject(float *col, int type, PyTypeObject *base_type) { ColorObject *self; - self= base_type ? (ColorObject *)base_type->tp_alloc(base_type, 0) : + self = base_type ? (ColorObject *)base_type->tp_alloc(base_type, 0) : (ColorObject *)PyObject_GC_New(ColorObject, &color_Type); if (self) { /* init callbacks as NULL */ - self->cb_user= NULL; - self->cb_type= self->cb_subtype= 0; + self->cb_user = NULL; + self->cb_type = self->cb_subtype = 0; if (type == Py_WRAP) { self->col = col; @@ -878,12 +878,12 @@ PyObject *Color_CreatePyObject(float *col, int type, PyTypeObject *base_type) PyObject *Color_CreatePyObject_cb(PyObject *cb_user, int cb_type, int cb_subtype) { - ColorObject *self= (ColorObject *)Color_CreatePyObject(NULL, Py_NEW, NULL); + ColorObject *self = (ColorObject *)Color_CreatePyObject(NULL, Py_NEW, NULL); if (self) { Py_INCREF(cb_user); - self->cb_user= cb_user; - self->cb_type= (unsigned char)cb_type; - self->cb_subtype= (unsigned char)cb_subtype; + self->cb_user = cb_user; + self->cb_type = (unsigned char)cb_type; + self->cb_subtype = (unsigned char)cb_subtype; PyObject_GC_Track(self); } diff --git a/source/blender/python/mathutils/mathutils_Euler.c b/source/blender/python/mathutils/mathutils_Euler.c index 08e5018b789..f6bd77cd453 100644 --- a/source/blender/python/mathutils/mathutils_Euler.c +++ b/source/blender/python/mathutils/mathutils_Euler.c @@ -44,11 +44,11 @@ //makes a new euler for you to play with static PyObject *Euler_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - PyObject *seq= NULL; - const char *order_str= NULL; + PyObject *seq = NULL; + const char *order_str = NULL; - float eul[EULER_SIZE]= {0.0f, 0.0f, 0.0f}; - short order= EULER_ORDER_XYZ; + float eul[EULER_SIZE] = {0.0f, 0.0f, 0.0f}; + short order = EULER_ORDER_XYZ; if (kwds && PyDict_Size(kwds)) { PyErr_SetString(PyExc_TypeError, @@ -64,7 +64,7 @@ static PyObject *Euler_new(PyTypeObject *type, PyObject *args, PyObject *kwds) case 0: break; case 2: - if ((order=euler_order_from_string(order_str, "mathutils.Euler()")) == -1) + if ((order = euler_order_from_string(order_str, "mathutils.Euler()")) == -1) return NULL; /* intentionally pass through */ case 1: @@ -79,12 +79,12 @@ static PyObject *Euler_new(PyTypeObject *type, PyObject *args, PyObject *kwds) static const char *euler_order_str(EulerObject *self) { static const char order[][4] = {"XYZ", "XZY", "YXZ", "YZX", "ZXY", "ZYX"}; - return order[self->order-EULER_ORDER_XYZ]; + return order[self->order - EULER_ORDER_XYZ]; } short euler_order_from_string(const char *str, const char *error_prefix) { - if ((str[0] && str[1] && str[2] && str[3]=='\0')) { + if ((str[0] && str[1] && str[2] && str[3] == '\0')) { switch (*((PY_INT32_T *)str)) { case 'X'|'Y'<<8|'Z'<<16: return EULER_ORDER_XYZ; case 'X'|'Z'<<8|'Y'<<16: return EULER_ORDER_XZY; @@ -107,15 +107,15 @@ static PyObject *Euler_ToTupleExt(EulerObject *self, int ndigits) PyObject *ret; int i; - ret= PyTuple_New(EULER_SIZE); + ret = PyTuple_New(EULER_SIZE); if (ndigits >= 0) { - for (i= 0; i < EULER_SIZE; i++) { + for (i = 0; i < EULER_SIZE; i++) { PyTuple_SET_ITEM(ret, i, PyFloat_FromDouble(double_round((double)self->eul[i], ndigits))); } } else { - for (i= 0; i < EULER_SIZE; i++) { + for (i = 0; i < EULER_SIZE; i++) { PyTuple_SET_ITEM(ret, i, PyFloat_FromDouble(self->eul[i])); } } @@ -310,9 +310,9 @@ static PyObject *Euler_repr(EulerObject * self) if (BaseMath_ReadCallback(self) == -1) return NULL; - tuple= Euler_ToTupleExt(self, -1); + tuple = Euler_ToTupleExt(self, -1); - ret= PyUnicode_FromFormat("Euler(%R, '%s')", tuple, euler_order_str(self)); + ret = PyUnicode_FromFormat("Euler(%R, '%s')", tuple, euler_order_str(self)); Py_DECREF(tuple); return ret; @@ -325,7 +325,7 @@ static PyObject *Euler_str(EulerObject * self) if (BaseMath_ReadCallback(self) == -1) return NULL; - ds= BLI_dynstr_new(); + ds = BLI_dynstr_new(); BLI_dynstr_appendf(ds, "", self->eul[0], self->eul[1], self->eul[2], euler_order_str(self)); @@ -333,19 +333,19 @@ static PyObject *Euler_str(EulerObject * self) return mathutils_dynstr_to_py(ds); /* frees ds */ } -static PyObject* Euler_richcmpr(PyObject *a, PyObject *b, int op) +static PyObject *Euler_richcmpr(PyObject *a, PyObject *b, int op) { PyObject *res; - int ok= -1; /* zero is true */ + int ok = -1; /* zero is true */ if (EulerObject_Check(a) && EulerObject_Check(b)) { - EulerObject *eulA= (EulerObject*)a; - EulerObject *eulB= (EulerObject*)b; + EulerObject *eulA = (EulerObject *)a; + EulerObject *eulB = (EulerObject *)b; if (BaseMath_ReadCallback(eulA) == -1 || BaseMath_ReadCallback(eulB) == -1) return NULL; - ok= ((eulA->order == eulB->order) && EXPP_VectorsAreEqual(eulA->eul, eulB->eul, EULER_SIZE, 1)) ? 0 : -1; + ok = ((eulA->order == eulB->order) && EXPP_VectorsAreEqual(eulA->eul, eulB->eul, EULER_SIZE, 1)) ? 0 : -1; } switch (op) { @@ -380,7 +380,7 @@ static int Euler_len(EulerObject *UNUSED(self)) //sequence accessor (get) static PyObject *Euler_item(EulerObject * self, int i) { - if (i<0) i= EULER_SIZE-i; + if (i < 0) i = EULER_SIZE - i; if (i < 0 || i >= EULER_SIZE) { PyErr_SetString(PyExc_IndexError, @@ -408,7 +408,7 @@ static int Euler_ass_item(EulerObject * self, int i, PyObject *value) return -1; } - if (i<0) i= EULER_SIZE-i; + if (i < 0) i = EULER_SIZE - i; if (i < 0 || i >= EULER_SIZE) { PyErr_SetString(PyExc_IndexError, @@ -435,11 +435,11 @@ static PyObject *Euler_slice(EulerObject * self, int begin, int end) return NULL; CLAMP(begin, 0, EULER_SIZE); - if (end<0) end= (EULER_SIZE + 1) + end; + if (end < 0) end = (EULER_SIZE + 1) + end; CLAMP(end, 0, EULER_SIZE); - begin= MIN2(begin, end); + begin = MIN2(begin, end); - tuple= PyTuple_New(end - begin); + tuple = PyTuple_New(end - begin); for (count = begin; count < end; count++) { PyTuple_SET_ITEM(tuple, count - begin, PyFloat_FromDouble(self->eul[count])); } @@ -457,11 +457,11 @@ static int Euler_ass_slice(EulerObject *self, int begin, int end, PyObject *seq) return -1; CLAMP(begin, 0, EULER_SIZE); - if (end<0) end= (EULER_SIZE + 1) + end; + if (end < 0) end = (EULER_SIZE + 1) + end; CLAMP(end, 0, EULER_SIZE); begin = MIN2(begin, end); - if ((size=mathutils_array_parse(eul, 0, EULER_SIZE, seq, "mathutils.Euler[begin:end] = []")) == -1) + if ((size = mathutils_array_parse(eul, 0, EULER_SIZE, seq, "mathutils.Euler[begin:end] = []")) == -1) return -1; if (size != (end - begin)) { @@ -471,7 +471,7 @@ static int Euler_ass_slice(EulerObject *self, int begin, int end, PyObject *seq) return -1; } - for (i= 0; i < EULER_SIZE; i++) + for (i = 0; i < EULER_SIZE; i++) self->eul[begin + i] = eul[i]; (void)BaseMath_WriteCallback(self); @@ -592,13 +592,13 @@ static PyObject *Euler_order_get(EulerObject *self, void *UNUSED(closure)) static int Euler_order_set(EulerObject *self, PyObject *value, void *UNUSED(closure)) { - const char *order_str= _PyUnicode_AsString(value); - short order= euler_order_from_string(order_str, "euler.order"); + const char *order_str = _PyUnicode_AsString(value); + short order = euler_order_from_string(order_str, "euler.order"); if (order == -1) return -1; - self->order= order; + self->order = order; (void)BaseMath_WriteCallback(self); /* order can be written back */ return 0; } @@ -693,13 +693,13 @@ PyObject *Euler_CreatePyObject(float *eul, short order, int type, PyTypeObject * { EulerObject *self; - self= base_type ? (EulerObject *)base_type->tp_alloc(base_type, 0) : + self = base_type ? (EulerObject *)base_type->tp_alloc(base_type, 0) : (EulerObject *)PyObject_GC_New(EulerObject, &euler_Type); if (self) { /* init callbacks as NULL */ - self->cb_user= NULL; - self->cb_type= self->cb_subtype= 0; + self->cb_user = NULL; + self->cb_type = self->cb_subtype = 0; if (type == Py_WRAP) { self->eul = eul; @@ -720,7 +720,7 @@ PyObject *Euler_CreatePyObject(float *eul, short order, int type, PyTypeObject * Py_FatalError("Euler(): invalid type!"); } - self->order= order; + self->order = order; } return (PyObject *)self; @@ -728,12 +728,12 @@ PyObject *Euler_CreatePyObject(float *eul, short order, int type, PyTypeObject * PyObject *Euler_CreatePyObject_cb(PyObject *cb_user, short order, int cb_type, int cb_subtype) { - EulerObject *self= (EulerObject *)Euler_CreatePyObject(NULL, order, Py_NEW, NULL); + EulerObject *self = (EulerObject *)Euler_CreatePyObject(NULL, order, Py_NEW, NULL); if (self) { Py_INCREF(cb_user); - self->cb_user= cb_user; - self->cb_type= (unsigned char)cb_type; - self->cb_subtype= (unsigned char)cb_subtype; + self->cb_user = cb_user; + self->cb_type = (unsigned char)cb_type; + self->cb_subtype = (unsigned char)cb_subtype; PyObject_GC_Track(self); } diff --git a/source/blender/python/mathutils/mathutils_Euler.h b/source/blender/python/mathutils/mathutils_Euler.h index 130384a1792..c42b0daffbc 100644 --- a/source/blender/python/mathutils/mathutils_Euler.h +++ b/source/blender/python/mathutils/mathutils_Euler.h @@ -47,7 +47,7 @@ typedef struct { /*struct data contains a pointer to the actual data that the object uses. It can use either PyMem allocated data (which will be stored in py_data) or be a wrapper for data allocated through -blender (stored in blend_data). This is an either/or struct not both*/ +blender (stored in blend_data). This is an either/or struct not both */ //prototypes PyObject *Euler_CreatePyObject( float *eul, short order, int type, PyTypeObject *base_type); diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index 07abed20ec7..307c9f8ab73 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -49,23 +49,23 @@ static PyObject *matrix__apply_to_copy(PyNoArgsFunction matrix_func, MatrixObjec static PyObject *MatrixAccess_CreatePyObject(MatrixObject *matrix, const eMatrixAccess_t type); /* matrix row callbacks */ -int mathutils_matrix_row_cb_index= -1; +int mathutils_matrix_row_cb_index = -1; static int mathutils_matrix_vector_check(BaseMathObject *bmo) { - MatrixObject *self= (MatrixObject *)bmo->cb_user; + MatrixObject *self = (MatrixObject *)bmo->cb_user; return BaseMath_ReadCallback(self); } static int mathutils_matrix_vector_get(BaseMathObject *bmo, int row) { - MatrixObject *self= (MatrixObject *)bmo->cb_user; + MatrixObject *self = (MatrixObject *)bmo->cb_user; int col; if (BaseMath_ReadCallback(self) == -1) return -1; - for (col=0; col < self->num_col; col++) { + for (col = 0; col < self->num_col; col++) { bmo->data[col] = MATRIX_ITEM(self, row, col); } @@ -74,13 +74,13 @@ static int mathutils_matrix_vector_get(BaseMathObject *bmo, int row) static int mathutils_matrix_vector_set(BaseMathObject *bmo, int row) { - MatrixObject *self= (MatrixObject *)bmo->cb_user; + MatrixObject *self = (MatrixObject *)bmo->cb_user; int col; if (BaseMath_ReadCallback(self) == -1) return -1; - for (col=0; col < self->num_col; col++) { + for (col = 0; col < self->num_col; col++) { MATRIX_ITEM(self, row, col) = bmo->data[col]; } @@ -90,18 +90,18 @@ static int mathutils_matrix_vector_set(BaseMathObject *bmo, int row) static int mathutils_matrix_vector_get_index(BaseMathObject *bmo, int row, int col) { - MatrixObject *self= (MatrixObject *)bmo->cb_user; + MatrixObject *self = (MatrixObject *)bmo->cb_user; if (BaseMath_ReadCallback(self) == -1) return -1; - bmo->data[col]= MATRIX_ITEM(self, row, col); + bmo->data[col] = MATRIX_ITEM(self, row, col); return 0; } static int mathutils_matrix_vector_set_index(BaseMathObject *bmo, int row, int col) { - MatrixObject *self= (MatrixObject *)bmo->cb_user; + MatrixObject *self = (MatrixObject *)bmo->cb_user; if (BaseMath_ReadCallback(self) == -1) return -1; @@ -122,17 +122,17 @@ Mathutils_Callback mathutils_matrix_row_cb = { /* matrix vector callbacks, this is so you can do matrix[i][j] = val */ /* matrix row callbacks */ -int mathutils_matrix_col_cb_index= -1; +int mathutils_matrix_col_cb_index = -1; static int mathutils_matrix_column_check(BaseMathObject *bmo) { - MatrixObject *self= (MatrixObject *)bmo->cb_user; + MatrixObject *self = (MatrixObject *)bmo->cb_user; return BaseMath_ReadCallback(self); } static int mathutils_matrix_column_get(BaseMathObject *bmo, int col) { - MatrixObject *self= (MatrixObject *)bmo->cb_user; + MatrixObject *self = (MatrixObject *)bmo->cb_user; int num_row; int row; @@ -151,7 +151,7 @@ static int mathutils_matrix_column_get(BaseMathObject *bmo, int col) static int mathutils_matrix_column_set(BaseMathObject *bmo, int col) { - MatrixObject *self= (MatrixObject *)bmo->cb_user; + MatrixObject *self = (MatrixObject *)bmo->cb_user; int num_row; int row; @@ -171,18 +171,18 @@ static int mathutils_matrix_column_set(BaseMathObject *bmo, int col) static int mathutils_matrix_column_get_index(BaseMathObject *bmo, int col, int row) { - MatrixObject *self= (MatrixObject *)bmo->cb_user; + MatrixObject *self = (MatrixObject *)bmo->cb_user; if (BaseMath_ReadCallback(self) == -1) return -1; - bmo->data[row]= MATRIX_ITEM(self, row, col); + bmo->data[row] = MATRIX_ITEM(self, row, col); return 0; } static int mathutils_matrix_column_set_index(BaseMathObject *bmo, int col, int row) { - MatrixObject *self= (MatrixObject *)bmo->cb_user; + MatrixObject *self = (MatrixObject *)bmo->cb_user; if (BaseMath_ReadCallback(self) == -1) return -1; @@ -219,23 +219,23 @@ static PyObject *Matrix_new(PyTypeObject *type, PyObject *args, PyObject *kwds) return Matrix_CreatePyObject(NULL, 4, 4, Py_NEW, type); case 1: { - PyObject *arg= PyTuple_GET_ITEM(args, 0); + PyObject *arg = PyTuple_GET_ITEM(args, 0); /* Input is now as a sequence of rows so length of sequence * is the number of rows */ /* -1 is an error, size checks will accunt for this */ - const unsigned short num_row= PySequence_Size(arg); + const unsigned short num_row = PySequence_Size(arg); if (num_row >= 2 && num_row <= 4) { - PyObject *item= PySequence_GetItem(arg, 0); + PyObject *item = PySequence_GetItem(arg, 0); /* Since each item is a row, number of items is the * same as the number of columns */ - const unsigned short num_col= PySequence_Size(item); + const unsigned short num_col = PySequence_Size(item); Py_XDECREF(item); if (num_col >= 2 && num_col <= 4) { /* sane row & col size, new matrix and assign as slice */ - PyObject *matrix= Matrix_CreatePyObject(NULL, num_col, num_row, Py_NEW, type); + PyObject *matrix = Matrix_CreatePyObject(NULL, num_col, num_row, Py_NEW, type); if (Matrix_ass_slice((MatrixObject *)matrix, 0, INT_MAX, arg) == 0) { return matrix; } @@ -256,8 +256,8 @@ static PyObject *Matrix_new(PyTypeObject *type, PyObject *args, PyObject *kwds) static PyObject *matrix__apply_to_copy(PyNoArgsFunction matrix_func, MatrixObject *self) { - PyObject *ret= Matrix_copy(self); - PyObject *ret_dummy= matrix_func(ret); + PyObject *ret = Matrix_copy(self); + PyObject *ret_dummy = matrix_func(ret); if (ret_dummy) { Py_DECREF(ret_dummy); return (PyObject *)ret; @@ -301,8 +301,8 @@ PyDoc_STRVAR(C_Matrix_Rotation_doc, ); static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args) { - PyObject *vec= NULL; - const char *axis= NULL; + PyObject *vec = NULL; + const char *axis = NULL; int matSize; double angle; /* use double because of precision problems at high values */ float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, @@ -316,8 +316,8 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args) } if (vec && PyUnicode_Check(vec)) { - axis= _PyUnicode_AsString((PyObject *)vec); - if (axis==NULL || axis[0]=='\0' || axis[1]!='\0' || axis[0] < 'X' || axis[0] > 'Z') { + axis = _PyUnicode_AsString((PyObject *)vec); + if (axis == NULL || axis[0] == '\0' || axis[1] != '\0' || axis[0] < 'X' || axis[0] > 'Z') { PyErr_SetString(PyExc_ValueError, "Matrix.Rotation(): " "3rd argument axis value must be a 3D vector " @@ -326,11 +326,11 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args) } else { /* use the string */ - vec= NULL; + vec = NULL; } } - angle= angle_wrap_rad(angle); + angle = angle_wrap_rad(angle); if (matSize != 2 && matSize != 3 && matSize != 4) { PyErr_SetString(PyExc_ValueError, @@ -361,8 +361,8 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args) axis_angle_to_mat3((float (*)[3])mat, tvec, angle); } else if (matSize == 2) { - const float angle_cos= cosf(angle); - const float angle_sin= sinf(angle); + const float angle_cos = cosf(angle); + const float angle_sin = sinf(angle); //2D rotation matrix mat[0] = angle_cos; @@ -420,7 +420,7 @@ PyDoc_STRVAR(C_Matrix_Scale_doc, ); static PyObject *C_Matrix_Scale(PyObject *cls, PyObject *args) { - PyObject *vec= NULL; + PyObject *vec = NULL; int vec_size; float tvec[3]; float factor; @@ -438,7 +438,7 @@ static PyObject *C_Matrix_Scale(PyObject *cls, PyObject *args) return NULL; } if (vec) { - vec_size= (matSize == 2 ? 2 : 3); + vec_size = (matSize == 2 ? 2 : 3); if (mathutils_array_parse(tvec, vec_size, vec_size, vec, "Matrix.Scale(factor, size, axis), invalid 'axis' arg") == -1) { return NULL; } @@ -526,13 +526,13 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args) if (PyUnicode_Check(axis)) { //ortho projection onto cardinal plane Py_ssize_t plane_len; - const char *plane= _PyUnicode_AsStringAndSize(axis, &plane_len); + const char *plane = _PyUnicode_AsStringAndSize(axis, &plane_len); if (matSize == 2) { - if (plane_len == 1 && plane[0]=='X') { - mat[0]= 1.0f; + if (plane_len == 1 && plane[0] == 'X') { + mat[0] = 1.0f; } - else if (plane_len == 1 && plane[0]=='Y') { - mat[3]= 1.0f; + else if (plane_len == 1 && plane[0] == 'Y') { + mat[3] = 1.0f; } else { PyErr_Format(PyExc_ValueError, @@ -543,17 +543,17 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args) } } else { - if (plane_len == 2 && plane[0]=='X' && plane[1]=='Y') { - mat[0]= 1.0f; - mat[4]= 1.0f; + if (plane_len == 2 && plane[0] == 'X' && plane[1] == 'Y') { + mat[0] = 1.0f; + mat[4] = 1.0f; } - else if (plane_len == 2 && plane[0]=='X' && plane[1]=='Z') { - mat[0]= 1.0f; - mat[8]= 1.0f; + else if (plane_len == 2 && plane[0] == 'X' && plane[1] == 'Z') { + mat[0] = 1.0f; + mat[8] = 1.0f; } - else if (plane_len == 2 && plane[0]=='Y' && plane[1]=='Z') { - mat[4]= 1.0f; - mat[8]= 1.0f; + else if (plane_len == 2 && plane[0] == 'Y' && plane[1] == 'Z') { + mat[4] = 1.0f; + mat[8] = 1.0f; } else { PyErr_Format(PyExc_ValueError, @@ -567,7 +567,7 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args) else { //arbitrary plane - int vec_size= (matSize == 2 ? 2 : 3); + int vec_size = (matSize == 2 ? 2 : 3); float tvec[4]; if (mathutils_array_parse(tvec, vec_size, vec_size, axis, @@ -644,9 +644,9 @@ static PyObject *C_Matrix_Shear(PyObject *cls, PyObject *args) } if (matSize == 2) { - float const factor= PyFloat_AsDouble(fac); + float const factor = PyFloat_AsDouble(fac); - if (factor==-1.0f && PyErr_Occurred()) { + if (factor == -1.0f && PyErr_Occurred()) { PyErr_SetString(PyExc_TypeError, "Matrix.Shear(): " "the factor to be a float"); @@ -751,7 +751,7 @@ static PyObject *Matrix_to_quaternion(MatrixObject *self) if (BaseMath_ReadCallback(self) == -1) return NULL; - /*must be 3-4 cols, 3-4 rows, square matrix*/ + /* must be 3-4 cols, 3-4 rows, square matrix */ if ((self->num_row < 3) || (self->num_col < 3) || (self->num_row != self->num_col)) { PyErr_SetString(PyExc_ValueError, "Matrix.to_quat(): " @@ -787,8 +787,8 @@ PyDoc_STRVAR(Matrix_to_euler_doc, ); static PyObject *Matrix_to_euler(MatrixObject *self, PyObject *args) { - const char *order_str= NULL; - short order= EULER_ORDER_XYZ; + const char *order_str = NULL; + short order = EULER_ORDER_XYZ; float eul[3], eul_compatf[3]; EulerObject *eul_compat = NULL; @@ -808,13 +808,13 @@ static PyObject *Matrix_to_euler(MatrixObject *self, PyObject *args) copy_v3_v3(eul_compatf, eul_compat->eul); } - /*must be 3-4 cols, 3-4 rows, square matrix*/ + /*must be 3-4 cols, 3-4 rows, square matrix */ if (self->num_row ==3 && self->num_col ==3) { - mat= (float (*)[3])self->matrix; + mat = (float (*)[3])self->matrix; } else if (self->num_row ==4 && self->num_col ==4) { copy_m3_m4(tmat, (float (*)[4])self->matrix); - mat= tmat; + mat = tmat; } else { PyErr_SetString(PyExc_ValueError, @@ -824,7 +824,7 @@ static PyObject *Matrix_to_euler(MatrixObject *self, PyObject *args) } if (order_str) { - order= euler_order_from_string(order_str, "Matrix.to_euler()"); + order = euler_order_from_string(order_str, "Matrix.to_euler()"); if (order == -1) return NULL; @@ -849,10 +849,10 @@ PyDoc_STRVAR(Matrix_resize_4x4_doc, ); static PyObject *Matrix_resize_4x4(MatrixObject *self) { - float mat[4][4]= MAT4_UNITY; + float mat[4][4] = MAT4_UNITY; int col; - if (self->wrapped==Py_WRAP) { + if (self->wrapped == Py_WRAP) { PyErr_SetString(PyExc_TypeError, "Matrix.resize_4x4(): " "cannot resize wrapped data - make a copy and resize that"); @@ -898,10 +898,10 @@ static PyObject *Matrix_to_4x4(MatrixObject *self) if (BaseMath_ReadCallback(self) == -1) return NULL; - if (self->num_row==4 && self->num_col==4) { + if (self->num_row == 4 && self->num_col == 4) { return Matrix_CreatePyObject(self->matrix, 4, 4, Py_NEW, Py_TYPE(self)); } - else if (self->num_row==3 && self->num_col==3) { + else if (self->num_row == 3 && self->num_col == 3) { float mat[4][4]; copy_m4_m3(mat, (float (*)[3])self->matrix); return Matrix_CreatePyObject((float *)mat, 4, 4, Py_NEW, Py_TYPE(self)); @@ -982,7 +982,7 @@ static PyObject *Matrix_to_scale(MatrixObject *self) if (BaseMath_ReadCallback(self) == -1) return NULL; - /*must be 3-4 cols, 3-4 rows, square matrix*/ + /*must be 3-4 cols, 3-4 rows, square matrix */ if ((self->num_row < 3) || (self->num_col < 3)) { PyErr_SetString(PyExc_TypeError, "Matrix.to_scale(): " @@ -1028,11 +1028,11 @@ static PyObject *Matrix_invert(MatrixObject *self) return NULL; } - /*calculate the determinant*/ + /* calculate the determinant */ det = matrix_determinant_internal(self); if (det != 0) { - /*calculate the classical adjoint*/ + /* calculate the classical adjoint */ if (self->num_col == 2) { mat[0] = MATRIX_ITEM(self, 1, 1); mat[1] = -MATRIX_ITEM(self, 0, 1); @@ -1045,11 +1045,11 @@ static PyObject *Matrix_invert(MatrixObject *self) else if (self->num_col == 4) { adjoint_m4_m4((float (*)[4]) mat, (float (*)[4])self->matrix); } - /*divide by determinate*/ + /* divide by determinate */ for (x = 0; x < (self->num_col * self->num_row); x++) { mat[x] /= det; } - /*set values*/ + /* set values */ for (x = 0; x < self->num_col; x++) { for (y = 0; y < self->num_row; y++) { MATRIX_ITEM(self, y, x) = mat[z]; @@ -1151,7 +1151,7 @@ static PyObject *Matrix_decompose(MatrixObject *self) mat4_to_loc_rot_size(loc, rot, size, (float (*)[4])self->matrix); mat3_to_quat(quat, rot); - ret= PyTuple_New(3); + ret = PyTuple_New(3); PyTuple_SET_ITEM(ret, 0, Vector_CreatePyObject(loc, 3, Py_NEW, NULL)); PyTuple_SET_ITEM(ret, 1, Quaternion_CreatePyObject(quat, Py_NEW, NULL)); PyTuple_SET_ITEM(ret, 2, Vector_CreatePyObject(size, 3, Py_NEW, NULL)); @@ -1176,7 +1176,7 @@ PyDoc_STRVAR(Matrix_lerp_doc, static PyObject *Matrix_lerp(MatrixObject *self, PyObject *args) { MatrixObject *mat2 = NULL; - float fac, mat[MATRIX_MAX_DIM*MATRIX_MAX_DIM]; + float fac, mat[MATRIX_MAX_DIM * MATRIX_MAX_DIM]; if (!PyArg_ParseTuple(args, "O!f:lerp", &matrix_Type, &mat2, &fac)) return NULL; @@ -1192,10 +1192,10 @@ static PyObject *Matrix_lerp(MatrixObject *self, PyObject *args) return NULL; /* TODO, different sized matrix */ - if (self->num_col==4 && self->num_row==4) { + if (self->num_col == 4 && self->num_row == 4) { blend_m4_m4m4((float (*)[4])mat, (float (*)[4])self->matrix, (float (*)[4])mat2->matrix, fac); } - else if (self->num_col==3 && self->num_row==3) { + else if (self->num_col == 3 && self->num_row == 3) { blend_m3_m3m3((float (*)[3])mat, (float (*)[3])self->matrix, (float (*)[3])mat2->matrix, fac); } else { @@ -1360,17 +1360,17 @@ static PyObject *Matrix_copy(MatrixObject *self) } /*----------------------------print object (internal)-------------*/ -/*print the object to screen*/ +/* print the object to screen */ static PyObject *Matrix_repr(MatrixObject *self) { int col, row; - PyObject *rows[MATRIX_MAX_DIM]= {NULL}; + PyObject *rows[MATRIX_MAX_DIM] = {NULL}; if (BaseMath_ReadCallback(self) == -1) return NULL; for (row = 0; row < self->num_row; row++) { - rows[row]= PyTuple_New(self->num_col); + rows[row] = PyTuple_New(self->num_col); for (col = 0; col < self->num_col; col++) { PyTuple_SET_ITEM(rows[row], col, PyFloat_FromDouble(MATRIX_ITEM(self, row, col))); } @@ -1393,7 +1393,7 @@ static PyObject *Matrix_repr(MatrixObject *self) return NULL; } -static PyObject* Matrix_str(MatrixObject *self) +static PyObject *Matrix_str(MatrixObject *self) { DynStr *ds; @@ -1405,14 +1405,14 @@ static PyObject* Matrix_str(MatrixObject *self) if (BaseMath_ReadCallback(self) == -1) return NULL; - ds= BLI_dynstr_new(); + ds = BLI_dynstr_new(); /* First determine the maximum width for each column */ for (col = 0; col < self->num_col; col++) { - maxsize[col]= 0; + maxsize[col] = 0; for (row = 0; row < self->num_row; row++) { - int size= BLI_snprintf(dummy_buf, sizeof(dummy_buf), "%.4f", MATRIX_ITEM(self, row, col)); - maxsize[col]= MAX2(maxsize[col], size); + int size = BLI_snprintf(dummy_buf, sizeof(dummy_buf), "%.4f", MATRIX_ITEM(self, row, col)); + maxsize[col] = MAX2(maxsize[col], size); } } @@ -1429,21 +1429,21 @@ static PyObject* Matrix_str(MatrixObject *self) return mathutils_dynstr_to_py(ds); /* frees ds */ } -static PyObject* Matrix_richcmpr(PyObject *a, PyObject *b, int op) +static PyObject *Matrix_richcmpr(PyObject *a, PyObject *b, int op) { PyObject *res; - int ok= -1; /* zero is true */ + int ok = -1; /* zero is true */ if (MatrixObject_Check(a) && MatrixObject_Check(b)) { - MatrixObject *matA= (MatrixObject*)a; - MatrixObject *matB= (MatrixObject*)b; + MatrixObject *matA = (MatrixObject *)a; + MatrixObject *matB = (MatrixObject *)b; if (BaseMath_ReadCallback(matA) == -1 || BaseMath_ReadCallback(matB) == -1) return NULL; - ok= ( (matA->num_row == matB->num_row) && - (matA->num_col == matB->num_col) && - EXPP_VectorsAreEqual(matA->matrix, matB->matrix, (matA->num_col * matA->num_row), 1) + ok = ( (matA->num_row == matB->num_row) && + (matA->num_col == matB->num_col) && + EXPP_VectorsAreEqual(matA->matrix, matB->matrix, (matA->num_col * matA->num_row), 1) ) ? 0 : -1; } @@ -1470,14 +1470,14 @@ static PyObject* Matrix_richcmpr(PyObject *a, PyObject *b, int op) /*---------------------SEQUENCE PROTOCOLS------------------------ ----------------------------len(object)------------------------ - sequence length*/ + sequence length */ static int Matrix_len(MatrixObject *self) { return (self->num_row); } /*----------------------------object[]--------------------------- sequence accessor (get) - the wrapped vector gives direct access to the matrix data*/ + the wrapped vector gives direct access to the matrix data */ static PyObject *Matrix_item_row(MatrixObject *self, int row) { if (BaseMath_ReadCallback(self) == -1) @@ -1574,10 +1574,10 @@ static PyObject *Matrix_slice(MatrixObject *self, int begin, int end) CLAMP(begin, 0, self->num_row); CLAMP(end, 0, self->num_row); - begin= MIN2(begin, end); + begin = MIN2(begin, end); - tuple= PyTuple_New(end - begin); - for (count= begin; count < end; count++) { + tuple = PyTuple_New(end - begin); + for (count = begin; count < end; count++) { PyTuple_SET_ITEM(tuple, count - begin, Vector_CreatePyObject_cb((PyObject *)self, self->num_col, mathutils_matrix_row_cb_index, count)); @@ -1589,7 +1589,7 @@ static PyObject *Matrix_slice(MatrixObject *self, int begin, int end) sequence slice (set)*/ static int Matrix_ass_slice(MatrixObject *self, int begin, int end, PyObject *value) { - PyObject *value_fast= NULL; + PyObject *value_fast = NULL; if (BaseMath_ReadCallback(self) == -1) return -1; @@ -1599,12 +1599,12 @@ static int Matrix_ass_slice(MatrixObject *self, int begin, int end, PyObject *va begin = MIN2(begin, end); /* non list/tuple cases */ - if (!(value_fast=PySequence_Fast(value, "matrix[begin:end] = value"))) { + if (!(value_fast = PySequence_Fast(value, "matrix[begin:end] = value"))) { /* PySequence_Fast sets the error */ return -1; } else { - const int size= end - begin; + const int size = end - begin; int row, col; float mat[16]; float vec[4]; @@ -1619,10 +1619,10 @@ static int Matrix_ass_slice(MatrixObject *self, int begin, int end, PyObject *va memcpy(mat, self->matrix, self->num_col * self->num_row * sizeof(float)); - /*parse sub items*/ + /* parse sub items */ for (row = begin; row < end; row++) { - /*parse each sub sequence*/ - PyObject *item= PySequence_Fast_GET_ITEM(value_fast, row - begin); + /* parse each sub sequence */ + PyObject *item = PySequence_Fast_GET_ITEM(value_fast, row - begin); if (mathutils_array_parse(vec, self->num_col, self->num_col, item, "matrix[begin:end] = value assignment") < 0) return -1; @@ -1648,8 +1648,8 @@ static PyObject *Matrix_add(PyObject *m1, PyObject *m2) float mat[16]; MatrixObject *mat1 = NULL, *mat2 = NULL; - mat1 = (MatrixObject*)m1; - mat2 = (MatrixObject*)m2; + mat1 = (MatrixObject *)m1; + mat2 = (MatrixObject *)m2; if (!MatrixObject_Check(m1) || !MatrixObject_Check(m2)) { PyErr_Format(PyExc_TypeError, @@ -1680,8 +1680,8 @@ static PyObject *Matrix_sub(PyObject *m1, PyObject *m2) float mat[16]; MatrixObject *mat1 = NULL, *mat2 = NULL; - mat1 = (MatrixObject*)m1; - mat2 = (MatrixObject*)m2; + mat1 = (MatrixObject *)m1; + mat2 = (MatrixObject *)m2; if (!MatrixObject_Check(m1) || !MatrixObject_Check(m2)) { PyErr_Format(PyExc_TypeError, @@ -1723,22 +1723,22 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2) MatrixObject *mat1 = NULL, *mat2 = NULL; if (MatrixObject_Check(m1)) { - mat1 = (MatrixObject*)m1; + mat1 = (MatrixObject *)m1; if (BaseMath_ReadCallback(mat1) == -1) return NULL; } if (MatrixObject_Check(m2)) { - mat2 = (MatrixObject*)m2; + mat2 = (MatrixObject *)m2; if (BaseMath_ReadCallback(mat2) == -1) return NULL; } if (mat1 && mat2) { - /*MATRIX * MATRIX*/ - float mat[16]= {0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f}; + /* MATRIX * MATRIX */ + float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; double dot = 0.0f; int col, row, item; @@ -1763,14 +1763,14 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2) } else if (mat2) { /*FLOAT/INT * MATRIX */ - if (((scalar= PyFloat_AsDouble(m1)) == -1.0f && PyErr_Occurred())==0) { + if (((scalar = PyFloat_AsDouble(m1)) == -1.0f && PyErr_Occurred()) == 0) { return matrix_mul_float(mat2, scalar); } } else if (mat1) { /* MATRIX * VECTOR */ if (VectorObject_Check(m2)) { - VectorObject *vec2= (VectorObject *)m2; + VectorObject *vec2 = (VectorObject *)m2; float tvec[4]; if (BaseMath_ReadCallback(vec2) == -1) return NULL; @@ -1788,7 +1788,7 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2) return Vector_CreatePyObject(tvec, vec_size, Py_NEW, Py_TYPE(m2)); } /*FLOAT/INT * MATRIX */ - else if (((scalar= PyFloat_AsDouble(m2)) == -1.0f && PyErr_Occurred())==0) { + else if (((scalar = PyFloat_AsDouble(m2)) == -1.0f && PyErr_Occurred()) == 0) { return matrix_mul_float(mat1, scalar); } } @@ -1802,7 +1802,7 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2) Py_TYPE(m1)->tp_name, Py_TYPE(m2)->tp_name); return NULL; } -static PyObject* Matrix_inv(MatrixObject *self) +static PyObject *Matrix_inv(MatrixObject *self) { if (BaseMath_ReadCallback(self) == -1) return NULL; @@ -1825,7 +1825,7 @@ static PySequenceMethods Matrix_SeqMethods = { }; -static PyObject *Matrix_subscript(MatrixObject* self, PyObject* item) +static PyObject *Matrix_subscript(MatrixObject *self, PyObject *item) { if (PyIndex_Check(item)) { Py_ssize_t i; @@ -1862,7 +1862,7 @@ static PyObject *Matrix_subscript(MatrixObject* self, PyObject* item) } } -static int Matrix_ass_subscript(MatrixObject* self, PyObject* item, PyObject* value) +static int Matrix_ass_subscript(MatrixObject *self, PyObject *item, PyObject *value) { if (PyIndex_Check(item)) { Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError); @@ -2188,16 +2188,16 @@ PyObject *Matrix_CreatePyObject(float *mat, return NULL; } - self= base_type ? (MatrixObject *)base_type->tp_alloc(base_type, 0) : - (MatrixObject *)PyObject_GC_New(MatrixObject, &matrix_Type); + self = base_type ? (MatrixObject *)base_type->tp_alloc(base_type, 0) : + (MatrixObject *)PyObject_GC_New(MatrixObject, &matrix_Type); if (self) { self->num_col = num_col; self->num_row = num_row; /* init callbacks as NULL */ - self->cb_user= NULL; - self->cb_type= self->cb_subtype= 0; + self->cb_user = NULL; + self->cb_type = self->cb_subtype = 0; if (type == Py_WRAP) { self->matrix = mat; @@ -2217,7 +2217,7 @@ PyObject *Matrix_CreatePyObject(float *mat, } else if (num_col == num_row) { /* or if no arguments are passed return identity matrix for square matrices */ - PyObject *ret_dummy= Matrix_identity(self); + PyObject *ret_dummy = Matrix_identity(self); Py_DECREF(ret_dummy); } else { @@ -2238,12 +2238,12 @@ PyObject *Matrix_CreatePyObject_cb(PyObject *cb_user, const unsigned short num_col, const unsigned short num_row, int cb_type, int cb_subtype) { - MatrixObject *self= (MatrixObject *)Matrix_CreatePyObject(NULL, num_col, num_row, Py_NEW, NULL); + MatrixObject *self = (MatrixObject *)Matrix_CreatePyObject(NULL, num_col, num_row, Py_NEW, NULL); if (self) { Py_INCREF(cb_user); - self->cb_user= cb_user; - self->cb_type= (unsigned char)cb_type; - self->cb_subtype= (unsigned char)cb_subtype; + self->cb_user = cb_user; + self->cb_type = (unsigned char)cb_type; + self->cb_subtype = (unsigned char)cb_subtype; PyObject_GC_Track(self); } return (PyObject *) self; @@ -2290,9 +2290,9 @@ static int MatrixAccess_len(MatrixAccessObject *self) self->matrix_user->num_col; } -static PyObject *MatrixAccess_subscript(MatrixAccessObject* self, PyObject* item) +static PyObject *MatrixAccess_subscript(MatrixAccessObject *self, PyObject *item) { - MatrixObject *matrix_user= self->matrix_user; + MatrixObject *matrix_user = self->matrix_user; if (PyIndex_Check(item)) { Py_ssize_t i; @@ -2319,9 +2319,9 @@ static PyObject *MatrixAccess_subscript(MatrixAccessObject* self, PyObject* item } } -static int MatrixAccess_ass_subscript(MatrixAccessObject* self, PyObject* item, PyObject* value) +static int MatrixAccess_ass_subscript(MatrixAccessObject *self, PyObject *item, PyObject *value) { - MatrixObject *matrix_user= self->matrix_user; + MatrixObject *matrix_user = self->matrix_user; if (PyIndex_Check(item)) { Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError); @@ -2385,12 +2385,12 @@ PyTypeObject matrix_access_Type = { static PyObject *MatrixAccess_CreatePyObject(MatrixObject *matrix, const eMatrixAccess_t type) { - MatrixAccessObject *matrix_access= (MatrixAccessObject *)PyObject_GC_New(MatrixObject, &matrix_access_Type); + MatrixAccessObject *matrix_access = (MatrixAccessObject *)PyObject_GC_New(MatrixObject, &matrix_access_Type); - matrix_access->matrix_user= matrix; + matrix_access->matrix_user = matrix; Py_INCREF(matrix); - matrix_access->type= type; + matrix_access->type = type; return (PyObject *)matrix_access; } diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c b/source/blender/python/mathutils/mathutils_Quaternion.c index 2dd266d83fb..a563e280f1c 100644 --- a/source/blender/python/mathutils/mathutils_Quaternion.c +++ b/source/blender/python/mathutils/mathutils_Quaternion.c @@ -51,15 +51,15 @@ static PyObject *Quaternion_to_tuple_ext(QuaternionObject *self, int ndigits) PyObject *ret; int i; - ret= PyTuple_New(QUAT_SIZE); + ret = PyTuple_New(QUAT_SIZE); if (ndigits >= 0) { - for (i= 0; i < QUAT_SIZE; i++) { + for (i = 0; i < QUAT_SIZE; i++) { PyTuple_SET_ITEM(ret, i, PyFloat_FromDouble(double_round((double)self->quat[i], ndigits))); } } else { - for (i= 0; i < QUAT_SIZE; i++) { + for (i = 0; i < QUAT_SIZE; i++) { PyTuple_SET_ITEM(ret, i, PyFloat_FromDouble(self->quat[i])); } } @@ -86,8 +86,8 @@ static PyObject *Quaternion_to_euler(QuaternionObject *self, PyObject *args) { float tquat[4]; float eul[3]; - const char *order_str= NULL; - short order= EULER_ORDER_XYZ; + const char *order_str = NULL; + short order = EULER_ORDER_XYZ; EulerObject *eul_compat = NULL; if (!PyArg_ParseTuple(args, "|sO!:to_euler", &order_str, &euler_Type, &eul_compat)) @@ -97,7 +97,7 @@ static PyObject *Quaternion_to_euler(QuaternionObject *self, PyObject *args) return NULL; if (order_str) { - order= euler_order_from_string(order_str, "Matrix.to_euler()"); + order = euler_order_from_string(order_str, "Matrix.to_euler()"); if (order == -1) return NULL; @@ -169,7 +169,7 @@ static PyObject *Quaternion_to_axis_angle(QuaternionObject *self) quat__axis_angle_sanitize(axis, &angle); - ret= PyTuple_New(2); + ret = PyTuple_New(2); PyTuple_SET_ITEM(ret, 0, Vector_CreatePyObject(axis, 3, Py_NEW, NULL)); PyTuple_SET_ITEM(ret, 1, PyFloat_FromDouble(angle)); return ret; @@ -320,7 +320,7 @@ static PyObject *Quaternion_rotate(QuaternionObject *self, PyObject *value) if (mathutils_any_to_rotmat(other_rmat, value, "Quaternion.rotate(value)") == -1) return NULL; - length= normalize_qt_qt(tquat, self->quat); + length = normalize_qt_qt(tquat, self->quat); quat_to_mat3(self_rmat, tquat); mul_m3_m3m3(rmat, other_rmat, self_rmat); @@ -486,9 +486,9 @@ static PyObject *Quaternion_repr(QuaternionObject *self) if (BaseMath_ReadCallback(self) == -1) return NULL; - tuple= Quaternion_to_tuple_ext(self, -1); + tuple = Quaternion_to_tuple_ext(self, -1); - ret= PyUnicode_FromFormat("Quaternion(%R)", tuple); + ret = PyUnicode_FromFormat("Quaternion(%R)", tuple); Py_DECREF(tuple); return ret; @@ -501,7 +501,7 @@ static PyObject *Quaternion_str(QuaternionObject *self) if (BaseMath_ReadCallback(self) == -1) return NULL; - ds= BLI_dynstr_new(); + ds = BLI_dynstr_new(); BLI_dynstr_appendf(ds, "", self->quat[0], self->quat[1], self->quat[2], self->quat[3]); @@ -509,19 +509,19 @@ static PyObject *Quaternion_str(QuaternionObject *self) return mathutils_dynstr_to_py(ds); /* frees ds */ } -static PyObject* Quaternion_richcmpr(PyObject *a, PyObject *b, int op) +static PyObject *Quaternion_richcmpr(PyObject *a, PyObject *b, int op) { PyObject *res; - int ok= -1; /* zero is true */ + int ok = -1; /* zero is true */ if (QuaternionObject_Check(a) && QuaternionObject_Check(b)) { - QuaternionObject *quatA= (QuaternionObject *)a; - QuaternionObject *quatB= (QuaternionObject *)b; + QuaternionObject *quatA = (QuaternionObject *)a; + QuaternionObject *quatB = (QuaternionObject *)b; if (BaseMath_ReadCallback(quatA) == -1 || BaseMath_ReadCallback(quatB) == -1) return NULL; - ok= (EXPP_VectorsAreEqual(quatA->quat, quatB->quat, QUAT_SIZE, 1)) ? 0 : -1; + ok = (EXPP_VectorsAreEqual(quatA->quat, quatB->quat, QUAT_SIZE, 1)) ? 0 : -1; } switch (op) { @@ -556,7 +556,7 @@ static int Quaternion_len(QuaternionObject *UNUSED(self)) //sequence accessor (get) static PyObject *Quaternion_item(QuaternionObject *self, int i) { - if (i<0) i= QUAT_SIZE-i; + if (i < 0) i = QUAT_SIZE-i; if (i < 0 || i >= QUAT_SIZE) { PyErr_SetString(PyExc_IndexError, @@ -575,15 +575,15 @@ static PyObject *Quaternion_item(QuaternionObject *self, int i) //sequence accessor (set) static int Quaternion_ass_item(QuaternionObject *self, int i, PyObject *ob) { - float scalar= (float)PyFloat_AsDouble(ob); - if (scalar==-1.0f && PyErr_Occurred()) { /* parsed item not a number */ + float scalar = (float)PyFloat_AsDouble(ob); + if (scalar == -1.0f && PyErr_Occurred()) { /* parsed item not a number */ PyErr_SetString(PyExc_TypeError, "quaternion[index] = x: " "index argument not a number"); return -1; } - if (i<0) i= QUAT_SIZE-i; + if (i < 0) i = QUAT_SIZE-i; if (i < 0 || i >= QUAT_SIZE) { PyErr_SetString(PyExc_IndexError, @@ -609,12 +609,12 @@ static PyObject *Quaternion_slice(QuaternionObject *self, int begin, int end) return NULL; CLAMP(begin, 0, QUAT_SIZE); - if (end<0) end= (QUAT_SIZE + 1) + end; + if (end < 0) end = (QUAT_SIZE + 1) + end; CLAMP(end, 0, QUAT_SIZE); - begin= MIN2(begin, end); + begin = MIN2(begin, end); - tuple= PyTuple_New(end - begin); - for (count= begin; count < end; count++) { + tuple = PyTuple_New(end - begin); + for (count = begin; count < end; count++) { PyTuple_SET_ITEM(tuple, count - begin, PyFloat_FromDouble(self->quat[count])); } @@ -631,11 +631,11 @@ static int Quaternion_ass_slice(QuaternionObject *self, int begin, int end, PyOb return -1; CLAMP(begin, 0, QUAT_SIZE); - if (end<0) end= (QUAT_SIZE + 1) + end; + if (end < 0) end = (QUAT_SIZE + 1) + end; CLAMP(end, 0, QUAT_SIZE); begin = MIN2(begin, end); - if ((size=mathutils_array_parse(quat, 0, QUAT_SIZE, seq, "mathutils.Quaternion[begin:end] = []")) == -1) + if ((size = mathutils_array_parse(quat, 0, QUAT_SIZE, seq, "mathutils.Quaternion[begin:end] = []")) == -1) return -1; if (size != (end - begin)) { @@ -646,7 +646,7 @@ static int Quaternion_ass_slice(QuaternionObject *self, int begin, int end, PyOb } /* parsed well - now set in vector */ - for (i= 0; i < size; i++) + for (i = 0; i < size; i++) self->quat[begin + i] = quat[i]; (void)BaseMath_WriteCallback(self); @@ -809,7 +809,7 @@ static PyObject *Quaternion_mul(PyObject *q1, PyObject *q2) } /* the only case this can happen (for a supported type is "FLOAT*QUAT") */ else if (quat2) { /* FLOAT*QUAT */ - if (((scalar= PyFloat_AsDouble(q1)) == -1.0f && PyErr_Occurred())==0) { + if (((scalar = PyFloat_AsDouble(q1)) == -1.0f && PyErr_Occurred()) == 0) { return quat_mul_float(quat2, scalar); } } @@ -836,7 +836,7 @@ static PyObject *Quaternion_mul(PyObject *q1, PyObject *q2) return Vector_CreatePyObject(tvec, 3, Py_NEW, Py_TYPE(vec2)); } /* QUAT * FLOAT */ - else if ((((scalar= PyFloat_AsDouble(q2)) == -1.0f && PyErr_Occurred())==0)) { + else if ((((scalar = PyFloat_AsDouble(q2)) == -1.0f && PyErr_Occurred()) == 0)) { return quat_mul_float(quat1, scalar); } } @@ -950,7 +950,7 @@ static PyObject *Quaternion_angle_get(QuaternionObject *self, void *UNUSED(closu normalize_qt_qt(tquat, self->quat); - angle= 2.0f * saacos(tquat[0]); + angle = 2.0f * saacos(tquat[0]); quat__axis_angle_sanitize(NULL, &angle); @@ -968,18 +968,18 @@ static int Quaternion_angle_set(QuaternionObject *self, PyObject *value, void *U if (BaseMath_ReadCallback(self) == -1) return -1; - len= normalize_qt_qt(tquat, self->quat); + len = normalize_qt_qt(tquat, self->quat); quat_to_axis_angle(axis, &angle_dummy, tquat); - angle= PyFloat_AsDouble(value); + angle = PyFloat_AsDouble(value); - if (angle==-1.0f && PyErr_Occurred()) { /* parsed item not a number */ + if (angle == -1.0f && PyErr_Occurred()) { /* parsed item not a number */ PyErr_SetString(PyExc_TypeError, "Quaternion.angle = value: float expected"); return -1; } - angle= angle_wrap_rad(angle); + angle = angle_wrap_rad(angle); quat__axis_angle_sanitize(axis, &angle); @@ -1021,7 +1021,7 @@ static int Quaternion_axis_vector_set(QuaternionObject *self, PyObject *value, v if (BaseMath_ReadCallback(self) == -1) return -1; - len= normalize_qt_qt(tquat, self->quat); + len = normalize_qt_qt(tquat, self->quat); quat_to_axis_angle(axis, &angle, tquat); /* axis value is unused */ if (mathutils_array_parse(axis, 3, 3, value, "quat.axis = other") == -1) @@ -1041,9 +1041,9 @@ static int Quaternion_axis_vector_set(QuaternionObject *self, PyObject *value, v //----------------------------------mathutils.Quaternion() -------------- static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - PyObject *seq= NULL; + PyObject *seq = NULL; double angle = 0.0f; - float quat[QUAT_SIZE]= {0.0f, 0.0f, 0.0f, 0.0f}; + float quat[QUAT_SIZE] = {0.0f, 0.0f, 0.0f, 0.0f}; if (kwds && PyDict_Size(kwds)) { PyErr_SetString(PyExc_TypeError, @@ -1065,7 +1065,7 @@ static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kw case 2: if (mathutils_array_parse(quat, 3, 3, seq, "mathutils.Quaternion()") == -1) return NULL; - angle= angle_wrap_rad(angle); /* clamp because of precision issues */ + angle = angle_wrap_rad(angle); /* clamp because of precision issues */ axis_angle_to_quat(quat, quat, angle); break; /* PyArg_ParseTuple assures no more then 2 */ @@ -1075,8 +1075,8 @@ static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kw static PyObject *quat__apply_to_copy(PyNoArgsFunction quat_func, QuaternionObject *self) { - PyObject *ret= Quaternion_copy(self); - PyObject *ret_dummy= quat_func(ret); + PyObject *ret = Quaternion_copy(self); + PyObject *ret_dummy = quat_func(ret); if (ret_dummy) { Py_DECREF(ret_dummy); return ret; @@ -1095,9 +1095,9 @@ static void quat__axis_angle_sanitize(float axis[3], float *angle) !finite(axis[1]) || !finite(axis[2])) { - axis[0]= 1.0f; - axis[1]= 0.0f; - axis[2]= 0.0f; + axis[0] = 1.0f; + axis[1] = 0.0f; + axis[2] = 0.0f; } else if ( EXPP_FloatsAreEqual(axis[0], 0.0f, 10) && EXPP_FloatsAreEqual(axis[1], 0.0f, 10) && @@ -1109,7 +1109,7 @@ static void quat__axis_angle_sanitize(float axis[3], float *angle) if (angle) { if (!finite(*angle)) { - *angle= 0.0f; + *angle = 0.0f; } } } @@ -1225,13 +1225,13 @@ PyObject *Quaternion_CreatePyObject(float *quat, int type, PyTypeObject *base_ty { QuaternionObject *self; - self= base_type ? (QuaternionObject *)base_type->tp_alloc(base_type, 0) : - (QuaternionObject *)PyObject_GC_New(QuaternionObject, &quaternion_Type); + self = base_type ? (QuaternionObject *)base_type->tp_alloc(base_type, 0) : + (QuaternionObject *)PyObject_GC_New(QuaternionObject, &quaternion_Type); if (self) { /* init callbacks as NULL */ - self->cb_user= NULL; - self->cb_type= self->cb_subtype= 0; + self->cb_user = NULL; + self->cb_type = self->cb_subtype = 0; if (type == Py_WRAP) { self->quat = quat; @@ -1256,12 +1256,12 @@ PyObject *Quaternion_CreatePyObject(float *quat, int type, PyTypeObject *base_ty PyObject *Quaternion_CreatePyObject_cb(PyObject *cb_user, int cb_type, int cb_subtype) { - QuaternionObject *self= (QuaternionObject *)Quaternion_CreatePyObject(NULL, Py_NEW, NULL); + QuaternionObject *self = (QuaternionObject *)Quaternion_CreatePyObject(NULL, Py_NEW, NULL); if (self) { Py_INCREF(cb_user); - self->cb_user= cb_user; - self->cb_type= (unsigned char)cb_type; - self->cb_subtype= (unsigned char)cb_subtype; + self->cb_user = cb_user; + self->cb_type = (unsigned char)cb_type; + self->cb_subtype = (unsigned char)cb_subtype; PyObject_GC_Track(self); } diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c index 69e51832bda..f5d4ca7ec4e 100644 --- a/source/blender/python/mathutils/mathutils_Vector.c +++ b/source/blender/python/mathutils/mathutils_Vector.c @@ -55,12 +55,12 @@ static int row_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject *v */ static PyObject *Vector_new(PyTypeObject *type, PyObject *args, PyObject *UNUSED(kwds)) { - float *vec= NULL; - int size= 3; /* default to a 3D vector */ + float *vec = NULL; + int size = 3; /* default to a 3D vector */ switch (PyTuple_GET_SIZE(args)) { case 0: - vec= PyMem_Malloc(size * sizeof(float)); + vec = PyMem_Malloc(size * sizeof(float)); if (vec == NULL) { PyErr_SetString(PyExc_MemoryError, @@ -72,7 +72,7 @@ static PyObject *Vector_new(PyTypeObject *type, PyObject *args, PyObject *UNUSED fill_vn_fl(vec, size, 0.0f); break; case 1: - if ((size=mathutils_array_parse_alloc(&vec, 2, PyTuple_GET_ITEM(args, 0), "mathutils.Vector()")) == -1) { + if ((size = mathutils_array_parse_alloc(&vec, 2, PyTuple_GET_ITEM(args, 0), "mathutils.Vector()")) == -1) { if (vec) { PyMem_Free(vec); } @@ -90,8 +90,8 @@ static PyObject *Vector_new(PyTypeObject *type, PyObject *args, PyObject *UNUSED static PyObject *vec__apply_to_copy(PyNoArgsFunction vec_func, VectorObject *self) { - PyObject *ret= Vector_copy(self); - PyObject *ret_dummy= vec_func(ret); + PyObject *ret = Vector_copy(self); + PyObject *ret_dummy = vec_func(ret); if (ret_dummy) { Py_DECREF(ret_dummy); return (PyObject *)ret; @@ -117,7 +117,7 @@ static PyObject *C_Vector_Fill(PyObject *cls, PyObject *args) { float *vec; int size; - float fill= 0.0f; + float fill = 0.0f; if (!PyArg_ParseTuple(args, "i|f:Vector.Fill", &size, &fill)) { return NULL; @@ -129,7 +129,7 @@ static PyObject *C_Vector_Fill(PyObject *cls, PyObject *args) return NULL; } - vec= PyMem_Malloc(size * sizeof(float)); + vec = PyMem_Malloc(size * sizeof(float)); if (vec == NULL) { PyErr_SetString(PyExc_MemoryError, @@ -159,8 +159,8 @@ static PyObject *C_Vector_Range(PyObject *cls, PyObject *args) { float *vec; int stop, size; - int start= 0; - int step= 1; + int start = 0; + int step = 1; if (!PyArg_ParseTuple(args, "i|ii:Vector.Range", &start, &stop, &step)) { return NULL; @@ -169,7 +169,7 @@ static PyObject *C_Vector_Range(PyObject *cls, PyObject *args) switch (PyTuple_GET_SIZE(args)) { case 1: size = start; - start= 0; + start = 0; break; case 2: if (start >= stop) { @@ -179,7 +179,7 @@ static PyObject *C_Vector_Range(PyObject *cls, PyObject *args) return NULL; } - size= stop - start; + size = stop - start; break; default: if (start >= stop) { @@ -188,13 +188,13 @@ static PyObject *C_Vector_Range(PyObject *cls, PyObject *args) "than the stop value"); return NULL; } - size= (stop - start)/step; + size = (stop - start)/step; if (size%step) size++; break; } - vec= PyMem_Malloc(size * sizeof(float)); + vec = PyMem_Malloc(size * sizeof(float)); if (vec == NULL) { PyErr_SetString(PyExc_MemoryError, @@ -236,9 +236,9 @@ static PyObject *C_Vector_Linspace(PyObject *cls, PyObject *args) return NULL; } - step= (end - start)/(float)(size-1); + step = (end - start)/(float)(size-1); - vec= PyMem_Malloc(size * sizeof(float)); + vec = PyMem_Malloc(size * sizeof(float)); if (vec == NULL) { PyErr_SetString(PyExc_MemoryError, @@ -265,7 +265,7 @@ PyDoc_STRVAR(C_Vector_Repeat_doc, static PyObject *C_Vector_Repeat(PyObject *cls, PyObject *args) { float *vec; - float *iter_vec= NULL; + float *iter_vec = NULL; int i, size, value_size; PyObject *value; @@ -279,7 +279,7 @@ static PyObject *C_Vector_Repeat(PyObject *cls, PyObject *args) return NULL; } - if ((value_size=mathutils_array_parse_alloc(&iter_vec, 2, value, "Vector.Repeat(vector, size), invalid 'vector' arg")) == -1) { + if ((value_size = mathutils_array_parse_alloc(&iter_vec, 2, value, "Vector.Repeat(vector, size), invalid 'vector' arg")) == -1) { PyMem_Free(iter_vec); return NULL; } @@ -291,7 +291,7 @@ static PyObject *C_Vector_Repeat(PyObject *cls, PyObject *args) return NULL; } - vec= PyMem_Malloc(size * sizeof(float)); + vec = PyMem_Malloc(size * sizeof(float)); if (vec == NULL) { PyErr_SetString(PyExc_MemoryError, @@ -300,9 +300,9 @@ static PyObject *C_Vector_Repeat(PyObject *cls, PyObject *args) return NULL; } - i= 0; + i = 0; while (i < size) { - vec[i]= iter_vec[i % value_size]; + vec[i] = iter_vec[i % value_size]; i++; } @@ -373,7 +373,7 @@ static PyObject *Vector_resize(VectorObject *self, PyObject *value) { int size; - if (self->wrapped==Py_WRAP) { + if (self->wrapped == Py_WRAP) { PyErr_SetString(PyExc_TypeError, "Vector.resize(): " "cannot resize wrapped data - only python vectors"); @@ -441,7 +441,7 @@ static PyObject *Vector_resized(VectorObject *self, PyObject *value) return NULL; } - vec= PyMem_Malloc(size * sizeof(float)); + vec = PyMem_Malloc(size * sizeof(float)); if (vec == NULL) { PyErr_SetString(PyExc_MemoryError, @@ -466,7 +466,7 @@ PyDoc_STRVAR(Vector_resize_2d_doc, ); static PyObject *Vector_resize_2d(VectorObject *self) { - if (self->wrapped==Py_WRAP) { + if (self->wrapped == Py_WRAP) { PyErr_SetString(PyExc_TypeError, "Vector.resize_2d(): " "cannot resize wrapped data - only python vectors"); @@ -501,7 +501,7 @@ PyDoc_STRVAR(Vector_resize_3d_doc, ); static PyObject *Vector_resize_3d(VectorObject *self) { - if (self->wrapped==Py_WRAP) { + if (self->wrapped == Py_WRAP) { PyErr_SetString(PyExc_TypeError, "Vector.resize_3d(): " "cannot resize wrapped data - only python vectors"); @@ -539,7 +539,7 @@ PyDoc_STRVAR(Vector_resize_4d_doc, ); static PyObject *Vector_resize_4d(VectorObject *self) { - if (self->wrapped==Py_WRAP) { + if (self->wrapped == Py_WRAP) { PyErr_SetString(PyExc_TypeError, "Vector.resize_4d(): " "cannot resize wrapped data - only python vectors"); @@ -595,7 +595,7 @@ PyDoc_STRVAR(Vector_to_3d_doc, ); static PyObject *Vector_to_3d(VectorObject *self) { - float tvec[3]= {0.0f}; + float tvec[3] = {0.0f}; if (BaseMath_ReadCallback(self) == -1) return NULL; @@ -613,7 +613,7 @@ PyDoc_STRVAR(Vector_to_4d_doc, ); static PyObject *Vector_to_4d(VectorObject *self) { - float tvec[4]= {0.0f, 0.0f, 0.0f, 1.0f}; + float tvec[4] = {0.0f, 0.0f, 0.0f, 1.0f}; if (BaseMath_ReadCallback(self) == -1) return NULL; @@ -638,7 +638,7 @@ static PyObject *Vector_to_tuple_ext(VectorObject *self, int ndigits) PyObject *ret; int i; - ret= PyTuple_New(self->size); + ret = PyTuple_New(self->size); if (ndigits >= 0) { for (i = 0; i < self->size; i++) { @@ -656,7 +656,7 @@ static PyObject *Vector_to_tuple_ext(VectorObject *self, int ndigits) static PyObject *Vector_to_tuple(VectorObject *self, PyObject *args) { - int ndigits= 0; + int ndigits = 0; if (!PyArg_ParseTuple(args, "|i:to_tuple", &ndigits)) return NULL; @@ -668,8 +668,8 @@ static PyObject *Vector_to_tuple(VectorObject *self, PyObject *args) return NULL; } - if (PyTuple_GET_SIZE(args)==0) - ndigits= -1; + if (PyTuple_GET_SIZE(args) == 0) + ndigits = -1; if (BaseMath_ReadCallback(self) == -1) return NULL; @@ -709,7 +709,7 @@ static PyObject *Vector_to_track_quat(VectorObject *self, PyObject *args) return NULL; if (strack) { - const char *axis_err_msg= "only X, -X, Y, -Y, Z or -Z for track axis"; + const char *axis_err_msg = "only X, -X, Y, -Y, Z or -Z for track axis"; if (strlen(strack) == 2) { if (strack[0] == '-') { @@ -757,7 +757,7 @@ static PyObject *Vector_to_track_quat(VectorObject *self, PyObject *args) } if (sup) { - const char *axis_err_msg= "only X, Y or Z for up axis"; + const char *axis_err_msg = "only X, Y or Z for up axis"; if (strlen(sup) == 1) { switch (*sup) { case 'X': @@ -821,7 +821,7 @@ static PyObject *Vector_reflect(VectorObject *self, PyObject *value) if (BaseMath_ReadCallback(self) == -1) return NULL; - if ((value_size= mathutils_array_parse(tvec, 2, 4, value, "Vector.reflect(other), invalid 'other' arg")) == -1) + if ((value_size = mathutils_array_parse(tvec, 2, 4, value, "Vector.reflect(other), invalid 'other' arg")) == -1) return NULL; if (self->size < 2 || self->size > 4) { @@ -875,7 +875,7 @@ static PyObject *Vector_cross(VectorObject *self, PyObject *value) return NULL; } - ret= (VectorObject *)Vector_CreatePyObject(NULL, 3, Py_NEW, Py_TYPE(self)); + ret = (VectorObject *)Vector_CreatePyObject(NULL, 3, Py_NEW, Py_TYPE(self)); cross_v3_v3v3(ret->vec, self->vec, tvec); return (PyObject *)ret; } @@ -925,12 +925,12 @@ PyDoc_STRVAR(Vector_angle_doc, ); static PyObject *Vector_angle(VectorObject *self, PyObject *args) { - const int size= MIN2(self->size, 3); /* 4D angle makes no sense */ + const int size = MIN2(self->size, 3); /* 4D angle makes no sense */ float tvec[MAX_DIMENSIONS]; PyObject *value; - double dot= 0.0f, dot_self= 0.0f, dot_other= 0.0f; + double dot = 0.0f, dot_self = 0.0f, dot_other = 0.0f; int x; - PyObject *fallback= NULL; + PyObject *fallback = NULL; if (!PyArg_ParseTuple(args, "O|O:angle", &value, &fallback)) return NULL; @@ -1022,7 +1022,7 @@ PyDoc_STRVAR(Vector_project_doc, ); static PyObject *Vector_project(VectorObject *self, PyObject *value) { - const int size= self->size; + const int size = self->size; float tvec[MAX_DIMENSIONS]; float vec[MAX_DIMENSIONS]; double dot = 0.0f, dot2 = 0.0f; @@ -1070,8 +1070,8 @@ PyDoc_STRVAR(Vector_lerp_doc, ); static PyObject *Vector_lerp(VectorObject *self, PyObject *args) { - const int size= self->size; - PyObject *value= NULL; + const int size = self->size; + PyObject *value = NULL; float fac, ifac; float *tvec, *vec; int x; @@ -1087,7 +1087,7 @@ static PyObject *Vector_lerp(VectorObject *self, PyObject *args) goto cleanup; } - vec= PyMem_Malloc(size * sizeof(float)); + vec = PyMem_Malloc(size * sizeof(float)); if (vec == NULL) { PyErr_SetString(PyExc_MemoryError, "Vector.lerp(): " @@ -1095,7 +1095,7 @@ static PyObject *Vector_lerp(VectorObject *self, PyObject *args) return NULL; } - ifac= 1.0f - fac; + ifac = 1.0f - fac; for (x = 0; x < size; x++) { vec[x] = (ifac * self->vec[x]) + (fac * tvec[x]); @@ -1166,8 +1166,8 @@ static PyObject *Vector_repr(VectorObject *self) if (BaseMath_ReadCallback(self) == -1) return NULL; - tuple= Vector_to_tuple_ext(self, -1); - ret= PyUnicode_FromFormat("Vector(%R)", tuple); + tuple = Vector_to_tuple_ext(self, -1); + ret = PyUnicode_FromFormat("Vector(%R)", tuple); Py_DECREF(tuple); return ret; } @@ -1181,7 +1181,7 @@ static PyObject *Vector_str(VectorObject *self) if (BaseMath_ReadCallback(self) == -1) return NULL; - ds= BLI_dynstr_new(); + ds = BLI_dynstr_new(); BLI_dynstr_append(ds, "size-i; + if (i < 0) i = self->size-i; if (i < 0 || i >= self->size) { if (is_attr) { @@ -1233,14 +1233,14 @@ static PyObject *Vector_item(VectorObject *self, int i) static int vector_ass_item_internal(VectorObject *self, int i, PyObject *value, const int is_attr) { float scalar; - if ((scalar=PyFloat_AsDouble(value))==-1.0f && PyErr_Occurred()) { /* parsed item not a number */ + if ((scalar = PyFloat_AsDouble(value)) == -1.0f && PyErr_Occurred()) { /* parsed item not a number */ PyErr_SetString(PyExc_TypeError, "vector[index] = x: " "index argument not a number"); return -1; } - if (i<0) i= self->size-i; + if (i < 0) i = self->size-i; if (i < 0 || i >= self->size) { if (is_attr) { @@ -1277,11 +1277,11 @@ static PyObject *Vector_slice(VectorObject *self, int begin, int end) return NULL; CLAMP(begin, 0, self->size); - if (end<0) end= self->size+end+1; + if (end < 0) end = self->size + end + 1; CLAMP(end, 0, self->size); - begin= MIN2(begin, end); + begin = MIN2(begin, end); - tuple= PyTuple_New(end - begin); + tuple = PyTuple_New(end - begin); for (count = begin; count < end; count++) { PyTuple_SET_ITEM(tuple, count - begin, PyFloat_FromDouble(self->vec[count])); } @@ -1292,7 +1292,7 @@ static PyObject *Vector_slice(VectorObject *self, int begin, int end) static int Vector_ass_slice(VectorObject *self, int begin, int end, PyObject *seq) { int size = 0; - float *vec= NULL; + float *vec = NULL; if (BaseMath_ReadCallback(self) == -1) return -1; @@ -1333,7 +1333,7 @@ cleanup: static PyObject *Vector_add(PyObject *v1, PyObject *v2) { VectorObject *vec1 = NULL, *vec2 = NULL; - float *vec= NULL; + float *vec = NULL; if (!VectorObject_Check(v1) || !VectorObject_Check(v2)) { PyErr_Format(PyExc_AttributeError, @@ -1356,7 +1356,7 @@ static PyObject *Vector_add(PyObject *v1, PyObject *v2) return NULL; } - vec= PyMem_Malloc(vec1->size * sizeof(float)); + vec = PyMem_Malloc(vec1->size * sizeof(float)); if (vec == NULL) { /*allocation failure*/ PyErr_SetString(PyExc_MemoryError, @@ -1428,7 +1428,7 @@ static PyObject *Vector_sub(PyObject *v1, PyObject *v2) return NULL; } - vec= PyMem_Malloc(vec1->size * sizeof(float)); + vec = PyMem_Malloc(vec1->size * sizeof(float)); if (vec == NULL) { /*allocation failure*/ PyErr_SetString(PyExc_MemoryError, @@ -1445,7 +1445,7 @@ static PyObject *Vector_sub(PyObject *v1, PyObject *v2) /* subtraction in-place: obj -= obj */ static PyObject *Vector_isub(PyObject *v1, PyObject *v2) { - VectorObject *vec1= NULL, *vec2= NULL; + VectorObject *vec1 = NULL, *vec2 = NULL; if (!VectorObject_Check(v1) || !VectorObject_Check(v2)) { PyErr_Format(PyExc_AttributeError, @@ -1486,7 +1486,7 @@ static PyObject *Vector_isub(PyObject *v1, PyObject *v2) * note: vector/matrix multiplication IS NOT COMMUTATIVE!!!! * note: assume read callbacks have been done first. */ -int column_vector_multiplication(float r_vec[MAX_DIMENSIONS], VectorObject* vec, MatrixObject * mat) +int column_vector_multiplication(float r_vec[MAX_DIMENSIONS], VectorObject *vec, MatrixObject *mat) { float vec_cpy[MAX_DIMENSIONS]; double dot = 0.0f; @@ -1522,8 +1522,7 @@ int column_vector_multiplication(float r_vec[MAX_DIMENSIONS], VectorObject* vec, static PyObject *vector_mul_float(VectorObject *vec, const float scalar) { - float *tvec= NULL; - tvec= PyMem_Malloc(vec->size * sizeof(float)); + float *tvec = PyMem_Malloc(vec->size * sizeof(float)); if (tvec == NULL) { /*allocation failure*/ PyErr_SetString(PyExc_MemoryError, @@ -1543,12 +1542,12 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2) int vec_size; if VectorObject_Check(v1) { - vec1= (VectorObject *)v1; + vec1 = (VectorObject *)v1; if (BaseMath_ReadCallback(vec1) == -1) return NULL; } if VectorObject_Check(v2) { - vec2= (VectorObject *)v2; + vec2 = (VectorObject *)v2; if (BaseMath_ReadCallback(vec2) == -1) return NULL; } @@ -1614,12 +1613,12 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2) #endif /* ------ to be removed ------*/ } - else if (((scalar= PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred())==0) { /* VEC * FLOAT */ + else if (((scalar = PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) == 0) { /* VEC * FLOAT */ return vector_mul_float(vec1, scalar); } } else if (vec2) { - if (((scalar= PyFloat_AsDouble(v1)) == -1.0f && PyErr_Occurred())==0) { /* FLOAT * VEC */ + if (((scalar = PyFloat_AsDouble(v1)) == -1.0f && PyErr_Occurred()) == 0) { /* FLOAT * VEC */ return vector_mul_float(vec2, scalar); } } @@ -1693,7 +1692,7 @@ static PyObject *Vector_imul(PyObject *v1, PyObject *v2) #endif /* ------ to be removed ------*/ } - else if (((scalar= PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred())==0) { /* VEC *= FLOAT */ + else if (((scalar = PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) == 0) { /* VEC *= FLOAT */ mul_vn_fl(vec->vec, vec->size, scalar); } else { @@ -1712,7 +1711,7 @@ static PyObject *Vector_imul(PyObject *v1, PyObject *v2) /* divid: obj / obj */ static PyObject *Vector_div(PyObject *v1, PyObject *v2) { - float *vec= NULL, scalar; + float *vec = NULL, scalar; VectorObject *vec1 = NULL; if (!VectorObject_Check(v1)) { /* not a vector */ @@ -1726,21 +1725,21 @@ static PyObject *Vector_div(PyObject *v1, PyObject *v2) if (BaseMath_ReadCallback(vec1) == -1) return NULL; - if ((scalar=PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) { /* parsed item not a number */ + if ((scalar = PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) { /* parsed item not a number */ PyErr_SetString(PyExc_TypeError, "Vector division: " "Vector must be divided by a float"); return NULL; } - if (scalar==0.0f) { + if (scalar == 0.0f) { PyErr_SetString(PyExc_ZeroDivisionError, "Vector division: " "divide by zero error"); return NULL; } - vec= PyMem_Malloc(vec1->size * sizeof(float)); + vec = PyMem_Malloc(vec1->size * sizeof(float)); if (vec == NULL) { /*allocation failure*/ PyErr_SetString(PyExc_MemoryError, @@ -1749,7 +1748,7 @@ static PyObject *Vector_div(PyObject *v1, PyObject *v2) return NULL; } - mul_vn_vn_fl(vec, vec1->vec, vec1->size, 1.0f/scalar); + mul_vn_vn_fl(vec, vec1->vec, vec1->size, 1.0f / scalar); return Vector_CreatePyObject_alloc(vec, vec1->size, Py_TYPE(v1)); } @@ -1763,21 +1762,21 @@ static PyObject *Vector_idiv(PyObject *v1, PyObject *v2) if (BaseMath_ReadCallback(vec1) == -1) return NULL; - if ((scalar=PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) { /* parsed item not a number */ + if ((scalar = PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) { /* parsed item not a number */ PyErr_SetString(PyExc_TypeError, "Vector division: " "Vector must be divided by a float"); return NULL; } - if (scalar==0.0f) { + if (scalar == 0.0f) { PyErr_SetString(PyExc_ZeroDivisionError, "Vector division: " "divide by zero error"); return NULL; } - mul_vn_fl(vec1->vec, vec1->size, 1.0f/scalar); + mul_vn_fl(vec1->vec, vec1->size, 1.0f / scalar); (void)BaseMath_WriteCallback(vec1); @@ -1794,7 +1793,7 @@ static PyObject *Vector_neg(VectorObject *self) if (BaseMath_ReadCallback(self) == -1) return NULL; - tvec= PyMem_Malloc(self->size * sizeof(float)); + tvec = PyMem_Malloc(self->size * sizeof(float)); negate_vn_vn(tvec, self->vec, self->size); return Vector_CreatePyObject_alloc(tvec, self->size, Py_TYPE(self)); } @@ -1812,7 +1811,7 @@ static double vec_magnitude_nosqrt(float *data, int size) /*------------------------tp_richcmpr returns -1 execption, 0 false, 1 true */ -static PyObject* Vector_richcmpr(PyObject *objectA, PyObject *objectB, int comparison_type) +static PyObject *Vector_richcmpr(PyObject *objectA, PyObject *objectB, int comparison_type) { VectorObject *vecA = NULL, *vecB = NULL; int result = 0; @@ -1909,7 +1908,7 @@ static PySequenceMethods Vector_SeqMethods = { (ssizeargfunc) NULL, /* sq_inplace_repeat */ }; -static PyObject *Vector_subscript(VectorObject* self, PyObject* item) +static PyObject *Vector_subscript(VectorObject *self, PyObject *item) { if (PyIndex_Check(item)) { Py_ssize_t i; @@ -1946,7 +1945,7 @@ static PyObject *Vector_subscript(VectorObject* self, PyObject* item) } } -static int Vector_ass_subscript(VectorObject* self, PyObject* item, PyObject* value) +static int Vector_ass_subscript(VectorObject *self, PyObject *item, PyObject *value) { if (PyIndex_Check(item)) { Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError); @@ -2054,7 +2053,7 @@ static int Vector_length_set(VectorObject *self, PyObject *value) if (BaseMath_ReadCallback(self) == -1) return -1; - if ((param=PyFloat_AsDouble(value)) == -1.0 && PyErr_Occurred()) { + if ((param = PyFloat_AsDouble(value)) == -1.0 && PyErr_Occurred()) { PyErr_SetString(PyExc_TypeError, "length must be set to a number"); return -1; @@ -2070,19 +2069,19 @@ static int Vector_length_set(VectorObject *self, PyObject *value) return 0; } - dot= dot_vn_vn(self->vec, self->vec, self->size); + dot = dot_vn_vn(self->vec, self->vec, self->size); if (!dot) /* cant sqrt zero */ return 0; dot = sqrt(dot); - if (dot==param) + if (dot == param) return 0; - dot= dot/param; + dot = dot / param; - mul_vn_fl(self->vec, self->size, 1.0/dot); + mul_vn_fl(self->vec, self->size, 1.0 / dot); (void)BaseMath_WriteCallback(self); /* checked already */ @@ -2161,7 +2160,7 @@ static int Vector_swizzle_set(VectorObject *self, PyObject *value, void *closure /* Check that the closure can be used with this vector: even 2D vectors have swizzles defined for axes z and w, but they would be invalid. */ swizzleClosure = GET_INT_FROM_POINTER(closure); - axis_from= 0; + axis_from = 0; while (swizzleClosure & SWIZZLE_VALID_AXIS) { axis_to = swizzleClosure & SWIZZLE_AXIS; if (axis_to >= self->size) @@ -2175,15 +2174,15 @@ static int Vector_swizzle_set(VectorObject *self, PyObject *value, void *closure axis_from++; } - if (((scalarVal=PyFloat_AsDouble(value)) == -1 && PyErr_Occurred())==0) { + if (((scalarVal = PyFloat_AsDouble(value)) == -1 && PyErr_Occurred()) == 0) { int i; - for (i=0; i < MAX_DIMENSIONS; i++) - vec_assign[i]= scalarVal; + for (i = 0; i < MAX_DIMENSIONS; i++) + vec_assign[i] = scalarVal; - size_from= axis_from; + size_from = axis_from; } else if ( (PyErr_Clear()), /* run but ignore the result */ - (size_from=mathutils_array_parse(vec_assign, 2, 4, value, + (size_from = mathutils_array_parse(vec_assign, 2, 4, value, "mathutils.Vector.**** = swizzle assignment")) == -1) { return -1; @@ -2619,7 +2618,7 @@ static int row_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject *v { float vec_cpy[MAX_DIMENSIONS]; double dot = 0.0f; - int row, col, z= 0, vec_size= vec->size; + int row, col, z = 0, vec_size = vec->size; if (mat->num_row != vec_size) { if (mat->num_row == 4 && vec_size == 3) { @@ -2818,22 +2817,22 @@ PyObject *Vector_CreatePyObject(float *vec, const int size, const int type, PyTy return NULL; } - self= base_type ? (VectorObject *)base_type->tp_alloc(base_type, 0) : - (VectorObject *)PyObject_GC_New(VectorObject, &vector_Type); + self = base_type ? (VectorObject *)base_type->tp_alloc(base_type, 0) : + (VectorObject *)PyObject_GC_New(VectorObject, &vector_Type); if (self) { self->size = size; /* init callbacks as NULL */ - self->cb_user= NULL; - self->cb_type= self->cb_subtype= 0; + self->cb_user = NULL; + self->cb_type = self->cb_subtype = 0; if (type == Py_WRAP) { self->vec = vec; self->wrapped = Py_WRAP; } else if (type == Py_NEW) { - self->vec= PyMem_Malloc(size * sizeof(float)); + self->vec = PyMem_Malloc(size * sizeof(float)); if (vec) { memcpy(self->vec, vec, size * sizeof(float)); } @@ -2855,12 +2854,12 @@ PyObject *Vector_CreatePyObject(float *vec, const int size, const int type, PyTy PyObject *Vector_CreatePyObject_cb(PyObject *cb_user, int size, int cb_type, int cb_subtype) { float dummy[4] = {0.0, 0.0, 0.0, 0.0}; /* dummy init vector, callbacks will be used on access */ - VectorObject *self= (VectorObject *)Vector_CreatePyObject(dummy, size, Py_NEW, NULL); + VectorObject *self = (VectorObject *)Vector_CreatePyObject(dummy, size, Py_NEW, NULL); if (self) { Py_INCREF(cb_user); - self->cb_user= cb_user; - self->cb_type= (unsigned char)cb_type; - self->cb_subtype= (unsigned char)cb_subtype; + self->cb_user = cb_user; + self->cb_type = (unsigned char)cb_type; + self->cb_subtype = (unsigned char)cb_subtype; PyObject_GC_Track(self); } @@ -2870,8 +2869,8 @@ PyObject *Vector_CreatePyObject_cb(PyObject *cb_user, int size, int cb_type, int PyObject *Vector_CreatePyObject_alloc(float *vec, const int size, PyTypeObject *base_type) { VectorObject *vect_ob; - vect_ob= (VectorObject *)Vector_CreatePyObject(vec, size, Py_WRAP, base_type); - vect_ob->wrapped= Py_NEW; + vect_ob = (VectorObject *)Vector_CreatePyObject(vec, size, Py_WRAP, base_type); + vect_ob->wrapped = Py_NEW; return (PyObject *)vect_ob; } diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c index f3a843baf66..d7e7bef5f23 100644 --- a/source/blender/python/mathutils/mathutils_geometry.c +++ b/source/blender/python/mathutils/mathutils_geometry.c @@ -47,7 +47,7 @@ #include "BLI_math.h" #include "BLI_utildefines.h" -#define SWAP_FLOAT(a, b, tmp) tmp=a; a=b; b=tmp +#define SWAP_FLOAT(a, b, tmp) tmp = a; a = b; b = tmp /*-------------------------DOC STRINGS ---------------------------*/ PyDoc_STRVAR(M_Geometry_doc, @@ -76,12 +76,12 @@ PyDoc_STRVAR(M_Geometry_intersect_ray_tri_doc, " :return: The point of intersection or None if no intersection is found\n" " :rtype: :class:`mathutils.Vector` or None\n" ); -static PyObject *M_Geometry_intersect_ray_tri(PyObject *UNUSED(self), PyObject* args) +static PyObject *M_Geometry_intersect_ray_tri(PyObject *UNUSED(self), PyObject *args) { VectorObject *ray, *ray_off, *vec1, *vec2, *vec3; float dir[3], orig[3], v1[3], v2[3], v3[3], e1[3], e2[3], pvec[3], tvec[3], qvec[3]; float det, inv_det, u, v, t; - int clip= 1; + int clip = 1; if (!PyArg_ParseTuple(args, "O!O!O!O!O!|i:intersect_ray_tri", @@ -125,19 +125,19 @@ static PyObject *M_Geometry_intersect_ray_tri(PyObject *UNUSED(self), PyObject* cross_v3_v3v3(pvec, dir, e2); /* if determinant is near zero, ray lies in plane of triangle */ - det= dot_v3v3(e1, pvec); + det = dot_v3v3(e1, pvec); if (det > -0.000001f && det < 0.000001f) { Py_RETURN_NONE; } - inv_det= 1.0f / det; + inv_det = 1.0f / det; /* calculate distance from v1 to ray origin */ sub_v3_v3v3(tvec, orig, v1); /* calculate U parameter and test bounds */ - u= dot_v3v3(tvec, pvec) * inv_det; + u = dot_v3v3(tvec, pvec) * inv_det; if (clip && (u < 0.0f || u > 1.0f)) { Py_RETURN_NONE; } @@ -146,14 +146,14 @@ static PyObject *M_Geometry_intersect_ray_tri(PyObject *UNUSED(self), PyObject* cross_v3_v3v3(qvec, tvec, e1); /* calculate V parameter and test bounds */ - v= dot_v3v3(dir, qvec) * inv_det; + v = dot_v3v3(dir, qvec) * inv_det; if (clip && (v < 0.0f || u + v > 1.0f)) { Py_RETURN_NONE; } /* calculate t, ray intersects triangle */ - t= dot_v3v3(e2, qvec) * inv_det; + t = dot_v3v3(e2, qvec) * inv_det; mul_v3_fl(dir, t); add_v3_v3v3(pvec, orig, dir); @@ -217,31 +217,31 @@ static PyObject *M_Geometry_intersect_line_line(PyObject *UNUSED(self), PyObject copy_v3_v3(v4, vec4->vec); } else { - v1[0]= vec1->vec[0]; - v1[1]= vec1->vec[1]; - v1[2]= 0.0f; + v1[0] = vec1->vec[0]; + v1[1] = vec1->vec[1]; + v1[2] = 0.0f; - v2[0]= vec2->vec[0]; - v2[1]= vec2->vec[1]; - v2[2]= 0.0f; + v2[0] = vec2->vec[0]; + v2[1] = vec2->vec[1]; + v2[2] = 0.0f; - v3[0]= vec3->vec[0]; - v3[1]= vec3->vec[1]; - v3[2]= 0.0f; + v3[0] = vec3->vec[0]; + v3[1] = vec3->vec[1]; + v3[2] = 0.0f; - v4[0]= vec4->vec[0]; - v4[1]= vec4->vec[1]; - v4[2]= 0.0f; + v4[0] = vec4->vec[0]; + v4[1] = vec4->vec[1]; + v4[2] = 0.0f; } - result= isect_line_line_v3(v1, v2, v3, v4, i1, i2); + result = isect_line_line_v3(v1, v2, v3, v4, i1, i2); if (result == 0) { /* colinear */ Py_RETURN_NONE; } else { - tuple= PyTuple_New(2); + tuple = PyTuple_New(2); PyTuple_SET_ITEM(tuple, 0, Vector_CreatePyObject(i1, vec1->size, Py_NEW, NULL)); PyTuple_SET_ITEM(tuple, 1, Vector_CreatePyObject(i2, vec1->size, Py_NEW, NULL)); return tuple; @@ -273,7 +273,7 @@ PyDoc_STRVAR(M_Geometry_normal_doc, " :type v4: :class:`mathutils.Vector`\n" " :rtype: :class:`mathutils.Vector`\n" ); -static PyObject *M_Geometry_normal(PyObject *UNUSED(self), PyObject* args) +static PyObject *M_Geometry_normal(PyObject *UNUSED(self), PyObject *args) { VectorObject *vec1, *vec2, *vec3, *vec4; float n[3]; @@ -356,7 +356,7 @@ PyDoc_STRVAR(M_Geometry_area_tri_doc, " :type v3: :class:`mathutils.Vector`\n" " :rtype: float\n" ); -static PyObject *M_Geometry_area_tri(PyObject *UNUSED(self), PyObject* args) +static PyObject *M_Geometry_area_tri(PyObject *UNUSED(self), PyObject *args) { VectorObject *vec1, *vec2, *vec3; @@ -411,7 +411,7 @@ PyDoc_STRVAR(M_Geometry_intersect_line_line_2d_doc, " :return: The point of intersection or None when not found\n" " :rtype: :class:`mathutils.Vector` or None\n" ); -static PyObject *M_Geometry_intersect_line_line_2d(PyObject *UNUSED(self), PyObject* args) +static PyObject *M_Geometry_intersect_line_line_2d(PyObject *UNUSED(self), PyObject *args) { VectorObject *line_a1, *line_a2, *line_b1, *line_b2; float vi[2]; @@ -459,10 +459,10 @@ PyDoc_STRVAR(M_Geometry_intersect_line_plane_doc, " :return: The point of intersection or None when not found\n" " :rtype: :class:`mathutils.Vector` or None\n" ); -static PyObject *M_Geometry_intersect_line_plane(PyObject *UNUSED(self), PyObject* args) +static PyObject *M_Geometry_intersect_line_plane(PyObject *UNUSED(self), PyObject *args) { VectorObject *line_a, *line_b, *plane_co, *plane_no; - int no_flip= 0; + int no_flip = 0; float isect[3]; if (!PyArg_ParseTuple(args, "O!O!O!O!|i:intersect_line_plane", &vector_Type, &line_a, @@ -513,7 +513,7 @@ PyDoc_STRVAR(M_Geometry_intersect_plane_plane_doc, " :return: The line of the intersection represented as a point and a vector\n" " :rtype: tuple pair of :class:`mathutils.Vector`\n" ); -static PyObject *M_Geometry_intersect_plane_plane(PyObject *UNUSED(self), PyObject* args) +static PyObject *M_Geometry_intersect_plane_plane(PyObject *UNUSED(self), PyObject *args) { PyObject *ret; VectorObject *plane_a_co, *plane_a_no, *plane_b_co, *plane_b_no; @@ -551,7 +551,7 @@ static PyObject *M_Geometry_intersect_plane_plane(PyObject *UNUSED(self), PyObje normalize_v3(isect_no); - ret= PyTuple_New(2); + ret = PyTuple_New(2); PyTuple_SET_ITEM(ret, 0, Vector_CreatePyObject(isect_co, 3, Py_NEW, NULL)); PyTuple_SET_ITEM(ret, 1, Vector_CreatePyObject(isect_no, 3, Py_NEW, NULL)); return ret; @@ -574,11 +574,11 @@ PyDoc_STRVAR(M_Geometry_intersect_line_sphere_doc, " :return: The intersection points as a pair of vectors or None when there is no intersection\n" " :rtype: A tuple pair containing :class:`mathutils.Vector` or None\n" ); -static PyObject *M_Geometry_intersect_line_sphere(PyObject *UNUSED(self), PyObject* args) +static PyObject *M_Geometry_intersect_line_sphere(PyObject *UNUSED(self), PyObject *args) { VectorObject *line_a, *line_b, *sphere_co; float sphere_radius; - int clip= TRUE; + int clip = TRUE; float isect_a[3]; float isect_b[3]; @@ -606,24 +606,24 @@ static PyObject *M_Geometry_intersect_line_sphere(PyObject *UNUSED(self), PyObje return NULL; } else { - short use_a= TRUE; - short use_b= TRUE; + short use_a = TRUE; + short use_b = TRUE; float lambda; - PyObject *ret= PyTuple_New(2); + PyObject *ret = PyTuple_New(2); switch (isect_line_sphere_v3(line_a->vec, line_b->vec, sphere_co->vec, sphere_radius, isect_a, isect_b)) { case 1: - if (!(!clip || (((lambda= line_point_factor_v3(isect_a, line_a->vec, line_b->vec)) >= 0.0f) && (lambda <= 1.0f)))) use_a= FALSE; - use_b= FALSE; + if (!(!clip || (((lambda = line_point_factor_v3(isect_a, line_a->vec, line_b->vec)) >= 0.0f) && (lambda <= 1.0f)))) use_a = FALSE; + use_b = FALSE; break; case 2: - if (!(!clip || (((lambda= line_point_factor_v3(isect_a, line_a->vec, line_b->vec)) >= 0.0f) && (lambda <= 1.0f)))) use_a= FALSE; - if (!(!clip || (((lambda= line_point_factor_v3(isect_b, line_a->vec, line_b->vec)) >= 0.0f) && (lambda <= 1.0f)))) use_b= FALSE; + if (!(!clip || (((lambda = line_point_factor_v3(isect_a, line_a->vec, line_b->vec)) >= 0.0f) && (lambda <= 1.0f)))) use_a = FALSE; + if (!(!clip || (((lambda = line_point_factor_v3(isect_b, line_a->vec, line_b->vec)) >= 0.0f) && (lambda <= 1.0f)))) use_b = FALSE; break; default: - use_a= FALSE; - use_b= FALSE; + use_a = FALSE; + use_b = FALSE; } if (use_a) { PyTuple_SET_ITEM(ret, 0, Vector_CreatePyObject(isect_a, 3, Py_NEW, NULL)); } @@ -654,11 +654,11 @@ PyDoc_STRVAR(M_Geometry_intersect_line_sphere_2d_doc, " :return: The intersection points as a pair of vectors or None when there is no intersection\n" " :rtype: A tuple pair containing :class:`mathutils.Vector` or None\n" ); -static PyObject *M_Geometry_intersect_line_sphere_2d(PyObject *UNUSED(self), PyObject* args) +static PyObject *M_Geometry_intersect_line_sphere_2d(PyObject *UNUSED(self), PyObject *args) { VectorObject *line_a, *line_b, *sphere_co; float sphere_radius; - int clip= TRUE; + int clip = TRUE; float isect_a[3]; float isect_b[3]; @@ -679,24 +679,24 @@ static PyObject *M_Geometry_intersect_line_sphere_2d(PyObject *UNUSED(self), PyO return NULL; } else { - short use_a= TRUE; - short use_b= TRUE; + short use_a = TRUE; + short use_b = TRUE; float lambda; - PyObject *ret= PyTuple_New(2); + PyObject *ret = PyTuple_New(2); switch (isect_line_sphere_v2(line_a->vec, line_b->vec, sphere_co->vec, sphere_radius, isect_a, isect_b)) { case 1: - if (!(!clip || (((lambda= line_point_factor_v2(isect_a, line_a->vec, line_b->vec)) >= 0.0f) && (lambda <= 1.0f)))) use_a= FALSE; - use_b= FALSE; + if (!(!clip || (((lambda = line_point_factor_v2(isect_a, line_a->vec, line_b->vec)) >= 0.0f) && (lambda <= 1.0f)))) use_a = FALSE; + use_b = FALSE; break; case 2: - if (!(!clip || (((lambda= line_point_factor_v2(isect_a, line_a->vec, line_b->vec)) >= 0.0f) && (lambda <= 1.0f)))) use_a= FALSE; - if (!(!clip || (((lambda= line_point_factor_v2(isect_b, line_a->vec, line_b->vec)) >= 0.0f) && (lambda <= 1.0f)))) use_b= FALSE; + if (!(!clip || (((lambda = line_point_factor_v2(isect_a, line_a->vec, line_b->vec)) >= 0.0f) && (lambda <= 1.0f)))) use_a = FALSE; + if (!(!clip || (((lambda = line_point_factor_v2(isect_b, line_a->vec, line_b->vec)) >= 0.0f) && (lambda <= 1.0f)))) use_b = FALSE; break; default: - use_a= FALSE; - use_b= FALSE; + use_a = FALSE; + use_b = FALSE; } if (use_a) { PyTuple_SET_ITEM(ret, 0, Vector_CreatePyObject(isect_a, 2, Py_NEW, NULL)); } @@ -722,7 +722,7 @@ PyDoc_STRVAR(M_Geometry_intersect_point_line_doc, " :type line_p1: :class:`mathutils.Vector`\n" " :rtype: (:class:`mathutils.Vector`, float)\n" ); -static PyObject *M_Geometry_intersect_point_line(PyObject *UNUSED(self), PyObject* args) +static PyObject *M_Geometry_intersect_point_line(PyObject *UNUSED(self), PyObject *args) { VectorObject *pt, *line_1, *line_2; float pt_in[3], pt_out[3], l1[3], l2[3]; @@ -745,19 +745,19 @@ static PyObject *M_Geometry_intersect_point_line(PyObject *UNUSED(self), PyObjec } /* accept 2d verts */ - if (pt->size==3) { copy_v3_v3(pt_in, pt->vec);} - else { pt_in[2]=0.0; copy_v2_v2(pt_in, pt->vec); } + if (pt->size == 3) { copy_v3_v3(pt_in, pt->vec);} + else { pt_in[2] = 0.0f; copy_v2_v2(pt_in, pt->vec); } - if (line_1->size==3) { copy_v3_v3(l1, line_1->vec);} - else { l1[2]=0.0; copy_v2_v2(l1, line_1->vec); } + if (line_1->size == 3) { copy_v3_v3(l1, line_1->vec);} + else { l1[2] = 0.0f; copy_v2_v2(l1, line_1->vec); } - if (line_2->size==3) { copy_v3_v3(l2, line_2->vec);} - else { l2[2]=0.0; copy_v2_v2(l2, line_2->vec); } + if (line_2->size == 3) { copy_v3_v3(l2, line_2->vec);} + else { l2[2] = 0.0f; copy_v2_v2(l2, line_2->vec); } /* do the calculation */ - lambda= closest_to_line_v3(pt_out, pt_in, l1, l2); + lambda = closest_to_line_v3(pt_out, pt_in, l1, l2); - ret= PyTuple_New(2); + ret = PyTuple_New(2); PyTuple_SET_ITEM(ret, 0, Vector_CreatePyObject(pt_out, 3, Py_NEW, NULL)); PyTuple_SET_ITEM(ret, 1, PyFloat_FromDouble(lambda)); return ret; @@ -778,7 +778,7 @@ PyDoc_STRVAR(M_Geometry_intersect_point_tri_2d_doc, " :type tri_p3: :class:`mathutils.Vector`\n" " :rtype: int\n" ); -static PyObject *M_Geometry_intersect_point_tri_2d(PyObject *UNUSED(self), PyObject* args) +static PyObject *M_Geometry_intersect_point_tri_2d(PyObject *UNUSED(self), PyObject *args) { VectorObject *pt_vec, *tri_p1, *tri_p2, *tri_p3; @@ -820,7 +820,7 @@ PyDoc_STRVAR(M_Geometry_intersect_point_quad_2d_doc, " :type quad_p4: :class:`mathutils.Vector`\n" " :rtype: int\n" ); -static PyObject *M_Geometry_intersect_point_quad_2d(PyObject *UNUSED(self), PyObject* args) +static PyObject *M_Geometry_intersect_point_quad_2d(PyObject *UNUSED(self), PyObject *args) { VectorObject *pt_vec, *quad_p1, *quad_p2, *quad_p3, *quad_p4; @@ -860,7 +860,7 @@ PyDoc_STRVAR(M_Geometry_distance_point_to_plane_doc, " :type plane_no: :class:`mathutils.Vector`\n" " :rtype: float\n" ); -static PyObject *M_Geometry_distance_point_to_plane(PyObject *UNUSED(self), PyObject* args) +static PyObject *M_Geometry_distance_point_to_plane(PyObject *UNUSED(self), PyObject *args) { VectorObject *pt, *plene_co, *plane_no; @@ -963,7 +963,7 @@ PyDoc_STRVAR(M_Geometry_interpolate_bezier_doc, " :return: The interpolated points\n" " :rtype: list of :class:`mathutils.Vector`'s\n" ); -static PyObject *M_Geometry_interpolate_bezier(PyObject *UNUSED(self), PyObject* args) +static PyObject *M_Geometry_interpolate_bezier(PyObject *UNUSED(self), PyObject *args) { VectorObject *vec_k1, *vec_h1, *vec_k2, *vec_h2; int resolu; @@ -972,10 +972,10 @@ static PyObject *M_Geometry_interpolate_bezier(PyObject *UNUSED(self), PyObject* float *coord_array, *fp; PyObject *list; - float k1[4]= {0.0, 0.0, 0.0, 0.0}; - float h1[4]= {0.0, 0.0, 0.0, 0.0}; - float k2[4]= {0.0, 0.0, 0.0, 0.0}; - float h2[4]= {0.0, 0.0, 0.0, 0.0}; + float k1[4] = {0.0, 0.0, 0.0, 0.0}; + float h1[4] = {0.0, 0.0, 0.0, 0.0}; + float k2[4] = {0.0, 0.0, 0.0, 0.0}; + float h2[4] = {0.0, 0.0, 0.0, 0.0}; if (!PyArg_ParseTuple(args, "O!O!O!O!i:interpolate_bezier", @@ -1001,21 +1001,21 @@ static PyObject *M_Geometry_interpolate_bezier(PyObject *UNUSED(self), PyObject* return NULL; } - dims= MAX4(vec_k1->size, vec_h1->size, vec_h2->size, vec_k2->size); + dims = MAX4(vec_k1->size, vec_h1->size, vec_h2->size, vec_k2->size); - for (i=0; i < vec_k1->size; i++) k1[i]= vec_k1->vec[i]; - for (i=0; i < vec_h1->size; i++) h1[i]= vec_h1->vec[i]; - for (i=0; i < vec_k2->size; i++) k2[i]= vec_k2->vec[i]; - for (i=0; i < vec_h2->size; i++) h2[i]= vec_h2->vec[i]; + for (i = 0; i < vec_k1->size; i++) k1[i] = vec_k1->vec[i]; + for (i = 0; i < vec_h1->size; i++) h1[i] = vec_h1->vec[i]; + for (i = 0; i < vec_k2->size; i++) k2[i] = vec_k2->vec[i]; + for (i = 0; i < vec_h2->size; i++) h2[i] = vec_h2->vec[i]; - coord_array= MEM_callocN(dims * (resolu) * sizeof(float), "interpolate_bezier"); - for (i=0; iverts to set the points from the vectors */ - int index, *dl_face, totpoints=0; + int index, *dl_face, totpoints = 0; if (!PySequence_Check(polyLineSeq)) { PyErr_SetString(PyExc_TypeError, @@ -1050,10 +1050,10 @@ static PyObject *M_Geometry_tesselate_polygon(PyObject *UNUSED(self), PyObject * return NULL; } - len_polylines= PySequence_Size(polyLineSeq); + len_polylines = PySequence_Size(polyLineSeq); - for (i= 0; i < len_polylines; ++i) { - polyLine= PySequence_GetItem(polyLineSeq, i); + for (i = 0; i < len_polylines; ++i) { + polyLine = PySequence_GetItem(polyLineSeq, i); if (!PySequence_Check(polyLine)) { freedisplist(&dispbase); Py_XDECREF(polyLine); /* may be null so use Py_XDECREF*/ @@ -1062,8 +1062,8 @@ static PyObject *M_Geometry_tesselate_polygon(PyObject *UNUSED(self), PyObject * return NULL; } - len_polypoints= PySequence_Size(polyLine); - if (len_polypoints>0) { /* dont bother adding edges as polylines */ + len_polypoints = PySequence_Size(polyLine); + if (len_polypoints > 0) { /* dont bother adding edges as polylines */ #if 0 if (EXPP_check_sequence_consistency(polyLine, &vector_Type) != 1) { freedisplist(&dispbase); @@ -1073,32 +1073,32 @@ static PyObject *M_Geometry_tesselate_polygon(PyObject *UNUSED(self), PyObject * return NULL; } #endif - dl= MEM_callocN(sizeof(DispList), "poly disp"); + dl = MEM_callocN(sizeof(DispList), "poly disp"); BLI_addtail(&dispbase, dl); - dl->type= DL_INDEX3; - dl->nr= len_polypoints; - dl->type= DL_POLY; - dl->parts= 1; /* no faces, 1 edge loop */ - dl->col= 0; /* no material */ - dl->verts= fp= MEM_callocN(sizeof(float)*3*len_polypoints, "dl verts"); - dl->index= MEM_callocN(sizeof(int)*3*len_polypoints, "dl index"); - - for (index= 0; indextype = DL_INDEX3; + dl->nr = len_polypoints; + dl->type = DL_POLY; + dl->parts = 1; /* no faces, 1 edge loop */ + dl->col = 0; /* no material */ + dl->verts = fp = MEM_callocN(sizeof(float) * 3 * len_polypoints, "dl verts"); + dl->index = MEM_callocN(sizeof(int) * 3 * len_polypoints, "dl index"); + + for (index = 0; index < len_polypoints; ++index, fp += 3) { + polyVec = PySequence_GetItem(polyLine, index); if (VectorObject_Check(polyVec)) { if (BaseMath_ReadCallback((VectorObject *)polyVec) == -1) - ls_error= 1; + ls_error = 1; - fp[0]= ((VectorObject *)polyVec)->vec[0]; - fp[1]= ((VectorObject *)polyVec)->vec[1]; + fp[0] = ((VectorObject *)polyVec)->vec[0]; + fp[1] = ((VectorObject *)polyVec)->vec[1]; if (((VectorObject *)polyVec)->size > 2) - fp[2]= ((VectorObject *)polyVec)->vec[2]; + fp[2] = ((VectorObject *)polyVec)->vec[2]; else - fp[2]= 0.0f; /* if its a 2d vector then set the z to be zero */ + fp[2] = 0.0f; /* if its a 2d vector then set the z to be zero */ } else { - ls_error= 1; + ls_error = 1; } totpoints++; @@ -1121,9 +1121,9 @@ static PyObject *M_Geometry_tesselate_polygon(PyObject *UNUSED(self), PyObject * /* The faces are stored in a new DisplayList thats added to the head of the listbase */ - dl= dispbase.first; + dl = dispbase.first; - tri_list= PyList_New(dl->parts); + tri_list = PyList_New(dl->parts); if (!tri_list) { freedisplist(&dispbase); PyErr_SetString(PyExc_RuntimeError, @@ -1131,11 +1131,11 @@ static PyObject *M_Geometry_tesselate_polygon(PyObject *UNUSED(self), PyObject * return NULL; } - index= 0; - dl_face= dl->index; + index = 0; + dl_face = dl->index; while (index < dl->parts) { PyList_SET_ITEM(tri_list, index, Py_BuildValue("iii", dl_face[0], dl_face[1], dl_face[2])); - dl_face+= 3; + dl_face += 3; index++; } freedisplist(&dispbase); @@ -1143,7 +1143,7 @@ static PyObject *M_Geometry_tesselate_polygon(PyObject *UNUSED(self), PyObject * else { /* no points, do this so scripts dont barf */ freedisplist(&dispbase); /* possible some dl was allocated */ - tri_list= PyList_New(0); + tri_list = PyList_New(0); } return tri_list; @@ -1164,13 +1164,13 @@ static int boxPack_FromPyObject(PyObject *value, boxPack **boxarray) return -1; } - len= PyList_GET_SIZE(value); + len = PyList_GET_SIZE(value); - (*boxarray)= MEM_mallocN(len*sizeof(boxPack), "boxPack box"); + *boxarray = MEM_mallocN(len * sizeof(boxPack), "boxPack box"); - for (i= 0; i < len; i++) { - list_item= PyList_GET_ITEM(value, i); + for (i = 0; i < len; i++) { + list_item = PyList_GET_ITEM(value, i); if (!PyList_Check(list_item) || PyList_GET_SIZE(list_item) < 4) { MEM_freeN(*boxarray); PyErr_SetString(PyExc_TypeError, @@ -1178,14 +1178,14 @@ static int boxPack_FromPyObject(PyObject *value, boxPack **boxarray) return -1; } - box= (*boxarray)+i; + box = (*boxarray) + i; - item_1= PyList_GET_ITEM(list_item, 2); - item_2= PyList_GET_ITEM(list_item, 3); + item_1 = PyList_GET_ITEM(list_item, 2); + item_2 = PyList_GET_ITEM(list_item, 3); - box->w= (float)PyFloat_AsDouble(item_1); - box->h= (float)PyFloat_AsDouble(item_2); - box->index= i; + box->w = (float)PyFloat_AsDouble(item_1); + box->h = (float)PyFloat_AsDouble(item_2); + box->index = i; /* accounts for error case too and overwrites with own error */ if (box->w < 0.0f || box->h < 0.0f) { @@ -1207,11 +1207,11 @@ static void boxPack_ToPyObject(PyObject *value, boxPack **boxarray) PyObject *list_item; boxPack *box; - len= PyList_GET_SIZE(value); + len = PyList_GET_SIZE(value); - for (i= 0; i < len; i++) { - box= (*boxarray)+i; - list_item= PyList_GET_ITEM(value, box->index); + for (i = 0; i < len; i++) { + box = (*boxarray)+i; + list_item = PyList_GET_ITEM(value, box->index); PyList_SET_ITEM(list_item, 0, PyFloat_FromDouble(box->x)); PyList_SET_ITEM(list_item, 1, PyFloat_FromDouble(box->y)); } @@ -1230,7 +1230,7 @@ PyDoc_STRVAR(M_Geometry_box_pack_2d_doc, ); static PyObject *M_Geometry_box_pack_2d(PyObject *UNUSED(self), PyObject *boxlist) { - float tot_width= 0.0f, tot_height= 0.0f; + float tot_width = 0.0f, tot_height = 0.0f; Py_ssize_t len; PyObject *ret; @@ -1241,9 +1241,9 @@ static PyObject *M_Geometry_box_pack_2d(PyObject *UNUSED(self), PyObject *boxlis return NULL; } - len= PyList_GET_SIZE(boxlist); + len = PyList_GET_SIZE(boxlist); if (len) { - boxPack *boxarray= NULL; + boxPack *boxarray = NULL; if (boxPack_FromPyObject(boxlist, &boxarray) == -1) { return NULL; /* exception set */ } @@ -1254,7 +1254,7 @@ static PyObject *M_Geometry_box_pack_2d(PyObject *UNUSED(self), PyObject *boxlis boxPack_ToPyObject(boxlist, &boxarray); } - ret= PyTuple_New(2); + ret = PyTuple_New(2); PyTuple_SET_ITEM(ret, 0, PyFloat_FromDouble(tot_width)); PyTuple_SET_ITEM(ret, 1, PyFloat_FromDouble(tot_width)); return ret; @@ -1263,7 +1263,7 @@ static PyObject *M_Geometry_box_pack_2d(PyObject *UNUSED(self), PyObject *boxlis #endif /* MATH_STANDALONE */ -static PyMethodDef M_Geometry_methods[]= { +static PyMethodDef M_Geometry_methods[] = { {"intersect_ray_tri", (PyCFunction) M_Geometry_intersect_ray_tri, METH_VARARGS, M_Geometry_intersect_ray_tri_doc}, {"intersect_point_line", (PyCFunction) M_Geometry_intersect_point_line, METH_VARARGS, M_Geometry_intersect_point_line_doc}, {"intersect_point_tri_2d", (PyCFunction) M_Geometry_intersect_point_tri_2d, METH_VARARGS, M_Geometry_intersect_point_tri_2d_doc}, @@ -1286,7 +1286,7 @@ static PyMethodDef M_Geometry_methods[]= { {NULL, NULL, 0, NULL} }; -static struct PyModuleDef M_Geometry_module_def= { +static struct PyModuleDef M_Geometry_module_def = { PyModuleDef_HEAD_INIT, "mathutils.geometry", /* m_name */ M_Geometry_doc, /* m_doc */ @@ -1301,6 +1301,6 @@ static struct PyModuleDef M_Geometry_module_def= { /*----------------------------MODULE INIT-------------------------*/ PyMODINIT_FUNC PyInit_mathutils_geometry(void) { - PyObject *submodule= PyModule_Create(&M_Geometry_module_def); + PyObject *submodule = PyModule_Create(&M_Geometry_module_def); return submodule; } diff --git a/source/blender/python/mathutils/mathutils_noise.c b/source/blender/python/mathutils/mathutils_noise.c index c0e8ac24baa..fceff965fcb 100644 --- a/source/blender/python/mathutils/mathutils_noise.c +++ b/source/blender/python/mathutils/mathutils_noise.c @@ -199,8 +199,8 @@ static float frand(void) /* Fills an array of length size with random numbers in the range (-1, 1)*/ static void rand_vn(float *array_tar, const int size) { - float *array_pt= array_tar + (size-1); - int i= size; + float *array_pt = array_tar + (size-1); + int i = size; while (i--) { *(array_pt--) = 2.0f * frand() - 1.0f; } } @@ -208,9 +208,9 @@ static void rand_vn(float *array_tar, const int size) static void noise_vector(float x, float y, float z, int nb, float v[3]) { /* Simply evaluate noise at 3 different positions */ - v[0]= (float)(2.0f * BLI_gNoise(1.f, x + 9.321f, y - 1.531f, z - 7.951f, 0, nb) - 1.0f); - v[1]= (float)(2.0f * BLI_gNoise(1.f, x, y, z, 0, nb) - 1.0f); - v[2]= (float)(2.0f * BLI_gNoise(1.f, x + 6.327f, y + 0.1671f, z - 2.672f, 0, nb) - 1.0f); + v[0] = (float)(2.0f * BLI_gNoise(1.f, x + 9.321f, y - 1.531f, z - 7.951f, 0, nb) - 1.0f); + v[1] = (float)(2.0f * BLI_gNoise(1.f, x, y, z, 0, nb) - 1.0f); + v[2] = (float)(2.0f * BLI_gNoise(1.f, x + 6.327f, y + 0.1671f, z - 2.672f, 0, nb) - 1.0f); } /* Returns a turbulence value for a given position (x, y, z) */ @@ -301,9 +301,9 @@ PyDoc_STRVAR(M_Noise_random_unit_vector_doc, ); static PyObject *M_Noise_random_unit_vector(PyObject *UNUSED(self), PyObject *args) { - float vec[4]= {0.0f, 0.0f, 0.0f, 0.0f}; - float norm= 2.0f; - int size= 3; + float vec[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + float norm = 2.0f; + int size = 3; if (!PyArg_ParseTuple(args, "|i:random_vector", &size)) return NULL; @@ -313,9 +313,9 @@ static PyObject *M_Noise_random_unit_vector(PyObject *UNUSED(self), PyObject *ar return NULL; } - while (norm==0.0f || norm>=1.0f) { + while (norm == 0.0f || norm >= 1.0f) { rand_vn(vec, size); - norm= normalize_vn(vec, size); + norm = normalize_vn(vec, size); } return Vector_CreatePyObject(vec, size, Py_NEW, NULL); @@ -384,7 +384,7 @@ static PyObject *M_Noise_noise(PyObject *UNUSED(self), PyObject *args) { PyObject *value; float vec[3]; - int nb= 1; + int nb = 1; if (!PyArg_ParseTuple(args, "O|i:noise", &value, &nb)) return NULL; @@ -410,7 +410,7 @@ static PyObject *M_Noise_noise_vector(PyObject *UNUSED(self), PyObject *args) { PyObject *value; float vec[3], r_vec[3]; - int nb= 1; + int nb = 1; if (!PyArg_ParseTuple(args, "O|i:noise_vector", &value, &nb)) return NULL; @@ -447,8 +447,8 @@ static PyObject *M_Noise_turbulence(PyObject *UNUSED(self), PyObject *args) { PyObject *value; float vec[3]; - int oct, hd, nb= 1; - float as= 0.5f, fs= 2.0f; + int oct, hd, nb = 1; + float as = 0.5f, fs = 2.0f; if (!PyArg_ParseTuple(args, "Oii|iff:turbulence", &value, &oct, &hd, &nb, &as, &fs)) return NULL; @@ -483,8 +483,8 @@ static PyObject *M_Noise_turbulence_vector(PyObject *UNUSED(self), PyObject *arg { PyObject *value; float vec[3], r_vec[3]; - int oct, hd, nb= 1; - float as =0.5f, fs= 2.0f; + int oct, hd, nb = 1; + float as =0.5f, fs = 2.0f; if (!PyArg_ParseTuple(args, "Oii|iff:turbulence_vector", &value, &oct, &hd, &nb, &as, &fs)) return NULL; @@ -519,7 +519,7 @@ static PyObject *M_Noise_fractal(PyObject *UNUSED(self), PyObject *args) PyObject *value; float vec[3]; float H, lac, oct; - int nb= 1; + int nb = 1; if (!PyArg_ParseTuple(args, "Offf|i:fractal", &value, &H, &lac, &oct, &nb)) return NULL; @@ -553,7 +553,7 @@ static PyObject *M_Noise_multi_fractal(PyObject *UNUSED(self), PyObject *args) PyObject *value; float vec[3]; float H, lac, oct; - int nb= 1; + int nb = 1; if (!PyArg_ParseTuple(args, "Offf|i:multi_fractal", &value, &H, &lac, &oct, &nb)) return NULL; @@ -585,7 +585,7 @@ static PyObject *M_Noise_variable_lacunarity(PyObject *UNUSED(self), PyObject *a PyObject *value; float vec[3]; float d; - int nt1= 1, nt2= 1; + int nt1 = 1, nt2 = 1; if (!PyArg_ParseTuple(args, "Of|ii:variable_lacunarity", &value, &d, &nt1, &nt2)) return NULL; @@ -621,7 +621,7 @@ static PyObject *M_Noise_hetero_terrain(PyObject *UNUSED(self), PyObject *args) PyObject *value; float vec[3]; float H, lac, oct, ofs; - int nb= 1; + int nb = 1; if (!PyArg_ParseTuple(args, "Offff|i:hetero_terrain", &value, &H, &lac, &oct, &ofs, &nb)) return NULL; @@ -659,7 +659,7 @@ static PyObject *M_Noise_hybrid_multi_fractal(PyObject *UNUSED(self), PyObject * PyObject *value; float vec[3]; float H, lac, oct, ofs, gn; - int nb= 1; + int nb = 1; if (!PyArg_ParseTuple(args, "Offfff|i:hybrid_multi_fractal", &value, &H, &lac, &oct, &ofs, &gn, &nb)) return NULL; @@ -697,7 +697,7 @@ static PyObject *M_Noise_ridged_multi_fractal(PyObject *UNUSED(self), PyObject * PyObject *value; float vec[3]; float H, lac, oct, ofs, gn; - int nb= 1; + int nb = 1; if (!PyArg_ParseTuple(args, "Offfff|i:ridged_multi_fractal", &value, &H, &lac, &oct, &ofs, &gn, &nb)) return NULL; @@ -728,8 +728,8 @@ static PyObject *M_Noise_voronoi(PyObject *UNUSED(self), PyObject *args) PyObject *list; float vec[3]; float da[4], pa[12]; - int dtype= 0; - float me= 2.5f; /* default minkovsky exponent */ + int dtype = 0; + float me = 2.5f; /* default minkovsky exponent */ int i; @@ -739,12 +739,12 @@ static PyObject *M_Noise_voronoi(PyObject *UNUSED(self), PyObject *args) if (mathutils_array_parse(vec, 3, 3, value, "voronoi: invalid 'position' arg") == -1) return NULL; - list= PyList_New(4); + list = PyList_New(4); voronoi(vec[0], vec[1], vec[2], da, pa, me, dtype); - for (i=0; i<4; i++) { - PyList_SET_ITEM(list, i, Vector_CreatePyObject(pa + 3*i, 3, Py_NEW, NULL)); + for (i = 0; i < 4; i++) { + PyList_SET_ITEM(list, i, Vector_CreatePyObject(pa + 3 * i, 3, Py_NEW, NULL)); } return Py_BuildValue("[[ffff]O]", da[0], da[1], da[2], da[3], list); @@ -841,11 +841,11 @@ PyMODINIT_FUNC PyInit_mathutils_noise(void) /* use current time as seed for random number generator by default */ setRndSeed(0); - PyModule_AddObject(submodule, "types", (item_types=PyInit_mathutils_noise_types())); + PyModule_AddObject(submodule, "types", (item_types = PyInit_mathutils_noise_types())); PyDict_SetItemString(PyThreadState_GET()->interp->modules, "noise.types", item_types); Py_INCREF(item_types); - PyModule_AddObject(submodule, "distance_metrics", (item_metrics=PyInit_mathutils_noise_metrics())); + PyModule_AddObject(submodule, "distance_metrics", (item_metrics = PyInit_mathutils_noise_metrics())); PyDict_SetItemString(PyThreadState_GET()->interp->modules, "noise.distance_metrics", item_metrics); Py_INCREF(item_metrics); -- cgit v1.2.3 From 67effc8aefcde5acc72a67aff76d367e22a091ae Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 25 Dec 2011 11:36:26 +0000 Subject: use docstrings for mathutils getset's, also some formatting edits, no functional changes. --- source/blender/python/mathutils/mathutils.c | 2 +- source/blender/python/mathutils/mathutils_Color.c | 45 ++++++---- source/blender/python/mathutils/mathutils_Euler.c | 46 +++++----- source/blender/python/mathutils/mathutils_Matrix.c | 64 ++++++++----- .../python/mathutils/mathutils_Quaternion.c | 30 +++++-- source/blender/python/mathutils/mathutils_Vector.c | 100 +++++++++++---------- .../blender/python/mathutils/mathutils_geometry.c | 6 +- 7 files changed, 177 insertions(+), 116 deletions(-) (limited to 'source/blender') diff --git a/source/blender/python/mathutils/mathutils.c b/source/blender/python/mathutils/mathutils.c index 42fa46207f3..739206feefd 100644 --- a/source/blender/python/mathutils/mathutils.c +++ b/source/blender/python/mathutils/mathutils.c @@ -43,7 +43,7 @@ PyDoc_STRVAR(M_Mathutils_doc, static int mathutils_array_parse_fast(float *array, int size, PyObject *value_fast, - const char *error_prefix) + const char *error_prefix) { PyObject *item; diff --git a/source/blender/python/mathutils/mathutils_Color.c b/source/blender/python/mathutils/mathutils_Color.c index c85380fb245..7f3f811c41a 100644 --- a/source/blender/python/mathutils/mathutils_Color.c +++ b/source/blender/python/mathutils/mathutils_Color.c @@ -111,7 +111,7 @@ static PyObject *Color_copy(ColorObject *self) //----------------------------print object (internal)-------------- //print the object to screen -static PyObject *Color_repr(ColorObject * self) +static PyObject *Color_repr(ColorObject *self) { PyObject *ret, *tuple; @@ -126,7 +126,7 @@ static PyObject *Color_repr(ColorObject * self) return ret; } -static PyObject *Color_str(ColorObject * self) +static PyObject *Color_str(ColorObject *self) { DynStr *ds; @@ -188,7 +188,7 @@ static int Color_len(ColorObject *UNUSED(self)) } //----------------------------object[]--------------------------- //sequence accessor (get) -static PyObject *Color_item(ColorObject * self, int i) +static PyObject *Color_item(ColorObject *self, int i) { if (i < 0) i = COLOR_SIZE - i; @@ -207,7 +207,7 @@ static PyObject *Color_item(ColorObject * self, int i) } //----------------------------object[]------------------------- //sequence accessor (set) -static int Color_ass_item(ColorObject * self, int i, PyObject *value) +static int Color_ass_item(ColorObject *self, int i, PyObject *value) { float f = PyFloat_AsDouble(value); @@ -235,7 +235,7 @@ static int Color_ass_item(ColorObject * self, int i, PyObject *value) } //----------------------------object[z:y]------------------------ //sequence slice (get) -static PyObject *Color_slice(ColorObject * self, int begin, int end) +static PyObject *Color_slice(ColorObject *self, int begin, int end) { PyObject *tuple; int count; @@ -670,18 +670,26 @@ static PyNumberMethods Color_NumMethods = { }; /* color channel, vector.r/g/b */ -static PyObject *Color_channel_get(ColorObject * self, void *type) +PyDoc_STRVAR(Color_channel_r_doc, "Red color channel.\n\n:type: float"); +PyDoc_STRVAR(Color_channel_g_doc, "Green color channel.\n\n:type: float"); +PyDoc_STRVAR(Color_channel_b_doc, "Blue color channel.\n\n:type: float"); + +static PyObject *Color_channel_get(ColorObject *self, void *type) { return Color_item(self, GET_INT_FROM_POINTER(type)); } -static int Color_channel_set(ColorObject * self, PyObject *value, void * type) +static int Color_channel_set(ColorObject *self, PyObject *value, void * type) { return Color_ass_item(self, GET_INT_FROM_POINTER(type), value); } /* color channel (HSV), color.h/s/v */ -static PyObject *Color_channel_hsv_get(ColorObject * self, void *type) +PyDoc_STRVAR(Color_channel_hsv_h_doc, "HSV Hue component in [0, 1].\n\n:type: float"); +PyDoc_STRVAR(Color_channel_hsv_s_doc, "HSV Saturation component in [0, 1].\n\n:type: float"); +PyDoc_STRVAR(Color_channel_hsv_v_doc, "HSV Value component in [0, 1].\n\n:type: float"); + +static PyObject *Color_channel_hsv_get(ColorObject *self, void *type) { float hsv[3]; int i = GET_INT_FROM_POINTER(type); @@ -694,7 +702,7 @@ static PyObject *Color_channel_hsv_get(ColorObject * self, void *type) return PyFloat_FromDouble(hsv[i]); } -static int Color_channel_hsv_set(ColorObject * self, PyObject *value, void * type) +static int Color_channel_hsv_set(ColorObject *self, PyObject *value, void * type) { float hsv[3]; int i = GET_INT_FROM_POINTER(type); @@ -722,7 +730,8 @@ static int Color_channel_hsv_set(ColorObject * self, PyObject *value, void * typ } /* color channel (HSV), color.h/s/v */ -static PyObject *Color_hsv_get(ColorObject * self, void *UNUSED(closure)) +PyDoc_STRVAR(Color_hsv_doc, "HSV Values in [0, 1].\n\n:type: float triplet"); +static PyObject *Color_hsv_get(ColorObject *self, void *UNUSED(closure)) { float hsv[3]; PyObject *ret; @@ -739,7 +748,7 @@ static PyObject *Color_hsv_get(ColorObject * self, void *UNUSED(closure)) return ret; } -static int Color_hsv_set(ColorObject * self, PyObject *value, void *UNUSED(closure)) +static int Color_hsv_set(ColorObject *self, PyObject *value, void *UNUSED(closure)) { float hsv[3]; @@ -762,15 +771,15 @@ static int Color_hsv_set(ColorObject * self, PyObject *value, void *UNUSED(closu /* Python attributes get/set structure: */ /*****************************************************************************/ static PyGetSetDef Color_getseters[] = { - {(char *)"r", (getter)Color_channel_get, (setter)Color_channel_set, (char *)"Red color channel.\n\n:type: float", (void *)0}, - {(char *)"g", (getter)Color_channel_get, (setter)Color_channel_set, (char *)"Green color channel.\n\n:type: float", (void *)1}, - {(char *)"b", (getter)Color_channel_get, (setter)Color_channel_set, (char *)"Blue color channel.\n\n:type: float", (void *)2}, + {(char *)"r", (getter)Color_channel_get, (setter)Color_channel_set, Color_channel_r_doc, (void *)0}, + {(char *)"g", (getter)Color_channel_get, (setter)Color_channel_set, Color_channel_g_doc, (void *)1}, + {(char *)"b", (getter)Color_channel_get, (setter)Color_channel_set, Color_channel_b_doc, (void *)2}, - {(char *)"h", (getter)Color_channel_hsv_get, (setter)Color_channel_hsv_set, (char *)"HSV Hue component in [0, 1].\n\n:type: float", (void *)0}, - {(char *)"s", (getter)Color_channel_hsv_get, (setter)Color_channel_hsv_set, (char *)"HSV Saturation component in [0, 1].\n\n:type: float", (void *)1}, - {(char *)"v", (getter)Color_channel_hsv_get, (setter)Color_channel_hsv_set, (char *)"HSV Value component in [0, 1].\n\n:type: float", (void *)2}, + {(char *)"h", (getter)Color_channel_hsv_get, (setter)Color_channel_hsv_set, (char *)Color_channel_hsv_h_doc, (void *)0}, + {(char *)"s", (getter)Color_channel_hsv_get, (setter)Color_channel_hsv_set, (char *)Color_channel_hsv_s_doc, (void *)1}, + {(char *)"v", (getter)Color_channel_hsv_get, (setter)Color_channel_hsv_set, (char *)Color_channel_hsv_v_doc, (void *)2}, - {(char *)"hsv", (getter)Color_hsv_get, (setter)Color_hsv_set, (char *)"HSV Values in [0, 1].\n\n:type: float triplet", (void *)0}, + {(char *)"hsv", (getter)Color_hsv_get, (setter)Color_hsv_set, (char *)Color_hsv_doc, (void *)0}, {(char *)"is_wrapped", (getter)BaseMathObject_is_wrapped_get, (setter)NULL, BaseMathObject_is_wrapped_doc, NULL}, {(char *)"owner", (getter)BaseMathObject_owner_get, (setter)NULL, BaseMathObject_owner_doc, NULL}, diff --git a/source/blender/python/mathutils/mathutils_Euler.c b/source/blender/python/mathutils/mathutils_Euler.c index f6bd77cd453..02ed208b35d 100644 --- a/source/blender/python/mathutils/mathutils_Euler.c +++ b/source/blender/python/mathutils/mathutils_Euler.c @@ -134,7 +134,7 @@ PyDoc_STRVAR(Euler_to_quaternion_doc, " :return: Quaternion representation of the euler.\n" " :rtype: :class:`Quaternion`\n" ); -static PyObject *Euler_to_quaternion(EulerObject * self) +static PyObject *Euler_to_quaternion(EulerObject *self) { float quat[4]; @@ -155,7 +155,7 @@ PyDoc_STRVAR(Euler_to_matrix_doc, " :return: A 3x3 roation matrix representation of the euler.\n" " :rtype: :class:`Matrix`\n" ); -static PyObject *Euler_to_matrix(EulerObject * self) +static PyObject *Euler_to_matrix(EulerObject *self) { float mat[9]; @@ -172,7 +172,7 @@ PyDoc_STRVAR(Euler_zero_doc, "\n" " Set all values to zero.\n" ); -static PyObject *Euler_zero(EulerObject * self) +static PyObject *Euler_zero(EulerObject *self) { zero_v3(self->eul); @@ -193,7 +193,7 @@ PyDoc_STRVAR(Euler_rotate_axis_doc, " :arg angle: angle in radians.\n" " :type angle: float\n" ); -static PyObject *Euler_rotate_axis(EulerObject * self, PyObject *args) +static PyObject *Euler_rotate_axis(EulerObject *self, PyObject *args) { float angle = 0.0f; int axis; /* actually a character */ @@ -231,7 +231,7 @@ PyDoc_STRVAR(Euler_rotate_doc, " :arg other: rotation component of mathutils value\n" " :type other: :class:`Euler`, :class:`Quaternion` or :class:`Matrix`\n" ); -static PyObject *Euler_rotate(EulerObject * self, PyObject *value) +static PyObject *Euler_rotate(EulerObject *self, PyObject *value) { float self_rmat[3][3], other_rmat[3][3], rmat[3][3]; @@ -258,7 +258,7 @@ PyDoc_STRVAR(Euler_make_compatible_doc, "\n" " .. note:: the rotation order is not taken into account for this function.\n" ); -static PyObject *Euler_make_compatible(EulerObject * self, PyObject *value) +static PyObject *Euler_make_compatible(EulerObject *self, PyObject *value) { float teul[EULER_SIZE]; @@ -303,7 +303,7 @@ static PyObject *Euler_copy(EulerObject *self) //----------------------------print object (internal)-------------- //print the object to screen -static PyObject *Euler_repr(EulerObject * self) +static PyObject *Euler_repr(EulerObject *self) { PyObject *ret, *tuple; @@ -318,7 +318,7 @@ static PyObject *Euler_repr(EulerObject * self) return ret; } -static PyObject *Euler_str(EulerObject * self) +static PyObject *Euler_str(EulerObject *self) { DynStr *ds; @@ -378,7 +378,7 @@ static int Euler_len(EulerObject *UNUSED(self)) } //----------------------------object[]--------------------------- //sequence accessor (get) -static PyObject *Euler_item(EulerObject * self, int i) +static PyObject *Euler_item(EulerObject *self, int i) { if (i < 0) i = EULER_SIZE - i; @@ -397,7 +397,7 @@ static PyObject *Euler_item(EulerObject * self, int i) } //----------------------------object[]------------------------- //sequence accessor (set) -static int Euler_ass_item(EulerObject * self, int i, PyObject *value) +static int Euler_ass_item(EulerObject *self, int i, PyObject *value) { float f = PyFloat_AsDouble(value); @@ -426,7 +426,7 @@ static int Euler_ass_item(EulerObject * self, int i, PyObject *value) } //----------------------------object[z:y]------------------------ //sequence slice (get) -static PyObject *Euler_slice(EulerObject * self, int begin, int end) +static PyObject *Euler_slice(EulerObject *self, int begin, int end) { PyObject *tuple; int count; @@ -568,9 +568,11 @@ static PyMappingMethods Euler_AsMapping = { (objobjargproc)Euler_ass_subscript }; -/* - * euler axis, euler.x/y/z - */ +/* euler axis, euler.x/y/z */ + +PyDoc_STRVAR(Euler_axis_doc, +"Euler axis angle in radians.\n\n:type: float" +); static PyObject *Euler_axis_get(EulerObject *self, void *type) { return Euler_item(self, GET_INT_FROM_POINTER(type)); @@ -582,6 +584,10 @@ static int Euler_axis_set(EulerObject *self, PyObject *value, void *type) } /* rotation order */ + +PyDoc_STRVAR(Euler_order_doc, +"Euler rotation order.\n\n:type: string in ['XYZ', 'XZY', 'YXZ', 'YZX', 'ZXY', 'ZYX']" +); static PyObject *Euler_order_get(EulerObject *self, void *UNUSED(closure)) { if (BaseMath_ReadCallback(self) == -1) /* can read order too */ @@ -607,13 +613,13 @@ static int Euler_order_set(EulerObject *self, PyObject *value, void *UNUSED(clos /* Python attributes get/set structure: */ /*****************************************************************************/ static PyGetSetDef Euler_getseters[] = { - {(char *)"x", (getter)Euler_axis_get, (setter)Euler_axis_set, (char *)"Euler X axis in radians.\n\n:type: float", (void *)0}, - {(char *)"y", (getter)Euler_axis_get, (setter)Euler_axis_set, (char *)"Euler Y axis in radians.\n\n:type: float", (void *)1}, - {(char *)"z", (getter)Euler_axis_get, (setter)Euler_axis_set, (char *)"Euler Z axis in radians.\n\n:type: float", (void *)2}, - {(char *)"order", (getter)Euler_order_get, (setter)Euler_order_set, (char *)"Euler rotation order.\n\n:type: string in ['XYZ', 'XZY', 'YXZ', 'YZX', 'ZXY', 'ZYX']", (void *)NULL}, + {(char *)"x", (getter)Euler_axis_get, (setter)Euler_axis_set, Euler_axis_doc, (void *)0}, + {(char *)"y", (getter)Euler_axis_get, (setter)Euler_axis_set, Euler_axis_doc, (void *)1}, + {(char *)"z", (getter)Euler_axis_get, (setter)Euler_axis_set, Euler_axis_doc, (void *)2}, + {(char *)"order", (getter)Euler_order_get, (setter)Euler_order_set, Euler_order_doc, (void *)NULL}, - {(char *)"is_wrapped", (getter)BaseMathObject_is_wrapped_get, (setter)NULL, (char *)BaseMathObject_is_wrapped_doc, NULL}, - {(char *)"owner", (getter)BaseMathObject_owner_get, (setter)NULL, (char *)BaseMathObject_owner_doc, NULL}, + {(char *)"is_wrapped", (getter)BaseMathObject_is_wrapped_get, (setter)NULL, BaseMathObject_is_wrapped_doc, NULL}, + {(char *)"owner", (getter)BaseMathObject_owner_get, (setter)NULL, BaseMathObject_owner_doc, NULL}, {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index 307c9f8ab73..7e881fd5dda 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -1938,16 +1938,25 @@ static PyNumberMethods Matrix_NumMethods = { NULL, /* nb_index */ }; +PyDoc_STRVAR(Matrix_row_size_doc, +"The row size of the matrix (readonly).\n\n:type: int" +); static PyObject *Matrix_row_size_get(MatrixObject *self, void *UNUSED(closure)) { return PyLong_FromLong((long) self->num_col); } +PyDoc_STRVAR(Matrix_col_size_doc, +"The column size of the matrix (readonly).\n\n:type: int" +); static PyObject *Matrix_col_size_get(MatrixObject *self, void *UNUSED(closure)) { return PyLong_FromLong((long) self->num_row); } +PyDoc_STRVAR(Matrix_translation_doc, +"The translation component of the matrix.\n\n:type: Vector" +); static PyObject *Matrix_translation_get(MatrixObject *self, void *UNUSED(closure)) { PyObject *ret; @@ -1968,15 +1977,6 @@ static PyObject *Matrix_translation_get(MatrixObject *self, void *UNUSED(closure return ret; } -static PyObject *Matrix_row_get(MatrixObject *self, void *UNUSED(closure)) -{ - return MatrixAccess_CreatePyObject(self, MAT_ACCESS_ROW); -} -static PyObject *Matrix_col_get(MatrixObject *self, void *UNUSED(closure)) -{ - return MatrixAccess_CreatePyObject(self, MAT_ACCESS_COL); -} - static int Matrix_translation_set(MatrixObject *self, PyObject *value, void *UNUSED(closure)) { float tvec[3]; @@ -2002,6 +2002,25 @@ static int Matrix_translation_set(MatrixObject *self, PyObject *value, void *UNU return 0; } +PyDoc_STRVAR(Matrix_row_doc, +"Access the matix by rows (default), (readonly).\n\n:type: Matrix Access" +); +static PyObject *Matrix_row_get(MatrixObject *self, void *UNUSED(closure)) +{ + return MatrixAccess_CreatePyObject(self, MAT_ACCESS_ROW); +} + +PyDoc_STRVAR(Matrix_col_doc, +"Access the matix by colums, 3x3 and 4x4 only, (readonly).\n\n:type: Matrix Access" +); +static PyObject *Matrix_col_get(MatrixObject *self, void *UNUSED(closure)) +{ + return MatrixAccess_CreatePyObject(self, MAT_ACCESS_COL); +} + +PyDoc_STRVAR(Matrix_median_scale_doc, +"The average scale applied to each axis (readonly).\n\n:type: float" +); static PyObject *Matrix_median_scale_get(MatrixObject *self, void *UNUSED(closure)) { float mat[3][3]; @@ -2022,6 +2041,9 @@ static PyObject *Matrix_median_scale_get(MatrixObject *self, void *UNUSED(closur return PyFloat_FromDouble(mat3_to_scale(mat)); } +PyDoc_STRVAR(Matrix_is_negative_doc, +"True if this matrix results in a negative scale, 3x3 and 4x4 only, (readonly).\n\n:type: bool" +); static PyObject *Matrix_is_negative_get(MatrixObject *self, void *UNUSED(closure)) { if (BaseMath_ReadCallback(self) == -1) @@ -2040,6 +2062,9 @@ static PyObject *Matrix_is_negative_get(MatrixObject *self, void *UNUSED(closure } } +PyDoc_STRVAR(Matrix_is_orthogonal_doc, +"True if this matrix is orthogonal, 3x3 and 4x4 only, (readonly).\n\n:type: bool" +); static PyObject *Matrix_is_orthogonal_get(MatrixObject *self, void *UNUSED(closure)) { if (BaseMath_ReadCallback(self) == -1) @@ -2062,17 +2087,16 @@ static PyObject *Matrix_is_orthogonal_get(MatrixObject *self, void *UNUSED(closu /* Python attributes get/set structure: */ /*****************************************************************************/ static PyGetSetDef Matrix_getseters[] = { - {(char *)"row_size", (getter)Matrix_row_size_get, (setter)NULL, (char *)"The row size of the matrix (readonly).\n\n:type: int", NULL}, - {(char *)"col_size", (getter)Matrix_col_size_get, (setter)NULL, (char *)"The column size of the matrix (readonly).\n\n:type: int", NULL}, - {(char *)"median_scale", (getter)Matrix_median_scale_get, (setter)NULL, (char *)"The average scale applied to each axis (readonly).\n\n:type: float", NULL}, - {(char *)"translation", (getter)Matrix_translation_get, (setter)Matrix_translation_set, (char *)"The translation component of the matrix.\n\n:type: Vector", NULL}, - /* MatrixAccess_CreatePyObject*/ - {(char *)"row", (getter)Matrix_row_get, (setter)NULL, (char *)"Access the matix by rows (default), (readonly).\n\n:type: Matrix Access", NULL}, - {(char *)"col", (getter)Matrix_col_get, (setter)NULL, (char *)"Access the matix by colums, 3x3 and 4x4 only, (readonly).\n\n:type: Matrix Access", NULL}, - {(char *)"is_negative", (getter)Matrix_is_negative_get, (setter)NULL, (char *)"True if this matrix results in a negative scale, 3x3 and 4x4 only, (readonly).\n\n:type: bool", NULL}, - {(char *)"is_orthogonal", (getter)Matrix_is_orthogonal_get, (setter)NULL, (char *)"True if this matrix is orthogonal, 3x3 and 4x4 only, (readonly).\n\n:type: bool", NULL}, - {(char *)"is_wrapped", (getter)BaseMathObject_is_wrapped_get, (setter)NULL, (char *)BaseMathObject_is_wrapped_doc, NULL}, - {(char *)"owner",(getter)BaseMathObject_owner_get, (setter)NULL, (char *)BaseMathObject_owner_doc, NULL}, + {(char *)"row_size", (getter)Matrix_row_size_get, (setter)NULL, Matrix_row_size_doc, NULL}, + {(char *)"col_size", (getter)Matrix_col_size_get, (setter)NULL, Matrix_col_size_doc, NULL}, + {(char *)"median_scale", (getter)Matrix_median_scale_get, (setter)NULL, Matrix_median_scale_doc, NULL}, + {(char *)"translation", (getter)Matrix_translation_get, (setter)Matrix_translation_set, Matrix_translation_doc, NULL}, + {(char *)"row", (getter)Matrix_row_get, (setter)NULL, Matrix_row_doc, NULL}, + {(char *)"col", (getter)Matrix_col_get, (setter)NULL, Matrix_col_doc, NULL}, + {(char *)"is_negative", (getter)Matrix_is_negative_get, (setter)NULL, Matrix_is_negative_doc, NULL}, + {(char *)"is_orthogonal", (getter)Matrix_is_orthogonal_get, (setter)NULL, Matrix_is_orthogonal_doc, NULL}, + {(char *)"is_wrapped", (getter)BaseMathObject_is_wrapped_get, (setter)NULL, BaseMathObject_is_wrapped_doc, NULL}, + {(char *)"owner",(getter)BaseMathObject_owner_get, (setter)NULL, BaseMathObject_owner_doc, NULL}, {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c b/source/blender/python/mathutils/mathutils_Quaternion.c index a563e280f1c..258a802b92b 100644 --- a/source/blender/python/mathutils/mathutils_Quaternion.c +++ b/source/blender/python/mathutils/mathutils_Quaternion.c @@ -922,6 +922,9 @@ static PyNumberMethods Quaternion_NumMethods = { NULL, /* nb_index */ }; +PyDoc_STRVAR(Quaternion_axis_doc, +"Quaternion axis value.\n\n:type: float" +); static PyObject *Quaternion_axis_get(QuaternionObject *self, void *type) { return Quaternion_item(self, GET_INT_FROM_POINTER(type)); @@ -932,6 +935,9 @@ static int Quaternion_axis_set(QuaternionObject *self, PyObject *value, void *ty return Quaternion_ass_item(self, GET_INT_FROM_POINTER(type), value); } +PyDoc_STRVAR(Quaternion_magnitude_doc, +"Size of the quaternion (readonly).\n\n:type: float" +); static PyObject *Quaternion_magnitude_get(QuaternionObject *self, void *UNUSED(closure)) { if (BaseMath_ReadCallback(self) == -1) @@ -940,6 +946,9 @@ static PyObject *Quaternion_magnitude_get(QuaternionObject *self, void *UNUSED(c return PyFloat_FromDouble(sqrt(dot_qtqt(self->quat, self->quat))); } +PyDoc_STRVAR(Quaternion_angle_doc, +"Angle of the quaternion.\n\n:type: float" +); static PyObject *Quaternion_angle_get(QuaternionObject *self, void *UNUSED(closure)) { float tquat[4]; @@ -992,6 +1001,9 @@ static int Quaternion_angle_set(QuaternionObject *self, PyObject *value, void *U return 0; } +PyDoc_STRVAR(Quaternion_axis_vector_doc, +"Quaternion axis as a vector.\n\n:type: :class:`Vector`" +); static PyObject *Quaternion_axis_vector_get(QuaternionObject *self, void *UNUSED(closure)) { float tquat[4]; @@ -1151,15 +1163,15 @@ static struct PyMethodDef Quaternion_methods[] = { /* Python attributes get/set structure: */ /*****************************************************************************/ static PyGetSetDef Quaternion_getseters[] = { - {(char *)"w", (getter)Quaternion_axis_get, (setter)Quaternion_axis_set, (char *)"Quaternion W value.\n\n:type: float", (void *)0}, - {(char *)"x", (getter)Quaternion_axis_get, (setter)Quaternion_axis_set, (char *)"Quaternion X axis.\n\n:type: float", (void *)1}, - {(char *)"y", (getter)Quaternion_axis_get, (setter)Quaternion_axis_set, (char *)"Quaternion Y axis.\n\n:type: float", (void *)2}, - {(char *)"z", (getter)Quaternion_axis_get, (setter)Quaternion_axis_set, (char *)"Quaternion Z axis.\n\n:type: float", (void *)3}, - {(char *)"magnitude", (getter)Quaternion_magnitude_get, (setter)NULL, (char *)"Size of the quaternion (readonly).\n\n:type: float", NULL}, - {(char *)"angle", (getter)Quaternion_angle_get, (setter)Quaternion_angle_set, (char *)"angle of the quaternion.\n\n:type: float", NULL}, - {(char *)"axis",(getter)Quaternion_axis_vector_get, (setter)Quaternion_axis_vector_set, (char *)"quaternion axis as a vector.\n\n:type: :class:`Vector`", NULL}, - {(char *)"is_wrapped", (getter)BaseMathObject_is_wrapped_get, (setter)NULL, (char *)BaseMathObject_is_wrapped_doc, NULL}, - {(char *)"owner", (getter)BaseMathObject_owner_get, (setter)NULL, (char *)BaseMathObject_owner_doc, NULL}, + {(char *)"w", (getter)Quaternion_axis_get, (setter)Quaternion_axis_set, Quaternion_axis_doc, (void *)0}, + {(char *)"x", (getter)Quaternion_axis_get, (setter)Quaternion_axis_set, Quaternion_axis_doc, (void *)1}, + {(char *)"y", (getter)Quaternion_axis_get, (setter)Quaternion_axis_set, Quaternion_axis_doc, (void *)2}, + {(char *)"z", (getter)Quaternion_axis_get, (setter)Quaternion_axis_set, Quaternion_axis_doc, (void *)3}, + {(char *)"magnitude", (getter)Quaternion_magnitude_get, (setter)NULL, Quaternion_magnitude_doc, NULL}, + {(char *)"angle", (getter)Quaternion_angle_get, (setter)Quaternion_angle_set, Quaternion_angle_doc, NULL}, + {(char *)"axis",(getter)Quaternion_axis_vector_get, (setter)Quaternion_axis_vector_set, Quaternion_axis_vector_doc, NULL}, + {(char *)"is_wrapped", (getter)BaseMathObject_is_wrapped_get, (setter)NULL, BaseMathObject_is_wrapped_doc, NULL}, + {(char *)"owner", (getter)BaseMathObject_owner_get, (setter)NULL, BaseMathObject_owner_doc, NULL}, {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c index f5d4ca7ec4e..79abf384eb0 100644 --- a/source/blender/python/mathutils/mathutils_Vector.c +++ b/source/blender/python/mathutils/mathutils_Vector.c @@ -174,8 +174,8 @@ static PyObject *C_Vector_Range(PyObject *cls, PyObject *args) case 2: if (start >= stop) { PyErr_SetString(PyExc_RuntimeError, - "Start value is larger" - "than the stop value"); + "Start value is larger" + "than the stop value"); return NULL; } @@ -184,8 +184,8 @@ static PyObject *C_Vector_Range(PyObject *cls, PyObject *args) default: if (start >= stop) { PyErr_SetString(PyExc_RuntimeError, - "Start value is larger" - "than the stop value"); + "Start value is larger" + "than the stop value"); return NULL; } size = (stop - start)/step; @@ -198,7 +198,7 @@ static PyObject *C_Vector_Range(PyObject *cls, PyObject *args) if (vec == NULL) { PyErr_SetString(PyExc_MemoryError, - "Vector.Range(): " + "Vector.Range(): " "problem allocating pointer space"); return NULL; } @@ -242,7 +242,7 @@ static PyObject *C_Vector_Linspace(PyObject *cls, PyObject *args) if (vec == NULL) { PyErr_SetString(PyExc_MemoryError, - "Vector.Linspace(): " + "Vector.Linspace(): " "problem allocating pointer space"); return NULL; } @@ -286,7 +286,7 @@ static PyObject *C_Vector_Repeat(PyObject *cls, PyObject *args) if (iter_vec == NULL) { PyErr_SetString(PyExc_MemoryError, - "Vector.Repeat(): " + "Vector.Repeat(): " "problem allocating pointer space"); return NULL; } @@ -295,7 +295,7 @@ static PyObject *C_Vector_Repeat(PyObject *cls, PyObject *args) if (vec == NULL) { PyErr_SetString(PyExc_MemoryError, - "Vector.Repeat(): " + "Vector.Repeat(): " "problem allocating pointer space"); return NULL; } @@ -445,7 +445,7 @@ static PyObject *Vector_resized(VectorObject *self, PyObject *value) if (vec == NULL) { PyErr_SetString(PyExc_MemoryError, - "Vector.resized(): " + "Vector.resized(): " "problem allocating pointer space"); return NULL; } @@ -2023,9 +2023,12 @@ static PyNumberMethods Vector_NumMethods = { /*------------------PY_OBECT DEFINITION--------------------------*/ -/* - * vector axis, vector.x/y/z/w - */ +/* vector axis, vector.x/y/z/w */ + +PyDoc_STRVAR(Vector_axis_x_doc, "Vector X axis.\n\n:type: float"); +PyDoc_STRVAR(Vector_axis_y_doc, "Vector Y axis.\n\n:type: float"); +PyDoc_STRVAR(Vector_axis_z_doc, "Vector Z axis (3D Vectors only).\n\n:type: float"); +PyDoc_STRVAR(Vector_axis_w_doc, "Vector W axis (4D Vectors only).\n\n:type: float"); static PyObject *Vector_axis_get(VectorObject *self, void *type) { @@ -2038,6 +2041,10 @@ static int Vector_axis_set(VectorObject *self, PyObject *value, void *type) } /* vector.length */ + +PyDoc_STRVAR(Vector_length_doc, +"Vector Length.\n\n:type: float" +); static PyObject *Vector_length_get(VectorObject *self, void *UNUSED(closure)) { if (BaseMath_ReadCallback(self) == -1) @@ -2089,6 +2096,9 @@ static int Vector_length_set(VectorObject *self, PyObject *value) } /* vector.length_squared */ +PyDoc_STRVAR(Vector_length_squared_doc, +"Vector length squared (v.dot(v)).\n\n:type: float" +); static PyObject *Vector_length_squared_get(VectorObject *self, void *UNUSED(closure)) { if (BaseMath_ReadCallback(self) == -1) @@ -2098,8 +2108,8 @@ static PyObject *Vector_length_squared_get(VectorObject *self, void *UNUSED(clos } /* Get a new Vector according to the provided swizzle. This function has little - error checking, as we are in control of the inputs: the closure is set by us - in Vector_createSwizzleGetSeter. */ + * error checking, as we are in control of the inputs: the closure is set by us + * in Vector_createSwizzleGetSeter. */ static PyObject *Vector_swizzle_get(VectorObject *self, void *closure) { size_t axis_to; @@ -2113,8 +2123,7 @@ static PyObject *Vector_swizzle_get(VectorObject *self, void *closure) /* Unpack the axes from the closure into an array. */ axis_to = 0; swizzleClosure = GET_INT_FROM_POINTER(closure); - while (swizzleClosure & SWIZZLE_VALID_AXIS) - { + while (swizzleClosure & SWIZZLE_VALID_AXIS) { axis_from = swizzleClosure & SWIZZLE_AXIS; if (axis_from >= self->size) { PyErr_SetString(PyExc_AttributeError, @@ -2132,15 +2141,15 @@ static PyObject *Vector_swizzle_get(VectorObject *self, void *closure) } /* Set the items of this vector using a swizzle. - - If value is a vector or list this operates like an array copy, except that - the destination is effectively re-ordered as defined by the swizzle. At - most min(len(source), len(dest)) values will be copied. - - If the value is scalar, it is copied to all axes listed in the swizzle. - - If an axis appears more than once in the swizzle, the final occurrence is - the one that determines its value. - - Returns 0 on success and -1 on failure. On failure, the vector will be - unchanged. */ + * - If value is a vector or list this operates like an array copy, except that + * the destination is effectively re-ordered as defined by the swizzle. At + * most min(len(source), len(dest)) values will be copied. + * - If the value is scalar, it is copied to all axes listed in the swizzle. + * - If an axis appears more than once in the swizzle, the final occurrence is + * the one that determines its value. + + * Returns 0 on success and -1 on failure. On failure, the vector will be + * unchanged. */ static int Vector_swizzle_set(VectorObject *self, PyObject *value, void *closure) { size_t size_from; @@ -2158,13 +2167,13 @@ static int Vector_swizzle_set(VectorObject *self, PyObject *value, void *closure return -1; /* Check that the closure can be used with this vector: even 2D vectors have - swizzles defined for axes z and w, but they would be invalid. */ + * swizzles defined for axes z and w, but they would be invalid. */ swizzleClosure = GET_INT_FROM_POINTER(closure); axis_from = 0; + while (swizzleClosure & SWIZZLE_VALID_AXIS) { axis_to = swizzleClosure & SWIZZLE_AXIS; - if (axis_to >= self->size) - { + if (axis_to >= self->size) { PyErr_SetString(PyExc_AttributeError, "Vector swizzle: " "specified axis not present"); @@ -2176,8 +2185,10 @@ static int Vector_swizzle_set(VectorObject *self, PyObject *value, void *closure if (((scalarVal = PyFloat_AsDouble(value)) == -1 && PyErr_Occurred()) == 0) { int i; - for (i = 0; i < MAX_DIMENSIONS; i++) + + for (i = 0; i < MAX_DIMENSIONS; i++) { vec_assign[i] = scalarVal; + } size_from = axis_from; } @@ -2197,8 +2208,8 @@ static int Vector_swizzle_set(VectorObject *self, PyObject *value, void *closure /* Copy vector contents onto swizzled axes. */ axis_from = 0; swizzleClosure = GET_INT_FROM_POINTER(closure); - while (swizzleClosure & SWIZZLE_VALID_AXIS) - { + + while (swizzleClosure & SWIZZLE_VALID_AXIS) { axis_to = swizzleClosure & SWIZZLE_AXIS; tvec[axis_to] = vec_assign[axis_from]; swizzleClosure = swizzleClosure >> SWIZZLE_BITS_PER_AXIS; @@ -2218,15 +2229,15 @@ static int Vector_swizzle_set(VectorObject *self, PyObject *value, void *closure /* Python attributes get/set structure: */ /*****************************************************************************/ static PyGetSetDef Vector_getseters[] = { - {(char *)"x", (getter)Vector_axis_get, (setter)Vector_axis_set, (char *)"Vector X axis.\n\n:type: float", (void *)0}, - {(char *)"y", (getter)Vector_axis_get, (setter)Vector_axis_set, (char *)"Vector Y axis.\n\n:type: float", (void *)1}, - {(char *)"z", (getter)Vector_axis_get, (setter)Vector_axis_set, (char *)"Vector Z axis (3D Vectors only).\n\n:type: float", (void *)2}, - {(char *)"w", (getter)Vector_axis_get, (setter)Vector_axis_set, (char *)"Vector W axis (4D Vectors only).\n\n:type: float", (void *)3}, - {(char *)"length", (getter)Vector_length_get, (setter)Vector_length_set, (char *)"Vector Length.\n\n:type: float", NULL}, - {(char *)"length_squared", (getter)Vector_length_squared_get, (setter)NULL, (char *)"Vector length squared (v.dot(v)).\n\n:type: float", NULL}, - {(char *)"magnitude", (getter)Vector_length_get, (setter)Vector_length_set, (char *)"Vector Length.\n\n:type: float", NULL}, - {(char *)"is_wrapped", (getter)BaseMathObject_is_wrapped_get, (setter)NULL, (char *)BaseMathObject_is_wrapped_doc, NULL}, - {(char *)"owner", (getter)BaseMathObject_owner_get, (setter)NULL, (char *)BaseMathObject_owner_doc, NULL}, + {(char *)"x", (getter)Vector_axis_get, (setter)Vector_axis_set, Vector_axis_x_doc, (void *)0}, + {(char *)"y", (getter)Vector_axis_get, (setter)Vector_axis_set, Vector_axis_y_doc, (void *)1}, + {(char *)"z", (getter)Vector_axis_get, (setter)Vector_axis_set, Vector_axis_z_doc, (void *)2}, + {(char *)"w", (getter)Vector_axis_get, (setter)Vector_axis_set, Vector_axis_w_doc, (void *)3}, + {(char *)"length", (getter)Vector_length_get, (setter)Vector_length_set, Vector_length_doc, NULL}, + {(char *)"length_squared", (getter)Vector_length_squared_get, (setter)NULL, Vector_length_squared_doc, NULL}, + {(char *)"magnitude", (getter)Vector_length_get, (setter)Vector_length_set, Vector_length_doc, NULL}, + {(char *)"is_wrapped", (getter)BaseMathObject_is_wrapped_get, (setter)NULL, BaseMathObject_is_wrapped_doc, NULL}, + {(char *)"owner", (getter)BaseMathObject_owner_get, (setter)NULL, BaseMathObject_owner_doc, NULL}, /* autogenerated swizzle attrs, see python script below */ {(char *)"xx", (getter)Vector_swizzle_get, (setter)NULL, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<= 2: axis_0_pos = axis_pos[axis_0] for axis_1 in axises: axis_1_pos = axis_pos[axis_1] - axis_dict[axis_0+axis_1] = '((%s|SWIZZLE_VALID_AXIS) | ((%s|SWIZZLE_VALID_AXIS)<2: for axis_2 in axises: axis_2_pos = axis_pos[axis_2] - axis_dict[axis_0+axis_1+axis_2] = '((%s|SWIZZLE_VALID_AXIS) | ((%s|SWIZZLE_VALID_AXIS)<3: for axis_3 in axises: axis_3_pos = axis_pos[axis_3] - axis_dict[axis_0+axis_1+axis_2+axis_3] = '((%s|SWIZZLE_VALID_AXIS) | ((%s|SWIZZLE_VALID_AXIS)<size; if (mat->num_row != vec_size) { @@ -2640,11 +2650,11 @@ static int row_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject *v rvec[3] = 1.0f; //muliplication for (col = 0; col < mat->num_col; col++) { + double dot = 0.0; for (row = 0; row < mat->num_row; row++) { dot += MATRIX_ITEM(mat, row, col) * vec_cpy[row]; } rvec[z++] = (float)dot; - dot = 0.0f; } return 0; } diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c index d7e7bef5f23..b4f3f4e470e 100644 --- a/source/blender/python/mathutils/mathutils_geometry.c +++ b/source/blender/python/mathutils/mathutils_geometry.c @@ -1052,7 +1052,7 @@ static PyObject *M_Geometry_tesselate_polygon(PyObject *UNUSED(self), PyObject * len_polylines = PySequence_Size(polyLineSeq); - for (i = 0; i < len_polylines; ++i) { + for (i = 0; i < len_polylines; i++) { polyLine = PySequence_GetItem(polyLineSeq, i); if (!PySequence_Check(polyLine)) { freedisplist(&dispbase); @@ -1083,7 +1083,7 @@ static PyObject *M_Geometry_tesselate_polygon(PyObject *UNUSED(self), PyObject * dl->verts = fp = MEM_callocN(sizeof(float) * 3 * len_polypoints, "dl verts"); dl->index = MEM_callocN(sizeof(int) * 3 * len_polypoints, "dl index"); - for (index = 0; index < len_polypoints; ++index, fp += 3) { + for (index = 0; index < len_polypoints; index++, fp += 3) { polyVec = PySequence_GetItem(polyLine, index); if (VectorObject_Check(polyVec)) { @@ -1210,7 +1210,7 @@ static void boxPack_ToPyObject(PyObject *value, boxPack **boxarray) len = PyList_GET_SIZE(value); for (i = 0; i < len; i++) { - box = (*boxarray)+i; + box = (*boxarray) + i; list_item = PyList_GET_ITEM(value, box->index); PyList_SET_ITEM(list_item, 0, PyFloat_FromDouble(box->x)); PyList_SET_ITEM(list_item, 1, PyFloat_FromDouble(box->y)); -- cgit v1.2.3 From 02d72b5c076f4ae1b47da74fe7a60a916edad9f2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 25 Dec 2011 21:27:23 +0000 Subject: include BLO_sys_types in customdata header rather than stdint directly. --- source/blender/blenkernel/BKE_customdata.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h index 7e2dfa2eefc..a4cef2d6862 100644 --- a/source/blender/blenkernel/BKE_customdata.h +++ b/source/blender/blenkernel/BKE_customdata.h @@ -34,14 +34,12 @@ #ifndef BKE_CUSTOMDATA_H #define BKE_CUSTOMDATA_H -#if defined(__APPLE__) && (__GNUC__ == 4) && (__GNUC_MINOR__ >= 6) -#include -#endif - #ifdef __cplusplus extern "C" { #endif +#include "../blenloader/BLO_sys_types.h" /* XXX, should have a more generic include for this */ + struct ID; struct CustomData; struct CustomDataLayer; -- cgit v1.2.3