Commit Graph

93 Commits

Author SHA1 Message Date
1e9bf0cfdb spaces -> tabs, (4 spaces == 1 tab, only for white space preceding text) 2010-03-22 09:30:00 +00:00
42ac4a3e7d Fix syntax for ID keyword. 2010-03-21 01:14:04 +00:00
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
07d4307af2 attempt to fix build error on msvc 2010-03-14 17:54:08 +00:00
431db9d478 remove unused includes 2010-03-14 16:06:43 +00:00
aec7174a42 fix for OBJ exporting Texface images 2010-03-02 14:57:28 +00:00
46d50b0d1f bugfix for displaying ID properties
- fixed memleak from 2.4x with setting arrays from python
- basic support for IDPropertyArrays

 context.object["foo"] = [{"smap": 10}, {"foo": 2}]
2010-03-02 11:35:28 +00:00
5455917274 comparing Vector(-2, 0, 0) and Vector(2, 0, 0) was returning true, this bug is years old, strange nobody noticed.
use float comparison from the "Ever Faster Float Comparisons" paper, tested with random values as well as random values converted to ints (where this existing code would fail).
2010-02-28 19:27:06 +00:00
ed7f4f2e3c make BGL and BLF modile names lowercase 2010-02-28 14:57:26 +00:00
c1cd33e166 examples for autogenerated docs are now implicit and used when available.
This means adding the file "bpy.props.py" in the examples dir will automatically be used when generating docs, unused examples give warnings.
2010-02-28 13:45:08 +00:00
fc1cb1670e include BLF in automated doc generation
http://www.blender.org/documentation/250PythonDoc/BLF.html
2010-02-28 11:54:48 +00:00
3bbf1917c5 python BLF module for drawing text, updated template to draw text in the 3D view. 2010-02-28 11:18:54 +00:00
0c89dcc25c matrix functions, to_3x3, to_4x4
force fixed time when recording in the BGE.
2010-02-23 09:39:47 +00:00
37b9c9fe4d VideoTexture: improvements to image data access API.
- Use BGL buffer instead of string for image data.
- Add buffer interface to image source.
- Allow customization of pixel format.
- Add valid property to check if the image data is available.

The image property of all Image source objects will now
return a BGL 'buffer' object. Previously it was returning
a string, which was not working at all with Python 3.1.
The BGL buffer type allows sequence access to bytes and
is directly usable in BGL OpenGL wrapper functions.
The buffer is formated as a 1 dimensional array of bytes
with 4 bytes per pixel in RGBA order.

BGL buffers will also be accepted in the ImageBuff load()
and plot() functions.

It is possible to customize the pixel format by using
the VideoTexture.imageToArray(image, mode) function:
the first argument is a Image source object, the second
optional argument is a format string using the R, G, B,
A, 0 and 1 characters. For example "BGR" means that each
pixel will be 3 bytes, corresponding to the Blue, Green
and Red channel in that order. Use 0 for a fixed hex 00
value, 1 for hex FF. The default mode is "RGBA".

All Image source objects now support the buffer interface
which allows to create memoryview objects for direct access
to the image internal buffer without memory copy. The buffer
format is one dimensional array of bytes with 4 bytes per
pixel in RGBA order. The buffer is writable, which allows
custom modifications of the image data.

v = memoryview(source)

A bug in the Python 3.1 buffer API will cause a crash if
the memoryview object cannot be created. Therefore, you
must always check first that an image data is available
before creating a memoryview object. Use the new valid
attribute for that:

if source.valid:
    v = memoryview(source)
    ...	

Note: the BGL buffer object itself does not yet support
the buffer interface.

Note: the valid attribute makes sense only if you use
image source in conjunction with texture object like this:

# refresh texture but keep image data in memory
texture.refresh(False)
if texture.source.valid:
    v = memoryview(texture.source)
    # process image
    ...
    # invalidate image for next texture refresh
    texture.source.refresh()

Limitation: While memoryview objects exist, the image cannot be
resized. Resizing occurs with ImageViewport objects when the
viewport size is changed or with ImageFFmpeg when a new image
is reloaded for example. Any attempt to resize will cause a
runtime error. Delete the memoryview objects is you want to
resize an image source object.
2010-02-21 22:20:00 +00:00
5589050c7e move include where it's needed and won't break other things. 2010-02-20 22:49:45 +00:00
86047ac3d5 typo in to_euler() 2010-02-20 22:36:32 +00:00
24827ce351 Fix compiling error on windows for mathutils commit 2010-02-20 21:01:05 +00:00
aa67aa9ecc Split numinput from transform (reusable in other operator).
Use in marker move operator.
2010-02-20 20:29:09 +00:00
02e7871149 Mathutils API: Euler support for rotation order.
Examples.
 euler = Euler(1, 2, 3)
 euler.order = 'ZXY'
 
 euler = matrix.to_euler('XZY')


Still missing rna support. this still wont give the right order, defaulting to XYZ.
 eul = object.rotation_euler
2010-02-20 19:49:04 +00:00
081c1205a3 correct fsf address 2010-02-12 13:34:04 +00:00
8f4c340915 bpy.utils.home_paths, use this to get script paths for the user/local/system blender paths. 2010-02-11 14:08:22 +00:00
15ef07d684 More tooltip editing 2010-02-11 02:03:18 +00:00
7fe3ab7e8e bugfix for reading invalid id prop lengths from python. 2010-02-01 18:38:33 +00:00
f776303de1 setting invalid vector swizzle attributes (from blender2.4x docs for instance), could crash blender.
- disallow setting swizzle's that have duplicate values: vec.xxx = [1,2,3]
 - raise an error if the list setting a swizzle's longer.
 - mathutils write callback was running on the wrong vector, which could crash blender.
2010-01-31 22:50:07 +00:00
fd3842f3a2 Mathutils doc improvements + other small things
- bpy.app moved into PyStructSequence (used by sys.float_info)
- added buildinfo into bpy.app.build_*
- bpy.ui removed (wasnt used)
- include external example files in Mathutils docs (only Mathutils and Vector are currently written)
- added support to auto document PyStructSequence's
- CMake had "'s inside all its strings.
2010-01-31 21:52:26 +00:00
dde838ec5e bugfix [#20417] <memory> shouldn't be stored in recent item list 2010-01-30 14:34:37 +00:00
ec48cbd267 utility functions is_negative_m3 & is_negative_m4, added python Mathutils access Matrix.is_negative
renamed Mathutils attribute wrapped -> is_wrapped
2010-01-30 13:15:39 +00:00
478dc000b3 * Mathutils attributes documented - http://www.blender.org/documentation/250PythonDoc/Mathutils.html
* Vector.difference() needed normalized vectors
* bpy.DEUBG -> bpy.app.debug
2010-01-27 21:33:39 +00:00
035daa2e2d py api - utility function for vectors.
quat = vec.difference(other)

also pedantic change with enum names.
2010-01-27 15:29:21 +00:00
f8200f14ae crash fix from own recent updates to Mathutils.RotationMatrix() 2010-01-27 12:53:25 +00:00
0a0f4c9d81 Mathutils refactor & include in sphinx generated docs, (TODO, include getset'ers in docs)
- Mathutils.MidpointVecs --> vector.lerp(other, fac)
 - Mathutils.AngleBetweenVecs --> vector.angle(other)
 - Mathutils.ProjectVecs --> vector.project(other)
 - Mathutils.DifferenceQuats --> quat.difference(other)
 - Mathutils.Slerp --> quat.slerp(other, fac)
 - Mathutils.Rand: removed, use pythons random module
 - Mathutils.RotationMatrix(angle, size, axis_flag, axis) --> Mathutils.RotationMatrix(angle, size, axis); merge axis & axis_flag args
 - Matrix.scalePart --> Matrix.scale_part
 - Matrix.translationPart --> Matrix.translation_part
 - Matrix.rotationPart --> Matrix.rotation_part
 - toMatrix --> to_matrix
 - toEuler --> to_euler
 - toQuat --> to_quat
 - Vector.toTrackQuat --> Vector.to_track_quat
2010-01-25 09:44:04 +00:00
8ec59c7c68 Math Lib:
* inline some more functions, from math_base and math_vector
* also made some changes to the way inline is done so it can
  work for more than one file
* reflect_v3_v3v3 requires input vectors to be normalized now.
* added rgb_to_grayscale
* added zero_v4, copy_v4_v4, swap_v4_v4, is_one_v3
* added box_clip_bounds_m4 to clip a bounding box against a
  projection matrix
2010-01-22 11:10:24 +00:00
e52084ced4 error message error 2010-01-22 02:24:58 +00:00
b0f87935a8 spelling errors, no real changes to code. 2010-01-14 10:59:42 +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
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
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
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
926201acf8 - string copy without .py wasnt terminating the string
- console import autocomplete wasnt including modules defined in C like BGL, Mathutils
2009-12-07 14:09:53 +00:00
33c444f965 User Script support added back.
- the scripts path set in the user preferences or ~/.blender/scripts/ui (io, op, io etc..) will be used to load scripts.
- the default home dir part probably only works in *nix os's

- Added a missing sync callback to vector.toTuple()
2009-11-30 22:32:04 +00:00
d98093a91a - added a new math function double_round, useful for rounding a number to a number of decimal places.
- added Mathutils vector method, vec.asTuple(round), since this is tedious in python and fairly common task.
2009-11-29 22:42:33 +00:00
383093957a Mathutils vec += vec wasnt running mathutls callbacks 2009-11-26 16:19:20 +00:00
854cc87a80 option to have scripts run on startup for per blendfile UI's 2009-11-20 15:01:09 +00:00
ac8ff25b2d idprop.get(key, default=None)
matching pythons dict.get()

removed checks for a failed PyObject_New(), if python cant make a new object your probably going to crash anyway.
2009-11-19 17:04:28 +00:00
3b4c9d9699 correcting ID property list was incorrect on porting 2009-11-19 11:56:13 +00:00
d3794d9f94 fix for memory leak, use Key Errors for pyrna getitem access & idprops 2009-11-18 13:02:09 +00:00
f7682e2e0f - in pose mode, pose bone properties are edited rather then armature bone
- new id property array method convert_to_pyobject()
- editing an array in the UI broke
- fixed for own error when updating ID prop api
2009-11-17 12:54:29 +00:00
3087da0b25 my chnges broke 'del idprop["key"]'
made it possible to remove properties from rna types.

eg.
 del group["someprop"]
2009-11-16 22:21:39 +00:00