[Bf-python] FaceNormals

Willian Padovani Germano wgermano at ig.com.br
Thu Oct 16 22:30:08 CEST 2003


Hi,

Yes, looks good.  It's not hard to do it in Python itself (as script writers
have been doing, you know), but it's not a bad idea to include this in
NMFace.

Just a few comments:

From: <models at paposo.com>
(...)
> How about this:
>
> //NMesh.c
> float fNormal[3];

No need for this outside the place where it is needed.  See below ...

> static PyObject *NMFace_getattr(PyObject *self, char *name)
> {
>      BPy_NMFace *mf = (BPy_NMFace *)self;
> .....
>
>  if(strcmp(name, "no") == 0)
> {

... Here: float fNormal[3] = {0.0,0.0,0.0};

>     CalcNormFloat( mf->v[0].co, mf->v[1].co, mf->v[2].co, fNormal)
>         return newVectorObject(fNormal, 3)

Can this CalcNormFloat fail?  If so a check is necessary.

>
> .....
>      return Py_FindMethod(NMFace_methods, (PyObject*)self, name);
> }
>
> //NMesh.h
> typedef struct {
> ....
>  float normal                //new

No need for this either, just create the normal on demand, wrap it and give
to the user, as above.  Also remember to update the docs and the
'__members__' section of the NMFace get_attr function.

> } BPy_NMFace; /* an NMesh face */
>
> That way you could just do:
> myNormal = myFace.no
>
> I haven't tested this yet but the concept is pretty simple. You would just
> return the normal for face just like any other variable

Don't forget to test well before committing, comparing the results against
normals that you see in the 3d view (I mean evident ones like from a xy
plane, etc) and normals calculated via python scripts, please, Joseph.  And
also check the Blender function to see if there's any subtlety about what
you can feed to the function that calculates normals.  If in doubt, we can
always email the bf-committers list or drop by #blendercoders ...

Ah, it's also very necessary to check that the user really stored NMVerts in
the face (from memory I recall that the checks are only done right before
converting the nmesh to mesh data).  There's this
EXPP_check_sequence_consistency()
function in gen_utils.c, you can use it or at least follow what it does.

Then once it is done, tease the guys at the elysiun forum telling them about
both vgroups (that makes vertex selection info possible) and face.no ; ).

--
Willian, wgermano at ig.com.br




More information about the Bf-python mailing list