meetric1/GMod-Seamless-Portals

Client-side traces do not hit the portal

Closed this issue · 8 comments

Hello,

Consider the following code:

-- Configuring the trace
gtTRACE = {}
gtTRACE.mask == MASK_ALL
gtTRACE.funct == SeamlessPortals.TraceLine
gtTRACE.collisiongroup == COLLISION_GROUP_NONE

print(gtTRACE.mask == MASK_ALL,
      gtTRACE.funct == SeamlessPortals.TraceLine,
      gtTRACE.collisiongroup == COLLISION_GROUP_NONE)

-- Running the trace
local tr = gtTRACE.funct(gtTRACE)
-- Exctracting trace result
local target, iteration = tr.Entity, (tonumber(iteration) or 0) + 1
local ok, act = (target and target:IsValid()), target 
-- Print trace result
print(iteration, ok, act, target)

What the game prints:

SERVER
true	true	true
100	true	seamless_portal	Entity [358][seamless_portal]
true	true	true
99	true	seamless_portal	Entity [358][seamless_portal]
true	true	true
98	true	seamless_portal	Entity [358][seamless_portal]
CLIENT
true	true	true
97	false	nil	Entity [0][worldspawn]
true	true	true
100	false	nil	Entity [0][worldspawn]
true	true	true
100	false	nil	Entity [0][worldspawn]

Adding this has the same effect gtTRACE.collisiongroup = (COLLISION_GROUP_WORLD) according to the wiki https://wiki.facepunch.com/gmod/Structures/Trace

Both base and x64 branches work the same

The workshop version appears not to have this issue. Probably the WS version is a bit forward from github, @Mee12345

This happens again. This time with the WS version: trace_info.txt

    LaserLib.DrawPoint(trace.HitPos)

    LaserLib.Call(5, function()
      print()
      print("--------START----------")
      local t = table.Copy(gtTRACE)
      t.action = (SeamlessPortals.TraceLine == gtTRACE.action) and "SeamlessPortals.TraceLine" or "util.TraceLine"
      PrintTable(t)
      print("--------FINISH----------")
      PrintTable(trace)
      local p = ents.FindByClass("seamless_portal")
      if(p[1] and LaserLib.IsValid(p[1])) then
        print("--------PORTAL----------")
        PrintTable(p[1]:GetTable())
      end
    end)

--------START----------
filter	=	Entity [680][gmod_laser]
action	=	SeamlessPortals.TraceLine -- Library is available. Use the non-modified (original) trace
mask	=	4294967295 -- MASK_ALL
--------FINISH----------
Entity	=	Entity [0][worldspawn] -- Passes trough portal and hits the wall behind it
HitTexture	=	PLASTER/PLASTERWALL016A -- Map wall
--------PORTAL---------
GetSize	=	function: 0x01ea1e9fba70
GetExitPortal	=	function: 0x01ea7cde4f58
Entity	=	Entity [127][seamless_portal]
Folder	=	entities/seamless_portal
Category	=	Seamless Portals
ClassName	=	seamless_portal
Player	=	Player [1][[Sk$Bh]Trick or treat KID!]
PrintName	=	Seamless Portal

Also it seems that some functions are also changed:

  1. SP:ExitPortal() becomes ent:GetExitPortal() server side
  2. ent:GetExitSize() becomes ent:GetSize() both realms

20230305103554_1

yeah I see why.. ok so on the client in singleplayer the physics mesh of the portals is not initialized so that bullets travel through instead of hitting it (thank garry for making the bullet hook predicted)

im gonna see if I can initialize the physics object but add a flag on the client that lets bullets pass through it.. that should fix the issue

Yeah, I recall it used to hit it, so it makes sense if something got changed :)

I pushed a fix, tell me if you experience any perf changes or anything.. clientside traceline seems to work now

ill update workshop once you confirm it works

Yep, this fixes it! Client and server both hit it!

20230307224256_1

Made sure I am also not using the WS version
image
image