Merge pull request #299 from Nazg-Gul/dev

Implement C-API accessor to evaluator topology
This commit is contained in:
gelder 2014-05-11 00:23:45 -07:00
commit b85324dbf9
2 changed files with 53 additions and 7 deletions

View File

@ -111,7 +111,7 @@ int openSubdiv_finishEvaluatorDescr(OpenSubdiv_EvaluatorDescr *evaluator_descr,
int openSubdiv_setEvaluatorCoarsePositions(
struct OpenSubdiv_EvaluatorDescr *evaluator_descr,
OpenSubdiv_EvaluatorDescr *evaluator_descr,
const float *positions, int numVertices)
{
std::string errorMessage;
@ -135,7 +135,7 @@ int openSubdiv_setEvaluatorCoarsePositions(
void openSubdiv_evaluateLimit(
struct OpenSubdiv_EvaluatorDescr *evaluation_descr,
OpenSubdiv_EvaluatorDescr *evaluation_descr,
int face_id, float u, float v,
float P[3], float dPdu[3], float dPdv[3])
{
@ -146,4 +146,30 @@ void openSubdiv_evaluateLimit(
evaluation_descr->evaluator.EvaluateLimit(coords, P, dPdu, dPdv);
}
void openSubdiv_getEvaluatorTopology(
OpenSubdiv_EvaluatorDescr *evaluation_descr,
int *numVertices,
int *refinementLevel,
int *numIndices,
int **indices,
int *numNVerts,
int **nverts)
{
// TODO(sergey): Tag data is also need to do the full comparison,
// but it's not that clear how to pass it via C-API and no real
// application to test this yet.
*numVertices = evaluation_descr->topology.numVertices;
*refinementLevel = evaluation_descr->topology.refinementLevel;
*numIndices = evaluation_descr->topology.indices.size();
*indices = &evaluation_descr->topology.indices[0];
*numNVerts = evaluation_descr->topology.nverts.size();
*nverts = &evaluation_descr->topology.nverts[0];
}
OpenSubdiv_EvaluatorDescr *openSubdiv_getEvaluatorTopologyDescr(
OpenSubdiv_EvaluatorDescr *evaluator_descr)
{
return (OpenSubdiv_EvaluatorDescr *) &evaluator_descr->topology;
}

View File

@ -29,10 +29,10 @@ extern "C" {
* KIND, either express or implied. See the Apache License for the specific
* language governing permissions and limitations under the Apache License.
*/
/* Types declaration. */
struct OpenSubdiv_EvaluatorDescr;
struct OpenSubdiv_TopologyDescr;
/* Methods to create and delete evaluators. */
struct OpenSubdiv_EvaluatorDescr *openSubdiv_createEvaluatorDescr(int numVertices);
@ -46,7 +46,7 @@ int openSubdiv_finishEvaluatorDescr(struct OpenSubdiv_EvaluatorDescr *evaluator_
int openSubdiv_setEvaluatorCoarsePositions(
struct OpenSubdiv_EvaluatorDescr *evaluator_descr,
const float *positions, int numVertices);
/* Evaluate the subdivision limit surface at the given ptex face and u/v, */
/* return position and derivative information. Derivative pointers can be */
/* NULL. Note that face index here is the ptex index, or the index into */
@ -55,8 +55,28 @@ void openSubdiv_evaluateLimit(
struct OpenSubdiv_EvaluatorDescr *evaluation_descr,
int face_id, float u, float v,
float P[3], float dPdu[3], float dPdv[3]);
/* Get topology stored in the evaluator descriptor in order to be able */
/* to check whether it still matches the mesh topology one is going to */
/* evaluate. */
void openSubdiv_getEvaluatorTopology(
struct OpenSubdiv_EvaluatorDescr *evaluation_descr,
int *numVertices,
int *refinementLevel,
int *numIndices,
int **indices,
int *numNVerts,
int **nverts);
/* Get pointer to a topology descriptor object. */
/* Useful for cases when some parts of the pipeline needs to know the */
/* topology object. For example this way it's possible to create a HbrMesh */
/* having evaluator without duplicating topology object. */
/* TODO(sergey): Consider moving the API call above to toplogy-capi. */
/* It'll make current usecase in Blender a bit more complicated, but would */
/* separate entities in OpenSubdiv side much clearer. */
struct OpenSubdiv_EvaluatorDescr *openSubdiv_getEvaluatorTopologyDescr(
struct OpenSubdiv_EvaluatorDescr *evaluator_descr);
#ifdef __cplusplus
}