Updates to q_math

This commit is contained in:
Walter Julius Hennecke 2014-08-13 18:42:16 +02:00
parent b8a419b5fe
commit 5afa43ec61
3 changed files with 1598 additions and 1597 deletions

View file

@ -11,68 +11,67 @@ vec3_t vec3_origin = {0,0,0};
vec3_t axisDefault[3] = { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } };
vec4_t colorTable[CT_MAX] =
{
{0, 0, 0, 0}, /* CT_NONE */
{0, 0, 0, 1}, /* CT_BLACK */
{1, 0, 0, 1}, /* CT_RED */
{0, 1, 0, 1}, /* CT_GREEN */
{0, 0, 1, 1}, /* CT_BLUE */
{1, 1, 0, 1}, /* CT_YELLOW */
{1, 0, 1, 1}, /* CT_MAGENTA */
{0, 1, 1, 1}, /* CT_CYAN */
{0.071, 0.271, 0.29, 1}, /* CT_TEAL */
{0.529, 0.373, 0.017, 1},/* CT_GOLD */
{1, 1, 1, 1}, /* CT_WHITE */
{0.75, 0.75, 0.75, 1}, /* CT_LTGREY */
{0.50, 0.50, 0.50, 1}, /* CT_MDGREY */
{0.25, 0.25, 0.25, 1}, /* CT_DKGREY */
{0.15, 0.15, 0.15, 1}, /* CT_DKGREY2 */
vec4_t colorTable[CT_MAX] = {
{0, 0, 0, 0}, /* CT_NONE */
{0, 0, 0, 1}, /* CT_BLACK */
{1, 0, 0, 1}, /* CT_RED */
{0, 1, 0, 1}, /* CT_GREEN */
{0, 0, 1, 1}, /* CT_BLUE */
{1, 1, 0, 1}, /* CT_YELLOW */
{1, 0, 1, 1}, /* CT_MAGENTA */
{0, 1, 1, 1}, /* CT_CYAN */
{0.071, 0.271, 0.29, 1}, /* CT_TEAL */
{0.529, 0.373, 0.017, 1},/* CT_GOLD */
{1, 1, 1, 1}, /* CT_WHITE */
{0.75, 0.75, 0.75, 1}, /* CT_LTGREY */
{0.50, 0.50, 0.50, 1}, /* CT_MDGREY */
{0.25, 0.25, 0.25, 1}, /* CT_DKGREY */
{0.15, 0.15, 0.15, 1}, /* CT_DKGREY2 */
{0.688, 0.797, 1, 1}, /* CT_VLTORANGE -- needs values */
{0.688, 0.797, 1, 1}, /* CT_LTORANGE */
{0.620, 0.710, 0.894, 1},/* CT_DKORANGE */
{0.463, 0.525, 0.671, 1},/* CT_VDKORANGE */
{0.688, 0.797, 1, 1}, /* CT_VLTORANGE -- needs values */
{0.688, 0.797, 1, 1}, /* CT_LTORANGE */
{0.620, 0.710, 0.894, 1},/* CT_DKORANGE */
{0.463, 0.525, 0.671, 1},/* CT_VDKORANGE */
{0.616, 0.718, 0.898, 1},/* CT_VLTBLUE1 */
{0.286, 0.506, 0.898, 1},/* CT_LTBLUE1 */
{0.082, 0.388, 0.898, 1},/* CT_DKBLUE1 */
{0.063, 0.278, 0.514, 1},/* CT_VDKBLUE1 */
{0.616, 0.718, 0.898, 1},/* CT_VLTBLUE1 */
{0.286, 0.506, 0.898, 1},/* CT_LTBLUE1 */
{0.082, 0.388, 0.898, 1},/* CT_DKBLUE1 */
{0.063, 0.278, 0.514, 1},/* CT_VDKBLUE1 */
{0.302, 0.380, 0.612, 1},/* CT_VLTBLUE2 -- needs values */
{0.196, 0.314, 0.612, 1},/* CT_LTBLUE2 */
{0.060, 0.227, 0.611, 1},/* CT_DKBLUE2 */
{0.043, 0.161, 0.459, 1},/* CT_VDKBLUE2 */
{0.302, 0.380, 0.612, 1},/* CT_VLTBLUE2 -- needs values */
{0.196, 0.314, 0.612, 1},/* CT_LTBLUE2 */
{0.060, 0.227, 0.611, 1},/* CT_DKBLUE2 */
{0.043, 0.161, 0.459, 1},/* CT_VDKBLUE2 */
{0.082, 0.388, 0.898, 1},/* CT_VLTBROWN1 -- needs values */
{0.082, 0.388, 0.898, 1},/* CT_LTBROWN1 */
{0.078, 0.320, 0.813, 1},/* CT_DKBROWN1 */
{0.060, 0.227, 0.611, 1},/* CT_VDKBROWN1 */
{0.082, 0.388, 0.898, 1},/* CT_VLTBROWN1 -- needs values */
{0.082, 0.388, 0.898, 1},/* CT_LTBROWN1 */
{0.078, 0.320, 0.813, 1},/* CT_DKBROWN1 */
{0.060, 0.227, 0.611, 1},/* CT_VDKBROWN1 */
{1, 0.784, 0.365, 1}, /* CT_VLTGOLD1 -- needs values */
{1, 0.706, 0.153, 1}, /* CT_LTGOLD1 */
{0.733, 0.514, 0.086, 1},/* CT_DKGOLD1 */
{0.549, 0.384, 0.063, 1},/* CT_VDKGOLD1 */
{1, 0.784, 0.365, 1}, /* CT_VLTGOLD1 -- needs values */
{1, 0.706, 0.153, 1}, /* CT_LTGOLD1 */
{0.733, 0.514, 0.086, 1},/* CT_DKGOLD1 */
{0.549, 0.384, 0.063, 1},/* CT_VDKGOLD1 */
{0.688, 0.797, 1, 1}, /* CT_VLTPURPLE1 -- needs values */
{0.688, 0.797, 1, 1}, /* CT_LTPURPLE1 */
{0.313, 0.578, 1, 1}, /* CT_DKPURPLE1 */
{0.031, 0.110, 0.341, 1},/* CT_VDKPURPLE1 */
{0.688, 0.797, 1, 1}, /* CT_VLTPURPLE1 -- needs values */
{0.688, 0.797, 1, 1}, /* CT_LTPURPLE1 */
{0.313, 0.578, 1, 1}, /* CT_DKPURPLE1 */
{0.031, 0.110, 0.341, 1},/* CT_VDKPURPLE1 */
{0.688, 0.797, 1, 1}, /* CT_VLTPURPLE2 -- needs values */
{0.688, 0.797, 1, 1}, /* CT_LTPURPLE2 */
{0.688, 0.797, 1, 1}, /* CT_DKPURPLE2 */
{0.031, 0.110, 0.341, 1},/* CT_VDKPURPLE2 */
{0.688, 0.797, 1, 1}, /* CT_VLTPURPLE2 -- needs values */
{0.688, 0.797, 1, 1}, /* CT_LTPURPLE2 */
{0.688, 0.797, 1, 1}, /* CT_DKPURPLE2 */
{0.031, 0.110, 0.341, 1},/* CT_VDKPURPLE2 */
{0.686, 0.808, 0.1, 1}, /* CT_VLTPURPLE3 */
{0.188, 0.494, 1, 1}, /* CT_LTPURPLE3 */
{0.094, 0.471, 1, 1}, /* CT_DKPURPLE3 */
{0.067, 0.325, 0.749, 1},/* CT_VDKPURPLE3 */
{0.686, 0.808, 0.1, 1}, /* CT_VLTPURPLE3 */
{0.188, 0.494, 1, 1}, /* CT_LTPURPLE3 */
{0.094, 0.471, 1, 1}, /* CT_DKPURPLE3 */
{0.067, 0.325, 0.749, 1},/* CT_VDKPURPLE3 */
{1, 0.612, 0.325, 1}, /* CT_VLTRED1 */
{1, 0.478, 0.098, 1}, /* CT_LTRED1 */
{1, 0.438, 0, 1}, /* CT_DKRED1 */
{0.784, 0.329, 0, 1}, /* CT_VDKRED1 */
{1, 0.612, 0.325, 1}, /* CT_VLTRED1 */
{1, 0.478, 0.098, 1}, /* CT_LTRED1 */
{1, 0.438, 0, 1}, /* CT_DKRED1 */
{0.784, 0.329, 0, 1}, /* CT_VDKRED1 */
};
@ -88,8 +87,7 @@ vec4_t colorLtGrey = {0.75, 0.75, 0.75, 1};
vec4_t colorMdGrey = {0.5, 0.5, 0.5, 1};
vec4_t colorDkGrey = {0.25, 0.25, 0.25, 1};
vec4_t g_color_table[8] =
{
vec4_t g_color_table[8] = {
{0.0, 0.0, 0.0, 1.0},
{1.0, 0.0, 0.0, 1.0},
{0.0, 1.0, 0.0, 1.0},
@ -98,113 +96,113 @@ vec4_t g_color_table[8] =
{0.0, 1.0, 1.0, 1.0},
{1.0, 0.0, 1.0, 1.0},
{1.0, 1.0, 1.0, 1.0},
};
};
vec3_t bytedirs[NUMVERTEXNORMALS] =
{
{-0.525731, 0.000000, 0.850651}, {-0.442863, 0.238856, 0.864188},
{-0.295242, 0.000000, 0.955423}, {-0.309017, 0.500000, 0.809017},
{-0.162460, 0.262866, 0.951056}, {0.000000, 0.000000, 1.000000},
{0.000000, 0.850651, 0.525731}, {-0.147621, 0.716567, 0.681718},
{0.147621, 0.716567, 0.681718}, {0.000000, 0.525731, 0.850651},
{0.309017, 0.500000, 0.809017}, {0.525731, 0.000000, 0.850651},
{0.295242, 0.000000, 0.955423}, {0.442863, 0.238856, 0.864188},
{0.162460, 0.262866, 0.951056}, {-0.681718, 0.147621, 0.716567},
{-0.809017, 0.309017, 0.500000},{-0.587785, 0.425325, 0.688191},
{-0.850651, 0.525731, 0.000000},{-0.864188, 0.442863, 0.238856},
{-0.716567, 0.681718, 0.147621},{-0.688191, 0.587785, 0.425325},
{-0.500000, 0.809017, 0.309017}, {-0.238856, 0.864188, 0.442863},
{-0.425325, 0.688191, 0.587785}, {-0.716567, 0.681718, -0.147621},
{-0.500000, 0.809017, -0.309017}, {-0.525731, 0.850651, 0.000000},
{0.000000, 0.850651, -0.525731}, {-0.238856, 0.864188, -0.442863},
{0.000000, 0.955423, -0.295242}, {-0.262866, 0.951056, -0.162460},
{0.000000, 1.000000, 0.000000}, {0.000000, 0.955423, 0.295242},
{-0.262866, 0.951056, 0.162460}, {0.238856, 0.864188, 0.442863},
{0.262866, 0.951056, 0.162460}, {0.500000, 0.809017, 0.309017},
{0.238856, 0.864188, -0.442863},{0.262866, 0.951056, -0.162460},
{0.500000, 0.809017, -0.309017},{0.850651, 0.525731, 0.000000},
{0.716567, 0.681718, 0.147621}, {0.716567, 0.681718, -0.147621},
{0.525731, 0.850651, 0.000000}, {0.425325, 0.688191, 0.587785},
{0.864188, 0.442863, 0.238856}, {0.688191, 0.587785, 0.425325},
{0.809017, 0.309017, 0.500000}, {0.681718, 0.147621, 0.716567},
{0.587785, 0.425325, 0.688191}, {0.955423, 0.295242, 0.000000},
{1.000000, 0.000000, 0.000000}, {0.951056, 0.162460, 0.262866},
{0.850651, -0.525731, 0.000000},{0.955423, -0.295242, 0.000000},
{0.864188, -0.442863, 0.238856}, {0.951056, -0.162460, 0.262866},
{0.809017, -0.309017, 0.500000}, {0.681718, -0.147621, 0.716567},
{0.850651, 0.000000, 0.525731}, {0.864188, 0.442863, -0.238856},
{0.809017, 0.309017, -0.500000}, {0.951056, 0.162460, -0.262866},
{0.525731, 0.000000, -0.850651}, {0.681718, 0.147621, -0.716567},
{0.681718, -0.147621, -0.716567},{0.850651, 0.000000, -0.525731},
{0.809017, -0.309017, -0.500000}, {0.864188, -0.442863, -0.238856},
{0.951056, -0.162460, -0.262866}, {0.147621, 0.716567, -0.681718},
{0.309017, 0.500000, -0.809017}, {0.425325, 0.688191, -0.587785},
{0.442863, 0.238856, -0.864188}, {0.587785, 0.425325, -0.688191},
{0.688191, 0.587785, -0.425325}, {-0.147621, 0.716567, -0.681718},
{-0.309017, 0.500000, -0.809017}, {0.000000, 0.525731, -0.850651},
{-0.525731, 0.000000, -0.850651}, {-0.442863, 0.238856, -0.864188},
{-0.295242, 0.000000, -0.955423}, {-0.162460, 0.262866, -0.951056},
{0.000000, 0.000000, -1.000000}, {0.295242, 0.000000, -0.955423},
{0.162460, 0.262866, -0.951056}, {-0.442863, -0.238856, -0.864188},
{-0.309017, -0.500000, -0.809017}, {-0.162460, -0.262866, -0.951056},
{0.000000, -0.850651, -0.525731}, {-0.147621, -0.716567, -0.681718},
{0.147621, -0.716567, -0.681718}, {0.000000, -0.525731, -0.850651},
{0.309017, -0.500000, -0.809017}, {0.442863, -0.238856, -0.864188},
{0.162460, -0.262866, -0.951056}, {0.238856, -0.864188, -0.442863},
{0.500000, -0.809017, -0.309017}, {0.425325, -0.688191, -0.587785},
{0.716567, -0.681718, -0.147621}, {0.688191, -0.587785, -0.425325},
{0.587785, -0.425325, -0.688191}, {0.000000, -0.955423, -0.295242},
{0.000000, -1.000000, 0.000000}, {0.262866, -0.951056, -0.162460},
{0.000000, -0.850651, 0.525731}, {0.000000, -0.955423, 0.295242},
{0.238856, -0.864188, 0.442863}, {0.262866, -0.951056, 0.162460},
{0.500000, -0.809017, 0.309017}, {0.716567, -0.681718, 0.147621},
{0.525731, -0.850651, 0.000000}, {-0.238856, -0.864188, -0.442863},
{-0.500000, -0.809017, -0.309017}, {-0.262866, -0.951056, -0.162460},
{-0.850651, -0.525731, 0.000000}, {-0.716567, -0.681718, -0.147621},
{-0.716567, -0.681718, 0.147621}, {-0.525731, -0.850651, 0.000000},
{-0.500000, -0.809017, 0.309017}, {-0.238856, -0.864188, 0.442863},
{-0.262866, -0.951056, 0.162460}, {-0.864188, -0.442863, 0.238856},
{-0.809017, -0.309017, 0.500000}, {-0.688191, -0.587785, 0.425325},
{-0.681718, -0.147621, 0.716567}, {-0.442863, -0.238856, 0.864188},
{-0.587785, -0.425325, 0.688191}, {-0.309017, -0.500000, 0.809017},
{-0.147621, -0.716567, 0.681718}, {-0.425325, -0.688191, 0.587785},
{-0.162460, -0.262866, 0.951056}, {0.442863, -0.238856, 0.864188},
{0.162460, -0.262866, 0.951056}, {0.309017, -0.500000, 0.809017},
{0.147621, -0.716567, 0.681718}, {0.000000, -0.525731, 0.850651},
{0.425325, -0.688191, 0.587785}, {0.587785, -0.425325, 0.688191},
{0.688191, -0.587785, 0.425325}, {-0.955423, 0.295242, 0.000000},
{-0.951056, 0.162460, 0.262866}, {-1.000000, 0.000000, 0.000000},
{-0.850651, 0.000000, 0.525731}, {-0.955423, -0.295242, 0.000000},
{-0.951056, -0.162460, 0.262866}, {-0.864188, 0.442863, -0.238856},
{-0.951056, 0.162460, -0.262866}, {-0.809017, 0.309017, -0.500000},
{-0.864188, -0.442863, -0.238856}, {-0.951056, -0.162460, -0.262866},
{-0.809017, -0.309017, -0.500000}, {-0.681718, 0.147621, -0.716567},
{-0.681718, -0.147621, -0.716567}, {-0.850651, 0.000000, -0.525731},
{-0.688191, 0.587785, -0.425325}, {-0.587785, 0.425325, -0.688191},
{-0.425325, 0.688191, -0.587785}, {-0.425325, -0.688191, -0.587785},
{-0.587785, -0.425325, -0.688191}, {-0.688191, -0.587785, -0.425325}
{-0.525731, 0.000000, 0.850651}, {-0.442863, 0.238856, 0.864188},
{-0.295242, 0.000000, 0.955423}, {-0.309017, 0.500000, 0.809017},
{-0.162460, 0.262866, 0.951056}, {0.000000, 0.000000, 1.000000},
{0.000000, 0.850651, 0.525731}, {-0.147621, 0.716567, 0.681718},
{0.147621, 0.716567, 0.681718}, {0.000000, 0.525731, 0.850651},
{0.309017, 0.500000, 0.809017}, {0.525731, 0.000000, 0.850651},
{0.295242, 0.000000, 0.955423}, {0.442863, 0.238856, 0.864188},
{0.162460, 0.262866, 0.951056}, {-0.681718, 0.147621, 0.716567},
{-0.809017, 0.309017, 0.500000},{-0.587785, 0.425325, 0.688191},
{-0.850651, 0.525731, 0.000000},{-0.864188, 0.442863, 0.238856},
{-0.716567, 0.681718, 0.147621},{-0.688191, 0.587785, 0.425325},
{-0.500000, 0.809017, 0.309017}, {-0.238856, 0.864188, 0.442863},
{-0.425325, 0.688191, 0.587785}, {-0.716567, 0.681718, -0.147621},
{-0.500000, 0.809017, -0.309017}, {-0.525731, 0.850651, 0.000000},
{0.000000, 0.850651, -0.525731}, {-0.238856, 0.864188, -0.442863},
{0.000000, 0.955423, -0.295242}, {-0.262866, 0.951056, -0.162460},
{0.000000, 1.000000, 0.000000}, {0.000000, 0.955423, 0.295242},
{-0.262866, 0.951056, 0.162460}, {0.238856, 0.864188, 0.442863},
{0.262866, 0.951056, 0.162460}, {0.500000, 0.809017, 0.309017},
{0.238856, 0.864188, -0.442863},{0.262866, 0.951056, -0.162460},
{0.500000, 0.809017, -0.309017},{0.850651, 0.525731, 0.000000},
{0.716567, 0.681718, 0.147621}, {0.716567, 0.681718, -0.147621},
{0.525731, 0.850651, 0.000000}, {0.425325, 0.688191, 0.587785},
{0.864188, 0.442863, 0.238856}, {0.688191, 0.587785, 0.425325},
{0.809017, 0.309017, 0.500000}, {0.681718, 0.147621, 0.716567},
{0.587785, 0.425325, 0.688191}, {0.955423, 0.295242, 0.000000},
{1.000000, 0.000000, 0.000000}, {0.951056, 0.162460, 0.262866},
{0.850651, -0.525731, 0.000000},{0.955423, -0.295242, 0.000000},
{0.864188, -0.442863, 0.238856}, {0.951056, -0.162460, 0.262866},
{0.809017, -0.309017, 0.500000}, {0.681718, -0.147621, 0.716567},
{0.850651, 0.000000, 0.525731}, {0.864188, 0.442863, -0.238856},
{0.809017, 0.309017, -0.500000}, {0.951056, 0.162460, -0.262866},
{0.525731, 0.000000, -0.850651}, {0.681718, 0.147621, -0.716567},
{0.681718, -0.147621, -0.716567},{0.850651, 0.000000, -0.525731},
{0.809017, -0.309017, -0.500000}, {0.864188, -0.442863, -0.238856},
{0.951056, -0.162460, -0.262866}, {0.147621, 0.716567, -0.681718},
{0.309017, 0.500000, -0.809017}, {0.425325, 0.688191, -0.587785},
{0.442863, 0.238856, -0.864188}, {0.587785, 0.425325, -0.688191},
{0.688191, 0.587785, -0.425325}, {-0.147621, 0.716567, -0.681718},
{-0.309017, 0.500000, -0.809017}, {0.000000, 0.525731, -0.850651},
{-0.525731, 0.000000, -0.850651}, {-0.442863, 0.238856, -0.864188},
{-0.295242, 0.000000, -0.955423}, {-0.162460, 0.262866, -0.951056},
{0.000000, 0.000000, -1.000000}, {0.295242, 0.000000, -0.955423},
{0.162460, 0.262866, -0.951056}, {-0.442863, -0.238856, -0.864188},
{-0.309017, -0.500000, -0.809017}, {-0.162460, -0.262866, -0.951056},
{0.000000, -0.850651, -0.525731}, {-0.147621, -0.716567, -0.681718},
{0.147621, -0.716567, -0.681718}, {0.000000, -0.525731, -0.850651},
{0.309017, -0.500000, -0.809017}, {0.442863, -0.238856, -0.864188},
{0.162460, -0.262866, -0.951056}, {0.238856, -0.864188, -0.442863},
{0.500000, -0.809017, -0.309017}, {0.425325, -0.688191, -0.587785},
{0.716567, -0.681718, -0.147621}, {0.688191, -0.587785, -0.425325},
{0.587785, -0.425325, -0.688191}, {0.000000, -0.955423, -0.295242},
{0.000000, -1.000000, 0.000000}, {0.262866, -0.951056, -0.162460},
{0.000000, -0.850651, 0.525731}, {0.000000, -0.955423, 0.295242},
{0.238856, -0.864188, 0.442863}, {0.262866, -0.951056, 0.162460},
{0.500000, -0.809017, 0.309017}, {0.716567, -0.681718, 0.147621},
{0.525731, -0.850651, 0.000000}, {-0.238856, -0.864188, -0.442863},
{-0.500000, -0.809017, -0.309017}, {-0.262866, -0.951056, -0.162460},
{-0.850651, -0.525731, 0.000000}, {-0.716567, -0.681718, -0.147621},
{-0.716567, -0.681718, 0.147621}, {-0.525731, -0.850651, 0.000000},
{-0.500000, -0.809017, 0.309017}, {-0.238856, -0.864188, 0.442863},
{-0.262866, -0.951056, 0.162460}, {-0.864188, -0.442863, 0.238856},
{-0.809017, -0.309017, 0.500000}, {-0.688191, -0.587785, 0.425325},
{-0.681718, -0.147621, 0.716567}, {-0.442863, -0.238856, 0.864188},
{-0.587785, -0.425325, 0.688191}, {-0.309017, -0.500000, 0.809017},
{-0.147621, -0.716567, 0.681718}, {-0.425325, -0.688191, 0.587785},
{-0.162460, -0.262866, 0.951056}, {0.442863, -0.238856, 0.864188},
{0.162460, -0.262866, 0.951056}, {0.309017, -0.500000, 0.809017},
{0.147621, -0.716567, 0.681718}, {0.000000, -0.525731, 0.850651},
{0.425325, -0.688191, 0.587785}, {0.587785, -0.425325, 0.688191},
{0.688191, -0.587785, 0.425325}, {-0.955423, 0.295242, 0.000000},
{-0.951056, 0.162460, 0.262866}, {-1.000000, 0.000000, 0.000000},
{-0.850651, 0.000000, 0.525731}, {-0.955423, -0.295242, 0.000000},
{-0.951056, -0.162460, 0.262866}, {-0.864188, 0.442863, -0.238856},
{-0.951056, 0.162460, -0.262866}, {-0.809017, 0.309017, -0.500000},
{-0.864188, -0.442863, -0.238856}, {-0.951056, -0.162460, -0.262866},
{-0.809017, -0.309017, -0.500000}, {-0.681718, 0.147621, -0.716567},
{-0.681718, -0.147621, -0.716567}, {-0.850651, 0.000000, -0.525731},
{-0.688191, 0.587785, -0.425325}, {-0.587785, 0.425325, -0.688191},
{-0.425325, 0.688191, -0.587785}, {-0.425325, -0.688191, -0.587785},
{-0.587785, -0.425325, -0.688191}, {-0.688191, -0.587785, -0.425325}
};
/*==============================================================*/
int32_t Q_rand( int32_t* seed ) {
int32_t Q_rand(int32_t* seed) {
*seed = (69069 * *seed + 1);
return *seed;
}
float Q_random( int32_t *seed ) {
return ( Q_rand( seed ) & 0xffff ) / (float)0x10000;
double Q_random(int32_t* seed) {
return ( Q_rand( seed ) & 0xffff ) / (double)0x10000;
}
float Q_crandom( int32_t *seed ) {
double Q_crandom(int32_t* seed) {
return 2.0 * ( Q_random( seed ) - 0.5 );
}
/*=======================================================*/
signed char ClampChar( int32_t i ) {
signed char ClampChar(int32_t i) {
if ( i < -128 ) {
return -128;
}
@ -214,7 +212,7 @@ signed char ClampChar( int32_t i ) {
return i;
}
int16_t ClampShort( int32_t i ) {
int16_t ClampShort(int32_t i) {
if ( i < (short)0x8000 ) {
return (short)0x8000;
}
@ -230,15 +228,15 @@ int16_t ClampShort( int32_t i ) {
* Converts a direction vector into a byte
*/
int32_t DirToByte( vec3_t dir ) {
int32_t i, best;
float d, bestd;
int32_t i = 0;
int32_t best = 0;
double d = 0.0;
double bestd = 0.0;
if ( dir == NULL ) {
return 0;
}
bestd = 0;
best = 0;
for (i=0 ; i<NUMVERTEXNORMALS ; i++)
{
d = DotProduct (dir, bytedirs[i]);
@ -264,8 +262,8 @@ void ByteToDir( int32_t b, vec3_t dir ) {
}
unsigned ColorBytes3 (float r, float g, float b) {
unsigned i;
uint32_t ColorBytes3(double r, double g, double b) {
uint32_t i = 0;
( (byte *)&i )[0] = r * 255;
( (byte *)&i )[1] = g * 255;
@ -274,8 +272,8 @@ unsigned ColorBytes3 (float r, float g, float b) {
return i;
}
unsigned ColorBytes4 (float r, float g, float b, float a) {
unsigned i;
uint32_t ColorBytes4(double r, double g, double b, double a) {
uint32_t i = 0;
( (byte *)&i )[0] = r * 255;
( (byte *)&i )[1] = g * 255;
@ -285,8 +283,8 @@ unsigned ColorBytes4 (float r, float g, float b, float a) {
return i;
}
float NormalizeColor( const vec3_t in, vec3_t out ) {
float max;
double NormalizeColor( const vec3_t in, vec3_t out ) {
double max;
max = in[0];
if ( in[1] > max ) {
@ -296,7 +294,7 @@ float NormalizeColor( const vec3_t in, vec3_t out ) {
max = in[2];
}
if ( !max ) {
if ( max == 0 ) {
VectorClear( out );
} else {
out[0] = in[0] / max;
@ -316,7 +314,8 @@ float NormalizeColor( const vec3_t in, vec3_t out ) {
*
*/
qboolean PlaneFromPoints( vec4_t plane, const vec3_t a, const vec3_t b, const vec3_t c ) {
vec3_t d1, d2;
vec3_t d1;
vec3_t d2;
VectorSubtract( b, a, d1 );
VectorSubtract( c, a, d2 );
@ -335,16 +334,17 @@ qboolean PlaneFromPoints( vec4_t plane, const vec3_t a, const vec3_t b, const ve
* This is not implemented very well...
*
*/
void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point,
float degrees ) {
float m[3][3];
float im[3][3];
float zrot[3][3];
float tmpmat[3][3];
float rot[3][3];
int32_t i;
vec3_t vr, vup, vf;
float rad;
void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, double degrees ) {
double m[3][3];
double im[3][3];
double zrot[3][3];
double tmpmat[3][3];
double rot[3][3];
int32_t i = 0;
vec3_t vr;
vec3_t vup;
vec3_t vf;
double rad = 0.0;
vf[0] = dir[0];
vf[1] = dir[1];
@ -396,7 +396,7 @@ void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point,
RotateAroundDirection
===============
*/
void RotateAroundDirection( vec3_t axis[3], float yaw ) {
void RotateAroundDirection(vec3_t axis[3], double yaw) {
/* create an arbitrary axis[1] */
PerpendicularVector( axis[1], axis[0] );
@ -414,8 +414,9 @@ void RotateAroundDirection( vec3_t axis[3], float yaw ) {
}
void vectoangles( const vec3_t value1, vec3_t angles ) {
float forward;
float yaw, pitch;
double forward = 0.0;
double yaw = 0.0;
double pitch = 0.0;
if ( value1[1] == 0 && value1[0] == 0 ) {
yaw = 0;
@ -459,7 +460,7 @@ AnglesToAxis
=================
*/
void AnglesToAxis( const vec3_t angles, vec3_t axis[3] ) {
vec3_t right;
vec3_t right;
/* angle vectors returns "right" instead of "y axis" */
AngleVectors( angles, axis[0], right, axis[2] );
@ -486,9 +487,9 @@ void AxisCopy( vec3_t in[3], vec3_t out[3] ) {
void ProjectPointOnPlane( vec3_t dst, const vec3_t p, const vec3_t normal )
{
float d;
double d = 0.0;
vec3_t n;
float inv_denom;
double inv_denom = 0.0;
inv_denom = 1.0F / DotProduct( normal, normal );

View file

@ -573,10 +573,10 @@ void _VectorCopy( const vec3_t in, vec3_t out );
void _VectorScale( const vec3_t in, float scale, vec3_t out );
void _VectorMA( const vec3_t veca, float scale, const vec3_t vecb, vec3_t vecc );
unsigned ColorBytes3 (float r, float g, float b);
unsigned ColorBytes4 (float r, float g, float b, float a);
uint32_t ColorBytes3(double r, double g, double b);
uint32_t ColorBytes4(double r, double g, double b, double a);
float NormalizeColor( const vec3_t in, vec3_t out );
double NormalizeColor(const vec3_t in, vec3_t out);
float RadiusFromBounds( const vec3_t mins, const vec3_t maxs );
void ClearBounds( vec3_t mins, vec3_t maxs );
@ -596,8 +596,8 @@ void VectorRotate( vec3_t in, vec3_t matrix[3], vec3_t out );
int32_t Q_log2(int32_t val);
int32_t Q_rand( int32_t *seed );
float Q_random( int32_t *seed );
float Q_crandom( int32_t *seed );
double Q_random( int32_t *seed );
double Q_crandom( int32_t *seed );
#define random() ((rand () & 0x7fff) / ((float)0x7fff))
#define crandom() (2.0 * (random() - 0.5))
@ -625,8 +625,8 @@ float AngleDelta ( float angle1, float angle2 );
qboolean PlaneFromPoints( vec4_t plane, const vec3_t a, const vec3_t b, const vec3_t c );
void ProjectPointOnPlane( vec3_t dst, const vec3_t p, const vec3_t normal );
void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, float degrees );
void RotateAroundDirection( vec3_t axis[3], float yaw );
void RotatePointAroundVector(vec3_t dst, const vec3_t dir, const vec3_t point, double degrees);
void RotateAroundDirection(vec3_t axis[3], double yaw);
void MakeNormalVectors( const vec3_t forward, vec3_t right, vec3_t up );
// perpendicular vector could be replaced by this

File diff suppressed because it is too large Load diff