Commit Graph

158 Commits

Author SHA1 Message Date
Ken Hughes
1eded8d677 Python API
----------
Undo for part of previous commit.  Campbell reminded me that UV texture faces
aren't "users" like other objects, so removing the code which changes them.
2006-12-20 23:26:14 +00:00
Ken Hughes
368928220d Python API
----------
Bugfix/enhancement: allow image of mesh's UV faces to be removed/cleared by
"del f.image" or "f.image = None", and handle image user counts correctly
when assigning/clearing images.
2006-12-20 22:56:58 +00:00
1041ad4719 added fakeUser and users to more pytypes 2006-12-17 02:16:29 +00:00
47ee194922 adding ed.key and face.edge_keys
avoids a lot of boiler place code in scripts that need to build connectivity.
2006-12-16 23:46:43 +00:00
a9447e4273 Enable/Disable DupFaces from the Python API.
Fixed a (own) bug in fakeUsers and added fakeUsers to Objects and Materials as well as Mesh.
2006-12-16 22:04:21 +00:00
1031caafc1 python multi UV support -
active index was incorrect, removing layers after they had non was crashing blender, now raise an error.
2006-12-13 03:21:14 +00:00
228bebfaa8 name changes from theeths suggestions
totUvLayers -> totalUVLayers
addUvLayers -> addUVLayers
2006-12-13 02:55:49 +00:00
080a5d5664 exposed CustomData_get_active_layer_index in BKE_customdata.h (needed by python to get the active layer)
added python api stuff to deal with Color and UV/Image layers.

me.activeUvLayer - int
me.activeColorLayer - int
me.totUvLayers - int
me.totColorLayers - int

me.addUvLayer()
me.addColorLayer()
me.removeUvLayer()
me.removeColorLayer()


Variable names may need changing.
2006-12-13 00:50:02 +00:00
80ee52e444 Multiple UV and vertex color layers: (still work in progress)
These can be created and deleted in the Mesh panel in the same place as
before. There is always one active UV and vertex color layer, that is
edited and displayed.

Important things to do:
- Render engine, material support
- Multires and NMesh now lose non active layers

Also CustomData changes to support muliple layers of the same type, and
changes to layer allocation, updated documentation is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
2006-12-12 21:29:09 +00:00
4f8079d49c Modifier Stack: Limit calculation to required data.
This commit upgrades the modifier stack to only calculate the data which is
needed, either by modifiers further down the stack or by other functions at
the end of the stack (e.g. drawing functions).

This speeds up modifier stack recalculation, especially where vertex
groups and UV coordinates are concerned. For example, a mesh with an Armature
modifier followed by a Subsurf modifier would previously have required the
Subsurf modifier to interpolate all the vertex groups in the mesh, slowing
down modifier calculations considerably. With this update, vertex group data
is not propagated beyond the Armature modifier, so calculations are faster.

Note that this depends on the order of modifiers in the stack. If the Armature
and Subsurf modifiers were swapped in the above example, the Subsurf modifier
would have to interpolate vertex groups, as they are needed by the Armature
modifier.
2006-12-05 17:42:03 +00:00
Ken Hughes
e906417a3a Python API
==========

Bugfix: using del operator on me.verts would cause a crash.
2006-12-01 21:20:40 +00:00
e10a86eef9 (Partial) fix for bug #5289:
Crash using Shape Widget Wizard script, was an error in customdata copy.
The script still throws a python error though, but that seems unrelated
to this crash.
2006-11-22 23:12:38 +00:00
e435fbc3c5 Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.

Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData


Replaced TFace by MTFace:

This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.


Removed DispListMesh:

This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.


Removed ssDM and meshDM DerivedMesh backends:

The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.


This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
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
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
ef56538c62 removed warning in last commit 2006-11-13 17:55:06 +00:00
26ef99157e made mesh.getFromObject() accept a python object as well as the object name.
accepting the name only was causing big problems when exporting library data, because duplicate names are possible the wrong data was exporting.
2006-11-13 17:37:01 +00:00
0e569035c7 made mesh getFromObject also copy the meshes flag 2006-10-22 02:43:04 +00:00
6e61448123 Mistake in recent schange to scn.objects.new() crashed Blender. fixed and also stopped Mesh_FromPyObject() clearning a meshes object if not called with an object. 2006-10-10 02:18:08 +00:00
dda63a9dde added comparison function to many python types so you can do == and =! 2006-10-06 16:48:28 +00:00
4811ba51ed Python API
added list like access to mesh face colors so you can say col[0] = 255 instead of col.r= 255
more importantly 'for ch in col' and 'tuple(col)'
2006-10-05 15:56:11 +00:00
0c6bb8c079 mesh.transform() was applying the inverted 4x4 matrix to the normals, without removing the translation part.
iter with a char value did not allow for -1, my bad, using short now.
2006-10-04 17:06:29 +00:00
ad51edd3bf Adding MDD import and export from patch 4969 with modifications, (import and export rvks, MDD is from lightwave AFAIK)
Added Mesh .key .removeAllKeys() and .insertKey() for MDD support (was using NMesh just for keys before)
Since this is aparently an experemental feature in NMesh we may want to change this.
2006-09-27 16:33:02 +00:00
3d3b64768d Mesh iterators (me.faces, me.edges, me.verts, face and edge iterator) store the iterator progress in the python object.
This made nested loops with the same python object mess up.
eg-
faces= me.faces
for f1 in faces:
  for f2 in faces:
    print f1.index,f2.index

This didnt work, fixed by initializing the iter value at -1, so any greater value will create a new BPyObject with its own iter value.
once iteration is finished, its set back to -1.

Also made face and edges iter value a char instead of an int to save some memory.
2006-09-22 10:08:41 +00:00
d89240ba12 added mesh_create_derived_view(ob) to DerivedMesh.c
exactly the same as mesh_create_derived_render(ob) except it uses the view modifier settings.

Added an optional arg to getFromObject to 'render' so you can choose to get the mesh displayed in the 3d view or generate one with render settings.
Solved bug 4612 getFromObject now works with soft body meshes (error was caused by getting the derived mesh from a copy of the object)

removed workaround for softbody bug in object_apply_def.py
2006-09-17 05:15:56 +00:00
6dbf2ccf55 bug of mine fixed
didnt chech that a material existed before accessing it- crashed with null materials and mesh.getFromObject()
2006-09-15 14:52:59 +00:00
5e4728369a made getFromObject() use a dummy mesh, rather then making a copy of the mesh and then replacing its data with the displist mesh.
aside from avoiding unneeded memory alloc/dealloc and bing faster this works around a recently discovered bug with the user count of copied Mesh keys... causing getFromObejct leak memory when used with mesh keys.
It also fixes a bug where getFromObejct with fluid-sim would corrupt memory.
2006-09-11 07:05:29 +00:00
bffe5dd087 Fixes bug #4834. The function was supposed to return a list of vertex
indices that are within the passed group. If one of the indices was not
in the group, it returned an exception, as opposed to just removing it from
the group as the documentation states.
2006-09-08 11:32:01 +00:00
f17e9a6cb9 resolved invalid bounding box from the object by freeing a new meshes bounding box.
added back bound box constraint to obj import (many OBJs have values outside the defulat clipping range)

BPyRender.py was missing a flag assignment.
2006-09-05 06:45:39 +00:00
4603f452c2 Animation department feature request: support for vertex groups in Lattices
In a quick glance: (temp image)
http://www.blender.org/bf/rt.png

Main reason is that Lattices are useful a lot for Armature deformation.
Lattices just provide much more precise and interesting control. However,
with only bone envelopes it's very hard to use.

Working with Lattice vertex groups is nearly identical to Mesh:
- on CTRL+P 'make parent' you can choose the deform option now
- In editmode, the buttons to control vertex groups are available
- In outliner you can select vertexgroups too
- Deforming Lattices with Armatures has all options as for Mesh now.

Note:
- No WeightPaint has been added yet. To compensate, the editmode
  drawing for a Lattice with vertex group shows weight values for the active
  vertex group.
- Lattice editmode doesn't undo/redo weight editing yet.
- Softbody for Lattice still uses own vertex weights

Implementation notes:
- derivedmesh weight_to_rgb() is now exported to drawobject.c
- been doing cleanups in code (order of includes, var declarations, etc)
- weightpaint button handling now is generic

I've checked on Brecht's proposal for Custom Element data;
http://mediawiki.blender.org/index.php/BlenderDev/CustomElementData
It could have been used, but that would mean the existing code for
vertexgroup handling and armature deform couldn't be re-used. I guess this
is really a later todo.
2006-09-03 12:16:14 +00:00
d0cabce889 added sharp edge to python edge flags 2006-08-29 10:04:10 +00:00
433f6c7043 Integration of the Google Summer of Code Modifier Stack Upgrade project. The
main features are:
* Modifiers can now be in any order in the modifier stack
* DerivedMesh now has a standard framework for custom element data to be passed
  through the stack with mesh data (being copied and interpolated as
  appropriate), so modifiers can access whatever data they need
* The modifier stack code has been refactored and a number of bugs have been
  removed
* The EdgeSplit modifier has been added:
  http://mediawiki.blender.org/index.php/BlenderDev/EdgeSplitModifier
* The DerivedMesh modifier has been added:
  http://mediawiki.blender.org/index.php/BlenderDev/DisplaceModifier
* The UVProject modifier has been added:
  http://mediawiki.blender.org/index.php/BlenderDev/UVProjectModifier

For more info, see:
http://mediawiki.blender.org/index.php/User:Artificer/ModifierStackUpgrade
(currently undergoing reorganisation)
2006-08-28 01:12:36 +00:00
Ken Hughes
69836ce9bc ===Python API===
More additions for Mesh.faces.extend(); allow faces with 2 verts or duplicate
verts to remain in the input list (although they are still not added to the
mesh) so that indexList option can return None for them.  The goal is for all
faces which are discarded to still be ignored but return None.
2006-08-25 16:01:16 +00:00
Ken Hughes
2ee94cbbac ===Python API===
New keyword parameters for Mesh.faces.extend() method:
  * ignoreDups: turns off checks for duplicate faces in the input list and
    existing mesh faces.  Intended for constructing new meshes where the
    faces are known to be unique.
  * indexList: makes the method return a list of new faces indices, which
    can be used to index new faces to add other attributes like color.  If
    duplicate faces are removed, None is placed in their list slot.
2006-08-24 20:02:22 +00:00
Ken Hughes
de762ae555 ===Python API===
Bugfix: Mesh.faces.extend() would incorrectly add duplicate faces in some
circumstances.
2006-08-24 19:28:36 +00:00
Ken Hughes
a217e546a4 ===Python API===
Fix return value problem in Mesh_getFakeUsers(): compiler warning in this case
was indicating a real bug.
2006-08-22 18:08:57 +00:00
d6d2d6f063 added fakeUser property to mesh (will need to add to all other library datablocks too)
and added __copy__ to quat and euler types as well as updating the docs.
2006-08-22 09:13:44 +00:00
Ken Hughes
a680d87902 ===Python API===
Patch to Mesh and NMesh APIs to bring FaceModes dict into sync (thanks jms).
2006-08-16 19:20:37 +00:00
515fe83f97 added __copy__ to mesh and object types, fixed a monor bug in setTexMesh and made Mesh.c use G.totMesh properly. 2006-08-13 01:51:47 +00:00
6a48654cce Added a octree implimentation for doing fast locational vertex lookups. 2006-07-31 13:28:00 +00:00
00a6a79899 added the texmesh to Mesh property to mesh. 2006-07-31 12:57:46 +00:00
cac265f7b6 faces faces added had vertex colors set to black.
use default_tface(tface) on all extended faces when tfaces exist.
2006-07-28 07:08:27 +00:00
Ken Hughes
b85c3fb1de ===Python API===
Bugfix #4728: passing an interator sequence to me.faces.delete() caused a
crash; check explicitly for lists or tuples.
2006-07-19 14:35:22 +00:00
Ken Hughes
861e0a347a ===Python API===
Bugfig #4527: add more robust bitfield checking for Mesh.mface.flags;
unconfirmed bug report that an exception was caused with RC3a that could
not be reproduced.  It was possible that a pre 2.42 .blend might have
some additional flag bits set that would have caused an error.
2006-07-06 16:40:49 +00:00
Ken Hughes
64d0d62ddd ===Python API===
Bugfix #4605: mball_to_mesh() doesn't create edges for new mesh, so
me.getFromObject() wouldn't display the new mesh until edit mode was entered.
Added a call to displistmesh_add_edges() to calculate them and then insert
into the new mesh.
2006-07-05 18:28:51 +00:00
be2c208077 Fixed a bug where face flags could not be set because of the faces existing flags.
A problem with the current flag seting in Mesh is that Mesh needs to know of all possible flags or setting a flag can raise an error from the faces own unrecognezed flag.
also stopped the active face flag raising an error so pythoners can do face1.flag |= face2.flag without checking for active face flags. if the flag is a part of the arg its removed quietly.
Checked Mesh flags, face modes and edge flags, should all be ok now.
2006-06-27 02:49:55 +00:00
1e9ce63b40 Fixed a bug where loose edges would raise an error when the FGON value was unset.
also added LOOSE to the EdgeFlags dict.
2006-06-26 04:14:12 +00:00
Ken Hughes
f478c9eca3 ===Python API===
Bugfix #4347: deleting vertex 0 incorrectly deleted all triangle face, since
check for v4==0 wasn't being done.
2006-06-17 14:08:15 +00:00
Ken Hughes
e77112f76b ===Python API===
added len() operator for MFaces, which returns number of MVerts.
2006-06-06 18:14:31 +00:00
721de110b2 Added Py_DECREF since PySequence_GetItem adds a reference where as PyTuple_GetItem borrows it.
Thank ken.
2006-06-06 17:28:39 +00:00