Discuss the development of new homebrew software, tools and libraries.
Moderators: cheriff, TyRaNiD
-
ciccan
- Posts: 2
- Joined: Sun Jul 17, 2005 6:44 am
Post
by ciccan »
Code: Select all
Index: gumInternal.c
===================================================================
--- gumInternal.c (revision 946)
+++ gumInternal.c (working copy)
@@ -65,7 +65,7 @@
void gumNormalize(ScePspFVector3* v)
{
- float l = (v->x*v->x) + (v->y*v->y) + (v->z*v->z);
+ float l = sqrtf((v->x*v->x) + (v->y*v->y) + (v->z*v->z));
if (l > GUM_EPSILON)
{
float il = 1.0f / l;
-
chp
- Posts: 313
- Joined: Wed Jun 23, 2004 7:16 am
Post
by chp »
Oops! That's what I get for writing code on a train without ability to test it. :)
Fixed. Thanks!
GE Dominator
-
ciccan
- Posts: 2
- Joined: Sun Jul 17, 2005 6:44 am
Post
by ciccan »
Here's a couple more. I think sceGumLookAt is OK with these changes.
Code: Select all
Index: gumInternal.c
===================================================================
--- gumInternal.c (revision 963)
+++ gumInternal.c (working copy)
@@ -58,9 +58,9 @@
void gumCrossProduct(ScePspFVector3*r, const ScePspFVector3* a, const ScePspFVector3* b)
{
- r->x = (a->y * b->z) + (a->z * b->y);
- r->y = (a->z * b->x) + (a->x * b->z);
- r->z = (a->x * b->y) + (a->y * b->x);
+ r->x = (a->y * b->z) - (a->z * b->y);
+ r->y = (a->z * b->x) - (a->x * b->z);
+ r->z = (a->x * b->y) - (a->y * b->x);
}
void gumNormalize(ScePspFVector3* v)
Index: sceGumLookAt.c
===================================================================
--- sceGumLookAt.c (revision 963)
+++ sceGumLookAt.c (working copy)
@@ -37,8 +37,8 @@
m.y.z = -forward.y;
m.z.z = -forward.z;
- sceGumMultMatrix(&m);
-
ieye.x = -eye->x; ieye.y = -eye->y; ieye.z = -eye->z;
sceGumTranslate(&ieye);
+
+ sceGumMultMatrix(&m);
}
-
chp
- Posts: 313
- Joined: Wed Jun 23, 2004 7:16 am
Post
by chp »
Thanks! Good thing someone tests this code. I sure didn't before submitting. And see how it turned out. :)
GE Dominator
-
Jim
- Posts: 476
- Joined: Sat Jul 02, 2005 10:06 pm
- Location: Sydney
-
Contact:
Post
by Jim »
Code: Select all
- float l = (v->x*v->x) + (v->y*v->y) + (v->z*v->z);
+ float l = sqrtf((v->x*v->x) + (v->y*v->y) + (v->z*v->z));
if (l > GUM_EPSILON)
{
float il = 1.0f / l;
I think
Code: Select all
float l = (v->x*v->x) + (v->y*v->y) + (v->z*v->z);
- if (l > GUM_EPSILON)
+ if (l > GUM_EPSILON*GUM_EPSILON)
{
- float il = 1.0f / l;
+ float il = 1.0f / sqrtf(l);
would be better.
Don't know how often this fragment is called though.
Great work with psp gl!
Jim
-
chp
- Posts: 313
- Joined: Wed Jun 23, 2004 7:16 am
Post
by chp »
Well, the if() is only to avoid creating a NaN from the division, so it should always be true as long as you pass it valid data.
Oh, and this isn't for pspgl... :)
GE Dominator
-
Jim
- Posts: 476
- Joined: Sat Jul 02, 2005 10:06 pm
- Location: Sydney
-
Contact:
Post
by Jim »
You're right, if GUM_EPSILON is very tiny, then GUM_EPSILON * GUM_EPSILON might underflow anyway.
Jim