This is a quick function to convert a ParcelOverlay into something a tad more useful. Posting it here incase anyone else can use it, and to get it tested.
Throw a region at it, and it should return a 64x64 array with unique ID's given to each parcel in the sim. -Adam ====================================================== private void ParcelOverlayToParcels_bitfill(int x, int y, int[,] Parcels, int index) { if(x < 0 || x >= 128) return; if(y < 0 || y >= 128) return; if(Parcels[x,y] == 0) { Parcels[x,y] = index; ParcelOverlayToParcels_bitfill(x-1,y,Parcels,index); ParcelOverlayToParcels_bitfill(x+1,y,Parcels,index); ParcelOverlayToParcels_bitfill(x-1,y-1,Parcels,index); ParcelOverlayToParcels_bitfill(x-1,y+1,Parcels,index); } } public int[,] ParcelOverlayToParcels(Region region) { byte[] Overlay = region.ParcelOverlay; int[,] ParcelsHigh = new int[128, 128]; int[,] Parcels = new int[64, 64]; int x, y; int x2, y2; int index; for(x = 0; x < 64; x++) for(y = 0; y < 64; y++) { x2 = x * 2; y2 = y * 2; ParcelsHigh[x2,y2] = 0; ParcelsHigh[x2 + 1,y2] = (Overlay[x * 64 + y] & 64) == 64 ? -1 : 0; ParcelsHigh[x2,y2 + 1] = (Overlay[x * 64 + y] & 128) == 128 ? -1 : 0; ParcelsHigh[x2+1,y2+1] = (ParcelsHigh[x2+1,y2] == -1 || ParcelsHigh[x2,y2 + 1] == -1) ? -1 : 0; } index = 0; for(x = 0; x < 64; x++) for(y = 0; y < 64; y++) { x2 = x * 2; y2 = y * 2; if(ParcelsHigh[x2,y2] == 0) { ParcelOverlayToParcels_bitfill(x2,y2,ParcelsHigh,index++); } } for(x = 0; x < 64; x++) for(y = 0; y < 64; y++) { x2 = x * 2; y2 = y * 2; Parcels[x,y] = ParcelsHigh[x2,y2]; } return Parcels; } _______________________________________________ libsecondlife-dev mailing list libsecondlife-dev@gna.org https://mail.gna.org/listinfo/libsecondlife-dev