VisTrace allows tracing visual meshes in Garry's Mod at high speeds on the CPU using https://github.com/madmann91/bvh, allowing for far higher fidelity scenes in Lua tracers without the massive performance cost of Lua mesh intersection.
Simply get the latest binary for your architecture from releases, and place it into garrysmod/lua/bin
, then require("VisTrace-vX.X")
in GLua.
For a more user friendly experience, get the Steam Workshop addon, which will automatically require the applicable version of the module, and provide integration with other addons (currently StarfallEx and Expression 2 #22).
While it's recommended to just download the latest release binary, if you want to test WIP features before a full release, or you want to help develop the module, then you'll need to set up your toolchain to compile VisTrace and its dependencies.
- CMake 3.20 or newer
- Ninja
- clang - Clang with MSVC backend to use OpenMP while being ABI compatible with source
- Clone the repository with the
--recursive
flag to init all submodules - Open the cloned folder in your editor of choice
- Select a preset to compile (
relwithsymbols
for debugging as building with full debug mode breaks ABI compatibility with Source) - Compile (compiled dll can be found in
out/build/{presetname}
)
VisTrace versions v0.10.0 and newer support user made extensions that can use and extend VisTrace's objects via interfaces in include
.
A quick start repository template is available here
Additionally, an svg badge is provided to include in your readmes to show that your addon/binary module is VisTrace compatible:
Markdown | Preview |
---|---|
[![VisTrace EXTENSION](https://github.com/Derpius/VisTrace/blob/branding/extension.svg?raw=true)](https://github.com/Derpius/VisTrace) |
If you'd like to submit any images/videos showcasing your use of VisTrace, please submit a PR/Issue on the branding branch.
Please note that any content submitted may be used on VisTrace's GitHub, and Workshop pages, as well as the website.
See the readme on the branding branch for the naming convention.
MOVING TO WIKI
For more detailed examples, see the Examples folder.
Will be moving to a dedicated branch
This will load the module, build the acceleration structure from all prop_physics
entities (and the world), get an entity to use as a hit marker, and traverse the scene each frame placing the hit marker at the trace hit position if we hit:
-- Instead of manually checking realm/vistrace version, and requiring by hand
-- You could use the VisTraceInit hook which will be called by the binary if
-- everything loaded OK (this however needs the VisTrace addon to be installed)
if SERVER then error("VisTrace can only be used on the client!") end
require("VisTrace-vX.X") -- Put current version here
local accel = vistrace.CreateAccel(ents.FindByClass("prop_physics")--[[, false]]) -- Pass false here to disable tracing world (useful if you just want to interact with entities)
local plr = LocalPlayer()
-- Change the entity ID here to one you want to use as a hit marker
-- hard coded here for simplicity of the example,
-- and assuming no addons that change this are mounted,
-- will be the first prop created on flatgrass in singleplayer
local hitMarker = Entity(68)
hook.Add("Think", "vistraceTest", function()
local hitData = accel:Traverse(plr:EyePos(), plr:GetAimVector())
if hitData then
hitMarker:SetPos(hitData:Pos())
end
end)