Skip to content

BSP (Source Engine Map) Ray Tracer / Ray Caster Library

License

Notifications You must be signed in to change notification settings

saiko-tech/bsp-tracer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bsp-tracer

BSP (Source Engine Map) Ray Tracer / Ray Caster Library.

Allows to do static / out-of-engine visibility checks and ray casting on BSP map files.
Can be used to get more accurate visibility info between players than there is available in CS:GO demos/replays (.dem files).

You may want to use this together with csgo-centrifuge to get the correct map version to trace against per demo.

Features

  • Faces (basic map geometry)
  • Brushes (walls / level shape)
  • Static Props (boxes, barrels, etc.)
    • Orientation / Angle
  • Displacements (terrain bumps and slopes)
  • Entities ("dynamic" props - doors, vents, etc.)

Example

package main

import (
	"fmt"
	"os"

	"github.com/go-gl/mathgl/mgl32"
	"github.com/saiko-tech/bsp-tracer/pkg/bsptracer"
)

func main() {
	csgoDir := os.Getenv("CSGO_DIR") // should point to "SteamLibrary/steamapps/common/Counter-Strike Global Offensive"

	m, err := bsptracer.LoadMapFromFileSystem(csgoDir+"/csgo/maps/de_cache.bsp", csgoDir+"/csgo/pak01", csgoDir+"/platform/platform_pak01")
	if err != nil {
		panic(err)
	}

	fmt.Println("A site -> A site, open:", m.IsVisible(mgl32.Vec3{-12, 1444, 1751}, mgl32.Vec3{-233, 1343, 1751})) // true
	fmt.Println("T spawn -> A site:", m.IsVisible(mgl32.Vec3{3306, 431, 1723}, mgl32.Vec3{-233, 1343, 1751}))      // false
	fmt.Println("mid through box:", m.IsVisible(mgl32.Vec3{-94, 452, 1677}, mgl32.Vec3{138, 396, 1677}))           // false
	fmt.Println("T spawn -> T spawn:", m.IsVisible(mgl32.Vec3{3306, 431, 1723}, mgl32.Vec3{3300, 400, 1720}))      // true
}

Development

Linting

Uses golangci-lint

Project Layout

Follows https://github.com/golang-standards/project-layout

Acknowledgements

About

BSP (Source Engine Map) Ray Tracer / Ray Caster Library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages