[Bf-python] curve module and surfaces

Fernando Serboncini fserb at campogeral.com.br
Mon Jun 14 10:02:19 CEST 2004


I was trying to use the curve module and I've realized that the
getNumPoints and getControlPoints functions were returning the wrong
number of points. They were returning only the first row of points. This
was without notice with NURBS curves, but makse NURBS surfaces wrong.

I don't know if this is an "already-discussed" topic, but since it's my
first time here, here it goes: Is the curve module suposed to support
NURBS surfaces, or only curves? My opinion is that it should support
both since I couldn't find any clear distinction between a NURBS curves
and surface on the code, except for the fact that NURBS curves control
points are co-planars.

Looking into the code, it seems that those function are using only the
pntsu field of the Nurb struct. I think the correct is to use
pntsu*pntsv. This allows buth surfaces and curves to work with this
module.

Here's the patch that fixed those two functions. 
I've tested and got the correct results.


[]s
Fernando Serboncini
http://fserb.com.br

--- blender.orig/source/blender/python/api2_2x/Curve.c	2004-06-06
19:42:50.000000000 -0300
+++ blender/source/blender/python/api2_2x/Curve.c	2004-06-14
04:20:42.051893480 -0300
@@ -780,8 +780,8 @@
 				       "curve index out of range"));
     }
 
-  /* check numpoint param against pntsu */
-  if (numpoint >= ptrnurb->pntsu)
+  /* check numpoint param against pntsu*pntsv */
+  if (numpoint >= ptrnurb->pntsu * ptrnurb->pntsv)
     return (EXPP_ReturnPyObjError (PyExc_AttributeError,
 				   "point index out of range"));
 
@@ -974,8 +974,8 @@
 				       "curve index out of range"));
     }
 
-  /* pntsu is the number of points in curve */
-  ret_val = PyInt_FromLong ((long) ptrnurb->pntsu);
+  /* pntsu*pntsv is the number of points in curve */
+  ret_val = PyInt_FromLong ((long) (ptrnurb->pntsu * ptrnurb->pntsv));
 
   if (ret_val)
     return ret_val;





More information about the Bf-python mailing list