projects
/
retroray
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
first render
[retroray]
/
libs
/
cgmath
/
cgmmisc.inl
diff --git
a/libs/cgmath/cgmmisc.inl
b/libs/cgmath/cgmmisc.inl
index
2ef8a11
..
0def727
100644
(file)
--- a/
libs/cgmath/cgmmisc.inl
+++ b/
libs/cgmath/cgmmisc.inl
@@
-1,5
+1,5
@@
/* gph-cmath - C graphics math library
/* gph-cmath - C graphics math library
- * Copyright (C) 2018 John Tsiombikas <nuclear@member.fsf.org>
+ * Copyright (C) 2018-2023 John Tsiombikas <nuclear@member.fsf.org>
*
* This program is free software. Feel free to use, modify, and/or redistribute
* it under the terms of the MIT/X11 license. See LICENSE for details.
*
* This program is free software. Feel free to use, modify, and/or redistribute
* it under the terms of the MIT/X11 license. See LICENSE for details.
@@
-10,12
+10,12
@@
static CGM_INLINE float cgm_deg_to_rad(float deg)
{
static CGM_INLINE float cgm_deg_to_rad(float deg)
{
- return M_PI * deg / 180.0f;
+ return CGM_PI * deg / 180.0f;
}
static CGM_INLINE float cgm_rad_to_deg(float rad)
{
}
static CGM_INLINE float cgm_rad_to_deg(float rad)
{
- return 180.0f * rad / M_PI;
+ return 180.0f * rad / CGM_PI;
}
static CGM_INLINE float cgm_smoothstep(float a, float b, float x)
}
static CGM_INLINE float cgm_smoothstep(float a, float b, float x)
@@
-87,7
+87,7
@@
static CGM_INLINE float cgm_spline(float a, float b, float c, float d, float t)
static CGM_INLINE void cgm_discrand(cgm_vec3 *pt, float rad)
{
static CGM_INLINE void cgm_discrand(cgm_vec3 *pt, float rad)
{
- float theta = 2.0f * M_PI * (float)rand() / RAND_MAX;
+ float theta = 2.0f * CGM_PI * (float)rand() / RAND_MAX;
float r = sqrt((float)rand() / RAND_MAX) * rad;
pt->x = cos(theta) * r;
pt->y = sin(theta) * r;
float r = sqrt((float)rand() / RAND_MAX) * rad;
pt->x = cos(theta) * r;
pt->y = sin(theta) * r;
@@
-101,7
+101,7
@@
static CGM_INLINE void cgm_sphrand(cgm_vec3 *pt, float rad)
u = (float)rand() / RAND_MAX;
v = (float)rand() / RAND_MAX;
u = (float)rand() / RAND_MAX;
v = (float)rand() / RAND_MAX;
- theta = 2.0f * M_PI * u;
+ theta = 2.0f * CGM_PI * u;
phi = acos(2.0f * v - 1.0f);
pt->x = cos(theta) * sin(phi) * rad;
phi = acos(2.0f * v - 1.0f);
pt->x = cos(theta) * sin(phi) * rad;
@@
-133,8
+133,9
@@
static CGM_INLINE void cgm_glu_unproject(float winx, float winy, float winz,
cgm_vec3 npos, res;
float inv_pv[16];
cgm_vec3 npos, res;
float inv_pv[16];
- cgm_mcopy(inv_pv, proj);
- cgm_mmul(inv_pv, view);
+ cgm_mcopy(inv_pv, view);
+ cgm_mmul(inv_pv, proj);
+ cgm_minverse(inv_pv);
npos.x = (winx - vp[0]) / vp[2];
npos.y = (winy - vp[1]) / vp[4];
npos.x = (winx - vp[0]) / vp[2];
npos.y = (winy - vp[1]) / vp[4];
@@
-153,8
+154,9
@@
static CGM_INLINE void cgm_pick_ray(cgm_ray *ray, float nx, float ny,
cgm_vec3 npos, farpt;
float inv_pv[16];
cgm_vec3 npos, farpt;
float inv_pv[16];
- cgm_mcopy(inv_pv, projmat);
- cgm_mmul(inv_pv, viewmat);
+ cgm_mcopy(inv_pv, viewmat);
+ cgm_mmul(inv_pv, projmat);
+ cgm_minverse(inv_pv);
cgm_vcons(&npos, nx, ny, 0.0f);
cgm_unproject(&ray->origin, &npos, inv_pv);
cgm_vcons(&npos, nx, ny, 0.0f);
cgm_unproject(&ray->origin, &npos, inv_pv);