| View previous topic :: View next topic |
| Author |
Message |
ciccan
Joined: 17 Jul 2005 Posts: 2
|
Posted: Sun Aug 28, 2005 5:13 pm Post subject: Small bug in gumInternal.c |
|
|
| Code: | 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;
|
|
|
| Back to top |
|
 |
chp
Joined: 23 Jun 2004 Posts: 313
|
Posted: Sun Aug 28, 2005 11:46 pm Post subject: |
|
|
Oops! That's what I get for writing code on a train without ability to test it. :)
Fixed. Thanks! _________________ GE Dominator |
|
| Back to top |
|
 |
ciccan
Joined: 17 Jul 2005 Posts: 2
|
Posted: Mon Aug 29, 2005 10:56 am Post subject: |
|
|
Here's a couple more. I think sceGumLookAt is OK with these changes.
| Code: | 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);
} |
|
|
| Back to top |
|
 |
chp
Joined: 23 Jun 2004 Posts: 313
|
Posted: Tue Aug 30, 2005 5:03 am Post subject: |
|
|
Thanks! Good thing someone tests this code. I sure didn't before submitting. And see how it turned out. :) _________________ GE Dominator |
|
| Back to top |
|
 |
Jim

Joined: 02 Jul 2005 Posts: 487 Location: Sydney
|
Posted: Tue Aug 30, 2005 4:07 pm Post subject: |
|
|
| Code: |
- 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: |
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 _________________ http://www.dbfinteractive.com |
|
| Back to top |
|
 |
chp
Joined: 23 Jun 2004 Posts: 313
|
Posted: Tue Aug 30, 2005 5:26 pm Post subject: |
|
|
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 |
|
| Back to top |
|
 |
Jim

Joined: 02 Jul 2005 Posts: 487 Location: Sydney
|
Posted: Tue Aug 30, 2005 5:49 pm Post subject: |
|
|
You're right, if GUM_EPSILON is very tiny, then GUM_EPSILON * GUM_EPSILON might underflow anyway.
Jim _________________ http://www.dbfinteractive.com |
|
| Back to top |
|
 |
|