diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-09-03 18:53:54 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-09-03 18:53:54 +0400 |
commit | 0cf0f5a62225f9f9cc2ed9715274e94dc09ad8b0 (patch) | |
tree | f89e9ebe84dc32179532ab8fc269c46b8b6e8b8a /source/blender/blenkernel | |
parent | 52cefa4bc1104231cf6c6ef5b12124df135e2914 (diff) |
rna api
- move: material.add_texture(tex, coords, mapto) --> material.texture_slots.add()
- added material.texture_slots.create(index), material.texture_slots.clear(index)
- texture slot functions also work for lamp and world now.
Other minor changes
- allow rna functions to set FUNC_NO_SELF and FUNC_USE_SELF_ID at once.
- [#23317] Changed some operators' RNA to accept lengths, a modification I made to this patch made it not work as intended, removed this edit so unit buttons appier in the UI for certain operators.
- Sphinx doc gen, 2 columns rather then 3, didnt quite fit in some cases.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_texture.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/texture.c | 43 |
2 files changed, 44 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_texture.h b/source/blender/blenkernel/BKE_texture.h index 380672dae04..99bb8db44ed 100644 --- a/source/blender/blenkernel/BKE_texture.h +++ b/source/blender/blenkernel/BKE_texture.h @@ -70,6 +70,7 @@ struct Tex *add_texture(const char *name); void tex_set_type(struct Tex *tex, int type); void default_mtex(struct MTex *mtex); struct MTex *add_mtex(void); +struct MTex *add_mtex_id(struct ID *id, int slot); struct Tex *copy_texture(struct Tex *tex); void make_local_texture(struct Tex *tex); void autotexname(struct Tex *tex); diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 9075c64d286..77416f4dd12 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -689,6 +689,49 @@ MTex *add_mtex() return mtex; } +/* slot -1 for first free ID */ +MTex *add_mtex_id(ID *id, int slot) +{ + MTex **mtex_ar; + short act; + + give_active_mtex(id, &mtex_ar, &act); + + if(mtex_ar==NULL) { + return NULL; + } + + if(slot==-1) { + /* find first free */ + int i; + for (i= 0; i < MAX_MTEX; i++) { + if (!mtex_ar[i]) { + slot= i; + break; + } + } + if(slot == -1) { + return NULL; + } + } + else { + /* make sure slot is valid */ + if(slot < 0 || slot >= MAX_MTEX) { + return NULL; + } + } + + if (mtex_ar[slot]) { + id_us_min((ID *)mtex_ar[slot]->tex); + MEM_freeN(mtex_ar[slot]); + mtex_ar[slot]= NULL; + } + + mtex_ar[slot]= add_mtex(); + + return mtex_ar[slot]; +} + /* ------------------------------------------------------------------------- */ Tex *copy_texture(Tex *tex) |