2 @Copyright Looking Glass Studios, Inc.
3 1996,1997,1998,1999,2000 Unpublished Work.
6 // $Header: r:/t2repos/thief2/src/actreact/dumbprox.cpp,v 1.2 1998/06/22 02:49:06 dc Exp $
7 // really dumb prox system for use for now
9 // this is a onedirectional model
10 // in which we assume that the number of objs in the world which might have
11 // prox info is very small compared to the number of objects in the world
12 // in general, such that it is faster/as fast to search all objects with
13 // the property, as opposed to scanning nearby space for objects which might
15 // clearly, as the effective prox distance drops, and the number of prox objects
16 // grows, this solution becomes a worse and worse fit to the actual problem
18 // as i see it, the real issue is quickly being able to create multiple prox
19 // properties, and that is the part that is bad about the current solution
41 #define PROX_PROP_IMPL kPropertyImplLlist
43 //static sPropertyDesc ProxPropDesc = { "Prox", 0, NULL, 0, 0, { "Prox", "Generic"} };
45 IBoolProperty
*ProxBuildProp(char *prox_name
)
47 sPropertyDesc
*ProxPropDesc
=new sPropertyDesc
;
48 memset(ProxPropDesc
,0,sizeof(sPropertyDesc
));
49 strncpy(ProxPropDesc
->name
,prox_name
,sizeof(ProxPropDesc
->name
));
50 ProxPropDesc
->flags
=kPropertyInstantiate
;
51 char *tmp_cat
=(char *)Malloc(sizeof("Prox")+1);
52 strcpy(tmp_cat
,"Prox");
53 ProxPropDesc
->ui
.category
=tmp_cat
;
54 char *tmp_name
=(char *)Malloc(strlen(prox_name
)+1);
55 strcpy(tmp_name
,prox_name
);
56 ProxPropDesc
->ui
.friendly_name
=tmp_name
;
57 IBoolProperty
*pProxProp
=CreateBoolProperty(ProxPropDesc
,PROX_PROP_IMPL
);
62 BOOL
ProxCheckLoc(IBoolProperty
*pProx
, mxs_vector
*src_pos
, float rad
, cDynObjArray
*objList
, ProxCallback pCB
)
64 sPropertyObjIter iter
;
66 BOOL found
=FALSE
, cur_val
=FALSE
;
69 if (src_pos
==NULL
) return FALSE
;
70 pProx
->IterStart(&iter
);
71 while (pProx
->IterNextValue(&iter
,&obj
,&cur_val
))
72 if (cur_val
&&(OBJ_IS_CONCRETE(obj
)))
74 mxs_vector
*iter_pos
=&ObjPosGet(obj
)->loc
.vec
;
75 float dist_2
=mx_dist2_vec(src_pos
,iter_pos
);
82 if ((*pCB
)(obj
,dist_2
)) // if callback returns true, abort out
86 pProx
->IterStop(&iter
);
90 BOOL
ProxCheckObj(IBoolProperty
*pProx
, ObjID src
, float rad
, cDynObjArray
*objList
, ProxCallback pCB
)
92 mxs_vector
*src_pos
=ObjPosGetLocVector(src
);
93 return ProxCheckLoc(pProx
,src_pos
,rad
,objList
,pCB
);