Commit Graph

59 Commits

Author SHA1 Message Date
6e086d4cfe =ID Properties Python Update=
ID Properties binding have now been added for textures.  Also,
the beginnings of supporting "del IDProperty Object" (which 
basically removes the property from it's parent group then frees
it) in python were done; really the only thing now is to figure 
out exactly *how* you overload the del operator. :S
2006-11-19 16:00:04 +00:00
Ken Hughes
318a694a25 Get rid of various warnings with gcc under linux 2006-11-17 17:50:43 +00:00
4c5fcf136b =ID Properties Update=
This commit adds file reading/writing of ID properties to all ID types, 
and also adds python access for NMesh, Mesh, Scene and Image.  Note 
that the file reading code might need some more work for certain 
future/planned features to save right.  Also I updated a few comments in idprop.c.
2006-11-17 06:14:15 +00:00
dda63a9dde added comparison function to many python types so you can do == and =! 2006-10-06 16:48:28 +00:00
d82f1f5f91 from looking at patch 4934 made all user preference paths settable with Blender.Set('val', data), also added exception errors which were on the todo.
image.filename was being limited to FILE_MAXDIR rather then FILE_MAXDIR + FILE_MAXFILE when setting.
2006-09-21 18:25:40 +00:00
95c185c4c5 Setting the image name was raising an error. 2006-09-21 17:03:24 +00:00
e472a3d852 renamed Blender.Image.SetCurrent(img) to img.makeCurrent() to be consistant with scene.
applied patch #4998 (array count), as well as adding other array settings, updated documentation as well.
added EXPP_setVec3Clamped() as a way to set a vector from getset attrs (used with array offset and scale)
2006-09-17 02:31:16 +00:00
c7d39e1a06 New images were being initialized with zero users (normal for other data types),
but for images user counts work differently.
(just noticed this is what blender does so Image.New() now does the same)

Many of the sys functions had maximum path thengths that were too short.
  char path[FILE_MAXFILE];
rather then
  char path[FILE_MAXDIR + FILE_MAXFILE];
2006-09-16 10:05:57 +00:00
e6960f3881 Python Metaballs api refactor, based on Mesh and Group modules.
* removed get/set in favor of setsetattrs
* added an element iterator to the metaball data type.
* now accepts vectors and quat for location dimensions and rotation.
and other small changes.
Docs updated shortly at.
http://members.iinet.net.au/~cpbarton/ideasman/BPY_API/Metaball-module.html

other changes
typo in image.c
metaballs constants in buttons_editing
2006-09-16 09:33:09 +00:00
2b7f09b8ea added Image.SetCurrent(img) and img.has_data so you can see if an image contains pixel info. 2006-09-16 06:18:41 +00:00
Ken Hughes
e194ccce5e ===Python API===
Bugfix: using Image.GetCurrent() and image.save() on the "Render Result"
image could result in a segfault since image->ibuf was NULL.  This change
forces ibuf to be created if necessary.

NOTE: the Image API needs additional methods/attributes for image.save() to
really do anything useful.  The image type, quality, etc., don't seem to be
gettable/settable so the resulting image file may not be in the format the
user would like.
2006-07-18 21:02:15 +00:00
dee16b9e3d * bug fix
[ #4228 ] Blender.Image.Load(filename) loads only on the first loading
- Image.Load() will now reload the image buffer when a image of the same name is loaded again
- small textual change in render code
2006-05-26 15:28:04 +00:00
1022107236 Image and Draw wernt converting the paths of an image properly.
Getting teh size of an image with a relative path "//foobar.png" would always fail.
2006-05-19 15:33:23 +00:00
e9718958ee Applied pack unpack from Pablo Martin (caedes),
http://projects.blender.org/tracker/?func=detail&atid=127&aid=3246&group_id=9
adds

Blender.c:
Blender.UnpackModes (dict with the unpack modes)
Blender.UnpackAll(mode)
Blender.PackAll()
Blender.CountPackedFiles()

Image.c:
image.packed (this was working)
image.pack()
image.unpack()

Sound.c:
sound.packed
sound.pack()
sound.unpack()
2006-05-06 06:17:46 +00:00
Stephen Swaney
342bb99a19 a little spring cleaning to remove some compiler warnings for
implicit declarations, redundant redeclarations, missing initializers,
nested externs and other cruft.

Cleaned up includes and moved extern _Type decls from Types.h into
Types.c since that is the only place where they are needed now.

Did not touch Ipo.[ch] since work is on-going there.
2006-04-16 15:28:50 +00:00
915cd5b80b Added python image pack/unpack per image. 2006-03-26 09:25:30 +00:00
Ken Hughes
e57ce8489b ===Python API===
Two small bugfixes:
   * Image.New() resets id.us to 0; it is set to 1 by new_image()
   * allow ima.depth and ima.size getters to propagate their own error
     messages (missing image was returning MemoryError)

Also, seems to me there's something funny going on with image id.us
accounting.  In do_image_buttons(), id.us is set whenever an image is
accessed vi the datablock menu:

        if(idtest!=id) {
            G.sima->image= (Image *)idtest;
            if(idtest->us==0) idtest->us= 1;
            allqueue(REDRAWIMAGE, 0);
        }

This is independent of whether a UV face is selected or not (and it also
seems that the number of UV faces linked to an image is not maintained
either).
2006-03-21 23:30:25 +00:00
2b7919a9f2 fixed returning true/false, thanks Willian. as well as removed the image space spesific image changed call. 2005-12-18 08:47:55 +00:00
e76e78e78a typo, thanks letterrip. 2005-12-16 22:40:20 +00:00
4a8087db76 Fixed some warnings from GetCurrent, remaining warnings seem to have no obvious solution
attr = Py_True; // Image.c:1107: warning: dereferencing type-punned pointer will break strict-aliasing rules
2005-12-15 02:06:37 +00:00
d527b0e585 Added
Image.New(name, w,h,depth)
Image.start- for animtex
Image.end - for animtex
Image.speed - for animtex
Image.packed - read only bool

See the pydocs for details.
2005-12-14 03:27:35 +00:00
7bba26d24b *warnings fixes 2005-12-13 14:29:56 +00:00
fadaa2fbe9 From kh_pylon:
You have to put Py_RETURN_NONE; inside { }; it's a two-line macro
Aparently breaks MacOS.
2005-12-13 00:27:10 +00:00
d73e312f88 Added Image.GetCurrent()
Previously the only way to get the current image was flaky and relyd on the image being assigned to a mesh.

try:
  me = Scene.GetCurrent().getAttiveObject().getData(mesh=1)
  image = me.faces[me.activeFace].image
except:
  image = None

...Can new be replaced by the following, and works even when there is no mesh.
image = Image.GetCurrent()

epydocs:
  Get the currently displayed Image from Blenders UV/Image window.
  When multiple images are displayed, the last active UV/Image windows image is used.
2005-12-13 00:00:11 +00:00
Stephen Swaney
bb5ae49992 A large collection of fixes from Ken Hughes including:
- corrections to constants
 - parameter type checking
 - correct use of METH_VARARGS vs METH_NOARGS
 - return objects instead of strings in Scene.getChildren() as per doc.
 - correct logical operators

Thanks, Ken!
2005-08-21 15:00:17 +00:00
8b060dd5ad - update to constant.c
- give it the key/items interface
  - creates some factory functions for const generation
- genutils methods
  - method for getting module constants
  - method for throwing errors with a print string
- updates to function names
- clean up interpreter launch a bit
2005-08-17 14:26:00 +00:00
Stephen Swaney
eb64e304b4 Patch #2758 Update of image module.
New Image methods from Austin Benesh:
- getPixelI(x, y)
- getMinXY()
- setPixelF(x, y, [r, g, b, a])
- setPixelI(x, y, [r, g, b, a])
- save()

sorry for the delay.
Thanks.
2005-08-10 17:50:18 +00:00
e60291d39c Header file clean up and warning fixes
- Mostly this cleans up the #includes and header files in the python project.
- Warning fixes are mostly casting issues and misc fixes. General warning clean up.
- #include Python.h MUST come as the first include to avoid the POSIX redefine warning in the unix makefiles
- fno-strict-aliasing flag added to makefile to fix a unavoidable type punning warning in types.c
2005-07-18 03:50:37 +00:00
22a18ecdb8 3D view orbit option: Around Active
This fixes the active object in place when orbiting the view.
	Choppy 15fps demo can be seen there: http://www.elysiun.com/~theeth/bf/around_active.html


Image Memory Grabage Collection
	This adds memory handling to the image code. An image is tagged each time it is used.
	During a collection cycle (frequency of cycles is user defined), if an image is older
	than a user defined limit, its buffer gets deallocated. This also applies to gl memory buffers.
	Images that are loading in GL memory needs to go through two time outs before being fully deallocated: the first time out deallocated the gl memorry, the second the buffer in ram.

	Notes:
		Image buffer loaded from python gets tagged as permanent upon load. That tag is removed when python stops using the image.
		I might have missed some tagging spots, especially in the rendering pipeline. Someone with more knowledge about this code should check to be careful.
		Tagging is done on every access, for rendering, this will probably be a performance hit. A scheme should be developped to only tag when the rendering is completed.
		Collecting is called in draw_object, most likely not the best place to do it.
		Safe from undo, since using undo deallocates memory anyway (like when loading a blend file with one currently opened)


Userpref DNA changes:
	I've changed a couple of flagging variables from short to int. Some because they needed more space, others to keep SDNA happy.


Info window changes:
	I've grouped a couple of buttons in aligned blocks and changed the color of mutually exclusive options to make them clearer.
	Matt didn't do any changes on that in tuhopuu, so hopefully I'm not stepping on anyone's feet with this.


Also changed double constants into floats with f in a couple of places (mostly space.c) to make compiler happier.
2005-07-06 00:33:41 +00:00
9ee2a1ee09 One file missing from prevous commit. This one is even worse, decref'ed a borrowed reference. 2005-06-17 05:37:24 +00:00
Stephen Swaney
8510196eca Rename Image.getPixel() to .getPixelF() as per discussion
to match OpenGl conventions and prepare for integer versions.
2005-05-22 18:43:29 +00:00
Stephen Swaney
9aadcfc2c4 New methods for Image module:
.getPixel( x, y ) returns float list of [r, g, b, a] for pixel
.getMaxXY()  returns image size as float list [x, y]

Contributed by Austin Benesh (mchs3d).  Thanks!

also ran code thru indent.
2005-04-30 19:30:35 +00:00
8e92ee8684 - remove all obsolete inclusions of BLI_winstuff.h (due to recent changes)
NOTE: BLI_winstuff.h was meant to be a wrapper around windows.h to handle
undefining various crap that windows.h defines. Platform specific headers
should only have to be included in a few places. This reduces the number
of inclusions of BLI_winstuff.h to 16 which is a much more reasonable
number (than the 144 or whatever it used to be)
2005-03-19 21:08:13 +00:00
34977b8937 BPython:
- applied Campbell Barton's patch for access to Oops location and selection of materials, mesh data and objects, slightly modified. Thanks, Campbell;
- got rid of warnings in many files, hopefully not introducing any other during the process.  Mostly this was done: 1) new EXPP_incr_ret_True/False functions were added and used instead of "Py_INCREF(Py_True/False); return Py_True/False;".  Currently at least the functions use the fact that PyTrue/False == 1/0 and use 1 and 0 to avoid the warnings. 2) Filling of certain types structs got 0's added for all not defined data and methods.  This is surely Python version specific, since these structs can change size and content at each major version number Python update.
2005-02-09 15:53:35 +00:00
05bf482f6a BPython:
- NMesh: made nmesh.update accept an optional 'vertex_shade' param to init vcols with shading info, like when you enter vpaint mode or press the relevant "make" button for a mesh without vcols.  This is still a test, the functionality was requested by Manuel Bastioni for the SSS script they are working on:
http://www.dedalo-3d.com/index.php?filename=SXCOL/makehuman/articles/subsurface_scattering_in_python.html
- sys: made makename() accept files with max FILE_MAXDIR+FILE_MAXFILE name length, should fix #2192.  Was only FILE_MAXFILE, a mistake;
- Image: added .setFilename(), contributed by Campbell Barton;
- Camera: added camera.get/setScale for the new param added by Ton for ortho cameras.  Requested by Jean-Michel Soler for the Texture Baker script;
- related doc updates.
2005-02-09 05:19:24 +00:00
41b251fab0 BPython:
- Fix related to bug #2157: crash in Blender.Image.image.reload() method.  "G.sima" was not being checked for validity.  Fix by Joilnen B. Leite (pidhash).  Thanks!
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2157&group_id=9
- Added optional argument to Blender.Object.object.getData() method: getData(only_name = True) or (only_name = 1) or (1) will return only the obdata name, not a wrapper for the given struct.  This is a test based on a request by Campbell Barton who submitted code for his proposed .getDataName() method (thanks!).
- doc updates and small fixes.
2005-02-02 03:38:31 +00:00
9f43accdb2 BPython:
- patch by Jonathan Merritt: new function Blender.Draw.Image() + its doc;
- patch by Campbell Barton: .users attribute for many types;
- tiny internal change in nmesh.hasVertexUV() method.

