Finding width and/or volume of an object

Okay, I’m trying to do a reasonably realistic way of determining how much material a sword will cut through.
I basically need a way to find width, or breadth of an object, if taken from a certain angle. Can this be done with a trace? How could I do this?

Bump. Surely there’s a way to get the dimensions of an object?

I assume you could use this.

Yes, but that won’t give me the volume. And I’m not sure if I can work out the volume from the bounding boxes.

[lua]local maxs = ent:OBBMaxs()
local mins = ent:OBBMins()
local height = maxs.z - mins.z
local width = maxs.x - mins.x
local length = maxs.y - mins.y
local volume = height * width * length

Will this work for limbs of an NPC or a player?

Probably not. The value returned uses OBB which isn’t completely effective but a mere approximation of what you can get.

I only need to calculate it once (to get the width of the arm).

Is there any other way to do this if OBB doesn’t work?

[quote=“JgcxCub, post:8, topic:66658”]

I only need to calculate it once (to get the width of the arm).

Could gm_queryphys help?

[quote=“Mossman1223, post:9, topic:66658”]

Will this work for limbs of an npc?

[quote=“JgcxCub, post:10, topic:66658”]

Presumably you could be able to hack something together, but really I haven’t a clue. Sorry if I’ve been unhelpful, but I think that you may be trying to ask for too much here… sadly the source engine is rather limited. Is this whole thing terribly important to your project? If not and I were you I’d just drop it and do other things to make it better.

local min,max = npc:GetHitBoxBounds(some_hitbox_id)


some_hitbox_id can be for instance .HitBox from a trace result.