[Bf-python] FaceNormals

Willian Padovani Germano wgermano at ig.com.br
Fri Oct 17 08:26:40 CEST 2003


Hi Joseph,

Small correction I remembered:

> > //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)

It's better to not use newVectorObject, there's no way to track the float
array later: memory leak.  This shows this function should only be used to
wrap things from Blender's database, like mesh vertices, etc.  Otherwise we
have leaks (and I'll check that, thanks Joseph!).

You can create a pylist from the three floats and return that, it's safer
and then there's no need to dinamically allocate fNormal[3], can be done as
above.

--
Willian, wgermano at ig.com.br




More information about the Bf-python mailing list