diff --git a/engine/client/pr_csqc.c b/engine/client/pr_csqc.c index 161e1912c..c4a7c7532 100644 --- a/engine/client/pr_csqc.c +++ b/engine/client/pr_csqc.c @@ -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) diff --git a/engine/client/pr_menu.c b/engine/client/pr_menu.c index a0e4788dc..2501424db 100644 --- a/engine/client/pr_menu.c +++ b/engine/client/pr_menu.c @@ -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 diff --git a/engine/server/pr_cmds.c b/engine/server/pr_cmds.c index 77be9443a..be1e5f6c7 100644 --- a/engine/server/pr_cmds.c +++ b/engine/server/pr_cmds.c @@ -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)