Open Jcw87 opened 10 years ago
I gave it a try and it doesn't allow you to set the contents of the entity. It seems to be used to define what the entity can collide with, but not the other way around. I tried to find another way but it seems to be deep inside the engine trace code and I haven't found anything of interest yet, so tell me if you have any lead.
I've done some more investigation into how traces are filtered. It seems that custom filtering is handled in CEngineTrace::TraceRay with a callback in ITraceFilter (which is used for things like preventing the player entity that fired a bullet from being hit by it), while normal filtering happens in CEngineTrace::ClipRayToCollideable. If the collision model is a studiomodel, it will first check that model for a CONTENTS mask and test the trace mask against it. This can be illustrated by spawning in a 'models/props_c17/fence01a.mdl', and shooting through it. Things seem to get a lot more complicated when custom collision meshes are involved (my entity uses Entity:PhysicsInitConvex). Even if I set my entity model to the fence model before using Entity:PhysicsInitConvex, bullets won't pass through, despite my tests with a server plugin that show that the engine still thinks it has the fence collision model and CONTENTS mask.
Whatever funky stuff Garry did to make custom collision meshes work, it doesn't play nice with the existing trace filter mechanisms.
Bump, this request is 3 years old. And I would really appreciate if this feature is added in next updates.
https://github.com/Facepunch/garrysmod-requests/issues/1055 This in a way allows you to "set" content flags.
no, only retrieve them
Doesn't returning nothing makes the rays to go pass through the entity?
local sent_contents = CONTENTS_PLAYERCLIP + CONTENTS_MONSTERCLIP
function ENT:TestCollision( startpos, delta, isbox, extents, mask )
if bit.band( mask, sent_contents ) ~= 0 then
return {}
end
return nil
end
Yeah, my alternative solution didn't work after the update. I really hoped it did. You need to return new hit pos which is bit hard to calculate.
I believe this got implemented in next update?
Can anyone confirm this also work with Entity:PhysicsInitConvex?
I believe this got implemented in next update?
Setting the physics object to for example CONTENTS_EMPTY
will make props pass through properly, but traces still hit, meaning players, nextbots, bullets, and lua traces will still collide with the entity regardless of what the physics object's Contents is. util.PointContents
will also still return the default value, CONTENTS_SOLID
for the entity/model I tested with.
Can anyone confirm this also work with Entity:PhysicsInitConvex?
Appears to have no effect on that either, beyond props being able to pass through.
Exposing this function would be very useful for creating things like props that only block players or NPCs using the various clip enums.
Yeah this hook unfortunately doesn't do much, the coolest thing it can is making entities collide with NPCCLIP brushes.
I thought the whole point of this hook was for changing interactions with brushes/player movement. https://github.com/Facepunch/garrysmod-requests/issues/1074 and https://github.com/Facepunch/garrysmod-requests/issues/1085 would be more useful though.
It would be very useful if scripted entities could define their own CONTENTS masks. For example, I want to have an entity block players and physics objects, but not bullets. This can only be achieved by changing the return value of CBaseEntity::PhysicsSolidMaskForEntity().
There used to be a function to do this, but it was removed in some update, and I can't remember what it was called before.