Skip to content

Commit acc55ae

Browse files
authored
Merge pull request #226 from marchc1/misc-fixes
Misc fixes
2 parents 7b37b14 + 87ea92c commit acc55ae

36 files changed

Lines changed: 2429 additions & 24 deletions
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#version 460
2+
// STATIC: "VERTEXCOLOR" "0..1"
3+
// STATIC: "CONSTANTCOLOR" "0..1"
4+
// STATIC: "SRGB" "0..1"
5+
// DYNAMIC: "HDRENABLED" "0..1"
6+
// DYNAMIC: "PIXELFOGTYPE" "0..2"
7+
8+
layout(location = 0) in vec2 vs_BaseTexCoord;
9+
layout(location = 1) in vec4 vs_Color;
10+
layout(location = 2) in vec4 vs_WorldPos_ProjPosZ;
11+
12+
layout(std140, binding = 6) uniform source_ps_constants {
13+
vec4 ps_const[256];
14+
};
15+
16+
out vec4 fragColor;
17+
18+
#include "common_gl460.fs"
19+
20+
layout(binding = 0) uniform sampler2D TexSampler;
21+
22+
#define g_Color ps_const[0]
23+
#define g_HDRColorScale ps_const[1].x
24+
#define g_EyePos_SpecExponent ps_const[11]
25+
#define g_FogParams ps_const[12]
26+
27+
void main()
28+
{
29+
vec4 result;
30+
vec4 color = texture(TexSampler, vs_BaseTexCoord);
31+
32+
#if VERTEXCOLOR
33+
color *= vs_Color;
34+
#endif
35+
36+
#if CONSTANTCOLOR
37+
color *= g_Color;
38+
#endif
39+
40+
#if HDRENABLED
41+
color.xyz *= g_HDRColorScale;
42+
#endif
43+
44+
float fogFactor = CalcPixelFogFactor(PIXELFOGTYPE, g_FogParams, g_EyePos_SpecExponent.xyz, vs_WorldPos_ProjPosZ.xyz, vs_WorldPos_ProjPosZ.w);
45+
#if SRGB
46+
result = FinalOutput(color, fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR);
47+
#else
48+
result = FinalOutput(color, fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_GAMMA);
49+
#endif
50+
51+
fragColor = result;
52+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#version 460
2+
// STATIC: "VERTEXCOLOR" "0..1"
3+
// STATIC: "SRGB" "0..1"
4+
5+
layout(location = 0) in vec3 v_Position;
6+
layout(location = 2) in vec4 v_Color;
7+
layout(location = 10) in vec4 v_TexCoord0;
8+
9+
layout(std140, binding = 0) uniform source_matrices {
10+
mat4 viewMatrix;
11+
mat4 projectionMatrix;
12+
mat4 modelMatrix;
13+
};
14+
15+
#include "common_gl460.glsl"
16+
17+
layout(location = 0) out vec2 vs_BaseTexCoord;
18+
layout(location = 1) out vec4 vs_Color;
19+
layout(location = 2) out vec4 vs_WorldPos_ProjPosZ;
20+
21+
#include "common_clipplanes_gl460.vs"
22+
23+
void main()
24+
{
25+
vec3 worldPos = (modelMatrix * vec4(v_Position, 1.0)).xyz;
26+
27+
vec4 projPos = projectionMatrix * viewMatrix * vec4(worldPos, 1.0);
28+
gl_Position = projPos;
29+
WriteUserClipDistances(gl_Position);
30+
31+
vs_WorldPos_ProjPosZ = vec4(worldPos, projPos.z);
32+
33+
vs_Color = vec4(1.0);
34+
#if VERTEXCOLOR
35+
#if SRGB
36+
vs_Color = vec4(GammaToLinear(v_Color.rgb), v_Color.a);
37+
#else
38+
vs_Color = v_Color;
39+
#endif
40+
#endif
41+
42+
vs_BaseTexCoord = v_TexCoord0.xy;
43+
}

‎Game.Client/C_BaseAnimating.cs‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
using Source.Common.Formats.BSP;
1212
using Source.Common.Formats.Keyvalues;
1313
using Source.Common.Mathematics;
14+
using Source.Common.Physics;
1415

1516
using System;
17+
using System.Collections;
1618
using System.Drawing;
1719
using System.Linq;
1820
using System.Net.NetworkInformation;
@@ -177,6 +179,21 @@ public void StudioFrameAdvance() {
177179
GroundSpeed = (float)GetSequenceGroundSpeed(hdr, GetSequence()) * GetModelScale();
178180
}
179181

182+
public override int VPhysicsGetObjectList(Span<IPhysicsObject?> list){
183+
if (IsRagdoll()) {
184+
int i;
185+
for (i = 0; i < Ragdoll.RagdollBoneCount(); ++i) {
186+
if (i >= list.Length)
187+
break;
188+
189+
list[i] = Ragdoll.GetElement(i);
190+
}
191+
return i;
192+
}
193+
194+
return base.VPhysicsGetObjectList(list);
195+
}
196+
180197
public TimeUnit_t GetSequenceMoveDist(StudioHdr? studioHdr, int sequence) {
181198
Animation.GetSequenceLinearMotion(studioHdr, sequence, PoseParameter, out Vector3 vecReturn);
182199

@@ -828,7 +845,7 @@ public string GetSequenceName(int sequence) {
828845
return Animation.GetSequenceName(GetModelPtr(), sequence);
829846
}
830847

831-
public object? Ragdoll; // TODO
848+
public ClientRagdoll? Ragdoll = null;
832849

833850
public override void OnDataChanged(DataUpdateType updateType) {
834851
if (Ragdoll != null && GetSequence() != PrevSequence) {

‎Game.Client/C_BaseCombatWeapon.cs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
using Game.Client.HUD;
1+
using Game.Client.HUD;
22
using Game.Shared;
33

44
using Source;
55
using Source.Common;
6+
using Source.Common.Input;
67

78
using System.Runtime.CompilerServices;
89

@@ -20,6 +21,8 @@ public C_BaseCombatWeapon() {
2021
public virtual bool WasDropped() => Dropped;
2122
public virtual void SetDropped() => Dropped = true;
2223
public virtual void DrawHUD() { }
24+
public virtual bool ShouldFreezeViewAngles() => false;
25+
public virtual int KeyInput(int down, ButtonCode keynum, ReadOnlySpan<char> currentBinding) => 1;
2326
public virtual void DrawHUDBackground() { }
2427
public override bool IsWeapon() => true;
2528
public static BaseCombatWeapon? GetActiveWeapon() {

‎Game.Client/C_BaseEntity.cs‎

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,17 @@ public C_BaseEntity() {
957957
IPhysicsObject? PhysicsObject = null!;
958958
public void VPhysicsUpdate(IPhysicsObject physics) { }
959959
public IPhysicsObject? VPhysicsGetObject() => PhysicsObject;
960-
public int VPhysicsGetObjectList(Span<IPhysicsObject> list) => throw new NotImplementedException();
960+
public virtual int VPhysicsGetObjectList(Span<IPhysicsObject?> list) {
961+
IPhysicsObject? phys = VPhysicsGetObject();
962+
if (phys != null) {
963+
Assert((phys.GetGameFlags() & PhysicsFlags.MultiObjectEntity) == 0);
964+
if (list.Length > 0) {
965+
list[0] = phys;
966+
return 1;
967+
}
968+
}
969+
return 0;
970+
}
961971

962972
public bool IsFloating() => false;
963973

@@ -1241,8 +1251,17 @@ public void GetRenderBounds(out Vector3 mins, out Vector3 maxs) {
12411251
if (nModelType == ModelType.Studio || nModelType == ModelType.Brush)
12421252
modelinfo.GetModelRenderBounds(GetModel(), out mins, out maxs);
12431253
else {
1244-
// todo
1245-
mins = maxs = default;
1254+
if (GetRenderAngles() == CollisionProp().GetCollisionAngles()) {
1255+
mins = CollisionProp().OBBMins();
1256+
maxs = CollisionProp().OBBMaxs();
1257+
}
1258+
else {
1259+
Assert(CollisionProp().GetCollisionAngles() == vec3_angle);
1260+
if (CollisionProp().BoundingRadius() == 0.0f)
1261+
mins = maxs = vec3_origin;
1262+
else
1263+
MathLib.IRotateAABB(EntityToWorldTransform(), CollisionProp().OBBMins(), CollisionProp().OBBMaxs(), out mins, out maxs);
1264+
}
12461265
}
12471266
}
12481267

‎Game.Client/ClientModeShared.cs‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Game.Client.HUD;
1+
using Game.Client.HUD;
22
using Game.Shared;
33

44
using Source;
@@ -165,6 +165,15 @@ public virtual int KeyInput(int down, ButtonCode keynum, ReadOnlySpan<char> curr
165165
if (HudElementKeyInput(down, keynum, currentBinding) == 0)
166166
return 0;
167167

168+
#if GMOD_DLL
169+
if (surface.IsCursorVisible() && (keynum == ButtonCode.MouseWheelUp || keynum == ButtonCode.MouseWheelDown))
170+
return 0;
171+
#endif
172+
173+
BaseCombatWeapon? activeWeapon = C_BaseCombatWeapon.GetActiveWeapon();
174+
if (activeWeapon != null)
175+
return activeWeapon.KeyInput(down, keynum, currentBinding);
176+
168177
return 1;
169178
}
170179

‎Game.Client/ClientThinkList.cs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,12 @@ private void CleanUpDeleteList() {
287287
pEntity.SetRemovalFlag(false);
288288

289289
IClientThinkable? pThink = cl_entitylist.GetClientThinkableFromHandle(handle);
290-
if (pThink != null)
290+
if (pThink != null)
291291
pThink.Release();
292292
}
293293
}
294+
295+
DeleteList.Clear();
294296
}
295297

296298
private void AddEntityToFrameThinkList(ThinkEntry pEntry, bool bAlwaysChain, ref int count, Span<ThinkEntry> ppFrameThinkList) {

‎Game.Client/GarrysMod/C_GMOD_Player.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public partial class C_GMOD_Player() : C_HL2MP_Player()
7474
public Vector3 WeaponColor;
7575

7676
public virtual Vector3 GetPlayerColor() => PlayerColor;
77+
public virtual Vector3 GetWeaponColor() => WeaponColor;
7778

7879
public virtual void SetPlayerColor(in Vector3 color) {
7980
if (PlayerColor != color)

‎Game.Client/HLClient.cs‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -800,9 +800,7 @@ public void GMOD_OnDrawSkybox() {
800800
throw new NotImplementedException();
801801
}
802802

803-
public void IN_MouseWheelAnalog(int value) {
804-
throw new NotImplementedException();
805-
}
803+
public void IN_MouseWheelAnalog(int value) => input.MouseWheeled(value);
806804

807805
public void GMOD_SignOnStateChanged(int userID, int oldState, int newState) {
808806
throw new NotImplementedException();

‎Game.Client/IInput.cs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ public interface IInput
2020
void ExtraMouseSample(double frametime, bool active);
2121
void ActivateMouse();
2222
void DeactivateMouse();
23+
#if GMOD_DLL
24+
void MouseWheeled(int delta);
25+
#endif
2326
void ClearStates();
2427
void CAM_Think();
2528
ref UserCmd GetUserCmd(int sequenceNumber);

0 commit comments

Comments
 (0)