Skip to content

[Bug]: NormalizeVector returning a false vector length #2297

Open
@mariokeks

Description

@mariokeks

Prerequisites

  • I have checked that my issue doesn't exist yet in the issue tracker

Operating System and Version

Debian GNU/Linux 12 (bookworm)

Game / AppID and Version

240 (Latest)

SourceMod Version

1.13.0.7215

Metamod:Source Version

1.12.0-dev+1217

Version Verification

Updated SourceMod Version

1.13.0.7219

Updated Metamod:Source Version

No response

Description

The NormalizeVector function doesn't work correctly with zero vectors in latest CSS versions (64 bit linux).
Instead of returning a zero length and a zero vector, it returns a very small, but incorrect, non-zero length.

This is different from how it behaves in the previous CSS version, where it correctly returns a zero length.

I guess a simple solution would be to implement an explicit check for zero vectors and returning a zero length instead of the VectorNormalize value.

Steps to Reproduce

#pragma semicolon 1
#pragma newdecls required

public void OnPluginStart() 
{
	RegAdminCmd("sm_test", Command_Test, ADMFLAG_ROOT, "Test command ( ͡° ͜ʖ ͡°)");
}

Action Command_Test(int client, int args)
{
	float fAngles[3];
	float fLength = NormalizeVector(fAngles, fAngles);
	ReplyToCommand(client, "Length: %f", fLength);
	return Plugin_Handled;
}

Relevant Log Output

Result (Latest CSS version)
sm_test
Length: 0.000009

Result (Previous CSS version)
sm_test
Length: 0.000000

Metadata

Metadata

Assignees

No one assigned

    Labels

    Buggeneral bugs; can be anything

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions