DracoPy icon indicating copy to clipboard operation
DracoPy copied to clipboard

Custom metadata support

Open romanov6416 opened this issue 4 years ago • 2 comments

Hi!

First, thank you for the library development. I want to use this lib in my python project. In addition to 3D geometry (draco mesh) I have to serialize/deserialize custom metadata attached to the mesh in the draco file. I see that current version of DracoPy doesn't support custom metadata. So I decided to make my own implementation of this in DracoPy.pyx file. And here I bumped into the problem:

I implemented recursive metadata struct. in DracoPy.h:

  struct MetadataObject {
    std::unordered_map<std::string, std::vector<uint8_t>> entries;
    std::unordered_map<std::string, MetadataObject> sub_metadatas;
  };

And DracoPy.pxd

cdef extern from "DracoPy.h" namespace "DracoFunctions":
    cdef struct MetadataObject:
        unordered_map[string, vector[uint8_t]] entries
        unordered_map[string, MetadataObject] sub_metadatas

Also I added a function (to DracoPy.h) parsing draco metadata to MetadataObject and pass it into encode_mesh function.

And when I try to compile my solution I got cython compilation error: RecursionError: maximum recursion depth exceeded while calling a Python object

I know declaring recursive structures is possible in Cython. But it seems impossible to declare EXTERNAL recursive structures in Cython (I didn't find anything about it in google)

So my question is do you have ideas how to forward draco structure Metadata to Python?

romanov6416 avatar Oct 18 '21 09:10 romanov6416

Created PR #20 to support metadata

romanov6416 avatar Oct 20 '21 21:10 romanov6416

Thanks for the PR romanov, I'm off until Friday, but I'll try to take a look then!

william-silversmith avatar Oct 20 '21 21:10 william-silversmith