bsp-tracer

module
v0.0.0-...-eed3b2b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2022 License: MIT

README

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

Directories

Path Synopsis
pkg
bsptracer
Package bsptracer implements Ray-Tracing / Ray-Casting on top of github.com/Galaco/bsp.
Package bsptracer implements Ray-Tracing / Ray-Casting on top of github.com/Galaco/bsp.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL