-
Notifications
You must be signed in to change notification settings - Fork 5
/
Layer.h
81 lines (67 loc) · 2.17 KB
/
Layer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#pragma once
#include "Viewport.h"
#include "Light.h"
#include "Mesh.h"
#include "DrawBatch.h"
#include "Pool.h"
#ifdef WIN32
#include "GL/glew.h"
#endif
class Camera;
class Deck;
class Material;
class MoyaiClient;
class Layer : public Group {
public:
Camera *camera;
Viewport *viewport;
Light *light;
int debug_id;
MoyaiClient *parent_client;
static const int PRIORITY_MAX = 2147483647;
// working area to avoid allocation in inner loops
SorterEntry sorter_opaque[Prop::CHILDREN_ABS_MAX];
SorterEntry sorter_transparent[Prop::CHILDREN_ABS_MAX];
int priority; // decided when inserting layer into moyaiclient
ObjectPool<Camera> dynamic_cameras;
ObjectPool<Viewport> dynamic_viewports;
void (*callback_func)(Layer *l,DrawBatchList *bl);
Layer() : Group(), camera(NULL), viewport(NULL), light(NULL), debug_id(0), priority(0), callback_func(NULL) {
to_render = true;
}
inline void setViewport( Viewport *vp ){
viewport = vp;
}
inline void setCamera(Camera *cam){
camera = cam;
}
inline void setLight(Light *l){
light = l;
}
void addDynamicCamera( Camera *cam );
void delDynamicCamera( Camera *cam );
void addDynamicViewport( Viewport *vp);
void delDynamicViewport( Viewport *vp);
void onTrackDynamicCameras();
void onTrackDynamicViewports();
bool hasDynamicCameras() {
return dynamic_cameras.size();
}
bool hasDynamicViewports() {
return dynamic_viewports.size();
}
int render( DrawBatchList *bl );
int renderAllProps( DrawBatchList *bl );
void selectCenterInside( Vec2 minloc, Vec2 maxloc, Prop*out[], int *outlen );
inline void selectCenterInside( Vec2 center, float dia, Prop *out[], int *outlen){
selectCenterInside( center - Vec2(dia,dia),
center + Vec2(dia,dia),
out, outlen );
}
inline void drawMesh( int dbg, Mesh *mesh, Deck *deck, Vec3 *loc, Vec3 *locofs, Vec3 *scl, Vec3 *rot, Vec3 *localloc, Vec3 *localscl, Vec3 *localrot, Material *material );
void setupProjectionMatrix3D();
Vec2 getScreenPos( Vec3 at );
Vec3 getWorldPos( Vec2 scrpos );
int getHighestPriority();
void setCallbackFunc( void (*cb)(Layer *l,DrawBatchList*) ) { callback_func = cb; }
};