Code Monkey home page Code Monkey logo

Comments (5)

jpaver avatar jpaver commented on May 21, 2024

Hey @mgerhardy, thanks for the report. Not sure if this reserved field will be used in the future, so having the assert is useful to alert us when a new feature supported by MV is possibly being used within a given .vox file.

That being said, not sure it will be used -- MV development appears to have slowed down a lot so perhaps it's fine.

Can you confirm that the voxedit.io model is loadable by MV?

from opengametools.

mgerhardy avatar mgerhardy commented on May 21, 2024

Yes. Sorry for not mentioning it. The model loads fine in magicavoxel

from opengametools.

mgerhardy avatar mgerhardy commented on May 21, 2024

maybe another thing for the context object - hand in a warn or error function to log these things. But asserting would prevent loading these models - even if everything else would be fine.

from opengametools.

jpaver avatar jpaver commented on May 21, 2024

But asserting would prevent loading these models - even if everything else would be fine

It is possible for clients of the library to skip specific asserts if they need to by checking the message passed to the assert:.

void _vox_assert_msg(bool condition, const char * msg_str) {
  // condition wasn't violated? exit
  if (condition)
    return;
  // ignore specific asserts.
  if (strcmp(msg_str, "unexpected value for reserved_id in LAYR chunk") == 0)
    return;
  fprintf(stderr, "%s", msg_str);
  raise(SIGTRAP);
}

#define ogt_assert(cond, msg_str)    do { _vox_assert_msg(cond, msg_str); } while(0)
#include "ogt_vox.h"

...but I do sympathize. This sort of assert is really a warning of potential forward compatibility issues. I wonder if we should add an ogt_assert_warn so the library client can distinguish between fatal asserts and warning asserts, and then independently override them. eg

// implement a fatal assert
#define ogt_assert(cond, msg)   do {               \
     if ( !cond ) {                                \
       fprintf( stderr, "%s", msg_str )            \
       raise(SIGTRAP);                             \
  } while( 0 ) 

// implement a warning assert
#define ogt_assert_warn(cond, msg)  do {           \
      if ( !cond )                                 \
        fprintf( stderr, "WARNING: %s", msg_str ); \
  } while( 0 )
#include "ogt_vox.h"

...of course, we'd just turn these reserved_id asserts into ogt_assert_warn, and if ogt_assert_warn wasn't overridden by the client, ogt_vox would define it itself. eg.

// user didn't override warning assert? just map it to ogt_assert
#ifndef ogt_assert_warn
   #define ogt_assert_warn         ogt_assert
#endif

@mgerhardy if you think this is a good direction, feel free to put together a PR - otherwise, it may take me a while to get to it.

from opengametools.

mgerhardy avatar mgerhardy commented on May 21, 2024

@jpaver there we go - a PR is made. But the locations of the ogt_warn usage are still open for discussion I think. I'm not sure if I hit all locations or maybe even hit too many. Feedback welcome.

from opengametools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.