Add a variation of the addentity builtin, for explicit light levels.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@6278 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2022-06-26 08:08:50 +00:00
parent 81ab9277ac
commit 304079e1dc
3 changed files with 48 additions and 1 deletions

View File

@ -1096,6 +1096,29 @@ static void QCBUILTIN PF_R_AddEntity(pubprogfuncs_t *prinst, struct globalvars_s
V_AddAxisEntity(&ent);
}
}
static void QCBUILTIN PF_R_AddEntityLighting(pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
csqcedict_t *in = (void*)G_EDICT(prinst, OFS_PARM0);
entity_t ent;
if (ED_ISFREE(in) || in->entnum == 0)
{
csqc_deprecated("Tried drawing a free/removed/world entity\n");
return;
}
if (CopyCSQCEdictToEntity(in, &ent))
{
ent.light_known = true;
VectorCopy(G_VECTOR(OFS_PARM1), ent.light_dir);
VectorCopy(G_VECTOR(OFS_PARM2), ent.light_avg);
VectorCopy(G_VECTOR(OFS_PARM3), ent.light_range);
CLQ1_AddShadow(&ent);
V_AddAxisEntity(&ent);
}
}
static void QCBUILTIN PF_R_RemoveEntity(pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
csqcedict_t *in = (void*)G_EDICT(prinst, OFS_PARM0);
@ -7206,6 +7229,8 @@ static struct {
{"clearscene", PF_R_ClearScene, 300}, // #300 void() clearscene (EXT_CSQC)
{"addentities", PF_R_AddEntityMask, 301}, // #301 void(float mask) addentities (EXT_CSQC)
{"addentity", PF_R_AddEntity, 302}, // #302 void(entity ent) addentity (EXT_CSQC)
{"addentity_lighting", PF_R_AddEntityLighting, 0},
{"removeentity", PF_R_RemoveEntity, 0},
{"setproperty", PF_R_SetViewFlag, 303}, // #303 float(float property, ...) setproperty (EXT_CSQC)
{"renderscene", PF_R_RenderScene, 304}, // #304 void() renderscene (EXT_CSQC)

View File

@ -2199,6 +2199,26 @@ static void QCBUILTIN PF_m_addentity(pubprogfuncs_t *prinst, struct globalvars_s
if (CopyMenuEdictToEntity(prinst, in, &ent))
V_AddAxisEntity(&ent);
}
static void QCBUILTIN PF_m_addentity_lighting(pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
menuedict_t *in = (void*)G_EDICT(prinst, OFS_PARM0);
entity_t ent;
if (in->ereftype == ER_FREE || in->entnum == 0)
{
Con_Printf("Tried drawing a free/removed/world entity\n");
return;
}
if (CopyMenuEdictToEntity(prinst, in, &ent))
{
ent.light_known = true;
VectorCopy(G_VECTOR(OFS_PARM1), ent.light_dir);
VectorCopy(G_VECTOR(OFS_PARM2), ent.light_avg);
VectorCopy(G_VECTOR(OFS_PARM3), ent.light_range);
V_AddAxisEntity(&ent);
}
}
static void QCBUILTIN PF_m_renderscene(pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
V_ApplyRefdef();
@ -2465,6 +2485,7 @@ static struct {
{"clearscene", PF_m_clearscene, 300},
// {"addentities", PF_Fixme, 301},
{"addentity", PF_m_addentity, 302},//FIXME: needs setmodel, origin, angles, colormap(eep), frame etc, skin,
{"addentity_lighting", PF_m_addentity_lighting, 0},
#ifdef CSQC_DAT
{"setproperty", PF_R_SetViewFlag, 303},//should be okay to share
#endif

View File

@ -11619,7 +11619,8 @@ static BuiltinList_t BuiltinList[] = { //nq qw h2 ebfs
{"clearscene", PF_Fixme, 0, 0, 0, 300, D("void()", "Forgets all rentities, polygons, and temporary dlights. Resets all view properties to their default values.")},// (EXT_CSQC)
{"addentities", PF_Fixme, 0, 0, 0, 301, D("void(float mask)", "Walks through all entities effectively doing this:\n if (ent.drawmask&mask){ if (!ent.predaw()) addentity(ent); }\nIf mask&MASK_DELTA, non-csqc entities, particles, and related effects will also be added to the rentity list.\n If mask&MASK_STDVIEWMODEL then the default view model will also be added.")},// (EXT_CSQC)
{"addentity", PF_Fixme, 0, 0, 0, 302, D("void(entity ent)", "Copies the entity fields into a new rentity for later rendering via addscene.")},// (EXT_CSQC)
{"removeentity", PF_Fixme, 0, 0, 0, 0, D("void(entity ent)", "Undoes all addentities added to the scene from the given entity, without removing ALL entities (useful for splitscreen/etc, readd modified versions as desired).")},// (EXT_CSQC)
{"addentity_lighting",PF_Fixme, 0, 0, 0, 0, D("void(entity ent, vector lightdir, vector lightavg, vector lightrange, int reserved1=0,void*reserved2=0)", "Copies the entity fields into a new rentity for later rendering via addscene, but with explicit lighting info.")},
{"removeentity", PF_Fixme, 0, 0, 0, 0, D("void(entity ent)", "Undoes all addentities added to the scene from the given entity, without removing ALL entities (useful for splitscreen/etc, readd modified versions as desired).")},
{"addtrisoup_simple",PF_Fixme, 0, 0, 0, 0, D("typedef float vec2[2];\ntypedef float vec3[3];\ntypedef float vec4[4];\ntypedef struct trisoup_simple_vert_s {vec3 xyz;vec2 st;vec4 rgba;} trisoup_simple_vert_t;\nvoid(string texturename, int flags, struct trisoup_simple_vert_s *verts, int *indexes, int numindexes)", "Adds the specified trisoup into the scene as additional geometry. This permits caching geometry to reduce builtin spam. Indexes are a triangle list (so eg quads will need 6 indicies to form two triangles). NOTE: this is not going to be a speedup over polygons if you're still generating lots of new data every frame.")},
{"setproperty", PF_Fixme, 0, 0, 0, 303, D("#define setviewprop setproperty\nfloat(float property, ...)", "Allows you to override default view properties like viewport, fov, and whether the engine hud will be drawn. Different VF_ values have slightly different arguments, some are vectors, some floats.")},// (EXT_CSQC)
{"renderscene", PF_Fixme, 0, 0, 0, 304, D("void()", "Draws all entities, polygons, and particles on the rentity list (which were added via addentities or addentity), using the various view properties set via setproperty. There is no ordering dependancy.\nThe scene must generally be cleared again before more entities are added, as entities will persist even over to the next frame.\nYou may call this builtin multiple times per frame, but should only be called from CSQC_UpdateView.")},// (EXT_CSQC)