qbsp: restore bspx brushes writing
This commit is contained in:
parent
1e6e938ead
commit
54799a11fc
|
|
@ -173,6 +173,7 @@ typedef struct mapdata_s {
|
||||||
// bspx data
|
// bspx data
|
||||||
std::vector<uint8_t> exported_lmshifts;
|
std::vector<uint8_t> exported_lmshifts;
|
||||||
bool needslmshifts = false;
|
bool needslmshifts = false;
|
||||||
|
std::vector<uint8_t> exported_bspxbrushes;
|
||||||
|
|
||||||
// helpers
|
// helpers
|
||||||
std::string texinfoTextureName(int texinfo) const {
|
std::string texinfoTextureName(int texinfo) const {
|
||||||
|
|
@ -222,11 +223,8 @@ int MakeFaceEdges(mapentity_t *entity, node_t *headnode);
|
||||||
void ExportClipNodes(mapentity_t *entity, node_t *headnode, const int hullnum);
|
void ExportClipNodes(mapentity_t *entity, node_t *headnode, const int hullnum);
|
||||||
void ExportDrawNodes(mapentity_t *entity, node_t *headnode, int firstface);
|
void ExportDrawNodes(mapentity_t *entity, node_t *headnode, int firstface);
|
||||||
|
|
||||||
struct bspxbrushes_s
|
struct bspxbrushes_s {
|
||||||
{
|
std::vector<uint8_t> lumpdata;
|
||||||
uint8_t *lumpinfo;
|
|
||||||
size_t lumpsize;
|
|
||||||
size_t lumpmaxsize;
|
|
||||||
};
|
};
|
||||||
void BSPX_Brushes_Finalize(struct bspxbrushes_s *ctx);
|
void BSPX_Brushes_Finalize(struct bspxbrushes_s *ctx);
|
||||||
void BSPX_Brushes_Init(struct bspxbrushes_s *ctx);
|
void BSPX_Brushes_Init(struct bspxbrushes_s *ctx);
|
||||||
|
|
|
||||||
31
qbsp/qbsp.cc
31
qbsp/qbsp.cc
|
|
@ -316,14 +316,21 @@ This lump replaces the clipnodes stuff for custom collision sizes.
|
||||||
*/
|
*/
|
||||||
void BSPX_Brushes_Finalize(struct bspxbrushes_s *ctx)
|
void BSPX_Brushes_Finalize(struct bspxbrushes_s *ctx)
|
||||||
{
|
{
|
||||||
//BSPX_AddLump("BRUSHLIST", ctx->lumpinfo, ctx->lumpsize); // FIXME: fix bspx
|
// Actually written in WriteBSPFile()
|
||||||
|
map.exported_bspxbrushes = std::move(ctx->lumpdata);
|
||||||
// free(ctx->lumpinfo);
|
|
||||||
}
|
}
|
||||||
void BSPX_Brushes_Init(struct bspxbrushes_s *ctx)
|
void BSPX_Brushes_Init(struct bspxbrushes_s *ctx)
|
||||||
{
|
{
|
||||||
memset(ctx, 0, sizeof(*ctx));
|
ctx->lumpdata.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
vec_push_bytes(std::vector<uint8_t>& vec, const void* data, size_t count) {
|
||||||
|
const uint8_t* bytes = static_cast<const uint8_t*>(data);
|
||||||
|
|
||||||
|
vec.insert(vec.end(), bytes, bytes + count);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
WriteBrushes
|
WriteBrushes
|
||||||
Generates a submodel's direct brush information to a separate file, so the engine doesn't need to depend upon specific hull sizes
|
Generates a submodel's direct brush information to a separate file, so the engine doesn't need to depend upon specific hull sizes
|
||||||
|
|
@ -372,18 +379,11 @@ void BSPX_Brushes_AddModel(struct bspxbrushes_s *ctx, int modelnum, brush_t *bru
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->lumpmaxsize < ctx->lumpsize + sizeof(permodel) + permodel.numbrushes*sizeof(perbrush) + permodel.numfaces*sizeof(perface))
|
|
||||||
{
|
|
||||||
ctx->lumpmaxsize = (ctx->lumpsize + sizeof(permodel) + permodel.numbrushes*sizeof(perbrush) + permodel.numfaces*sizeof(perface))*2;
|
|
||||||
ctx->lumpinfo = (uint8_t *) realloc(ctx->lumpinfo, ctx->lumpmaxsize);
|
|
||||||
}
|
|
||||||
|
|
||||||
permodel.ver = LittleLong(1);
|
permodel.ver = LittleLong(1);
|
||||||
permodel.modelnum = LittleLong(modelnum);
|
permodel.modelnum = LittleLong(modelnum);
|
||||||
permodel.numbrushes = LittleLong(permodel.numbrushes);
|
permodel.numbrushes = LittleLong(permodel.numbrushes);
|
||||||
permodel.numfaces = LittleLong(permodel.numfaces);
|
permodel.numfaces = LittleLong(permodel.numfaces);
|
||||||
memcpy(ctx->lumpinfo+ctx->lumpsize, &permodel, sizeof(permodel));
|
vec_push_bytes(ctx->lumpdata, &permodel, sizeof(permodel));
|
||||||
ctx->lumpsize += sizeof(permodel);
|
|
||||||
|
|
||||||
for (b = brushes; b; b = b->next)
|
for (b = brushes; b; b = b->next)
|
||||||
{
|
{
|
||||||
|
|
@ -428,8 +428,7 @@ void BSPX_Brushes_AddModel(struct bspxbrushes_s *ctx, int modelnum, brush_t *bru
|
||||||
}
|
}
|
||||||
perbrush.contents = LittleShort(perbrush.contents);
|
perbrush.contents = LittleShort(perbrush.contents);
|
||||||
perbrush.numfaces = LittleShort(perbrush.numfaces);
|
perbrush.numfaces = LittleShort(perbrush.numfaces);
|
||||||
memcpy(ctx->lumpinfo+ctx->lumpsize, &perbrush, sizeof(perbrush));
|
vec_push_bytes(ctx->lumpdata, &perbrush, sizeof(perbrush));
|
||||||
ctx->lumpsize += sizeof(perbrush);
|
|
||||||
|
|
||||||
for (f = b->faces; f; f = f->next)
|
for (f = b->faces; f; f = f->next)
|
||||||
{
|
{
|
||||||
|
|
@ -454,11 +453,11 @@ void BSPX_Brushes_AddModel(struct bspxbrushes_s *ctx, int modelnum, brush_t *bru
|
||||||
perface.dist = map.planes[f->planenum].dist;
|
perface.dist = map.planes[f->planenum].dist;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(ctx->lumpinfo+ctx->lumpsize, &perface, sizeof(perface));
|
vec_push_bytes(ctx->lumpdata, &perface, sizeof(perface));
|
||||||
ctx->lumpsize += sizeof(perface);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* for generating BRUSHLIST bspx lump */
|
/* for generating BRUSHLIST bspx lump */
|
||||||
static void BSPX_CreateBrushList(void)
|
static void BSPX_CreateBrushList(void)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -441,6 +441,9 @@ WriteBSPFile()
|
||||||
if (map.needslmshifts) {
|
if (map.needslmshifts) {
|
||||||
BSPX_AddLump(&bspdata, "LMSHIFT", map.exported_lmshifts.data(), map.exported_lmshifts.size());
|
BSPX_AddLump(&bspdata, "LMSHIFT", map.exported_lmshifts.data(), map.exported_lmshifts.size());
|
||||||
}
|
}
|
||||||
|
if (!map.exported_bspxbrushes.empty()) {
|
||||||
|
BSPX_AddLump(&bspdata, "BRUSHLIST", map.exported_bspxbrushes.data(), map.exported_bspxbrushes.size());
|
||||||
|
}
|
||||||
|
|
||||||
ConvertBSPFormat(&bspdata, options.target_version);
|
ConvertBSPFormat(&bspdata, options.target_version);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue