mirror of https://github.com/aap/librw.git
committing old changes and a fix
This commit is contained in:
parent
e3c1f30856
commit
f1d04ff732
|
@ -355,6 +355,21 @@ Camera::setFarPlane(float32 far)
|
|||
calczShiftScale(this);
|
||||
}
|
||||
|
||||
int32
|
||||
Camera::frustumTestSphere(Sphere *s)
|
||||
{
|
||||
int32 res = SPHEREINSIDE;
|
||||
FrustumPlane *p = this->frustumPlanes;
|
||||
for(int32 i = 0; i < 6; i++){
|
||||
float32 dist = dot(p->plane.normal, s->center) - p->plane.distance;
|
||||
if(s->radius < dist)
|
||||
return SPHEREOUTSIDE;
|
||||
if(s->radius > -dist)
|
||||
res = SPHEREBOUNDARY;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
struct CameraChunkData
|
||||
{
|
||||
V2d viewWindow;
|
||||
|
|
|
@ -105,6 +105,7 @@ Geometry::streamRead(Stream *stream)
|
|||
GeoStreamData buf;
|
||||
SurfaceProperties surfProps;
|
||||
MaterialList *ret;
|
||||
static SurfaceProperties reset = { 1.0f, 1.0f, 1.0f };
|
||||
|
||||
if(!findChunk(stream, ID_STRUCT, nil, &version)){
|
||||
RWERROR((ERR_CHUNK, "STRUCT"));
|
||||
|
@ -154,7 +155,7 @@ Geometry::streamRead(Stream *stream)
|
|||
defaultSurfaceProps = surfProps;
|
||||
ret = MaterialList::streamRead(stream, &geo->matList);
|
||||
if(version < 0x34000)
|
||||
defaultSurfaceProps = (SurfaceProperties){ 1.0f, 1.0f, 1.0f };
|
||||
defaultSurfaceProps = reset;
|
||||
if(ret == nil)
|
||||
goto fail;
|
||||
if(s_plglist.streamRead(stream, geo))
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
#include <stdint.h>
|
||||
#endif
|
||||
#include <cmath>
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
#ifdef RW_GL3
|
||||
#define RW_OPENGL
|
||||
|
|
|
@ -572,6 +572,8 @@ struct Camera : PluginBase<Camera>
|
|||
enum { ID = 4 };
|
||||
enum { PERSPECTIVE = 1, PARALLEL };
|
||||
enum { CLEARIMAGE = 0x1, CLEARZ = 0x2};
|
||||
// return value of frustumTestSphere
|
||||
enum { SPHEREOUTSIDE, SPHEREBOUNDARY, SPHEREINSIDE };
|
||||
|
||||
ObjectWithFrame object;
|
||||
void (*beginUpdateCB)(Camera*);
|
||||
|
@ -612,6 +614,7 @@ struct Camera : PluginBase<Camera>
|
|||
void clear(RGBA *col, uint32 mode);
|
||||
void setNearPlane(float32);
|
||||
void setFarPlane(float32);
|
||||
int32 frustumTestSphere(Sphere *s);
|
||||
static Camera *streamRead(Stream *stream);
|
||||
bool streamWrite(Stream *stream);
|
||||
uint32 streamGetSize(void);
|
||||
|
|
Loading…
Reference in New Issue