syoyo / tinygltf

Header only C++11 tiny glTF 2.0 library
MIT License
2.01k stars 409 forks source link

No default initialization of `light` and `emitter` in `tinygltf::Node` #431

Closed dyollb closed 1 year ago

dyollb commented 1 year ago

Describe the issue

No default initialization of light and emitter in tinygltf::Node. This causes crash in json serialization

To Reproduce

Expected behaviour

Code should initialize parameters not marked as required (or all) with something meaningful that can be tested against, e.g. -1.

Fix:

namespace tinygltf {
class Node {
 public:
  Node() = default;

  DEFAULT_METHODS(Node)

  bool operator==(const Node &) const;

  int camera = -1;  // the index of the camera referenced by this node

  std::string name;
  int skin = -1;
  int mesh = -1;
  int light = -1;  // light source index (KHR_lights_punctual)
  int emitter = -1; // audio emitter index (KHR_audio)

Screenshots

na

Additional context na

syoyo commented 1 year ago

Good catch! Thanks! Fixed!