]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
added Math_atov function (ascii to vector), tries to parse any imaginable vector...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 27 Mar 2003 08:02:43 +0000 (08:02 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 27 Mar 2003 08:02:43 +0000 (08:02 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2854 d7cf8633-e32d-0410-b094-e92efae38249

mathlib.c
mathlib.h

index a55ab9d6df90b2ef526322591e06be8e630dccb8..e55de85377b9e91473539410c5e3f228cdd161de 100644 (file)
--- a/mathlib.c
+++ b/mathlib.c
@@ -518,3 +518,25 @@ void Matrix4x4_Print (const matrix4x4_t *in)
        , in->m[2][0], in->m[2][1], in->m[2][2], in->m[2][3]
        , in->m[3][0], in->m[3][1], in->m[3][2], in->m[3][3]);
 }
+
+int Math_atov(const char *s, vec3_t out)
+{
+       int i;
+       VectorClear(out);
+       if (*s == '\'')
+               s++;
+       for (i = 0;i < 3;i++)
+       {
+               while (*s == ' ' || *s == '\t')
+                       s++;
+               out[i] = atof (s);
+               if (out[i] == 0 && *s != '-' && *s != '+' && (*s < '0' || *s > '9'))
+                       break; // not a number
+               while (*s && *s != ' ' && *s !='\t' && *s != '\'')
+                       s++;
+               if (*s == '\'')
+                       break;
+       }
+       return i;
+}
+
index 3d5678525c5ef3c912fa67d1541835b302feacb3..ba362ce32b4262c9b27d3ed19b791e83b19db278 100644 (file)
--- a/mathlib.h
+++ b/mathlib.h
@@ -223,6 +223,7 @@ float RadiusFromBoundsAndOrigin (const vec3_t mins, const vec3_t maxs, const vec
 // print a matrix to the console
 struct matrix4x4_s;
 void Matrix4x4_Print(const struct matrix4x4_s *in);
+int Math_atov(const char *s, vec3_t out);
 
 #endif