Re: [K3d-development] Generic primitive refactoring
Brought to you by:
barche
From: Timothy M. S. <ts...@k-...> - 2009-02-16 05:08:09
|
Carsten Haubold wrote: > I haven't followed the developement really because I was pretty busy, > but if you need help with restructuring the NURBS part I'll do my best > to support you. You da man! > It shouldn't be a problem to remove the gprim_factory from the > modifiers, a bigger problem is that the data is accessed directly in > some modifiers, because gprim was not flexible enough. Aside from being another example of why gprim_factory was a mistake, this should be no problem. > So the arrays where the NURBS data is stored in are now more generic? > All the operations on the data need to change as well, right? Nope - the set of arrays that are used to store NURBS primitives are exactly the same, so the operations themselves don't need to change. What's changing is that the arrays will be stored in generic k3d::mesh::primitive objects (which can contain arbitrary collections of arrays) instead of the old k3d::mesh::nurbs_curve_groups_t and k3d::mesh::nurbs_patches_t classes. To make it easier to work with NURBS, there are now some helper classes that store references to all the arrays: * k3d::nurbs_curve::primitive * k3d::nurbs_curve::const_primitive * k3d::nurbs_patch::primitive * k3d::nurbs_patch::const_primitive There are methods to create and validate NURBS primitives that return these new helper classes, which eliminates all of the error-prone and repetitive code that we used to write for creating arrays. So instead of: k3d::mesh::nurbs_patches_t* patches = mesh.nurbs_patches.create(); k3d::mesh::indices_t& patch_first_points = patches->patch_first_points.create(); k3d::mesh::counts_t& patch_u_counts = patches->patch_u_counts.create(); /* 24 more just like these */ patch_first_points.push_back(foo); ... you can do: boost::scoped_ptr<k3d::nurbs_patch::primitive> primitive = k3d::nurbs_patch::create(mesh); primitive->patch_first_points.push_back(foo); ... Note that this cleans-up the code dramatically, and accomplishes around 75% of what gprim_factory was originally about (hiding the details of array creation). Cheers, Tim |