Commit Graph

94 Commits

Author SHA1 Message Date
Campbell Barton 2c8e1e633c comment unused lines. 2011-08-15 03:41:31 +00:00
Campbell Barton 9c8cc9fe60 rna option not to save certain properties for redoing later, currently only used by operator presets. 2011-06-07 10:54:57 +00:00
Campbell Barton 8cee328546 Support for update callbacks in python defined RNA properties as discussed last meeting.
This means script authors can perform actions using these callbacks rather then on drawing which puts blender in a readonly state.

Simple example:

import bpy
def up_func(self, context):
    print("test")

bpy.types.Scene.testprop = bpy.props.FloatProperty(update=up_func)
bpy.context.scene.testprop = 11

# prints -> test
2011-06-06 17:50:20 +00:00
Campbell Barton 155d589333 add the property as an argument to enum item functions, not used yet but needed for dynamic python enums. 2011-05-26 13:38:16 +00:00
Brecht Van Lommel 66f51ba5d1 RNA: make mechanism used by operators to keep python instance alive more generic, to be used by render engine later. 2011-05-18 11:21:10 +00:00
Brecht Van Lommel 178ba76b09 RNA: pass Main rather than Context to register/unregister callbacks. 2011-05-18 10:56:26 +00:00
Campbell Barton 70cd0803ab add new subtype PROP_COORDS, for generic coordinates that are not to be changed by units. 2011-04-08 13:32:56 +00:00
Brecht Van Lommel 128bed8480 RNA: use a different method to set DNA types for BlendData* collections, to
solve issues with c++ api.
2011-03-13 13:01:02 +00:00
Nathan Letwory a47ca06502 doxygen: blender/makesrna tagged. 2011-02-27 20:20:01 +00:00
Nathan Letwory 5b607701a7 doxygen: prevent GPL license block from being parsed as doxygen comment. 2011-02-23 10:52:22 +00:00
Campbell Barton 8ea0b4685c misc small changes:
- rename rna collection structs Main prefix to BlendData: eg, MainObjects --> BlendDataObjects
- printing python collection now prints its type (when available)
- renamed shadowed vars in bpy_rna.c.
- when making functions static I also made debugging/test functions static, reverse and add definitions to headers instead.
2011-02-14 03:15:55 +00:00
Campbell Barton daa09a4a60 Raise an exception when registering classes with ID names which are too long. (related to bug ), found while looking into bug [#25776]. 2011-01-24 03:38:34 +00:00
Campbell Barton 86bbab7de5 remove/comment unused defines. 2011-01-15 16:14:57 +00:00
Campbell Barton 9733e5f76f revert part of Tons commit r33884.
- rather then use unlink="None", just don't pass unlink as a keyword. This is more pythonic.
- added an RNA flag for properties which cant be unlinked by setting to None.
2010-12-30 12:22:28 +00:00
Campbell Barton d624d1cbdd pass along the context to extension functions, this was already being done in all cases except for the render engine.
this allows python to NULL its internal context while scripts are not running.
2010-12-07 04:12:15 +00:00
Campbell Barton b45c3363fd fix for some pedantic warnings. 2010-12-03 01:52:28 +00:00
Campbell Barton ee1d2adc16 partial fix for [#23532]
- Python calling operators didn't run WM_operator_properties_sanitize() so enum functions called from python were given a NULL context.
- PROP_ENUM_NO_CONTEXT and PROP_NEVER_NULL used the same value in the enum (possible conflict).
2010-11-23 12:05:35 +00:00
Campbell Barton dfb8c5974e rna support for passing dynamic sized arrays to rna functions
using this for object.vertex_groups.assign([index list ...], group, weight, mode)
2010-08-31 11:31:21 +00:00
Campbell Barton 4e3390437e - Properties from base classes are now registered too, this allows class mix-in's to define properties.
An example of how this is useful - an importer mixin could define the filepath properties and a generic invoke function which can run the subclasses exec for each selected file.

- Panels and Menus now skip the property check when registering.

- renamed _idproperties_ to _idprops_ in function names, function names were getting very long.
2010-08-19 10:16:30 +00:00
Nicholas Bishop 63791e03d6 * Partially revert r30763, where PROP_IMAGEPATH was added.
* Brush icon property back to not using image browser until a better solution is decided on.
2010-07-26 23:40:46 +00:00
Nicholas Bishop 8fb499c34f * Added a new RNA subtype, PROP_IMAGEPATH. It's the same as PROP_FILEPATH, but for images only.
* Changed UI code to display image browser for PROP_IMAGEPATH
* Set the icon_filepath RNA property for brushes to use PROP_IMAGEPATH
* Changed preview icon drawing to ignore unset icons
* Fixed const warnings in brush RNA
2010-07-26 18:37:47 +00:00
Campbell Barton 556b57febf get rid of some warnings,
removed NG_LoopBackNetworkDeviceInterface::GetNetworkVersion(), wasnt used anywhere.
2010-06-05 15:31:55 +00:00
Campbell Barton b9662fc637 patch from Dan Eicher
- pose markers new/remove
- font load/remove
- world load/remove
- particles new/remove

commented out node-tree for now since from what I can tell these have to be atteched to material/scene/texture (unlike other ID types)
2010-05-15 13:30:14 +00:00
Campbell Barton cd6332ca1e patch from Dan Eicher
rna add/remove functions for lattices, brushes and metaballs
2010-05-14 21:16:37 +00:00
Brecht Van Lommel 9a85013692 Merge various small changes from render branch:
* Division by zero fix for TNT SVD code.
* Sound fix, in case ffmpeg decode fails, don't use the samples.
* Fix for incorrect bounds of transformed objects in new raytracing code.
* Gave memory arena's a name used for allocations for easier memory
  usage debugging.
* Dupligroup no_draw option was using layers but not restrict view/render
  setting. (not a bugfix exactly but would do display list context switching
  while drawing for no reason).
* Fix objects instanced on hair particles not giving consistent results
  when the object is transformed.
* New math functions: madd_v4_v4fl, len_squared_v3v3, interp_v4_v4v4v4,
  mul_v4_m4v4, SH and form factor functions, box_minmax_bounds_m4.
* mul_m4_m4m4 and mul_m3_m3m3 now accept the same pointers for multiple
  arguments.
* endjob callback for WM jobs system.
* Geometry node uv/color layer now has search list/autocomplete.
* Various small buildsystem tweaks, not strictly needed yet in trunk.
2010-04-15 10:28:32 +00:00
Brecht Van Lommel 5bc2d53507 fix for parsing python args to rna functions, was using allocated size as argument count.
(commit 27670 by Campbell from render25 branch)
2010-03-23 15:04:06 +00:00
Brecht Van Lommel 33e0ea0e59 py/rna functions for adding and removing curve data.
(commit 27666 by Campbell from render25 branch)
2010-03-23 14:58:36 +00:00
Campbell Barton 391cc2d004 merge own commits into render branch into trunk since 27560
27562, 27570, 27571, 27574, 27576, 27577, 27579, 27590, 27591, 27594, 27595, 27596, 27599, 27605, 27611, 27612, 27613, 27614, 27623
2010-03-20 16:41:01 +00:00
Campbell Barton 081c1205a3 correct fsf address 2010-02-12 13:34:04 +00:00
Campbell Barton ecaa50ed7b PROP_ANIMATEABLE -> PROP_ANIMATABLE (more common spelling) 2010-02-02 00:02:55 +00:00
Campbell Barton 039d087171 subtype support for properties in bpy.props. 2010-02-01 22:04:33 +00:00
Martin Poirier fb7878a2c2 PROP_ENUM_NO_CONTEXT flag for rna properties, forcing enum item functions to be passed a null context (to return non-contextual items).
This is set on keymap item operator properties and macro definition operator properties to make them non-contextual (since the context at definition time is most likely not the same then at execution time, it's better to have all options visible).

This removes some more errors in keymap export and import.

This commit also sanitize some enum item function, making sure they can cope with null context and have usable defaults in that case.
2010-01-27 21:19:39 +00:00
Elia Sarti 9733e902a5 RNA functions
Fixed and completed support for returning multiple values. This includes support for returning arrays, both fixed and dynamically sized. The way this is achieved is by storing an additional int value next to the dynamic parameter in the ParameterList stack which gets passed to the C function as an additional parameter. In the case of return parameters it is duty of the C function to set this int to the correct length value for the dynamic parameter (which makes sense). Note that for the dynamic output/return parameter it is assumed the function has allocated that memory (which gets freed automatically).

Also, I cleaned the makesrna's bridge function generation code a bit and renamed PROP_RETURN to PROP_OUTPUT, which represents better the reality now that there are multiple returns. The function now to mark multiple returns (outputs) is RNA_def_function_output.

For an example, look at Action.get_frame_range in rna_action_api.c, by the way Aligorith I removed the #ifdef for this function now that there's support for returning arrays, feel free to modify (the function seems to work).
2010-01-24 10:51:59 +00:00
Brecht Van Lommel 00318eaa2e RNA: added option to pass self ID to RNA functions. 2010-01-22 10:58:02 +00:00
Campbell Barton 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
Campbell Barton 689450a8f1 rna/py api
bpy.data.groups.new()/remove()
bpy.data.actions.new()/remove()
2010-01-11 23:40:01 +00:00
Campbell Barton b6a1bc575b rna/py api
bpy.data.scenes.remove(scene) # now works without crashing
bpy.data.texts.new(name)/remove(text)/load(path) # added
2010-01-11 00:41:31 +00:00
Campbell Barton 3b03984294 Change how 'Main' collection type definitons work so that 'self' can be used without overriding the srna type. 2010-01-10 15:20:22 +00:00
Campbell Barton 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
Campbell Barton 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
Campbell Barton 22a892f402 - make ToolSettings.mesh_selection_mode into an array of 3 bools rather then an enum since multiple can be set at once.
- ToolSettings had its id.data set to NULL when taken directly from the context (causing a crash in cases)
- menu for changing vert/edge/face selection now a python menu, removed operator.
- wm.context_set_value(), would really prefer not to have this since it evaluates the value as a python expression however there are no ways to define arrays in PyOperators
2009-12-22 16:11:11 +00:00
Campbell Barton 7fcb5d33ff values that had units set would not be coerced into Mathutils types by the python api.
eg. scene.cursor_location wasnt a vector
2009-12-10 09:38:58 +00:00
Brecht Van Lommel 07904712e8 RNA:
* Property update functions no longer get context, instead they get only
  Main and Scene. The RNA api was intended to be as context-less as
  possible, since it doesn't really matter who is changing the property,
  everything that uses the property should be updated.
* There's still one exception case that use it now, screen operations
  still depend on context too much. It also revealed a few places using
  context where they shouldn't.
* Ideally Scene shouldn't be passed, but much of Blender still depends on
  it, should be dropped when we try to support multiple scene editing.

Change was planned for a while, but need this now to be able to call
update without a context pointer.
2009-12-08 17:23:48 +00:00
Campbell Barton 750764f411 rna flag PROP_ENUM_FLAG which makes rna props a tuple of enums when converted into a PyObject
only used by wm.invoke_props_popup() currently
2009-12-07 00:16:57 +00:00
Matt Ebb b89138564e Changes to Color Management
After testing and feedback, I've decided to slightly modify the way color 
management works internally. While the previous method worked well for 
rendering, was a smaller transition and had some advantages over this
new method, it was a bit more ambiguous, and was making things difficult 
for other areas such as compositing.

This implementation now considers all color data (with only a couple of 
exceptions such as brush colors) to be stored in linear RGB color space, 
rather than sRGB as previously. This brings it in line with Nuke, which also 
operates this way, quite successfully. Color swatches, pickers, color ramp 
display are now gamma corrected to display gamma so you can see what 
you're doing, but the numbers themselves are considered linear. This 
makes understanding blending modes more clear (a 0.5 value on overlay 
will not change the result now) as well as making color swatches act more 
predictably in the compositor, however bringing over color values from 
applications like photoshop or gimp, that operate in a gamma space, 
will give identical results.

This commit will convert over existing files saved by earlier 2.5 versions to 
work generally the same, though there may be some slight differences with 
things like textures. Now that we're set on changing other areas of shading, 
this won't be too disruptive overall.

I've made a diagram explaining the pipeline here:
http://mke3.net/blender/devel/2.5/25_linear_workflow_pipeline.png

and some docs here:
http://www.blender.org/development/release-logs/blender-250/color-management/
2009-12-02 07:56:34 +00:00
Matt Ebb ce4b63aa3f Fix for [#20008] In the Graph Editor, clicking on the eye doesn't update the GUI
As part of this, fixed a typo in rna flags which was causing some strange behaviour with icons earlier. Reverted the workaround for this, too.
2009-11-25 08:28:57 +00:00
Brecht Van Lommel a84a59b64e Fix #19638: crash when assiging self in boolean modifier.
Also:
* UI now takes ID self check flag into account so that e.g. it
  doesn't offer to the make object it's own parent.
* Mesh loop cuts number of cuts had wrong limits.
* Don't use mesh_get_derived_final in modifier stack, but
  ob->derivedFinal instead. Avoids crashes on dependency loops,
  and in case there is no loop it should have been created.
2009-10-19 12:13:32 +00:00
Campbell Barton c7c2e3de1e set scene, currently UI is in the render buttons, should be moved to a scene buttons area.
added a property flag PROP_ID_SELF_CHECK, so properties can be set to point to anything but themselves.
2009-10-14 13:20:20 +00:00
Brecht Van Lommel 3ebd58673f Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.

There's actually 3 levels now:

* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
  or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
  to .py files as well to make creating distributable configurations
  easier.

Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.


Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
  keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
  added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
Brecht Van Lommel b26ef33b8e Fix #19311: adding/opening datablocks did not always make the right
one active. Now there's a function to get the pointer + property from
the UI, just like for the animation operators.

Also two fixes for fileselect events, regions are now preserved so that
context is restored to the old region, and the cancel callback is called
when the operator is cancelled.
2009-10-01 23:32:57 +00:00