Skip to content

Feat: add custom entity fiter to Trace#203

Closed
chenbuyi2019 wants to merge 1 commit intoswiftly-solution:betafrom
chenbuyi2019:feat-custom-trace-filter
Closed

Feat: add custom entity fiter to Trace#203
chenbuyi2019 wants to merge 1 commit intoswiftly-solution:betafrom
chenbuyi2019:feat-custom-trace-filter

Conversation

@chenbuyi2019
Copy link
Copy Markdown
Contributor

Description

Add custom entity fiter to Trace.
So we could easily bypass the entity by its class\team or even color.

And new simple trace line functions.
Too many params won't make it simple.

I dont think trace should be called from another thread.
So I just put CustomFilterFunc in static and set it to null after the trace finished.
It means the current custom filter of the current running trace.

Examples:

var eyepos = pawn.GetEyePos();
var ang = pawn.EyeAngles;
var result = new CGameTrace();
core.Trace.SimpleTraceLineFilter(eyepos, ang, ref result, (ent) =>
{
    if (ent.Equals(pawn)) { return false; }
    if (ent.DesignerName.Equals("player") && ent.TeamNum == 3)
    {
        return true;
    }
    return false;
});
var eyepos = pawn.GetEyePos();
var ang = pawn.EyeAngles;
ang.ToDirectionVectors(out var fwd, out var _, out var _);
var end = eyepos + new Vector(
    fwd.X * 8192f,
    fwd.Y * 8192f,
    fwd.Z * 8192f
);
var result = new CGameTrace();

var ray = new Ray_t
{
    Type = RayType_t.RAY_TYPE_LINE
};
var filter = new CTraceFilter((ent) =>
{
    if (ent.Equals(pawn)) { return false; }
    if (ent.DesignerName.Equals("player") && ent.TeamNum == 3)
    {
        return true;
    }
    return false;
});
filter.QueryShapeAttributes.ObjectSetMask = RnQueryObjectSet.All;
filter.QueryShapeAttributes.CollisionGroup = CollisionGroup.Always;
core.Trace.TraceShape(eyepos, end, ray, filter, ref result);

Type of Change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Code refactoring (no functional changes)
  • Performance improvement
  • Test coverage improvement
  • Build/CI improvement

Related Issues

Fixes #(issue number)
Closes #(issue number)
Related to #(issue number)

Changes Made

  • Native changes (C++)
  • Managed Changes (C#)
  • API additions/modifications
  • Memory management improvements
  • Network handling changes
  • SDK updates
  • Build system changes

Detailed Changes

New functions add to ITraceManager.

Testing

Test Environment

  • OS: Windows 11
  • Game: Counter-Strike 2

Test Cases

Describe the test cases you've run:

Breaking Changes

List any breaking changes and migration steps:

Performance Impact

  • No performance impact
  • Positive performance impact
  • Negative performance impact (explain below)
  • Performance impact unknown

Details:

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Screenshots/Videos (if applicable)

Add screenshots or videos demonstrating the changes:

Additional Notes

Any additional information, context, or notes for reviewers:


For Maintainers

  • Code review completed
  • Tests pass
  • Ready to merge

@chenbuyi2019 chenbuyi2019 changed the title Feat: add SimpleTraceLineFilter Feat: Add custom entity fiter to Trace Dec 26, 2025
@chenbuyi2019 chenbuyi2019 changed the title Feat: Add custom entity fiter to Trace Feat: add custom entity fiter to Trace Dec 26, 2025
@github-project-automation github-project-automation Bot moved this from Backlog to In review in SwiftlyS2 - Roadmap Jan 6, 2026
@skuzzis
Copy link
Copy Markdown
Member

skuzzis commented Jan 9, 2026

The pull request isn't merged yet as we're rethinking some design choices for the Trace API

@skuzzis
Copy link
Copy Markdown
Member

skuzzis commented Mar 22, 2026

This PR will be addresses in #289

@skuzzis skuzzis closed this Mar 22, 2026
@github-project-automation github-project-automation Bot moved this from In review to Done in SwiftlyS2 - Roadmap Mar 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants