Commit Graph

2584 Commits

Author SHA1 Message Date
8ae76d7249 pep8 compliance for Randomize objects loc/rot/scale.
- scale min -1 to 1 rather then -100 to 100
- default precision for float props to 2.
2010-01-19 09:36:40 +00:00
849024df83 patch [#20724] Randomize Loc Rot Size py operator for B2.5
written from scratch by Daniel Salazar (zanqdo). added own modifications.

New property type
 bpy.props.FloatVectorProperty(), only difference with float is it takes a 'size' argument and optional 'default' sequence of floats.

moved bpy.props.* functions out of bpy_rna.c into their own C file.
2010-01-19 00:59:36 +00:00
fe67b9d6f2 reference docs: include type info with function return values 2010-01-18 10:45:54 +00:00
381e926600 fixed sphinx doc generator
- arguments, return values indentation means they get correctly interpreted by sphinx
- functions with no return values were displaying return as ()
- return values were getting the '(optional)' added in some cases.

Example:
http://www.blender.org/documentation/250PythonDoc/bpy.ops.object.html
2010-01-17 20:59:35 +00:00
c7dfa96aea bugfix [#20639] BF25_SVN_25888 and below - OBJ and 3DS import fails
blender supports type changing for textures in a way that python doesnt.
add a new general function.

Example usage:
 tex = bpy.data.textures.new("Foo")
 tex.type = 'IMAGE'
 tex = tex.recast_type()

Macro to give the number of users accounting for fake user.
 ID_REAL_USERS(id)
Use this so you can remove a datablock if it has a fake users as well as apply transformations to it in the 3D view.

Move api function bpy.data.add_texture() --> bpy.data.textures.new()/remove()
2010-01-17 20:06:34 +00:00
7bea39af62 Workaround to fix #20645. Iteration over multidim arrays and slicing of them is broken.
Before fixing this I'd like to clean BPY a bit.
2010-01-16 15:20:27 +00:00
5272991e8b generic operator menu was searching for "type" and using the first enum property if it wasnt found.
this is too arbitrary and could break if roperty order is changed.
store the property in the operator type that is to be used for menu and enum search func's.

python function for searching operator enums on invoke. (just need dynamic python enums now)
 wm.invoke_search_popup(self)
2010-01-15 22:40:33 +00:00
2b3a6b38b7 remove duplicate code from operator/macro initialization 2010-01-15 22:02:32 +00:00
b0f87935a8 spelling errors, no real changes to code. 2010-01-14 10:59:42 +00:00
ebb9286fd6 Fix for cmake + windows debug build crash on startup, PYTHONPATH needs to be set, Py_SetPythonHome seems insufficient. Not sure why this is needed or if there is a better solution, but couldn't find another one. 2010-01-11 11:11:21 +00:00
b36a05bb7e - fix for crash if drivers were used in the .B.blend
- fix for problem where proxy objects could enter editmode but not exit
2010-01-10 20:01:13 +00:00
08c9ecb3b0 RNA/Py API
change how data is added. eg.
 bpy.data.add_mesh(name) --> bpy.data.meshes.new(name)
 bpy.data.remove_lamp(lamp) --> bpy.data.lamps.remove(lamp)


image and texture stil use add_* funcs
2010-01-09 23:44:01 +00:00
a868e8623c - RNA support for returning copied strings from functions, flagging strings as PROP_THICK_WRAP does this.
- scene.render_data.frame_path(frame=num), returns the output path for rending images of video.
- scene.render_data.file_extension, readonly attribute, gives the extension ".jpg", ".mov" etc
- player support was guessing names, use the above functions to get the actual names used, accounting for #'s replacing numbers.
2010-01-08 13:52:38 +00:00
d3a718dc2f fix for own but in recent driver optimization [#20580] Driver Crasher rev [25763]
recalculate names when needed
2010-01-06 22:42:13 +00:00
bd6b19267d write our to a shorter path, was failing unless you made the path manually since it was trying to write to a subsub dir that didnt exist. 2010-01-06 09:42:41 +00:00
3b5014c69b Python descriptions were not getting used in tooltips. 2010-01-05 20:19:54 +00:00
01b762e846 fix for bpyob.foreach_set(), when the list is empty 2010-01-05 13:55:51 +00:00
52a2b82852 speedup for driver execution, use PyUnicode_InternFromString() for variable names, cache hash and string -> unicode conversion for driver variables. 2010-01-05 10:54:54 +00:00
e90b6eefb1 patch from Benoit Bolsee (ben2610) for 4 bugs in report [#20527] Several bugs in RNA
from the report...


# bug 1. UV properties are not raw editable but are reported 
#        as RAW_TYPE_INT by RNA causing wrong conversion 
#        internally (bpy_rna.c line 2205)
# bug 2. raw update of UV coordinates crash blender (rna_access.c line 252)
mtfaces.foreach_set("uv", rawuvs)
# workaround:
#for i in range(int(len(faces)/4)):
#   mtfaces[i].uv = uvs[i]

# bug 3. raw update of non-array property fails (rna_access.c line 2270)
mfaces.foreach_set("material_index", mats)
# workaround:
# for i in range(int(len(mfaces))):
#    mfaces[i].material_index = mats[i]

# bug 4. It is not possible to add a vertex color layer using mesh API.
me.add_vertex_color()
# no workaround...
2010-01-04 22:30:09 +00:00
a9861e3381 Durian Request: Drivers Recode
Highlights:
* Support for Multi-Target Variables
This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that.

* New Variable Types
With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones).

* New Driver Types
In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to.

* Fix for Driver F-Curve colouring bug 
Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used.


Notes:
* This commit breaks existing 2.5 files with drivers (in other words, they are lost forever). 
* Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later.
* Version patching for 2.49 files still needs to be put back in place.
2010-01-04 21:15:45 +00:00
bed3c5254f pyrna array slice assignment
- accept any sequence
- disallow deleting & resizing via slices
2010-01-04 20:53:52 +00:00
d1da5cb99a support for rna functions returning mathutils types - so object.rat_cast() returns Mathutils vectors rather then tuples 2010-01-04 13:29:55 +00:00
04d0261c37 new python submodule. eg.
from bpy.app import binary_path, version, version_string, home

can add constant variables from blender here as needed (maybe functions too... bpy.app.memory_usage() ?)
2010-01-02 23:14:01 +00:00
e7d863cee5 editbone.transform(matrix) function, requested by Cessen.
Also added matrix.median_scale attribute to get the average scale from the matrix, use for scaling bone envalopes.
2010-01-02 22:47:56 +00:00
cf7b19c0ba fix for mistake in last commit. also forgot to call RNA_parameter_list_end() in some places, (ok the function does nothing now, but some day it might do) 2010-01-02 19:01:19 +00:00
cef8b2088f sphinx support for documenting multiple return values 2010-01-02 18:55:07 +00:00
78b2eb8d3c PyRna float/bool/int slicing.
- fixed slice assignment.
- fix for slowdown where getting a slice would get the entire array and free it for every item in the array (malloc and free for arrays >32).
- fix for thick wrapped returning an array referencing the original pointer when coercing into a mathutils type failed.

TODO
- slice assignment currently only sypports lists.
- dimensions are ignored for multidimensional arrays.
2010-01-02 17:33:44 +00:00
e83940d994 support for multiple return values from rna functions & support for returning arrays, (no functions are using this yet).
patch from Elia Sarti, (vekoon) with some modifications mainly for the python api.

- multiple values are returned as a typle in the order that are defined.
- added support for registered types returning multiple arguments (untested).
- renamed func->ret --> func->c_ret, since this only defines what the C function returns.
2010-01-02 10:42:38 +00:00
453945e9e3 remove python api cruft from custom operator registration 2009-12-30 22:51:44 +00:00
b00cddeb66 Macro registration using the normal rna registration methods (like operators).
bpy.types.register(MacroClass)

instead of

bpy.ops.add_macro(MacroClass)

The rest is unchanged.

Also remove some now unused code for the old registration methods (there's still some remaining).
2009-12-30 22:14:32 +00:00
3702998fec python macro operators didnt have a compatible draw function assigned. also remove duplicate define. 2009-12-30 20:15:28 +00:00
5cd837a562 * speedup for animating bones, in one scene with sintel and a dragon animated its over 4x faster.
* utility function BLI_findstring to avoid listbase lookup loops everywhere.
  eg: 
    ListBase *lb= objects= &CTX_data_main(C)->object;
    Object *ob= BLI_findstring(lb, name, offsetof(ID, name) + 2);

* made some more math functions use const's, (fix warnings I made in previous commits)
2009-12-29 15:40:26 +00:00
d741b37236 flag to make rna props 'thick wrapped', so returning a property wont try maintain a reference to the original rna property with callbacks.
also needed for functions that return vectors/matrix's
2009-12-28 22:59:09 +00:00
d64834a6ce Python attribute lookup. Don't use RNA functions that don't have defined callbacks (can happen for operator functions used for registration only). 2009-12-28 22:48:10 +00:00
98f1d6957e new python module constants
* bpy.home - result of BLI_gethome()
* bpy.version - BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION
* bpy.version_string, as above, formatted: "%d.%02d (sub %d)"
2009-12-28 10:00:04 +00:00
fde4686d77 barycentric transform utility geometry function.
From 2 triangles and 1 point, the relative position between the point and the first triangle is applied to the second triangle to find the target point.
the barycentric weights are calculated in 2D space with a signed area so values outside the triangle bounds are supported.

wrapped by python:
 pt_to = Geometry.BarycentricTransform(pt_from, t1a, t1b, t1c, t2a, t1b, t1c)

NOTE: 
- moved some barycentric weight functions out of projection painting into the math lib.
- ended up making some of the math functions use const args.
TODO:
- support exceptional cases. zero area tries and similar.
2009-12-27 01:32:58 +00:00
d5592fe254 fixes for errors/warnings found with cppcheck 2009-12-26 20:23:13 +00:00
5689ab3975 classmethods were excluded from docs, hide self & cls arguments for functions and class methods,
made some rna ui funcs not display as optional.
2009-12-26 17:49:08 +00:00
24ab5416da * sphinx docgen *
py_function_args wasnt working right (was using function namespace for function args), use pythons inspect module instead.
move the function to get a type description into rna_info
2009-12-26 16:47:25 +00:00
5afd084513 replace dynamic_menu.py with Menu classmethods much less complicated.
access append/prepend eg.

bpy.types.INFO_MT_file_import.append(lambda self, context: self.layout.operator("import_some.format"))
2009-12-25 22:16:19 +00:00
693d9fd771 sphinx rna api documentation generator to replace epydocs
- view docs menu item opens sphinx URL
- can be searched (even when local)
- uses rna_info module for introspection
- also documents python defined functions and decorator properties (defined in bpy_types.py)
- experemental python file:line references for python operators.
2009-12-25 15:50:53 +00:00
4c5a314fef update rna_info and rna_rna for better introspection 2009-12-25 14:42:00 +00:00
bbe13e7823 * register operators like other classes
* operators now return sets (converted into flags)
* can't remove bpy_operator_wrap.c since macro's still use the custom register funcs
2009-12-24 19:50:43 +00:00
4dd3e6c360 support for registering operators using the same internal rna api as panels, menus, headers & render engines since there was a fair bit of duplicate functionality.
will remove the old system and update scripts next.
2009-12-24 16:10:26 +00:00
bb452f29d6 minor pyapi changes 2009-12-24 11:40:14 +00:00
8f5b2e946b BGE bug #20446: revert to orignal code, the problems comes from misunderstanding of matrix theory. More details in bug report. 2009-12-22 09:46:03 +00:00
Dalai Felinto
9c22e846fe [#20446] mathutils: bugfix for matrix * matrix - patch by Paul Parchenko (parfoure) thanks
From the tracker:
- typo was making the multiplication to transpose resulting matrix
eg
####
from Mathutils import *
from math import radians

cont = GameLogic.getCurrentController()
owner = cont.owner

owner.worldOrientation = RotationMatrix(radians(1), 3, 'z') * owner.worldOrientation
####
2009-12-22 07:27:53 +00:00
ca16488e81 MSVC 9 compile fixes and cleanups
* added renamed files in revision 25337
* renamed BLI_util.h -> BLI_path_util.h for consistency
* cleanup of #includes: removed BLI_blenlib.h in favour of direct includes of the needed headerfiles in a few places.
* removed debug print in sequencer.c
* added missing include in blenkernel/blender.c -> bad dependency, needs to be fixed still
2009-12-13 17:46:30 +00:00
b3f03250de use tp_getset rather then checking the string on getattr for 'id_data' attribute 2009-12-13 10:46:34 +00:00
cff8de339d [#20288] FBX exporter fails
* disallow registering operators that have properties starting with an underscore which caused this problem.
2009-12-11 00:51:14 +00:00