light: convert light.c to light.cc
This commit is contained in:
parent
3056971ae6
commit
f641e93ca2
|
|
@ -25,6 +25,10 @@
|
|||
#include <common/cmdlib.h>
|
||||
#include <common/log.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* upper design bounds */
|
||||
|
||||
#define MAX_MAP_HULLS_Q1 4
|
||||
|
|
@ -469,4 +473,8 @@ void ConvertBSPFormat(int32_t version, bspdata_t *bspdata);
|
|||
void BSPX_AddLump(bspdata_t *bspdata, const char *xname, const void *xdata, size_t xsize);
|
||||
const void *BSPX_GetLump(bspdata_t *bspdata, const char *xname, size_t *xsize);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __COMMON_BSPFILE_H__ */
|
||||
|
|
|
|||
|
|
@ -29,6 +29,10 @@
|
|||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define stringify__(x) #x
|
||||
#define stringify(x) stringify__(x)
|
||||
|
||||
|
|
@ -141,4 +145,8 @@ void Q_CopyFile(const char *from, char *to);
|
|||
extern qboolean archive;
|
||||
extern char archivedir[1024];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __COMMON_CMDLIB_H__ */
|
||||
|
|
|
|||
|
|
@ -30,6 +30,10 @@
|
|||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef __GNUC__
|
||||
#define __attribute__(x)
|
||||
#endif
|
||||
|
|
@ -51,4 +55,8 @@ void logprint_silent(const char *fmt, ...)
|
|||
void logprint_locked__(const char *fmt, ...)
|
||||
__attribute__((format(printf,1,2)));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __COMMON_LOG_H__ */
|
||||
|
|
|
|||
|
|
@ -23,6 +23,10 @@
|
|||
#include <float.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef DOUBLEVEC_T
|
||||
#define vec_t double
|
||||
#define VECT_MAX DBL_MAX;
|
||||
|
|
@ -135,4 +139,8 @@ double VectorLength(const vec3_t v);
|
|||
const char *VecStr(const vec3_t vec);
|
||||
const char *VecStrf(const vec3_t vec);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __COMMON_MATHLIB_H__ */
|
||||
|
|
|
|||
|
|
@ -3,6 +3,10 @@
|
|||
#ifndef __COMMON_THREADS_H__
|
||||
#define __COMMON_THREADS_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern int numthreads;
|
||||
|
||||
void LowerProcessPriority(void);
|
||||
|
|
@ -17,4 +21,8 @@ void ThreadUnlock(void);
|
|||
/* Call if needing to print to stdout - should be called with lock held */
|
||||
void InterruptThreadProgress__(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __COMMON_THREADS_H__ */
|
||||
|
|
|
|||
|
|
@ -24,6 +24,10 @@
|
|||
#include <common/bspfile.h>
|
||||
#include <light/light.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define DEFAULTLIGHTLEVEL 300
|
||||
|
||||
typedef struct epair_s {
|
||||
|
|
@ -128,4 +132,8 @@ void LoadEntities(const bsp2_t *bsp);
|
|||
void SetupLights(const bsp2_t *bsp);
|
||||
void WriteEntitiesToString(bsp2_t *bsp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __LIGHT_ENTITIES_H__ */
|
||||
|
|
|
|||
|
|
@ -27,6 +27,10 @@
|
|||
#include <common/threads.h>
|
||||
#include <light/litfile.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ON_EPSILON 0.1
|
||||
#define ANGLE_EPSILON 0.001
|
||||
|
||||
|
|
@ -238,4 +242,8 @@ extern qboolean phongDebug;
|
|||
|
||||
extern char mapfilename[1024];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __LIGHT_LIGHT_H__ */
|
||||
|
|
|
|||
|
|
@ -22,6 +22,10 @@
|
|||
|
||||
#include <common/bspfile.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define LIT_VERSION 1
|
||||
|
||||
typedef struct litheader_s {
|
||||
|
|
@ -46,4 +50,8 @@ typedef struct {
|
|||
void WriteLitFile(const bsp2_t *bsp, facesup_t *facesup, const char *filename, int version);
|
||||
void WriteLuxFile(const bsp2_t *bsp, const char *filename, int version);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __LIGHT_LITFILE_H__ */
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ set(LIGHT_SOURCES
|
|||
litfile.c
|
||||
ltface.c
|
||||
trace.c
|
||||
light.c
|
||||
light.cc
|
||||
${CMAKE_SOURCE_DIR}/common/bspfile.c
|
||||
${CMAKE_SOURCE_DIR}/common/cmdlib.c
|
||||
${CMAKE_SOURCE_DIR}/common/mathlib.c
|
||||
|
|
@ -22,5 +22,7 @@ set(LIGHT_SOURCES
|
|||
|
||||
add_executable(light ${LIGHT_SOURCES})
|
||||
target_link_libraries (light ${CMAKE_THREAD_LIBS_INIT})
|
||||
set_property(TARGET light PROPERTY CXX_STANDARD 11)
|
||||
set_property(TARGET light PROPERTY CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
install(TARGETS light RUNTIME DESTINATION bin)
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ static void *
|
|||
LightThread(void *arg)
|
||||
{
|
||||
int facenum, i;
|
||||
const bsp2_t *bsp = arg;
|
||||
const bsp2_t *bsp = (const bsp2_t *)arg;
|
||||
const modelinfo_t *face_modelinfo;
|
||||
struct ltface_ctx *ctx;
|
||||
|
||||
|
|
@ -203,7 +203,7 @@ FindModelInfo(const bsp2_t *bsp, const char *lmscaleoverride)
|
|||
modelinfo_t *info;
|
||||
float lightmapscale;
|
||||
|
||||
shadowmodels = malloc(sizeof(dmodel_t *) * (bsp->nummodels + 1));
|
||||
shadowmodels = (const dmodel_t **)malloc(sizeof(dmodel_t *) * (bsp->nummodels + 1));
|
||||
memset(shadowmodels, 0, sizeof(dmodel_t *) * (bsp->nummodels + 1));
|
||||
|
||||
/* The world always casts shadows */
|
||||
|
|
@ -335,7 +335,7 @@ CalcualateVertexNormals(const bsp2_t *bsp)
|
|||
bsp2_dface_t *f;
|
||||
vec3_t norm;
|
||||
|
||||
vertex_normals = malloc(sizeof(vec3_t) * bsp->numvertexes);
|
||||
vertex_normals = (vec3_t *)malloc(sizeof(vec3_t) * bsp->numvertexes);
|
||||
memset(vertex_normals, 0, sizeof(vec3_t) * bsp->numvertexes);
|
||||
|
||||
for (i = 0; i < bsp->numfaces; i++)
|
||||
|
|
@ -384,7 +384,7 @@ LightWorld(bspdata_t *bspdata, qboolean forcedscale)
|
|||
|
||||
/* FIXME - remove this limit */
|
||||
bsp->lightdatasize = MAX_MAP_LIGHTING;
|
||||
bsp->dlightdata = malloc(bsp->lightdatasize + 16); /* for alignment */
|
||||
bsp->dlightdata = (byte *)malloc(bsp->lightdatasize + 16); /* for alignment */
|
||||
if (!bsp->dlightdata)
|
||||
Error("%s: allocation of %i bytes failed.",
|
||||
__func__, bsp->lightdatasize);
|
||||
|
|
@ -401,7 +401,7 @@ LightWorld(bspdata_t *bspdata, qboolean forcedscale)
|
|||
lit_file_end = lit_filebase + 3 * (MAX_MAP_LIGHTING / 4);
|
||||
|
||||
/* lux data stored in a separate buffer */
|
||||
lux_buffer = malloc(bsp->lightdatasize*3);
|
||||
lux_buffer = (byte *)malloc(bsp->lightdatasize*3);
|
||||
lux_filebase = lux_buffer + 12 - ((uintptr_t)lux_buffer % 12);
|
||||
lux_file_p = lux_filebase;
|
||||
lux_file_end = lux_filebase + 3 * (MAX_MAP_LIGHTING / 4);
|
||||
|
|
@ -410,12 +410,12 @@ LightWorld(bspdata_t *bspdata, qboolean forcedscale)
|
|||
if (forcedscale)
|
||||
BSPX_AddLump(bspdata, "LMSHIFT", NULL, 0);
|
||||
|
||||
lmshift_lump = BSPX_GetLump(bspdata, "LMSHIFT", NULL);
|
||||
lmshift_lump = (const unsigned char *)BSPX_GetLump(bspdata, "LMSHIFT", NULL);
|
||||
if (!lmshift_lump && write_litfile != ~0)
|
||||
faces_sup = NULL; //no scales, no lit2
|
||||
else
|
||||
{ //we have scales or lit2 output. yay...
|
||||
faces_sup = malloc(sizeof(*faces_sup) * bsp->numfaces);
|
||||
faces_sup = (facesup_t *)malloc(sizeof(*faces_sup) * bsp->numfaces);
|
||||
memset(faces_sup, 0, sizeof(*faces_sup) * bsp->numfaces);
|
||||
if (lmshift_lump)
|
||||
{
|
||||
|
|
@ -440,8 +440,8 @@ LightWorld(bspdata_t *bspdata, qboolean forcedscale)
|
|||
|
||||
if (faces_sup)
|
||||
{
|
||||
uint8_t *styles = malloc(sizeof(*styles)*4*bsp->numfaces);
|
||||
int32_t *offsets = malloc(sizeof(*offsets)*bsp->numfaces);
|
||||
uint8_t *styles = (uint8_t *)malloc(sizeof(*styles)*4*bsp->numfaces);
|
||||
int32_t *offsets = (int32_t *)malloc(sizeof(*offsets)*bsp->numfaces);
|
||||
for (i = 0; i < bsp->numfaces; i++)
|
||||
{
|
||||
offsets[i] = faces_sup[i].lightofs;
|
||||
|
|
@ -676,7 +676,7 @@ main(int argc, const char **argv)
|
|||
|
||||
LoadEntities(bsp);
|
||||
|
||||
modelinfo = malloc(bsp->nummodels * sizeof(*modelinfo));
|
||||
modelinfo = (modelinfo_t *)malloc(bsp->nummodels * sizeof(*modelinfo));
|
||||
FindModelInfo(bsp, lmscaleoverride);
|
||||
SetupLights(bsp);
|
||||
|
||||
Loading…
Reference in New Issue