• Render.DrawBeam limit?
    3 replies, posted
Is there some kind of limit on [b][url=http://wiki.garrysmod.com/?title=Render.DrawBeam]Render.DrawBeam [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]? I'm writing some SEnts that use multiples Beams, and it seems to start breaking after about 10 are on screen. The SEnt is a laser grid, each beam utilizing a Trace to kill the player on touch (For an obstical course gamemode). Here's whats going on... [T]http://uploadingit.com/file/axmlzuj8dngtuakw/sent_trace_errors.png[/T]
Doing traces in rendering hooks CAN give very weird results.
Maybe its better to use at this point [url=http://wiki.garrysmod.com/?title=Util.TraceHull]util.TraceHull[/url] and give its maximum height/width instead of multiple lines.
[QUOTE=Wizard of Ass;34031053]Doing traces in rendering hooks CAN give very weird results.[/QUOTE] I'm not calling the traces on the client end, i'm doing so on the server under the Think() function. I store the start and end vectors in a couple NWVec's (which may be a bad practice, sorry) on the SEnt, then access them on the client side code (GetNWVector) to draw the beam. I figure its a limitation of either the render library, Source, or Garry's Mod. In that case, "damn." That or i'm doing something way wrong which is always a possibility. [editline]4th January 2012[/editline] Code- Server: [LUA]function ENT:Think() for i=1,5,1 do local pos = self:GetPos() - (self:GetForward() * 2) + Vector( 0, 0, self:CalculateBeamPosition(i * 0.25) + 75 ) local ang = self:GetRight() * -1 local trace = {} trace.start = pos trace.endpos = pos+(ang*self.Data.TraceDistance) trace.filter = self local tr = util.TraceLine(trace) if (tr.HitNonWorld && tr.Entity:IsPlayer()) then self:HurtPlayer(tr.Entity) end self:SetNetworkedVector("BeamDrawStart"..i, tr.StartPos) self:SetNetworkedVector("BeamDrawEnd"..i, tr.HitPos) end self:NextThink( CurTime() + 0.001 ) return true end function ENT:CalculateBeamPosition( offset ) local A = 75 local W = 1 local O = offset return A * math.sin(W * CurTime() - O) end[/LUA] Client: [LUA]function ENT:Draw() self:DrawModel() render.SetMaterial( Material( "trails/laser" ) ) render.DrawBeam( self:GetNetworkedVector("BeamDrawStart1"), self:GetNetworkedVector("BeamDrawEnd1"), 10, 1, 1, Color(110, 255, 255, 200) ) render.DrawBeam( self:GetNetworkedVector("BeamDrawStart2"), self:GetNetworkedVector("BeamDrawEnd2"), 10, 1, 1, Color(110, 255, 255, 200) ) render.DrawBeam( self:GetNetworkedVector("BeamDrawStart3"), self:GetNetworkedVector("BeamDrawEnd3"), 10, 1, 1, Color(110, 255, 255, 200) ) render.DrawBeam( self:GetNetworkedVector("BeamDrawStart4"), self:GetNetworkedVector("BeamDrawEnd4"), 10, 1, 1, Color(110, 255, 255, 200) ) render.DrawBeam( self:GetNetworkedVector("BeamDrawStart5"), self:GetNetworkedVector("BeamDrawEnd5"), 10, 1, 1, Color(110, 255, 255, 200) ) end[/LUA] [editline]4th January 2012[/editline] [QUOTE=Zeh Matt;34031235]Maybe its better to use at this point [url=http://wiki.garrysmod.com/?title=Util.TraceHull]util.TraceHull[/url] and give its maximum height/width instead of multiple lines.[/QUOTE] I would like to keep this functionality: [T]http://uploadingit.com/file/gfdkllaa7rvqzcy0/sent_laser_block.png[/T] Doing a single trace for all beams would stop them all short. Besides that, performance doesn't seem to be an issue, I've had multiples of the sent running with no performance hit. I haven't tested it on my dedi server yet, though.
Sorry, you need to Log In to post a reply to this thread.