MCPcopy Create free account
hub / github.com/BoomingTech/Piccolo / fixIndex

Function fixIndex

engine/3rdparty/tinyobjloader/tiny_obj_loader.h:800–821  ·  view source on GitHub ↗

Make index zero-base, and also support relative index.

Source from the content-addressed store, hash-verified

798
799// Make index zero-base, and also support relative index.
800static inline bool fixIndex(int idx, int n, int *ret) {
801 if (!ret) {
802 return false;
803 }
804
805 if (idx > 0) {
806 (*ret) = idx - 1;
807 return true;
808 }
809
810 if (idx == 0) {
811 // zero is not allowed according to the spec.
812 return false;
813 }
814
815 if (idx < 0) {
816 (*ret) = n + idx; // negative value = relative
817 return true;
818 }
819
820 return false; // never reach here.
821}
822
823static inline std::string parseString(const char **token) {
824 std::string s;

Callers 1

parseTripleFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected