committing old changes and a fix

This commit is contained in:
aap 2017-07-11 08:18:15 +02:00
parent e3c1f30856
commit f1d04ff732
4 changed files with 23 additions and 1 deletions

View File

@ -355,6 +355,21 @@ Camera::setFarPlane(float32 far)
calczShiftScale(this); 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 struct CameraChunkData
{ {
V2d viewWindow; V2d viewWindow;

View File

@ -105,6 +105,7 @@ Geometry::streamRead(Stream *stream)
GeoStreamData buf; GeoStreamData buf;
SurfaceProperties surfProps; SurfaceProperties surfProps;
MaterialList *ret; MaterialList *ret;
static SurfaceProperties reset = { 1.0f, 1.0f, 1.0f };
if(!findChunk(stream, ID_STRUCT, nil, &version)){ if(!findChunk(stream, ID_STRUCT, nil, &version)){
RWERROR((ERR_CHUNK, "STRUCT")); RWERROR((ERR_CHUNK, "STRUCT"));
@ -154,7 +155,7 @@ Geometry::streamRead(Stream *stream)
defaultSurfaceProps = surfProps; defaultSurfaceProps = surfProps;
ret = MaterialList::streamRead(stream, &geo->matList); ret = MaterialList::streamRead(stream, &geo->matList);
if(version < 0x34000) if(version < 0x34000)
defaultSurfaceProps = (SurfaceProperties){ 1.0f, 1.0f, 1.0f }; defaultSurfaceProps = reset;
if(ret == nil) if(ret == nil)
goto fail; goto fail;
if(s_plglist.streamRead(stream, geo)) if(s_plglist.streamRead(stream, geo))

View File

@ -2,6 +2,9 @@
#include <stdint.h> #include <stdint.h>
#endif #endif
#include <cmath> #include <cmath>
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#ifdef RW_GL3 #ifdef RW_GL3
#define RW_OPENGL #define RW_OPENGL

View File

@ -572,6 +572,8 @@ struct Camera : PluginBase<Camera>
enum { ID = 4 }; enum { ID = 4 };
enum { PERSPECTIVE = 1, PARALLEL }; enum { PERSPECTIVE = 1, PARALLEL };
enum { CLEARIMAGE = 0x1, CLEARZ = 0x2}; enum { CLEARIMAGE = 0x1, CLEARZ = 0x2};
// return value of frustumTestSphere
enum { SPHEREOUTSIDE, SPHEREBOUNDARY, SPHEREINSIDE };
ObjectWithFrame object; ObjectWithFrame object;
void (*beginUpdateCB)(Camera*); void (*beginUpdateCB)(Camera*);
@ -612,6 +614,7 @@ struct Camera : PluginBase<Camera>
void clear(RGBA *col, uint32 mode); void clear(RGBA *col, uint32 mode);
void setNearPlane(float32); void setNearPlane(float32);
void setFarPlane(float32); void setFarPlane(float32);
int32 frustumTestSphere(Sphere *s);
static Camera *streamRead(Stream *stream); static Camera *streamRead(Stream *stream);
bool streamWrite(Stream *stream); bool streamWrite(Stream *stream);
uint32 streamGetSize(void); uint32 streamGetSize(void);