forked from mirrors/principia
Rename and deduplicate name colliding vert structs
This commit is contained in:
parent
a22c9ed7e6
commit
e1ceb49cd2
15 changed files with 111 additions and 141 deletions
25
src/cable.cc
25
src/cable.cc
|
|
@ -20,17 +20,11 @@
|
|||
|
||||
#define NUM_SUBDIVISIONS 3
|
||||
|
||||
struct vertex {
|
||||
struct cable_vert {
|
||||
tvec3 pos;
|
||||
tvec3 nor;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct cvert {
|
||||
tvec3 p;
|
||||
tvec3 n;
|
||||
tvec2 u;
|
||||
} __attribute__((packed));
|
||||
|
||||
bool cable::initialized = false;
|
||||
|
||||
static struct tms_mesh *_mesh;
|
||||
|
|
@ -64,7 +58,7 @@ cable::_init(void)
|
|||
/* initialize cable buffers */
|
||||
{
|
||||
points_per_cable = (int)pow(2.f, (float)(NUM_SUBDIVISIONS))+1;
|
||||
buf = new tms::gbuffer(MAX_CABLES * points_per_cable * QUALITY * sizeof(struct vertex));
|
||||
buf = new tms::gbuffer(MAX_CABLES * points_per_cable * QUALITY * sizeof(struct cable_vert));
|
||||
ibuf = new tms::gbuffer(MAX_CABLES * (points_per_cable-1) * (QUALITY) * 6 * sizeof(uint16_t));
|
||||
|
||||
buf->usage = GL_STREAM_DRAW;
|
||||
|
|
@ -126,7 +120,7 @@ cable::_init(void)
|
|||
plug_ibuf->target = GL_ELEMENT_ARRAY_BUFFER;
|
||||
|
||||
for (int x=0; x<3; x++) {
|
||||
plug_buf[x] = new tms::gbuffer(MAX_PLUGS * vertices_per_plug * sizeof(struct vertex));
|
||||
plug_buf[x] = new tms::gbuffer(MAX_PLUGS * vertices_per_plug * sizeof(struct cable_vert));
|
||||
plug_buf[x]->usage = GL_STREAM_DRAW;
|
||||
|
||||
plug_va[x] = new tms::varray(2);
|
||||
|
|
@ -204,7 +198,7 @@ cable::upload_buffers(void)
|
|||
_mesh->i_start = 0;
|
||||
_mesh->i_count = counter*(ibuf->size/MAX_CABLES) / sizeof(uint16_t);
|
||||
if (counter)
|
||||
buf->upload_partial(counter * points_per_cable * 4 * sizeof(struct vertex)); /* this 4 = QUALITY? */
|
||||
buf->upload_partial(counter * points_per_cable * 4 * sizeof(struct cable_vert)); /* this 4 = QUALITY? */
|
||||
|
||||
for (int x=0; x<3; x++) {
|
||||
int count = plug_counter[x];
|
||||
|
|
@ -215,7 +209,7 @@ cable::upload_buffers(void)
|
|||
plug_mesh[x]->i_count = count*(indices_per_plug);
|
||||
|
||||
if (count) {
|
||||
plug_buf[x]->upload_partial((count*vertices_per_plug) * sizeof(struct vertex));
|
||||
plug_buf[x]->upload_partial((count*vertices_per_plug) * sizeof(struct cable_vert));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -447,8 +441,8 @@ cable::update(void)
|
|||
this->create_joint(); /* update the length of the cable every frame if we are paused */
|
||||
}
|
||||
|
||||
int base = num*(((buf->size/MAX_CABLES))/sizeof(struct vertex));
|
||||
struct vertex *v = ((struct vertex*)buf->get_buffer())+base;
|
||||
int base = num*(((buf->size/MAX_CABLES))/sizeof(struct cable_vert));
|
||||
cable_vert *v = ((cable_vert *)buf->get_buffer())+base;
|
||||
|
||||
float cable_z = fmaxf(this->p[0]->get_layer(), this->p[1]->get_layer()) * LAYER_DEPTH;
|
||||
|
||||
|
|
@ -805,13 +799,13 @@ plug_base::update(void)
|
|||
if (num > MAX_PLUGS - 1) num = MAX_PLUGS - 1;
|
||||
|
||||
int base = (num*vertices_per_plug);
|
||||
struct vertex *v = ((struct vertex*)plug_buf[l]->get_buffer());
|
||||
cable_vert *v = ((cable_vert *)plug_buf[l]->get_buffer());
|
||||
v += base;
|
||||
|
||||
struct tms_mesh *mm = mesh_factory::get_mesh(MODEL_PLUG_SIMPLE);
|
||||
struct tms_gbuffer *r_vbuf = mm->vertex_array->gbufs[0].gbuf;
|
||||
|
||||
struct cvert *rv = (struct cvert*)((char*)tms_gbuffer_get_buffer(r_vbuf)+mm->v_start);
|
||||
cvert *rv = (cvert *)((char*)tms_gbuffer_get_buffer(r_vbuf)+mm->v_start);
|
||||
int num_rv = mm->v_count;
|
||||
|
||||
for (int x=0; x<num_rv; x++) {
|
||||
|
|
@ -1057,4 +1051,3 @@ plug_base::on_release(game *g)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,23 +19,17 @@ static struct tms_gbuffer *grass_vbuf[MAX_CHUNKS];
|
|||
static struct tms_varray *grass_va[MAX_CHUNKS];
|
||||
static struct tms_gbuffer *grass_ibuf;
|
||||
|
||||
struct vertex {
|
||||
struct terrain_vert {
|
||||
tvec3 pos;
|
||||
tvec3 nor;
|
||||
tvec2 uv;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct grass_vertex {
|
||||
struct grass_vert {
|
||||
tvec4 pos;
|
||||
tvec2 uv;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct cvert {
|
||||
tvec3 p;
|
||||
tvec3 n;
|
||||
tvec2 u;
|
||||
} __attribute__((packed));
|
||||
|
||||
static int vertices_per_tpixel;
|
||||
static int indices_per_tpixel;
|
||||
|
||||
|
|
@ -80,7 +74,7 @@ void chunk_window::_init() {
|
|||
}
|
||||
|
||||
for (int x=0; x<MAX_CHUNKS; x++) {
|
||||
vbuf[x] = new tms::gbuffer((3 * 16 * 16 * vertices_per_tpixel * sizeof(struct vertex))/* / 4 * 3*/);
|
||||
vbuf[x] = new tms::gbuffer((3 * 16 * 16 * vertices_per_tpixel * sizeof(struct terrain_vert))/* / 4 * 3*/);
|
||||
vbuf[x]->usage = GL_STREAM_DRAW;
|
||||
|
||||
va[x] = tms_varray_alloc(3);
|
||||
|
|
@ -89,7 +83,7 @@ void chunk_window::_init() {
|
|||
tms_varray_map_attribute(va[x], "texcoord", 2, GL_FLOAT, vbuf[x]);
|
||||
mesh_pool[x] = tms_mesh_alloc(va[x], ibuf);
|
||||
|
||||
grass_vbuf[x] = new tms::gbuffer(MAX_GRASS_VERTS_PER_CHUNK*sizeof(struct grass_vertex));
|
||||
grass_vbuf[x] = new tms::gbuffer(MAX_GRASS_VERTS_PER_CHUNK*sizeof(struct grass_vert));
|
||||
grass_vbuf[x]->usage = GL_STREAM_DRAW;
|
||||
|
||||
grass_va[x] = tms_varray_alloc(2);
|
||||
|
|
@ -278,9 +272,9 @@ chunk_window::load_slot(int s, level_chunk *c)
|
|||
rv_tri[x] = (struct cvert*)((char*)tms_gbuffer_get_buffer(vbuf)+mm2->v_start);
|
||||
}
|
||||
|
||||
struct vertex *v_first = (struct vertex*)tms_gbuffer_get_buffer(vbuf[s]);
|
||||
terrain_vert *v_first = (terrain_vert *)tms_gbuffer_get_buffer(vbuf[s]);
|
||||
|
||||
struct grass_vertex *v_grass = (struct grass_vertex*)tms_gbuffer_get_buffer(grass_vbuf[s]);
|
||||
grass_vert *v_grass = (grass_vert *)tms_gbuffer_get_buffer(grass_vbuf[s]);
|
||||
int num_grass = 0;
|
||||
int num_grass_01 = 0;
|
||||
|
||||
|
|
@ -346,19 +340,19 @@ chunk_window::load_slot(int s, level_chunk *c)
|
|||
}
|
||||
}
|
||||
|
||||
v_grass[num_grass++] = (struct grass_vertex){
|
||||
v_grass[num_grass++] = (grass_vert){
|
||||
(tvec4){x*.5f + .25f+w2, y*.5f + height+h2, gx*.25f+z*LAYER_DEPTH - .25f+.01f, 1.f},
|
||||
(tvec2){.25f+u, .9f},
|
||||
};
|
||||
v_grass[num_grass++] = (struct grass_vertex){
|
||||
v_grass[num_grass++] = (grass_vert){
|
||||
(tvec4){x*.5f - .25f-w1, y*.5f + height+h1, gx*.25f+z*LAYER_DEPTH - .25f+.01f, 1.f},
|
||||
(tvec2){u, 0.9f},
|
||||
};
|
||||
v_grass[num_grass++] = (struct grass_vertex){
|
||||
v_grass[num_grass++] = (grass_vert){
|
||||
(tvec4){x*.5f - .25f, y*.5f + .22f+b1, gx*.25f+z*LAYER_DEPTH - .25f+.01f, diffuse},
|
||||
(tvec2){u, 0.f},
|
||||
};
|
||||
v_grass[num_grass++] = (struct grass_vertex){
|
||||
v_grass[num_grass++] = (grass_vert){
|
||||
(tvec4){x*.5f + .25f, y*.5f + .22f+b2, gx*.25f+z*LAYER_DEPTH - .25f+.01f, std::max(diffuse, diffuse_lim)},
|
||||
(tvec2){.25f+u, 0.f},
|
||||
};
|
||||
|
|
@ -393,7 +387,7 @@ chunk_window::load_slot(int s, level_chunk *c)
|
|||
}
|
||||
|
||||
int base = (num*vertices_per_tpixel);
|
||||
struct vertex *v = v_first + base;
|
||||
terrain_vert *v = v_first + base;
|
||||
|
||||
//float as = .5f;//tp->get_size()*2.f;
|
||||
float rs = (3.f - size)*(.125f);
|
||||
|
|
@ -447,7 +441,7 @@ chunk_window::load_slot(int s, level_chunk *c)
|
|||
}
|
||||
|
||||
if (num)
|
||||
tms_gbuffer_upload_partial(vbuf[s], num*vertices_per_tpixel*sizeof(struct vertex));
|
||||
tms_gbuffer_upload_partial(vbuf[s], num*vertices_per_tpixel*sizeof(struct terrain_vert));
|
||||
|
||||
c->grass_entity[0].mesh->i_start = 0;
|
||||
c->grass_entity[0].mesh->i_count = num_grass_01/4*6;
|
||||
|
|
@ -456,7 +450,7 @@ chunk_window::load_slot(int s, level_chunk *c)
|
|||
c->grass_entity[1].mesh->i_count = (num_grass-num_grass_01)/4*6;
|
||||
|
||||
if (num_grass)
|
||||
tms_gbuffer_upload_partial(grass_vbuf[s], num_grass*sizeof(struct grass_vertex));
|
||||
tms_gbuffer_upload_partial(grass_vbuf[s], num_grass*sizeof(struct grass_vert));
|
||||
}
|
||||
|
||||
static level_chunk *_c = 0;
|
||||
|
|
|
|||
|
|
@ -10,12 +10,12 @@ static tms::entity *e2;
|
|||
|
||||
static uint32_t n = 0;
|
||||
|
||||
struct vert {
|
||||
struct fluidbuf_vert {
|
||||
tvec3 pos;
|
||||
tvec3 uv;
|
||||
};
|
||||
|
||||
static struct vert base[4];
|
||||
static fluidbuf_vert base[4];
|
||||
|
||||
void fluidbuffer::reset()
|
||||
{
|
||||
|
|
@ -45,7 +45,7 @@ void fluidbuffer::_init()
|
|||
{
|
||||
tms_infof("Initializing fluidbuffer...");
|
||||
|
||||
verts = new tms::gbuffer(4*(FLUIDBUFFER_MAX)*sizeof(struct vert));
|
||||
verts = new tms::gbuffer(4*(FLUIDBUFFER_MAX)*sizeof(struct fluidbuf_vert));
|
||||
verts->usage = TMS_GBUFFER_STREAM_DRAW;
|
||||
|
||||
indices = new tms::gbuffer(6*FLUIDBUFFER_MAX*sizeof(uint32_t));
|
||||
|
|
@ -71,19 +71,19 @@ void fluidbuffer::_init()
|
|||
|
||||
indices->upload();
|
||||
|
||||
base[0] = (struct vert){
|
||||
base[0] = (fluidbuf_vert){
|
||||
(tvec3){.5f,.5f,0.f},
|
||||
(tvec3){.5f, 1.f, 0.f}
|
||||
};
|
||||
base[1] = (struct vert){
|
||||
base[1] = (fluidbuf_vert){
|
||||
(tvec3){-.5f,.5f,0.f},
|
||||
(tvec3){0.f, 1.f, 0.f},
|
||||
};
|
||||
base[2] = (struct vert){
|
||||
base[2] = (fluidbuf_vert){
|
||||
(tvec3){-.5f,-.5f,0.f},
|
||||
(tvec3){0.f, .75f, 0.f},
|
||||
};
|
||||
base[3] = (struct vert){
|
||||
base[3] = (fluidbuf_vert){
|
||||
(tvec3){.5f,-.5f,0.f},
|
||||
(tvec3){.5f, .75f, 0.f},
|
||||
};
|
||||
|
|
@ -100,7 +100,7 @@ void fluidbuffer::add(
|
|||
uint32_t particle_limit = ((W->level.version <= LEVEL_VERSION_1_5_1) ? FLUIDBUFFER_MAX_1_5_1 : FLUIDBUFFER_MAX);
|
||||
if (n >= particle_limit) return;
|
||||
|
||||
struct vert *vert_buf = (struct vert*) verts->get_buffer();
|
||||
fluidbuf_vert *vert_buf = (fluidbuf_vert *) verts->get_buffer();
|
||||
for (int ix=0; ix<4; ix++) {
|
||||
vert_buf[n*4+ix] = base[ix];
|
||||
|
||||
|
|
@ -124,5 +124,5 @@ void fluidbuffer::upload()
|
|||
mesh->i_start = 0;
|
||||
mesh->i_count = n*6;
|
||||
}
|
||||
if (n) verts->upload_partial(n*4*sizeof(struct vert));
|
||||
if (n) verts->upload_partial(n*4*sizeof(struct fluidbuf_vert));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,14 +17,14 @@ static int vp;
|
|||
static int ip;
|
||||
|
||||
/* from */
|
||||
struct vertex {
|
||||
struct gb_vert {
|
||||
tvec3 pos;
|
||||
tvec3 nor;
|
||||
tvec2 uv;
|
||||
};
|
||||
|
||||
/* to */
|
||||
struct vertex2 {
|
||||
struct gb_vert2 {
|
||||
tvec3 pos;
|
||||
tvec3 nor;
|
||||
} __attribute__ ((packed));
|
||||
|
|
@ -33,7 +33,7 @@ void gearbox::_init()
|
|||
{
|
||||
num_mslots = 0;
|
||||
|
||||
vbuf = tms_gbuffer_alloc(4096*sizeof(struct vertex2));
|
||||
vbuf = tms_gbuffer_alloc(4096*sizeof(struct gb_vert2));
|
||||
ibuf = tms_gbuffer_alloc(32*4096*sizeof(uint16_t));
|
||||
ibuf->target = GL_ELEMENT_ARRAY_BUFFER;
|
||||
|
||||
|
|
@ -46,13 +46,13 @@ void gearbox::_init()
|
|||
static void
|
||||
addmesh(struct tms_mesh *from, float dx, float dy, int *num_v, int *num_i)
|
||||
{
|
||||
struct vertex *v = (struct vertex*)(from->vertex_array->gbufs[0].gbuf->buf+from->v_start);
|
||||
gb_vert *v = (gb_vert *)(from->vertex_array->gbufs[0].gbuf->buf+from->v_start);
|
||||
uint16_t *i = (uint16_t*)(from->indices->buf+from->i_start*sizeof(uint16_t));
|
||||
|
||||
struct vertex2 *nv = (struct vertex2*)(vbuf->buf+vp*sizeof(struct vertex2));
|
||||
gb_vert2 *nv = (gb_vert2 *)(vbuf->buf+vp*sizeof(struct gb_vert2));
|
||||
uint16_t *ni = (uint16_t *)(ibuf->buf+ip*sizeof(uint16_t));
|
||||
|
||||
int last_base = from->v_start / sizeof(struct vertex);
|
||||
int last_base = from->v_start / sizeof(struct gb_vert);
|
||||
|
||||
for (int x=0; x<from->i_count; x++)
|
||||
ni[x] = i[x] - last_base + vp;
|
||||
|
|
@ -92,7 +92,7 @@ recreate_meshes()
|
|||
num_v = 0;
|
||||
num_i = 0;
|
||||
|
||||
m->v_start = vp*sizeof(struct vertex2);
|
||||
m->v_start = vp*sizeof(struct gb_vert2);
|
||||
m->i_start = ip;
|
||||
|
||||
if (a == 0) {
|
||||
|
|
@ -120,7 +120,7 @@ recreate_meshes()
|
|||
}
|
||||
}
|
||||
|
||||
tms_gbuffer_upload_partial(vbuf, vp*sizeof(struct vertex2));
|
||||
tms_gbuffer_upload_partial(vbuf, vp*sizeof(struct gb_vert2));
|
||||
tms_gbuffer_upload_partial(ibuf, ip*sizeof(uint16_t));
|
||||
}
|
||||
|
||||
|
|
|
|||
12
src/group.cc
12
src/group.cc
|
|
@ -18,12 +18,6 @@ struct plastic_vert {
|
|||
tvec3 color;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct cvert {
|
||||
tvec3 p;
|
||||
tvec3 n;
|
||||
tvec2 u;
|
||||
} __attribute__((packed));
|
||||
|
||||
void
|
||||
group::update()
|
||||
{
|
||||
|
|
@ -125,12 +119,6 @@ group::create_mesh(void)
|
|||
{
|
||||
float rm[16];
|
||||
|
||||
struct cvert {
|
||||
tvec3 p;
|
||||
tvec3 n;
|
||||
tvec2 u;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct vert {
|
||||
tvec3 p;
|
||||
tvec3 n;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ static float cam_y = 0.f;
|
|||
static int n = 0;
|
||||
static int n2 = 0;
|
||||
|
||||
struct vert {
|
||||
struct linebuf_vert {
|
||||
tvec3 pos;
|
||||
tvec2 uv;
|
||||
tvec4 color;
|
||||
|
|
@ -84,10 +84,10 @@ void linebuffer::_init()
|
|||
{
|
||||
tms_infof("Initializing linebuffer");
|
||||
|
||||
verts = new tms::gbuffer(4*LINEBUFFER_MAX*sizeof(struct vert));
|
||||
verts = new tms::gbuffer(4*LINEBUFFER_MAX*sizeof(struct linebuf_vert));
|
||||
verts->usage = TMS_GBUFFER_STREAM_DRAW;
|
||||
|
||||
verts2 = new tms::gbuffer(4*LINEBUFFER_MAX*sizeof(struct vert));
|
||||
verts2 = new tms::gbuffer(4*LINEBUFFER_MAX*sizeof(struct linebuf_vert));
|
||||
verts2->usage = TMS_GBUFFER_STREAM_DRAW;
|
||||
|
||||
indices = new tms::gbuffer(6*LINEBUFFER_MAX*sizeof(uint16_t));
|
||||
|
|
@ -131,7 +131,7 @@ void linebuffer::add(
|
|||
)
|
||||
{
|
||||
if (n < LINEBUFFER_MAX) {
|
||||
struct vert *_b = (struct vert*)verts->get_buffer();
|
||||
linebuf_vert *_b = (linebuf_vert*)verts->get_buffer();
|
||||
|
||||
b2Vec2 tangent = b2Vec2((y2-y1), -(x2-x1));
|
||||
tangent *= 1.f / tangent.Length();
|
||||
|
|
@ -190,7 +190,7 @@ void linebuffer::add2(
|
|||
)
|
||||
{
|
||||
if (n2 < LINEBUFFER_MAX) {
|
||||
struct vert *_b = (struct vert*)verts2->get_buffer();
|
||||
linebuf_vert *_b = (linebuf_vert *)verts2->get_buffer();
|
||||
|
||||
b2Vec2 tangent = b2Vec2((y2-y1), -(x2-x1));
|
||||
tangent *= 1.f / tangent.Length();
|
||||
|
|
@ -251,10 +251,10 @@ void linebuffer::upload()
|
|||
mesh2->i_count = n2*6;
|
||||
}
|
||||
if (n) {
|
||||
verts->upload_partial(n*4*sizeof(struct vert));
|
||||
verts->upload_partial(n*4*sizeof(struct linebuf_vert));
|
||||
}
|
||||
if (n2) {
|
||||
verts2->upload_partial(n2*4*sizeof(struct vert));
|
||||
verts2->upload_partial(n2*4*sizeof(struct linebuf_vert));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
14
src/pixel.cc
14
src/pixel.cc
|
|
@ -7,18 +7,12 @@
|
|||
bool pixel::initialized = false;
|
||||
static bool _modified = false;
|
||||
|
||||
struct vertex {
|
||||
struct pixel_vert {
|
||||
tvec3 pos;
|
||||
tvec3 nor;
|
||||
tvec3 col;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct cvert {
|
||||
tvec3 p;
|
||||
tvec3 n;
|
||||
tvec2 u;
|
||||
} __attribute__((packed));
|
||||
|
||||
static struct tms_mesh *_mesh[3];
|
||||
static struct tms_entity *_e[3];
|
||||
static tms::varray *_va[3];
|
||||
|
|
@ -52,7 +46,7 @@ pixel::initialize()
|
|||
|
||||
for (int x=0; x<3; x++) {
|
||||
|
||||
_buf[x] = new tms::gbuffer(MAX_PIXELS * vertices_per_pixel * sizeof(struct vertex));
|
||||
_buf[x] = new tms::gbuffer(MAX_PIXELS * vertices_per_pixel * sizeof(struct pixel_vert));
|
||||
_buf[x]->usage = GL_STREAM_DRAW;
|
||||
|
||||
_va[x] = new tms::varray(3);
|
||||
|
|
@ -128,7 +122,7 @@ pixel::upload_buffers(void)
|
|||
_mesh[x]->i_count = (count*indices_per_pixel);
|
||||
|
||||
if (count) {
|
||||
_buf[x]->upload_partial((count*vertices_per_pixel) * sizeof(struct vertex));
|
||||
_buf[x]->upload_partial((count*vertices_per_pixel) * sizeof(struct pixel_vert));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -192,7 +186,7 @@ void pixel::update()
|
|||
int num = __sync_fetch_and_add(&_counter[l], 1);
|
||||
|
||||
int base = (num*vertices_per_pixel);
|
||||
struct vertex *v = ((struct vertex*)_buf[l]->get_buffer());
|
||||
pixel_vert *v = ((pixel_vert *)_buf[l]->get_buffer());
|
||||
v += base;
|
||||
|
||||
struct tms_mesh *mm = mesh_factory::get_mesh(MODEL_BOX_NOTEX);
|
||||
|
|
|
|||
16
src/plant.cc
16
src/plant.cc
|
|
@ -116,7 +116,7 @@ static bool buffer_modified = false;
|
|||
|
||||
static int counter;
|
||||
|
||||
struct vertex {
|
||||
struct plant_vert {
|
||||
tvec3 pos;
|
||||
tvec3 nor;
|
||||
tvec3 tan;
|
||||
|
|
@ -124,7 +124,7 @@ struct vertex {
|
|||
} __attribute__ ((packed));
|
||||
|
||||
void plant::_init() {
|
||||
vbuf = tms_gbuffer_alloc(MAX_BRANCHES*sizeof(struct vertex)*QUALITY*MAX_SECTIONS);
|
||||
vbuf = tms_gbuffer_alloc(MAX_BRANCHES*sizeof(struct plant_vert)*QUALITY*MAX_SECTIONS);
|
||||
ibuf = tms_gbuffer_alloc(MAX_BRANCHES*MAX_SECTIONS * (QUALITY) * 6 * sizeof(short));
|
||||
|
||||
vbuf->usage = GL_STREAM_DRAW;
|
||||
|
|
@ -1379,7 +1379,7 @@ plant::break_branch(plant_branch *br, plant_section *s, bool create_resources)
|
|||
}
|
||||
|
||||
int
|
||||
plant::update_mesh(plant_section *s, struct vertex *v, int y, bool search_only)
|
||||
plant::update_mesh(plant_section *s, struct plant_vert *v, int y, bool search_only)
|
||||
{
|
||||
plant_branch *extensions[64]; /* XXX */
|
||||
int num_extensions = 0;
|
||||
|
|
@ -1451,7 +1451,7 @@ plant::update_mesh(plant_section *s, struct vertex *v, int y, bool search_only)
|
|||
}
|
||||
|
||||
int
|
||||
plant::mesh_add_section(struct vertex *v, int y, b2Vec2 bp, b2Vec2 axis, float width)
|
||||
plant::mesh_add_section(struct plant_vert *v, int y, b2Vec2 bp, b2Vec2 axis, float width)
|
||||
{
|
||||
static const float step = (M_PI*2.f) / (float)QUALITY;
|
||||
|
||||
|
|
@ -1487,7 +1487,7 @@ plant::mesh_add_section(struct vertex *v, int y, b2Vec2 bp, b2Vec2 axis, float w
|
|||
* since each section renders at the end point
|
||||
**/
|
||||
int
|
||||
plant::mesh_add_pre_branch_sections(plant_branch *br, struct vertex *v, int y)
|
||||
plant::mesh_add_pre_branch_sections(plant_branch *br, struct plant_vert *v, int y)
|
||||
{
|
||||
y = this->mesh_add_section(v, y, br->first->get_start_point(), br->first->get_vector(), 0.f);
|
||||
y = this->mesh_add_section(v, y, br->first->get_start_point(), br->first->get_vector(), br->first->get_width()*1.5f);
|
||||
|
|
@ -1496,7 +1496,7 @@ plant::mesh_add_pre_branch_sections(plant_branch *br, struct vertex *v, int y)
|
|||
}
|
||||
|
||||
int
|
||||
plant::mesh_add_post_branch_sections(plant_branch *br, struct vertex *v, int y)
|
||||
plant::mesh_add_post_branch_sections(plant_branch *br, struct plant_vert *v, int y)
|
||||
{
|
||||
return this->mesh_add_section(v, y, br->last->get_end_point(), br->last->get_vector(), 0.f);
|
||||
}
|
||||
|
|
@ -1511,7 +1511,7 @@ void
|
|||
plant::upload_buffers()
|
||||
{
|
||||
if (buffer_modified) {
|
||||
tms_gbuffer_upload_partial(vbuf, (top_slot+1)*sizeof(struct vertex)*QUALITY*MAX_SECTIONS);
|
||||
tms_gbuffer_upload_partial(vbuf, (top_slot+1)*sizeof(struct plant_vert)*QUALITY*MAX_SECTIONS);
|
||||
buffer_modified = false;
|
||||
} else {
|
||||
//tms_debugf("no branch modified");
|
||||
|
|
@ -1578,7 +1578,7 @@ plant::update_meshes(plant_branch *br)
|
|||
plant_section *s = br->first;
|
||||
plant_section *last = br->last;
|
||||
|
||||
struct vertex *v = (struct vertex*)tms_gbuffer_get_buffer(vbuf);
|
||||
plant_vert *v = (plant_vert *)tms_gbuffer_get_buffer(vbuf);
|
||||
v += br->slot * QUALITY*MAX_SECTIONS;
|
||||
|
||||
int y = this->update_mesh(s, v, 0, !do_update);
|
||||
|
|
|
|||
|
|
@ -268,10 +268,10 @@ class plant : public entity_simpleconnect
|
|||
plant_leaf *create_leaf(plant_branch *br);
|
||||
|
||||
void update_meshes(plant_branch *br);
|
||||
int update_mesh(plant_section *s, struct vertex *v, int y, bool search_only);
|
||||
int mesh_add_pre_branch_sections(plant_branch *br, struct vertex *v, int y);
|
||||
int mesh_add_post_branch_sections(plant_branch *br, struct vertex *v, int y);
|
||||
int mesh_add_section(struct vertex *v, int y, b2Vec2 position, b2Vec2 axis, float width);
|
||||
int update_mesh(plant_section *s, struct plant_vert *v, int y, bool search_only);
|
||||
int mesh_add_pre_branch_sections(plant_branch *br, struct plant_vert *v, int y);
|
||||
int mesh_add_post_branch_sections(plant_branch *br, struct plant_vert *v, int y);
|
||||
int mesh_add_section(struct plant_vert *v, int y, b2Vec2 position, b2Vec2 axis, float width);
|
||||
|
||||
void settle();
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ struct tms_gbuffer *ibuf;
|
|||
polygon *slots[MAX_POLYGONS];
|
||||
bool modified; /* if the vertex buffer has been modified */
|
||||
|
||||
struct vertex {
|
||||
struct poly_vert {
|
||||
tvec3 pos;
|
||||
tvec3 nor;
|
||||
tvec3 col;
|
||||
|
|
@ -18,7 +18,7 @@ struct vertex {
|
|||
void
|
||||
polygon::_init()
|
||||
{
|
||||
vbuf = tms_gbuffer_alloc(20 * MAX_POLYGONS * sizeof(struct vertex));
|
||||
vbuf = tms_gbuffer_alloc(20 * MAX_POLYGONS * sizeof(struct poly_vert));
|
||||
vbuf->usage = GL_STATIC_DRAW;
|
||||
|
||||
ibuf = tms_gbuffer_alloc(90 * MAX_POLYGONS * sizeof(uint16_t));
|
||||
|
|
@ -351,7 +351,7 @@ polygon::update_mesh()
|
|||
return;
|
||||
}
|
||||
|
||||
struct vertex *v = (struct vertex*)tms_gbuffer_get_buffer(vbuf);
|
||||
poly_vert *v = (poly_vert *)tms_gbuffer_get_buffer(vbuf);
|
||||
v += this->slot*20;
|
||||
|
||||
float depth = (std::min((int)this->properties[0].v.i8, 3)+1.f) * .25f;
|
||||
|
|
|
|||
16
src/rope.cc
16
src/rope.cc
|
|
@ -21,7 +21,7 @@ static tms::gbuffer *ibuf = 0;
|
|||
|
||||
static volatile int counter = 1;
|
||||
|
||||
struct vertex {
|
||||
struct rope_vert {
|
||||
tvec3 pos;
|
||||
tvec3 nor;
|
||||
tvec2 tex;
|
||||
|
|
@ -35,7 +35,7 @@ rope::_init()
|
|||
|
||||
b2Vec2 dir;
|
||||
|
||||
buf = new tms::gbuffer(MAX_ROPES * ROPE_LENGTH * QUALITY * sizeof(struct vertex));
|
||||
buf = new tms::gbuffer(MAX_ROPES * ROPE_LENGTH * QUALITY * sizeof(struct rope_vert));
|
||||
ibuf = new tms::gbuffer(MAX_ROPES * (ROPE_LENGTH-1) * (QUALITY) * 6 * sizeof(short));
|
||||
|
||||
buf->usage = GL_STREAM_DRAW;
|
||||
|
|
@ -54,7 +54,7 @@ rope::_init()
|
|||
tmat4_load_identity(_e->M);
|
||||
tmat3_load_identity(_e->N);
|
||||
|
||||
struct vertex *v = (struct vertex*)buf->get_buffer();
|
||||
rope_vert *v = (rope_vert *)buf->get_buffer();
|
||||
short *id = (short*)ibuf->get_buffer();
|
||||
|
||||
int num_i = 0;
|
||||
|
|
@ -151,7 +151,7 @@ rope::upload_buffers(void)
|
|||
_mesh->i_start = 0;
|
||||
_mesh->i_count = counter*(ibuf->size/MAX_ROPES) / sizeof(uint16_t);
|
||||
if (counter)
|
||||
buf->upload_partial(counter * QUALITY * ROPE_LENGTH * sizeof(struct vertex));
|
||||
buf->upload_partial(counter * QUALITY * ROPE_LENGTH * sizeof(struct rope_vert));
|
||||
//ibuf->upload();
|
||||
}
|
||||
|
||||
|
|
@ -406,8 +406,8 @@ rope::ghost_update(void)
|
|||
|
||||
if (this->num >= MAX_ROPES) this->num = MAX_ROPES-1;
|
||||
|
||||
int base = this->num*(((buf->size/MAX_ROPES))/sizeof(struct vertex));
|
||||
struct vertex *v = ((struct vertex*)buf->get_buffer()) + base;
|
||||
int base = this->num*(((buf->size/MAX_ROPES))/sizeof(struct rope_vert));
|
||||
rope_vert *v = ((rope_vert *)buf->get_buffer()) + base;
|
||||
|
||||
this->refresh_predef_form();
|
||||
|
||||
|
|
@ -506,8 +506,8 @@ rope::update(void)
|
|||
|
||||
if (this->num >= MAX_ROPES) this->num = MAX_ROPES-1;
|
||||
|
||||
int base = this->num*(((buf->size/MAX_ROPES))/sizeof(struct vertex));
|
||||
struct vertex *v = ((struct vertex*)buf->get_buffer()) + base;
|
||||
int base = this->num*(((buf->size/MAX_ROPES))/sizeof(struct rope_vert));
|
||||
rope_vert *v = ((rope_vert *)buf->get_buffer()) + base;
|
||||
|
||||
float step = (M_PI*2.f) / (float)QUALITY;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@ static tms::entity *e2;
|
|||
static int n = 0;
|
||||
static int n2 = 0;
|
||||
|
||||
struct vert {
|
||||
struct spritebuf_vert {
|
||||
tvec3 pos;
|
||||
tvec2 uv;
|
||||
tvec4 color;
|
||||
};
|
||||
|
||||
static struct vert base[4];
|
||||
static spritebuf_vert base[4];
|
||||
|
||||
void spritebuffer::reset()
|
||||
{
|
||||
|
|
@ -67,10 +67,10 @@ void spritebuffer::_init()
|
|||
{
|
||||
tms_infof("Initializing spritebuffer...");
|
||||
|
||||
verts = new tms::gbuffer(4*SPRITEBUFFER_MAX*sizeof(struct vert));
|
||||
verts = new tms::gbuffer(4*SPRITEBUFFER_MAX*sizeof(struct spritebuf_vert));
|
||||
verts->usage = TMS_GBUFFER_STREAM_DRAW;
|
||||
|
||||
verts2 = new tms::gbuffer(4*SPRITEBUFFER_MAX*sizeof(struct vert));
|
||||
verts2 = new tms::gbuffer(4*SPRITEBUFFER_MAX*sizeof(struct spritebuf_vert));
|
||||
verts2->usage = TMS_GBUFFER_STREAM_DRAW;
|
||||
|
||||
indices = new tms::gbuffer(6*SPRITEBUFFER_MAX*sizeof(uint16_t));
|
||||
|
|
@ -102,22 +102,22 @@ void spritebuffer::_init()
|
|||
|
||||
indices->upload();
|
||||
|
||||
base[0] = (struct vert){
|
||||
base[0] = (spritebuf_vert){
|
||||
(tvec3){.5f,.5f,0.f},
|
||||
(tvec2){.5f, 1.f},
|
||||
(tvec4){0.f, 0.f, 0.f, 0.f},
|
||||
};
|
||||
base[1] = (struct vert){
|
||||
base[1] = (spritebuf_vert){
|
||||
(tvec3){-.5f,.5f,0.f},
|
||||
(tvec2){0.f, 1.f},
|
||||
(tvec4){0.f, 0.f, 0.f, 0.f},
|
||||
};
|
||||
base[2] = (struct vert){
|
||||
base[2] = (spritebuf_vert){
|
||||
(tvec3){-.5f,-.5f,0.f},
|
||||
(tvec2){0.f, .75f},
|
||||
(tvec4){0.f, 0.f, 0.f, 0.f},
|
||||
};
|
||||
base[3] = (struct vert){
|
||||
base[3] = (spritebuf_vert){
|
||||
(tvec3){.5f,-.5f,0.f},
|
||||
(tvec2){.5f, .75f},
|
||||
(tvec4){0.f, 0.f, 0.f, 0.f},
|
||||
|
|
@ -135,7 +135,7 @@ spritebuffer::add(float x, float y, float z,
|
|||
tmath_sincos(rot, &sn, &cs);
|
||||
|
||||
if (n < SPRITEBUFFER_MAX) {
|
||||
struct vert *_b = (struct vert*)verts->get_buffer();
|
||||
spritebuf_vert *_b = (spritebuf_vert*)verts->get_buffer();
|
||||
for (int ix=0; ix<4; ix++) {
|
||||
_b[n*4+ix] = base[ix];
|
||||
|
||||
|
|
@ -169,7 +169,7 @@ spritebuffer::add(float x, float y, float z,
|
|||
float w, float h, int sprite)
|
||||
{
|
||||
if (n < SPRITEBUFFER_MAX) {
|
||||
struct vert *_b = (struct vert*)verts->get_buffer();
|
||||
spritebuf_vert *_b = (spritebuf_vert*)verts->get_buffer();
|
||||
for (int ix=0; ix<4; ix++) {
|
||||
_b[n*4+ix] = base[ix];
|
||||
|
||||
|
|
@ -201,7 +201,7 @@ spritebuffer::add2(float x, float y, float z,
|
|||
tmath_sincos(rot, &sn, &cs);
|
||||
|
||||
if (n2 < SPRITEBUFFER_MAX) {
|
||||
struct vert *_b = (struct vert*)verts2->get_buffer();
|
||||
spritebuf_vert *_b = (spritebuf_vert*)verts2->get_buffer();
|
||||
for (int ix=0; ix<4; ix++) {
|
||||
_b[n2*4+ix] = base[ix];
|
||||
|
||||
|
|
@ -235,7 +235,7 @@ spritebuffer::add2(float x, float y, float z,
|
|||
float w, float h, int sprite)
|
||||
{
|
||||
if (n2 < SPRITEBUFFER_MAX) {
|
||||
struct vert *_b = (struct vert*)verts2->get_buffer();
|
||||
spritebuf_vert *_b = (spritebuf_vert*)verts2->get_buffer();
|
||||
for (int ix=0; ix<4; ix++) {
|
||||
_b[n2*4+ix] = base[ix];
|
||||
|
||||
|
|
@ -268,7 +268,7 @@ void spritebuffer::upload()
|
|||
mesh2->i_start = 0;
|
||||
mesh2->i_count = n2*6;
|
||||
}
|
||||
if (n) verts->upload_partial(n*4*sizeof(struct vert));
|
||||
if (n2) verts2->upload_partial(n2*4*sizeof(struct vert));
|
||||
if (n) verts->upload_partial(n*4*sizeof(struct spritebuf_vert));
|
||||
if (n2) verts2->upload_partial(n2*4*sizeof(struct spritebuf_vert));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,22 +14,22 @@ static tms::entity *e2;
|
|||
static int n = 0;
|
||||
static int n2 = 0;
|
||||
|
||||
struct vert {
|
||||
struct textbuf_vert {
|
||||
tvec3 pos;
|
||||
tvec2 uv;
|
||||
tvec4 color;
|
||||
};
|
||||
|
||||
static struct vert base[4];
|
||||
static textbuf_vert base[4];
|
||||
|
||||
void textbuffer::_init()
|
||||
{
|
||||
tms_infof("Initializing textbuffer...");
|
||||
|
||||
verts = new tms::gbuffer(4*TEXTBUFFER_MAX*sizeof(struct vert));
|
||||
verts = new tms::gbuffer(4*TEXTBUFFER_MAX*sizeof(struct textbuf_vert));
|
||||
verts->usage = TMS_GBUFFER_STREAM_DRAW;
|
||||
|
||||
verts2 = new tms::gbuffer(4*TEXTBUFFER_MAX*sizeof(struct vert));
|
||||
verts2 = new tms::gbuffer(4*TEXTBUFFER_MAX*sizeof(struct textbuf_vert));
|
||||
verts2->usage = TMS_GBUFFER_STREAM_DRAW;
|
||||
|
||||
indices = new tms::gbuffer(6*TEXTBUFFER_MAX*sizeof(uint16_t));
|
||||
|
|
@ -61,22 +61,22 @@ void textbuffer::_init()
|
|||
|
||||
indices->upload();
|
||||
|
||||
base[0] = (struct vert){
|
||||
base[0] = (textbuf_vert){
|
||||
(tvec3){.5f,.5f,0.f},
|
||||
(tvec2){.5f, 1.f},
|
||||
(tvec4){0.f, 0.f, 0.f, 0.f},
|
||||
};
|
||||
base[1] = (struct vert){
|
||||
base[1] = (textbuf_vert){
|
||||
(tvec3){-.5f,.5f,0.f},
|
||||
(tvec2){0.f, 1.f},
|
||||
(tvec4){0.f, 0.f, 0.f, 0.f},
|
||||
};
|
||||
base[2] = (struct vert){
|
||||
base[2] = (textbuf_vert){
|
||||
(tvec3){-.5f,-.5f,0.f},
|
||||
(tvec2){0.f, .5f},
|
||||
(tvec4){0.f, 0.f, 0.f, 0.f},
|
||||
};
|
||||
base[3] = (struct vert){
|
||||
base[3] = (textbuf_vert){
|
||||
(tvec3){.5f,-.5f,0.f},
|
||||
(tvec2){.5f, .5f},
|
||||
(tvec4){0.f, 0.f, 0.f, 0.f},
|
||||
|
|
@ -104,8 +104,8 @@ textbuffer::upload()
|
|||
mesh2->i_count = n2*6;
|
||||
}
|
||||
|
||||
if (n) verts->upload_partial(n*4*sizeof(struct vert));
|
||||
if (n2) verts2->upload_partial(n2*4*sizeof(struct vert));
|
||||
if (n) verts->upload_partial(n*4*sizeof(struct textbuf_vert));
|
||||
if (n2) verts2->upload_partial(n2*4*sizeof(struct textbuf_vert));
|
||||
}
|
||||
|
||||
tms::entity *
|
||||
|
|
@ -168,7 +168,7 @@ textbuffer::add_char(glyph *gl,
|
|||
tvec2 uvt = {(float)tx / TEX_WIDTH, (float)ty / TEX_HEIGHT};
|
||||
|
||||
if (n < TEXTBUFFER_MAX) {
|
||||
struct vert *_b = (struct vert*)verts->get_buffer();
|
||||
textbuf_vert *_b = (textbuf_vert *)verts->get_buffer();
|
||||
for (int ix=0; ix<4; ix++) {
|
||||
_b[n*4+ix] = base[ix];
|
||||
|
||||
|
|
@ -202,7 +202,7 @@ textbuffer::add_bg(
|
|||
float w, float h)
|
||||
{
|
||||
if (n < TEXTBUFFER_MAX) {
|
||||
struct vert *_b = (struct vert*)verts->get_buffer();
|
||||
textbuf_vert *_b = (textbuf_vert *)verts->get_buffer();
|
||||
for (int ix=0; ix<4; ix++) {
|
||||
_b[n*4+ix] = base[ix];
|
||||
|
||||
|
|
@ -245,7 +245,7 @@ textbuffer::add_char2(glyph *gl,
|
|||
tvec2 uvt = {(float)tx / TEX_WIDTH, (float)ty / TEX_HEIGHT};
|
||||
|
||||
if (n2 < TEXTBUFFER_MAX) {
|
||||
struct vert *_b = (struct vert*)verts2->get_buffer();
|
||||
textbuf_vert *_b = (textbuf_vert *)verts2->get_buffer();
|
||||
for (int ix=0; ix<4; ix++) {
|
||||
_b[n2*4+ix] = base[ix];
|
||||
|
||||
|
|
|
|||
|
|
@ -180,18 +180,12 @@ struct tpixel_material tpixel_materials[NUM_TPIXEL_MATERIALS] = {
|
|||
bool tpixel::initialized = false;
|
||||
static bool _modified = false;
|
||||
|
||||
struct vertex {
|
||||
struct tpixel_vert {
|
||||
tvec3 pos;
|
||||
tvec3 nor;
|
||||
tvec2 uv;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct cvert {
|
||||
tvec3 p;
|
||||
tvec3 n;
|
||||
tvec2 u;
|
||||
} __attribute__((packed));
|
||||
|
||||
static struct tms_mesh *_mesh[3];
|
||||
static struct tms_entity *_e[3];
|
||||
static tms::varray *_va[3];
|
||||
|
|
@ -225,7 +219,7 @@ tpixel::initialize()
|
|||
|
||||
for (int x=0; x<3; x++) {
|
||||
|
||||
_buf[x] = new tms::gbuffer(MAX_TPIXELS * vertices_per_tpixel * sizeof(struct vertex));
|
||||
_buf[x] = new tms::gbuffer(MAX_TPIXELS * vertices_per_tpixel * sizeof(struct tpixel_vert));
|
||||
_buf[x]->usage = GL_STREAM_DRAW;
|
||||
|
||||
_va[x] = new tms::varray(3);
|
||||
|
|
@ -294,7 +288,7 @@ tpixel::upload_buffers(void)
|
|||
_mesh[x]->i_count = (count*indices_per_tpixel);
|
||||
|
||||
if (count)
|
||||
_buf[x]->upload_partial((count*vertices_per_tpixel) * sizeof(struct vertex));
|
||||
_buf[x]->upload_partial((count*vertices_per_tpixel) * sizeof(struct tpixel_vert));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -464,7 +458,7 @@ tpixel::update()
|
|||
int num = __sync_fetch_and_add(&_counter[l], 1);
|
||||
|
||||
int base = (num*vertices_per_tpixel);
|
||||
struct vertex *v = ((struct vertex*)_buf[l]->get_buffer());
|
||||
tpixel_vert *v = ((tpixel_vert*)_buf[l]->get_buffer());
|
||||
v += base;
|
||||
|
||||
struct tms_mesh *mm = mesh_factory::get_mesh(MODEL_BOX_TEX);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,16 @@
|
|||
#pragma once
|
||||
|
||||
#include "tms/math/vector.h"
|
||||
#include <stdint.h>
|
||||
|
||||
class entity;
|
||||
|
||||
struct cvert {
|
||||
tvec3 p;
|
||||
tvec3 n;
|
||||
tvec2 u;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct chunk_pos {
|
||||
int x, y;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue