ID:1775503
 
I'm unsure if this should go under Design Philosophy or here, sorry if I'm mistaken.

I needed a way to give objs different bounds at certain parts of the obj, for example, a tree trunk is slimmer than the canopy is, so you want to appear under the canopy (a wider bound_width) but you also need the base to be dense and have proper bounds so you can walk up to the side of the trunk, and for it to be dense. Also I wanted objs to become translucent when you stop into their bounds.

What I'm actually inquiring about, is there a way to set different bounds for different parts of a whole obj without splitting it up (as I've done below), or am I stuck with my current system?

var
obj/turfs
tree/canopy/tree_canopy = new

obj/faux_bounds
layer = 6
Crossed ( atom/movable/a )
for ( var/obj/turfs/turf in bounds ( ) )
turf.alpha = 125

Uncrossed ( atom/movable/a )
for ( var/obj/turfs/turf in bounds ( ) )
turf.alpha = 255

obj/turfs
layer = TURF_LAYER

tree
icon = 'Summer Tree.dmi'
icon_state = "Trunk"
density = 1
bound_x = 35
bound_y = 7
bound_width = 25
bound_height = 23

New ( )
. = .. ( )
overlays += tree_canopy

canopy
icon_state = "Canopy"
layer = 5
density = 0
bound_x = 8
bound_y = 31
bound_width = 79
bound_height = 65

obj/faux_bounds is an obj generated for each obj/turfs in the world at runtime,
proc/generate_faux_bounds  ( )
var
icon/i
obj/atom/faux_bounds/faux_bounds

for ( var/obj/turfs/t in world )
// Since the obj/turfs are split into two different parts I need the complete width/height of the obj, not just what the bound_width/height are set at compile time.
i = new ( t.icon )
faux_bounds = new
faux_bounds.bound_width = i.Width ( )
faux_bounds.bound_height = i.Height ( )
faux_bounds.loc = t.loc

i = null
faux_bounds = null


And, if I'm not being too needy, is there a better/more efficient way to go about this but still keep the functionality I had in mind intact.
Yeah. I'm stomped too, I'd say you'd have to continue to break your objects into separates parts and define the bounding boxes accordingly.
Cloud Magic wrote:
BYOND uses Bounding Boxes for pixel movement. It is not currently feasible to use pixel-perfect collision.

I wouldn't be entirely sure about this. There are ways. But I can only say it'd work in a single-player environment.