mirror of https://github.com/aap/librw.git
commit
9a11b9b4b2
|
@ -127,7 +127,7 @@ slerp(const Quat &q, const Quat &p, float32 a)
|
||||||
c = -c;
|
c = -c;
|
||||||
q1 = negate(q1);
|
q1 = negate(q1);
|
||||||
}
|
}
|
||||||
float32 phi = acos(c);
|
float32 phi = acosf(c);
|
||||||
if(phi > 0.00001f){
|
if(phi > 0.00001f){
|
||||||
float32 s = sinf(phi);
|
float32 s = sinf(phi);
|
||||||
return add(scale(q1, sinf((1.0f-a)*phi)/s),
|
return add(scale(q1, sinf((1.0f-a)*phi)/s),
|
||||||
|
@ -561,8 +561,8 @@ Matrix::makeRotation(Matrix *dst, const V3d *axis, float32 angle)
|
||||||
if(len != 0.0f) len = 1.0f/sqrtf(len);
|
if(len != 0.0f) len = 1.0f/sqrtf(len);
|
||||||
V3d v = rw::scale(*axis, len);
|
V3d v = rw::scale(*axis, len);
|
||||||
angle = angle*(float)M_PI/180.0f;
|
angle = angle*(float)M_PI/180.0f;
|
||||||
float32 s = sin(angle);
|
float32 s = sinf(angle);
|
||||||
float32 c = cos(angle);
|
float32 c = cosf(angle);
|
||||||
float32 t = 1.0f - c;
|
float32 t = 1.0f - c;
|
||||||
|
|
||||||
dst->right.x = c + v.x*v.x*t;
|
dst->right.x = c + v.x*v.x*t;
|
||||||
|
@ -743,7 +743,7 @@ memLittle16_func(void *data, uint32 size)
|
||||||
size >>= 1;
|
size >>= 1;
|
||||||
while(size--){
|
while(size--){
|
||||||
w = *words++;
|
w = *words++;
|
||||||
*bytes++ = w;
|
*bytes++ = (uint8)w;
|
||||||
*bytes++ = w >> 8;
|
*bytes++ = w >> 8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -500,8 +500,8 @@ Camera::setFOV(float32 hfov, float32 ratio)
|
||||||
V2d v;
|
V2d v;
|
||||||
float w, h;
|
float w, h;
|
||||||
|
|
||||||
w = this->frameBuffer->width;
|
w = (float)this->frameBuffer->width;
|
||||||
h = this->frameBuffer->height;
|
h = (float)this->frameBuffer->height;
|
||||||
if(w < 1 || h < 1){
|
if(w < 1 || h < 1){
|
||||||
w = 1;
|
w = 1;
|
||||||
h = 1;
|
h = 1;
|
||||||
|
@ -513,7 +513,7 @@ Camera::setFOV(float32 hfov, float32 ratio)
|
||||||
float vfov = atanf(tanf(hfov/2) / ar1) *2;
|
float vfov = atanf(tanf(hfov/2) / ar1) *2;
|
||||||
hfov = atanf(tanf(vfov/2) * ar2) *2;
|
hfov = atanf(tanf(vfov/2) * ar2) *2;
|
||||||
|
|
||||||
float32 a = tan(hfov);
|
float32 a = tanf(hfov);
|
||||||
v.set(a, a/ratio);
|
v.set(a, a/ratio);
|
||||||
this->setViewWindow(&v);
|
this->setViewWindow(&v);
|
||||||
v.set(0.0f, 0.0f);
|
v.set(0.0f, 0.0f);
|
||||||
|
|
|
@ -162,8 +162,8 @@ Charset::printChar(int32 c, int32 x, int32 y)
|
||||||
du = this->desc.width_internal/(float32)this->raster->width;
|
du = this->desc.width_internal/(float32)this->raster->width;
|
||||||
dv = this->desc.height_internal/(float32)this->raster->height;
|
dv = this->desc.height_internal/(float32)this->raster->height;
|
||||||
|
|
||||||
vert->setScreenX(x);
|
vert->setScreenX((float)x);
|
||||||
vert->setScreenY(y);
|
vert->setScreenY((float)y);
|
||||||
vert->setScreenZ(rw::im2d::GetNearZ());
|
vert->setScreenZ(rw::im2d::GetNearZ());
|
||||||
vert->setCameraZ(cam->nearPlane);
|
vert->setCameraZ(cam->nearPlane);
|
||||||
vert->setRecipCameraZ(recipZ);
|
vert->setRecipCameraZ(recipZ);
|
||||||
|
@ -172,8 +172,8 @@ Charset::printChar(int32 c, int32 x, int32 y)
|
||||||
vert->setV(v, recipZ);
|
vert->setV(v, recipZ);
|
||||||
vert++;
|
vert++;
|
||||||
|
|
||||||
vert->setScreenX(x+this->desc.width_internal);
|
vert->setScreenX(float(x+this->desc.width_internal));
|
||||||
vert->setScreenY(y);
|
vert->setScreenY((float)y);
|
||||||
vert->setScreenZ(rw::im2d::GetNearZ());
|
vert->setScreenZ(rw::im2d::GetNearZ());
|
||||||
vert->setCameraZ(cam->nearPlane);
|
vert->setCameraZ(cam->nearPlane);
|
||||||
vert->setRecipCameraZ(recipZ);
|
vert->setRecipCameraZ(recipZ);
|
||||||
|
@ -182,8 +182,8 @@ Charset::printChar(int32 c, int32 x, int32 y)
|
||||||
vert->setV(v, recipZ);
|
vert->setV(v, recipZ);
|
||||||
vert++;
|
vert++;
|
||||||
|
|
||||||
vert->setScreenX(x);
|
vert->setScreenX((float)x);
|
||||||
vert->setScreenY(y+this->desc.height_internal);
|
vert->setScreenY(float(y+this->desc.height_internal));
|
||||||
vert->setScreenZ(rw::im2d::GetNearZ());
|
vert->setScreenZ(rw::im2d::GetNearZ());
|
||||||
vert->setCameraZ(cam->nearPlane);
|
vert->setCameraZ(cam->nearPlane);
|
||||||
vert->setRecipCameraZ(recipZ);
|
vert->setRecipCameraZ(recipZ);
|
||||||
|
@ -192,8 +192,8 @@ Charset::printChar(int32 c, int32 x, int32 y)
|
||||||
vert->setV(v+dv, recipZ);
|
vert->setV(v+dv, recipZ);
|
||||||
vert++;
|
vert++;
|
||||||
|
|
||||||
vert->setScreenX(x+this->desc.width_internal);
|
vert->setScreenX(float(x+this->desc.width_internal));
|
||||||
vert->setScreenY(y+this->desc.height_internal);
|
vert->setScreenY(float(y+this->desc.height_internal));
|
||||||
vert->setScreenZ(rw::im2d::GetNearZ());
|
vert->setScreenZ(rw::im2d::GetNearZ());
|
||||||
vert->setCameraZ(cam->nearPlane);
|
vert->setCameraZ(cam->nearPlane);
|
||||||
vert->setRecipCameraZ(recipZ);
|
vert->setRecipCameraZ(recipZ);
|
||||||
|
|
|
@ -118,7 +118,7 @@ readMesh(Stream *stream, int32 len, void *object, int32, int32)
|
||||||
|
|
||||||
stream->read32(&mhs, sizeof(MeshHeaderStream));
|
stream->read32(&mhs, sizeof(MeshHeaderStream));
|
||||||
// Have to do this dance for War Drum's meshes
|
// Have to do this dance for War Drum's meshes
|
||||||
bool32 hasData = len > sizeof(MeshHeaderStream)+mhs.numMeshes*sizeof(MeshStream);
|
bool32 hasData = len > int32(sizeof(MeshHeaderStream)+mhs.numMeshes*sizeof(MeshStream));
|
||||||
assert(geo->meshHeader == nil);
|
assert(geo->meshHeader == nil);
|
||||||
geo->meshHeader = nil;
|
geo->meshHeader = nil;
|
||||||
mh = geo->allocateMeshes(mhs.numMeshes, mhs.totalIndices,
|
mh = geo->allocateMeshes(mhs.numMeshes, mhs.totalIndices,
|
||||||
|
|
|
@ -76,13 +76,13 @@ Light::destroy(void)
|
||||||
void
|
void
|
||||||
Light::setAngle(float32 angle)
|
Light::setAngle(float32 angle)
|
||||||
{
|
{
|
||||||
this->minusCosAngle = -cos(angle);
|
this->minusCosAngle = -cosf(angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
float32
|
float32
|
||||||
Light::getAngle(void)
|
Light::getAngle(void)
|
||||||
{
|
{
|
||||||
return acos(-this->minusCosAngle);
|
return acosf(-this->minusCosAngle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -123,7 +123,7 @@ Light::streamRead(Stream *stream)
|
||||||
light->minusCosAngle = a;
|
light->minusCosAngle = a;
|
||||||
else
|
else
|
||||||
// tan -> -cos
|
// tan -> -cos
|
||||||
light->minusCosAngle = -1.0f/sqrt(a*a+1.0f);
|
light->minusCosAngle = -1.0f/sqrtf(a*a+1.0f);
|
||||||
light->object.object.flags = (uint8)buf.type_flags;
|
light->object.object.flags = (uint8)buf.type_flags;
|
||||||
if(s_plglist.streamRead(stream, light))
|
if(s_plglist.streamRead(stream, light))
|
||||||
return light;
|
return light;
|
||||||
|
@ -144,7 +144,7 @@ Light::streamWrite(Stream *stream)
|
||||||
if(version >= 0x30300)
|
if(version >= 0x30300)
|
||||||
buf.minusCosAngle = this->minusCosAngle;
|
buf.minusCosAngle = this->minusCosAngle;
|
||||||
else
|
else
|
||||||
buf.minusCosAngle = tan(acos(-this->minusCosAngle));
|
buf.minusCosAngle = tanf(acosf(-this->minusCosAngle));
|
||||||
buf.type_flags = (uint32)this->object.object.flags |
|
buf.type_flags = (uint32)this->object.object.flags |
|
||||||
(uint32)this->object.object.subType << 16;
|
(uint32)this->object.object.subType << 16;
|
||||||
stream->write32(&buf, sizeof(LightChunkData));
|
stream->write32(&buf, sizeof(LightChunkData));
|
||||||
|
|
|
@ -211,7 +211,7 @@ inline V2d neg(const V2d &a) { return makeV2d(-a.x, -a.y); }
|
||||||
inline V2d add(const V2d &a, const V2d &b) { return makeV2d(a.x+b.x, a.y+b.y); }
|
inline V2d add(const V2d &a, const V2d &b) { return makeV2d(a.x+b.x, a.y+b.y); }
|
||||||
inline V2d sub(const V2d &a, const V2d &b) { return makeV2d(a.x-b.x, a.y-b.y); }
|
inline V2d sub(const V2d &a, const V2d &b) { return makeV2d(a.x-b.x, a.y-b.y); }
|
||||||
inline V2d scale(const V2d &a, float32 r) { return makeV2d(a.x*r, a.y*r); }
|
inline V2d scale(const V2d &a, float32 r) { return makeV2d(a.x*r, a.y*r); }
|
||||||
inline float32 length(const V2d &v) { return sqrt(v.x*v.x + v.y*v.y); }
|
inline float32 length(const V2d &v) { return sqrtf(v.x*v.x + v.y*v.y); }
|
||||||
inline V2d normalize(const V2d &v) { return scale(v, 1.0f/length(v)); }
|
inline V2d normalize(const V2d &v) { return scale(v, 1.0f/length(v)); }
|
||||||
|
|
||||||
struct V3d
|
struct V3d
|
||||||
|
@ -229,7 +229,7 @@ inline V3d neg(const V3d &a) { return makeV3d(-a.x, -a.y, -a.z); }
|
||||||
inline V3d add(const V3d &a, const V3d &b) { return makeV3d(a.x+b.x, a.y+b.y, a.z+b.z); }
|
inline V3d add(const V3d &a, const V3d &b) { return makeV3d(a.x+b.x, a.y+b.y, a.z+b.z); }
|
||||||
inline V3d sub(const V3d &a, const V3d &b) { return makeV3d(a.x-b.x, a.y-b.y, a.z-b.z); }
|
inline V3d sub(const V3d &a, const V3d &b) { return makeV3d(a.x-b.x, a.y-b.y, a.z-b.z); }
|
||||||
inline V3d scale(const V3d &a, float32 r) { return makeV3d(a.x*r, a.y*r, a.z*r); }
|
inline V3d scale(const V3d &a, float32 r) { return makeV3d(a.x*r, a.y*r, a.z*r); }
|
||||||
inline float32 length(const V3d &v) { return sqrt(v.x*v.x + v.y*v.y + v.z*v.z); }
|
inline float32 length(const V3d &v) { return sqrtf(v.x*v.x + v.y*v.y + v.z*v.z); }
|
||||||
inline V3d normalize(const V3d &v) { return scale(v, 1.0f/length(v)); }
|
inline V3d normalize(const V3d &v) { return scale(v, 1.0f/length(v)); }
|
||||||
inline V3d setlength(const V3d &v, float32 l) { return scale(v, l/length(v)); }
|
inline V3d setlength(const V3d &v, float32 l) { return scale(v, l/length(v)); }
|
||||||
V3d cross(const V3d &a, const V3d &b);
|
V3d cross(const V3d &a, const V3d &b);
|
||||||
|
@ -263,7 +263,7 @@ struct Quat
|
||||||
float32 x, y, z, w;
|
float32 x, y, z, w;
|
||||||
|
|
||||||
static Quat rotation(float32 angle, const V3d &axis){
|
static Quat rotation(float32 angle, const V3d &axis){
|
||||||
return makeQuat(cos(angle/2.0f), scale(normalize(axis), sin(angle/2.0f))); }
|
return makeQuat(cosf(angle/2.0f), scale(normalize(axis), sinf(angle/2.0f))); }
|
||||||
void set(float32 w, float32 x, float32 y, float32 z){
|
void set(float32 w, float32 x, float32 y, float32 z){
|
||||||
this->w = w; this->x = x; this->y = y; this->z = z; }
|
this->w = w; this->x = x; this->y = y; this->z = z; }
|
||||||
V3d vec(void){ return makeV3d(x, y, z); }
|
V3d vec(void){ return makeV3d(x, y, z); }
|
||||||
|
@ -278,7 +278,7 @@ inline Quat sub(const Quat &q, const Quat &p) { return makeQuat(q.w-p.w, q.x-p.x
|
||||||
inline Quat negate(const Quat &q) { return makeQuat(-q.w, -q.x, -q.y, -q.z); }
|
inline Quat negate(const Quat &q) { return makeQuat(-q.w, -q.x, -q.y, -q.z); }
|
||||||
inline float32 dot(const Quat &q, const Quat &p) { return q.w*p.w + q.x*p.x + q.y*p.y + q.z*p.z; }
|
inline float32 dot(const Quat &q, const Quat &p) { return q.w*p.w + q.x*p.x + q.y*p.y + q.z*p.z; }
|
||||||
inline Quat scale(const Quat &q, float32 r) { return makeQuat(q.w*r, q.x*r, q.y*r, q.z*r); }
|
inline Quat scale(const Quat &q, float32 r) { return makeQuat(q.w*r, q.x*r, q.y*r, q.z*r); }
|
||||||
inline float32 length(const Quat &q) { return sqrt(q.w*q.w + q.x*q.x + q.y*q.y + q.z*q.z); }
|
inline float32 length(const Quat &q) { return sqrtf(q.w*q.w + q.x*q.x + q.y*q.y + q.z*q.z); }
|
||||||
inline Quat normalize(const Quat &q) { return scale(q, 1.0f/length(q)); }
|
inline Quat normalize(const Quat &q) { return scale(q, 1.0f/length(q)); }
|
||||||
inline Quat conj(const Quat &q) { return makeQuat(q.w, -q.x, -q.y, -q.z); }
|
inline Quat conj(const Quat &q) { return makeQuat(q.w, -q.x, -q.y, -q.z); }
|
||||||
Quat mult(const Quat &q, const Quat &p);
|
Quat mult(const Quat &q, const Quat &p);
|
||||||
|
|
|
@ -227,7 +227,7 @@ uvAnimParamApplyCB(void *result, void *frame)
|
||||||
static V3d xlat2 = { 0.5f, 0.5f, 0.0f };
|
static V3d xlat2 = { 0.5f, 0.5f, 0.0f };
|
||||||
static V3d axis = { 0.0f, 0.0f, 1.0f };
|
static V3d axis = { 0.0f, 0.0f, 1.0f };
|
||||||
m->translate(&xlat1, COMBINEPOSTCONCAT);
|
m->translate(&xlat1, COMBINEPOSTCONCAT);
|
||||||
m->rotate(&axis, p->theta*180.0f/M_PI, COMBINEPOSTCONCAT);
|
m->rotate(&axis, p->theta*180.0f/(float)M_PI, COMBINEPOSTCONCAT);
|
||||||
m->translate(&xlat2, COMBINEPOSTCONCAT);
|
m->translate(&xlat2, COMBINEPOSTCONCAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue