int EnumMarkerRegionById(ReaProject* _proj, int _id, bool* _isrgn, double* _pos, double* _end, const char** _name, int* _num, int* _color) { if (_id > 0) { const char* name2; double pos2, end2; bool isrgn = IsRegion(_id), isrgn2; int num=(_id&0x3FFFFFFF), x=0, lastx=0, num2, col2; while ((x = EnumProjectMarkers3(_proj, x, &isrgn2, &pos2, &end2, &name2, &num2, &col2))) { if (num == num2 && isrgn == isrgn2) { if (_isrgn) *_isrgn = isrgn2; if (_pos) *_pos = pos2; if (_end) *_end = end2; if (_name) *_name = name2; if (_num) *_num = num2; if (_color) *_color = col2; return lastx; } lastx=x; } } return -1; }
int GetMarkerRegionIndexFromId(ReaProject* _proj, int _id) { if (_id > 0) { int x=0, lastx=0, num=(_id&0x3FFFFFFF), num2; bool isrgn = IsRegion(_id), isrgn2; while ((x = EnumProjectMarkers3(_proj, x, &isrgn2, NULL, NULL, NULL, &num2, NULL))) { if (num == num2 && isrgn == isrgn2) return lastx; lastx=x; } } return -1; }
bool Location::CheckWithinBounds(iEngine* engine,const csVector3 &p,const iSector* sector) { if(!IsRegion()) return false; if(GetSector(engine) != sector) return false; // Thanks to http://astronomy.swin.edu.au/~pbourke/geometry/insidepoly/ // for this example code. int counter = 0; size_t i,N=locs.GetSize(); float xinters; csVector3 p1,p2; p1 = locs[0]->pos; for(i=1; i<=N; i++) { p2 = locs[i % N]->pos; if(p.z > csMin(p1.z,p2.z)) { if(p.z <= csMax(p1.z,p2.z)) { if(p.x <= csMax(p1.x,p2.x)) { if(p1.z != p2.z) { xinters = (p.z-p1.z)*(p2.x-p1.x)/(p2.z-p1.z)+p1.x; if(p1.x == p2.x || p.x <= xinters) counter++; } } } } p1 = p2; } return (counter % 2 != 0); }