Thanks to Jonathan and Campbell for the patches and the patience!
2005-01-13 03:04:12 +00:00
fa9135385a BPython:
- Blender.Window: added function GetPerspMatrix() (Tom Musgrave's patch, thanks);
- added Chris Want's patch to tell argc, argv to the Python interpreter (thanks, Hos);
- Blender.Image: added image.glFree() to free textures bound by the recently added
  image.glLoad() (both suggested by Campbell Barton -- thanks, with these Blender can
  be used to load textures for scripts);
- Blender.Sound: removed for now at least a few get/set methods of vars that can't be
  accessed via interface;
- renamed Get/makeActive to Get/setCurrent in Blender.World (actually added alias for
  now), same in Blender.Sound: renamed makeActive to setCurrent.  Stephen Swaney
  pointed this some weeks ago, we should stick to one naming convention.
- added documentation for Sound and Window.Theme modules and the other added
  functions, made other small updates.
- Blender.Object: made 'worldspace' become the default output of .getMatrix and .mat/.matrix:
  after reading a discussion on blender.org's Python forum where eeshlo mentioned the
  pre 2.34 default was worldspace, I took a better look at Blender's relevant code,
  confirmed, talked to Theeth about this and as he suggested am changing the default
  back to 'worldspace'.
2004-10-20 05:51:24 +00:00
Stephen Swaney
a509b8adc9 Another round in the Great BPy Cleanup:
Run everything thru indent to cleanup spaces vs tabs.
Clean up some of the comments by hand.
BGL.c was not touched due to all that macro wackyness.

There are no functional changes to the code.
Pre-indent versions of source are tagged with
tag bpy-cleanup-20040925 , just in case.
2004-09-25 20:30:40 +00:00
Nathan Letwory
16593b506a make sure this also builds on Windows. 2004-09-23 21:27:16 +00:00
e7d3039d12 - Blender: added option 'scriptsdir' to Blender.Get();
- small updates to the docs;
- Object: small fix to getMatrix: check during_script() to avoid undesired loops; added old behavior (pre 2.34) as option: .getMatrix('oldlocal');
- tentative fix for bug #1275: scene REDRAW scriptlinks were not being executed (the call to do so was missing):
http://projects.blender.org/tracker/index.php?func=detail&aid=1275&group_id=9&atid=125
    added the call in drawview.c, in drawview3dspace().  This causes the scriptlink to be called for each visible view3d, but that's what happens with object redraw scriptlinks, too.  Anyway, this is still a test.  The place was chosen based on the idea that a scene redraw scriptlink is like an object redraw one, but for all objs in the scene at once.

- Window.Theme: new submodule, to get/set theme options in Blender;
- Added the script save_theme.py (Help menu for now), to save the current theme in Blender as an executable script (currently shown in the Scripts->Misc menu).

There's more work to do for themes, like defining a proper place for them in the interface, adding documentation (for now the added script and the ones it generates can give a pretty good idea of how to use the new module), probably extending themes to support SpaceScript and so on.
2004-09-21 05:28:17 +00:00
376468d383 Fixing a blenderplayer compile error reported by Meino Christian Cramer:
- added mainqenter to stubs.c so it can be used in blender/blenkernel/intern/blender.c's setup_app_data.

We can't run the onload scriptlink in setup_app_data because the visible areas won't have been updated and redrawn for the loaded .blend file until control returns to screenmain() in blender/src/editscreen.c.  So an ONLOAD_SCRIPT event is entered in setup_app_data and caught in screenmain, where the onload script is then executed.  All for a good looking demo mode ...

BPython:
- Added image.getBindCode() method, contributed by Andrew Corrigan (thanks!).
2004-07-16 06:00:40 +00:00
Stephen Swaney
a703837179 Replace deprecated methods from old api:
PythonReturnErrorObject
  PythonIncRef

Fix some compiler warnings about missing initializers
in method tables.
2004-06-06 22:42:51 +00:00
8a64e0e867 BPython:
- Campbell Barton contributed another function (thanks again), the Image.reload method:
  with this a script can keep an image that is being edited and saved by an external program updated in Blender.
2004-05-25 10:36:58 +00:00
5e7f9dfa08 BPython:
-- New module: Blender.Texture, by new developer Alex Mole.
Most of it is done: guess only Ipo, envmap, colorband and plugin were not implemented yet.
2003-11-23 17:46:06 +00:00
fe07b232b7 * got rid of a warning in editipo.c:
changed "get_ipo(key, ..." to "get_ipo((ID *)key, ..." in line 107.
* changed insert_meshkey(Mesh *me) to insert_meshkey(Mesh *me, short offline):
   To call this function from a script, so that it doesn't pop the
   "relative / absolute" dialog window when the "offline" arg is non-zero.

Exppython:

* NMesh module:
   - Added method NMesh.addMaterial(mat) to the NMesh module:
   alternative safer (aka slower) way to add materials.
   - Added optional arg to NMesh_update():
   if given and equal to 1, the mesh normals are recalculated.
   - Fixed NMesh.getVertexInfluences: it was segfaulting when a NULL bone was
   linked to the vertex.  Thanks to Jiba on the bf-python mailing list for
   bug report and sample .blend file.  Also made this method give an IndexError
   when the vertex index is out of range.
* Material module:
   Added specR, specG, specB vars for compatibility with the 2.25 API.
   Pointed by Manuel Bastioni.
* Image module:
    Exposed image width, height and depth parameters.
    From a suggestion by jms.
* BPython Ref Doc:
  - Small updates to reflect the above additions.
  - Added info for the Bone type in the Armature doc.
2003-07-30 21:15:41 +00:00
c467b19c75 Exppython:
- More documentation files for epydoc.
- Few minor changes in other files.
2003-07-12 18:02:54 +00:00
aa820ec420 Exppython:
- Continued getting rid of print methods and updating repr ones:
    Needed to fix crashes on Windows >= 98 systems.
- Found and fixed a few small memory leaks in EXPP_interface, related to
  execution of script links.
2003-07-05 01:18:41 +00:00
eaf1cdd383 - More renaming all around to follow our conventions
- Implemented partially Blender.Sys
- Worked on issues related to sys, path
- Took away most "debug" printfs
2003-06-28 07:38:21 +00:00
06ee04fb05 * Added more doc files for epydoc and a test for the camera module.
* Moved public declarations in camera and lamp to a new file: bpy_types.h.
* Fixed minor bugs in material, rgbTuple and Lamp + other minor changes.
* Made part of the changes to conform to decided naming conventions.
2003-06-24 07:21:17 +00:00