What's the deal with linking and unlinking entities?


(IneQuation) #1

Like in the topic - could someone elaborate on trap_LinkEntity and trap_UnlinkEntity functions? What do they exactly do, where and why should they be used and stuff? Thanks in advance. :slight_smile:

Rookie One


(dvldrmmr) #2

its my understanding that linking an entity makes it possible to do collision detection against the bsp tree?? at least thats what it seems like to me - i havent really looked at the quake3 engine code to see for sure - someone correct me if im wrong (which is entirely possible lol)


(SCDS_reyalP) #3

From the quake 3 engine source (code/server/server.h)


void SV_UnlinkEntity( sharedEntity_t *ent );
// call before removing an entity, and before trying to move one,
// so it doesn't clip against itself

void SV_LinkEntity( sharedEntity_t *ent );
// Needs to be called any time an entity changes origin, mins, maxs,
// or solid.  Automatically unlinks if needed.
// sets ent->v.absmin and ent->v.absmax
// sets ent->leafnums[] for pvs determination even if the entity
// is not solid


(bani) #4

if you just want to exclude an entity temporarily from collision detection (eg for traces), changing ent->r.linked is far less expensive than doing unlinkentity/linkentity. note that this won’t work on quake3 or anything except ET.


(IneQuation) #5

OK, thanks. :slight_smile: This clears up a lot. :slight_smile: