Skip to content

Conversation

@deltamolfar
Copy link
Contributor

@deltamolfar deltamolfar commented Oct 10, 2025

Adds gmod_wire_customprop entity into the wiremod, an entity with custom physics mesh, which isn't spawnable by itself but by the E2/duplicator, and maybe in future, by something else.

It's essentially starfall's custom mesh prop with a few tweaks:

  • 16-bit precision vertices positions instead of sf's 32.
  • Lower default amount of vertices per convex. As the performance bottleneck of the custom prop is client's ENT:BuildPhysics function, and self:PhysicsInitMultiConvex function in particular which seemingly takes more resources exponentially with the rise of verticies amount, I've decided (and tested by stressing/abusing different limits) to lower the verticies limit and raise convexes limit instead.
  • Added convar-controller limit to these props (default is 16), as without it - it's possible to abuse client's performance horribly
  • Expression2 functions to spawn said props (+ dynamic cost of creation)

Example of usage: (again, taken mostly from SF's example, not trying to credit myself for other's stuff)

propSpawnUndo(0)

const Fidelity = 15
const X = 150
const Y = 100
const Z = 50

const Convexes = table(
    # cube
    array(
        vec(0, 0, 0), vec(X, 0, 0), vec(X, Y, 0), vec(0, Y, 0),
        vec(0, 0, Z), vec(X, 0, Z), vec(X, Y, Z), vec(0, Y, Z)
    ),
    # cylinder
    array(
        # cone
        vec(X/2, Y/2, Z*3)
    )
)

# cylinder base
for(I = 1, Fidelity) {
    local T = _PI*2 / Fidelity * I
    local Cos = X/2 + cosr(T) * X/4
    local Sin = Y/2 + sinr(T) * Y/4
    
    Convexes[2,array]:pushVector(vec(Cos, Sin, Z))
    Convexes[2,array]:pushVector(vec(Cos, Sin, Z*2))
}

customPropSpawn(Convexes)

@Fasteroid
Copy link
Contributor

Fasteroid commented Nov 7, 2025

I'm in possession of a starfall which spawns an extremely crash-prone level 3 serpinski pyramid (it can crash the server merely by contacting another one of itself).  It has 64 convexes but only 4 verts per convex.  Looks kinda like this:

what it looks like

It might be risky to allow a lot of convexes—the physics mesh isn't costly to build for those but it does cost more to simulate.

Want some help stress-testing this weekend?

@deltamolfar
Copy link
Contributor Author

Want some help stress-testing this weekend?

Help is always appreciated :)
Regarding the convexes - the default limit it 16 per prop, but if it proves issues, I'm alright with brining it down to 8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants