Files
BlitzNext/Runtime/blitz3d/world.hpp
T

50 lines
1.3 KiB
C++
Raw Normal View History

2019-01-18 21:26:42 +01:00
#pragma once
2014-01-31 08:23:00 +13:00
#include <list>
2019-01-18 15:55:06 +01:00
#include "camera.hpp"
#include "light.hpp"
#include "listener.hpp"
2019-01-18 17:04:17 +01:00
#include "mirror.hpp"
#include "model.hpp"
2014-01-31 08:23:00 +13:00
2019-01-18 17:04:17 +01:00
#define WORLD_COLLISION_TYPES 16
#define WORLD_COLLISION_HITS 4
2019-01-18 17:04:17 +01:00
class World {
public:
2014-01-31 08:23:00 +13:00
//collision methods
2019-01-18 17:04:17 +01:00
enum { COLLISION_METHOD_SPHERE = 1, COLLISION_METHOD_POLYGON = 2, COLLISION_METHOD_BOX = 3 };
2014-01-31 08:23:00 +13:00
//collision actions
2019-01-18 17:04:17 +01:00
enum {
COLLISION_RESPONSE_NONE = 0,
COLLISION_RESPONSE_STOP = 1,
COLLISION_RESPONSE_SLIDE = 2,
COLLISION_RESPONSE_SLIDEXZ = 3,
2014-01-31 08:23:00 +13:00
};
void clearCollisions();
2019-01-18 17:04:17 +01:00
void addCollision(int src_type, int dest_type, int method, int response);
2014-01-31 08:23:00 +13:00
2019-01-18 17:04:17 +01:00
void update(float elapsed);
2014-01-31 08:23:00 +13:00
void capture();
2019-01-18 17:04:17 +01:00
void render(float tween);
2014-01-31 08:23:00 +13:00
2019-01-18 17:04:17 +01:00
bool CheckLineOfSight(Object* src, Object* dest);
bool hitTest(const Line& line, float radius, Object* obj, const Transform& tf, int method, Collision* curr_coll);
Object* traceRay(const Line& line, float radius, ObjCollision* curr_coll);
2014-01-31 08:23:00 +13:00
2019-01-18 17:04:17 +01:00
private:
struct CollInfo {
int dst_type, method, response;
2014-01-31 08:23:00 +13:00
};
2019-01-18 21:26:42 +01:00
std::vector<CollInfo> _collInfo[WORLD_COLLISION_TYPES];
std::list<Object*> _objsByType[WORLD_COLLISION_TYPES];
std::list<Object*> _objsByTypeSwappable[WORLD_COLLISION_TYPES];
2014-01-31 08:23:00 +13:00
2019-01-18 17:04:17 +01:00
void collide(Object* src);
void render(Camera* c, Mirror* m);
void render(Model* m, const RenderContext& rc);
2014-01-31 08:23:00 +13:00
void flushTransparent();
};