env_sun: Make pitch/angles compatible with Source's way of handling them.

This commit is contained in:
Marco Cawthorne 2020-11-24 02:24:30 +01:00
parent ce2b16bb2e
commit 31c7354dda
3 changed files with 23 additions and 7 deletions

View File

@ -619,13 +619,11 @@ CSQC_ConsoleCommand(string sCMD)
case "dev_sunpos":
vector sunpos;
vector sunang;
vector a = getproperty(VF_ANGLES);
makevectors(getproperty(VF_ANGLES));
sunpos = v_forward * -1;
sunang = vectoangles(sunpos);
localcmd(sprintf("r_shadows_throwdirection %v\n", sunpos));
print(sprintf("env_sun: pitch: %d; angle: %d\n", sunang[0], sunang[1]));
print(sprintf("light_environment: pitch %d; sunangle %d\n", a[0], a[1]));
print(sprintf("env_sun: pitch: %d; angle: %d\n", -sunang[0], sunang[1]));
break;
case "dev_measure":
static vector measurepos;

View File

@ -20,6 +20,7 @@ int trace_surfaceflagsi;
"targetname" Name
"pitch" Sun glow pitch.
"angle" Sun glow angle.
"use_angles" Use the 'angles' yaw value instead of the one from 'angle'.
STUB!
@ -47,6 +48,7 @@ class env_sun:CBaseEntity
{
vector m_vecLensPos;
float m_flLensAlpha;
int m_iUseAngles;
void(void) env_sun;
virtual void(void) Init;
@ -66,7 +68,17 @@ env_sun::predraw(void)
void
env_sun::postdraw(void)
{
makevectors(m_vecLensPos);
if (!m_iUseAngles)
makevectors(m_vecLensPos);
else {
vector ang;
ang = m_vecLensPos;
ang[1] = angles[1];
makevectors(ang);
}
v_forward *= -1;
vector lens_pos = getproperty(VF_ORIGIN) + (v_forward * 16384);
vector lens_1 = project(lens_pos) - (FLARE_SIZE / 2);
@ -115,6 +127,7 @@ env_sun::Initialized(void)
{
makevectors(m_vecLensPos);
m_vecLensPos = vectoangles(v_forward);
localcmd(sprintf("r_shadows_throwdirection %v\n", v_forward * -1));
}
void
@ -124,7 +137,9 @@ env_sun::env_sun(void)
precache_pic("textures/sfx/flare2");
precache_pic("textures/sfx/flare3");
precache_pic("textures/sfx/flare4");
solid = SOLID_NOT;
drawmask = MASK_ENGINE;
setsize(this, [0,0,0], [0,0,0]);
setorigin(this, origin);
Init();
}
@ -133,11 +148,14 @@ env_sun::SpawnKey(string strField, string strKey)
{
switch (strField) {
case "pitch":
m_vecLensPos[0] = stof(strKey);
m_vecLensPos[0] = -stof(strKey);
break;
case "angle":
m_vecLensPos[1] = stof(strKey);
break;
case "use_angles":
m_iUseAngles = stoi(strKey);
break;
default:
CBaseEntity::SpawnKey(strField, strKey);
}

View File

@ -38,7 +38,7 @@ ctrl_btnadvanced_start(void)
g_menupage = PAGE_ADVANCEDCONTROLS;
}
localsound("../media/launch_dnmenu1.wav");
localsound("../media/launch_dnmenu1.wav");
header.SetStartEndPos(50,172,45,45);
header.SetStartEndSize(156,26,460,80);
header.m_lerp = 0.0f;