/*! * \brief Check if anything is in a cylinder * \param cyl the cylinder to check * \param flags collision flags * \return 0 if nothing in cyl else returns Y Offset to put cylinder in a proper place */ static float ANCHOR_CheckAnythingInCylinder(const Cylinder & cyl, CollisionFlags flags) { long rad = (cyl.radius + 230) * ACTIVEBKG->Xmul; long px = cyl.origin.x * ACTIVEBKG->Xmul; long pz = cyl.origin.z * ACTIVEBKG->Zmul; if(px > ACTIVEBKG->Xsize - 2 - rad) return 0.f; if(px < 1 + rad) return 0.f; if(pz > ACTIVEBKG->Zsize - 2 - rad) return 0.f; if(pz < 1 + rad) return 0.f; float anything = 999999.f; for(short z = pz - rad; z <= pz + rad; z++) for(short x = px - rad; x <= px + rad; x++) { const EERIE_BKG_INFO feg = ACTIVEBKG->fastdata[x][z]; for(long k = 0; k < feg.nbpoly; k++) { const EERIEPOLY ep = feg.polydata[k]; if(ep.type & (POLY_WATER | POLY_TRANS | POLY_NOCOL)) continue; if(ep.min.y < anything) { float minanything = std::min(anything, ANCHOR_IsPolyInCylinder(ep, cyl, flags)); if(anything != minanything) anything = minanything; } } } EERIEPOLY *ep = ANCHOR_CheckInPolyPrecis(cyl.origin + Vec3f(0.f, cyl.height, 0.f)); if(ep) anything = std::min(anything, ep->min.y); float tempo; if(ep && GetTruePolyY(ep, cyl.origin, &tempo)) anything = std::min(anything, tempo); anything = anything - cyl.origin.y; return anything; }
static void AnchorData_Create_Phase_II_Original_Method(EERIE_BACKGROUND * eb) { Vec3f pos; float count = 0; long lastper = -1; long per; float total = static_cast<float>(eb->Zsize * eb->Xsize); for(long j = 0; j < eb->Zsize; j++) for(long i = 0; i < eb->Xsize; i++) { per = count / total * 100.f; if(per != lastper) { LogInfo << "Anchor Generation: %" << per << " (Pass II)"; lastper = per; } count += 1.f; EERIE_BKG_INFO * eg = &eb->fastdata[i][j]; pos.x = (float)((float)((float)i) * (float)eb->Xdiv); pos.y = 0.f; pos.z = (float)((float)((float)j) * (float)eb->Zdiv); Cylinder currcyl; currcyl.radius = 30; currcyl.height = -150.f; currcyl.origin = pos; if(eg->nbpolyin) { long ok = 0; for(long kkk = 0; kkk < eg->nbpolyin; kkk++) { EERIEPOLY * ep = eg->polyin[kkk]; if (ep->type & POLY_PRECISE_PATH) { ok = 1; break; } } if(!ok) continue; float roof = GetTileMinY(i, j); float current_y = GetTileMaxY(i, j); while(current_y > roof) { long added = 0; for(float pposz = 0.f; pposz < 1.f; pposz += 0.1f) for(float pposx = 0.f; pposx < 1.f; pposx += 0.1f) { currcyl.origin.x = pos.x + pposx * eb->Xdiv; currcyl.origin.z = pos.z + pposz * eb->Zdiv; currcyl.origin.y = current_y; EERIEPOLY * ep2 = ANCHOR_CheckInPolyPrecis(currcyl.origin + Vec3f(0.f, -10.f, 0.f)); if(!ep2) continue; if(!(ep2->type & POLY_DOUBLESIDED) && (ep2->norm.y > 0.f)) continue; if(ep2->type & POLY_NOPATH) continue; if(ANCHOR_AttemptValidCylinderPos(currcyl, NULL, CFLAG_NO_INTERCOL | CFLAG_EXTRA_PRECISION | CFLAG_RETURN_HEIGHT | CFLAG_ANCHOR_GENERATION)) { EERIEPOLY * ep2 = ANCHOR_CheckInPolyPrecis(currcyl.origin + Vec3f(0.f, -10.f, 0.f)); if(!ep2) continue; if(!(ep2->type & POLY_DOUBLESIDED) && (ep2->norm.y > 0.f)) continue; if(ep2->type & POLY_NOPATH) continue; if(DirectAddAnchor_Original_Method(eb, eg, &currcyl.origin)) { added = 1; } } } if(added) current_y -= 160.f; current_y -= 50.f; } } } }
static bool DirectAddAnchor_Original_Method(EERIE_BACKGROUND * eb, EERIE_BKG_INFO * eg, Vec3f * pos) { long found = 0; long stop_radius = 0; Cylinder testcyl; Cylinder currcyl; Cylinder bestcyl; bestcyl.height = 0; bestcyl.radius = 0; currcyl.radius = 40; currcyl.height = -165.f; currcyl.origin = *pos; stop_radius = 0; found = 0; long climb = 0; while (stop_radius != 1) { testcyl = currcyl; testcyl.radius += INC_RADIUS; if (ANCHOR_AttemptValidCylinderPos(testcyl, NULL, CFLAG_NO_INTERCOL | CFLAG_EXTRA_PRECISION | CFLAG_ANCHOR_GENERATION)) { currcyl = testcyl; found = 1; } else { if ((testcyl.origin.y != currcyl.origin.y) && (glm::abs(testcyl.origin.y - pos->y) < 50)) { testcyl.radius -= INC_RADIUS; currcyl = testcyl; climb++; } else stop_radius = 1; } if (climb > 4) stop_radius = 1; if (currcyl.radius >= 50.f) stop_radius = 1; } if(found && currcyl.radius >= bestcyl.radius) { bestcyl = currcyl; } else { return false; } if(CylinderAboveInvalidZone(bestcyl)) return false; for (long k = 0; k < eb->nbanchors; k++) { ANCHOR_DATA * ad = &eb->anchors[k]; if(closerThan(ad->pos, bestcyl.origin, 50.f)) { return false; } if(closerThan(Vec2f(ad->pos.x, ad->pos.z), Vec2f(bestcyl.origin.x, bestcyl.origin.z), 45.f)) { if (glm::abs(ad->pos.y - bestcyl.origin.y) < 90.f) return false; EERIEPOLY * ep = ANCHOR_CheckInPolyPrecis(ad->pos); EERIEPOLY * ep2 = ANCHOR_CheckInPolyPrecis(Vec3f(ad->pos.x, bestcyl.origin.y, ad->pos.z)); if (ep2 == ep) return false; } } eg->ianchors = (long *)realloc(eg->ianchors, sizeof(long) * (eg->nbianchors + 1)); eg->ianchors[eg->nbianchors] = eb->nbanchors; eg->nbianchors++; eb->anchors = (ANCHOR_DATA *)realloc(eb->anchors, sizeof(ANCHOR_DATA) * (eb->nbanchors + 1)); ANCHOR_DATA * ad = &eb->anchors[eb->nbanchors]; ad->pos = bestcyl.origin; ad->height = bestcyl.height; ad->radius = bestcyl.radius; ad->linked = NULL; ad->nblinked = 0; ad->flags = 0; eb->nbanchors++; return true; }
void AnchorData_Create(EERIE_BACKGROUND * eb) { AnchorData_ClearAll(eb); Vec3f pos; float count = 0; long lastper = -1; long per; float total = static_cast<float>(eb->Zsize * eb->Xsize * 9); for(long j = 0; j < eb->Zsize; j++) for(long i = 0; i < eb->Xsize; i++) { long LASTFOUND = 0; for(long divv = 0; divv < 9; divv++) { long divvx, divvy; switch (divv) { case 0: divvx = 0; divvy = 0; break; case 1: divvx = 1; divvy = 0; break; case 2: divvx = 2; divvy = 0; break; case 3: divvx = 0; divvy = 1; break; case 4: divvx = 1; divvy = 1; break; case 5: divvx = 2; divvy = 1; break; case 6: divvx = 0; divvy = 2; break; case 7: divvx = 1; divvy = 2; break; case 8: divvx = 2; divvy = 2; break; } per = count / total * 100.f; if(per != lastper) { LogInfo << "Anchor Generation: %" << per; lastper = per; } count += 1.f; if(LASTFOUND) break; EERIE_BKG_INFO * eg = &eb->fastdata[i][j]; pos.x = (float)((float)((float)i + 0.33f * (float)divvx) * (float)eb->Xdiv); pos.y = 0.f; pos.z = (float)((float)((float)j + 0.33f * (float)divvy) * (float)eb->Zdiv); EERIEPOLY * ep = GetMinPoly(pos); Cylinder currcyl; currcyl.radius = 20 - (4.f * divv); currcyl.height = -120.f; currcyl.origin = pos; if(ep) { EERIEPOLY * epmax; epmax = GetMaxPoly(pos); float roof = 9999999.f; if(ep) roof = ep->min.y - 300; if(epmax) roof = epmax->min.y - 300; float current_y = ep->max.y; while(current_y > roof) { currcyl.origin.y = current_y; EERIEPOLY * ep2 = ANCHOR_CheckInPolyPrecis(currcyl.origin + Vec3f(0.f, -30.f, 0.f)); if( ep2 && !(ep2->type & POLY_DOUBLESIDED) && (ep2->norm.y > 0.f) ) { ep2 = NULL; } if(ep2 && !(ep2->type & POLY_NOPATH)) { bool bval = ANCHOR_AttemptValidCylinderPos(currcyl, NULL, CFLAG_NO_INTERCOL | CFLAG_EXTRA_PRECISION | CFLAG_RETURN_HEIGHT | CFLAG_ANCHOR_GENERATION); if( bval && currcyl.origin.y - 10.f <= current_y ) { EERIEPOLY * ep2 = ANCHOR_CheckInPolyPrecis(currcyl.origin + Vec3f(0.f, -38.f, 0.f)); if(ep2 && !(ep2->type & POLY_DOUBLESIDED) && (ep2->norm.y > 0.f)) { current_y -= 10.f; } else if ((ep2) && (ep2->type & POLY_NOPATH)) { current_y -= 10.f; } else if (AddAnchor_Original_Method(eb, eg, &currcyl.origin)) { LASTFOUND++; current_y = currcyl.origin.y + currcyl.height; } else { current_y -= 10.f; } } else { current_y -= 10.f; } } else { current_y -= 10.f; } } } } } AnchorData_Create_Phase_II_Original_Method(eb); AnchorData_Create_Links_Original_Method(eb); }
bool DirectAddAnchor_Original_Method(EERIE_BACKGROUND * eb, EERIE_BKG_INFO * eg, EERIE_3D * pos, long flags) { long found = 0; long best = 0; long stop_radius = 0; float best_dist = 99999999999.f; float v_dist = 99999999999.f; EERIE_CYLINDER testcyl; EERIE_CYLINDER currcyl; EERIE_CYLINDER bestcyl; bestcyl.height = 0; bestcyl.radius = 0; currcyl.radius = 40; currcyl.height = -165.f; currcyl.origin.x = pos->x; currcyl.origin.y = pos->y; currcyl.origin.z = pos->z; stop_radius = 0; found = 0; long climb = 0; while (stop_radius != 1) { memcpy(&testcyl, &currcyl, sizeof(EERIE_CYLINDER)); testcyl.radius += INC_RADIUS; if (ANCHOR_AttemptValidCylinderPos(&testcyl, NULL, CFLAG_NO_INTERCOL | CFLAG_EXTRA_PRECISION | CFLAG_ANCHOR_GENERATION)) { memcpy(&currcyl, &testcyl, sizeof(EERIE_CYLINDER)); found = 1; } else { if ((testcyl.origin.y != currcyl.origin.y) && (EEfabs(testcyl.origin.y - pos->y) < 50)) { testcyl.radius -= INC_RADIUS; memcpy(&currcyl, &testcyl, sizeof(EERIE_CYLINDER)); climb++; } else stop_radius = 1; } if (climb > 4) stop_radius = 1; if (currcyl.radius >= 50.f) stop_radius = 1; } if (found) { float dist = TRUEEEDistance3D(pos, &currcyl.origin); float vd = EEfabs(pos->y - currcyl.origin.y); if ((currcyl.radius >= bestcyl.radius)) { if (((best_dist > dist) && (currcyl.radius == bestcyl.radius)) || (currcyl.radius > bestcyl.radius)) { memcpy(&bestcyl, &currcyl, sizeof(EERIE_CYLINDER)); best_dist = dist; v_dist = vd; best = 1; } } } if (!best) return FALSE; if (CylinderAboveInvalidZone(&bestcyl)) return FALSE; for (long k = 0; k < eb->nbanchors; k++) { _ANCHOR_DATA * ad = &eb->anchors[k]; if (TRUEEEDistance3D(&ad->pos, &bestcyl.origin) < 50.f) return FALSE; if (TRUEDistance2D(ad->pos.x, ad->pos.z, bestcyl.origin.x, bestcyl.origin.z) < 45.f) { if (EEfabs(ad->pos.y - bestcyl.origin.y) < 90.f) return FALSE; EERIEPOLY * ep = ANCHOR_CheckInPolyPrecis(ad->pos.x, ad->pos.y, ad->pos.z); EERIEPOLY * ep2 = ANCHOR_CheckInPolyPrecis(ad->pos.x, bestcyl.origin.y, ad->pos.z); if (ep2 == ep) return FALSE; } } eg->ianchors = (long *)realloc(eg->ianchors, sizeof(long) * (eg->nbianchors + 1)); if (!eg->ianchors) HERMES_Memory_Emergency_Out(); eg->ianchors[eg->nbianchors] = eb->nbanchors; eg->nbianchors++; eb->anchors = (_ANCHOR_DATA *)realloc(eb->anchors, sizeof(_ANCHOR_DATA) * (eb->nbanchors + 1)); if (!eb->anchors) HERMES_Memory_Emergency_Out(); _ANCHOR_DATA * ad = &eb->anchors[eb->nbanchors]; ad->pos.x = bestcyl.origin.x; ad->pos.y = bestcyl.origin.y; ad->pos.z = bestcyl.origin.z; ad->height = bestcyl.height; ad->radius = bestcyl.radius; ad->linked = NULL; ad->nblinked = 0; ad->flags = 0; eb->nbanchors++; return TRUE; }
//----------------------------------------------------------------------------- // Returns 0 if nothing in cyl // Else returns Y Offset to put cylinder in a proper place float ANCHOR_CheckAnythingInCylinder(EERIE_CYLINDER * cyl, INTERACTIVE_OBJ * ioo, long flags) { long rad; F2L((cyl->radius + 230)*ACTIVEBKG->Xmul, &rad); long px, pz; F2L(cyl->origin.x * ACTIVEBKG->Xmul, &px); if (px > ACTIVEBKG->Xsize - 2 - rad) return 0.f; if (px < 1 + rad) return 0.f; F2L(cyl->origin.z * ACTIVEBKG->Zmul, &pz); if (pz > ACTIVEBKG->Zsize - 2 - rad) return 0.f; if (pz < 1 + rad) return 0.f; float anything = 999999.f; EERIEPOLY * ep; FAST_BKG_DATA * feg; /* TO KEEP... EERIE_BKG_INFO * eg=&ACTIVEBKG->Backg[px+pz*ACTIVEBKG->Xsize]; if ( (cyl->origin.y+cyl->height < eg->tile_miny) && (cyl->origin.y > eg->tile_miny) //|| (cyl->origin.y > eg->tile_maxy) ) { return 999999.f; } */ for (long j = pz - rad; j <= pz + rad; j++) for (long i = px - rad; i <= px + rad; i++) { feg = &ACTIVEBKG->fastdata[i][j]; for (long k = 0; k < feg->nbpoly; k++) { ep = &feg->polydata[k]; if (ep->type & (POLY_WATER | POLY_TRANS | POLY_NOCOL)) continue; if (ep->min.y < anything) { float minanything = __min(anything, ANCHOR_IsPolyInCylinder(ep, cyl, flags)); if (anything != minanything) { anything = minanything; } } } } ep = ANCHOR_CheckInPolyPrecis(cyl->origin.x, cyl->origin.y + cyl->height, cyl->origin.z); if (ep) anything = __min(anything, ep->min.y); float tempo; if ((ep) && (GetTruePolyY(ep, &cyl->origin, &tempo))) anything = __min(anything, tempo); anything = anything - cyl->origin.y; return anything; }
//////////////////////////////////////////////////////////////////////////////////// // ALTERNATIVE METHOD void AnchorData_Create_Alternative_Method_I(EERIE_BACKGROUND * eb) { char text[256]; AnchorData_ClearAll(eb); EERIE_BKG_INFO * eg; EERIEPOLY * ep; EERIE_3D pos; long k; float count = 0; long lastper = -1; long per; float total = ARX_CLEAN_WARN_CAST_FLOAT(eb->Zsize * eb->Xsize * 4); for (long j = 0; j < eb->Zsize; j++) for (long i = 0; i < eb->Xsize; i++) { long LASTFOUND = 0; for (long divv = 0; divv < 4; divv++) { long divvx, divvy; switch (divv) { case 0: divvx = 0; divvy = 0; break; case 1: divvx = 1; divvy = 1; break; case 2: divvx = 0; divvy = 1; break; case 3: divvx = 1; divvy = 0; break; } float current_y = 99999999999.f; F2L((float)count / total * 100.f, &per); if (per != lastper) { sprintf(text, "Anchor Generation: %d%%", per); lastper = per; _ShowText(text); } count += 1.f; danaeApp.WinManageMess(); if (LASTFOUND) break; eg = &eb->Backg[i+j*eb->Xsize]; pos.x = (float)((float)((float)i + 0.5f * (float)divvx) * (float)eb->Xdiv); pos.y = 0.f; pos.z = (float)((float)((float)j + 0.5f * (float)divvy) * (float)eb->Zdiv); ep = GetMinPoly(pos.x, pos.y, pos.z); k = 0; EERIE_CYLINDER currcyl; currcyl.radius = 20 - (4.f * divv); currcyl.height = -120.f; currcyl.origin.x = pos.x; currcyl.origin.y = pos.y; currcyl.origin.z = pos.z; if (ep) { EERIEPOLY * epmax; epmax = GetMaxPoly(pos.x, pos.y, pos.z); float roof = 9999999.f; if (ep) roof = ep->min.y - 300; if (epmax) roof = epmax->min.y - 300; current_y = ep->max.y; while (current_y > roof) { currcyl.origin.y = current_y; EERIEPOLY * ep2 = ANCHOR_CheckInPolyPrecis(currcyl.origin.x, currcyl.origin.y - 30.f, currcyl.origin.z); if (ep2 && !(ep2->type & POLY_DOUBLESIDED) && (ep2->norm.y > 0.f)) ep2 = NULL; if ((ep2) && !(ep2->type & POLY_NOPATH)) { BOOL bval = ANCHOR_AttemptValidCylinderPos(&currcyl, NULL, CFLAG_NO_INTERCOL | CFLAG_EXTRA_PRECISION | CFLAG_RETURN_HEIGHT | CFLAG_ANCHOR_GENERATION); if ((bval) && (currcyl.origin.y - 10.f <= current_y)) { EERIEPOLY * ep2 = ANCHOR_CheckInPolyPrecis(currcyl.origin.x, currcyl.origin.y - 38.f, currcyl.origin.z); if (ep2 && !(ep2->type & POLY_DOUBLESIDED) && (ep2->norm.y > 0.f)) { current_y -= 10.f; } else if ((ep2) && (ep2->type & POLY_NOPATH)) { current_y -= 10.f; } else if (AddAnchor_Original_Method(eb, eg, &currcyl.origin, 0)) { LASTFOUND++; current_y = currcyl.origin.y + currcyl.height; } else current_y -= 10.f; } else current_y -= 10.f; } else current_y -= 10.f; } } } } AnchorData_Create_Phase_II_Original_Method(eb); AnchorData_Create_Links_Original_Method(eb); /* TO KEEP // Parses Anchors to refine anchor creation... long ii,ia,ji,ja; EERIE_3D p1,p2; EERIE_BKG_INFO * eg2; count=0; total=eb->Zsize*eb->Xsize; long usable=0; if (0) for (j=0;j<eb->Zsize;j++) for (long i=0;i<eb->Xsize;i++) { F2L((float)count/(float)total*100.f,&per); if (per!=lastper) { sprintf(text,"Anchor Generation Pass II: %d%% Suitable %d",per,usable); lastper=per; _ShowText(text); } count++; eg=&eb->Backg[i+j*eb->Xsize]; for (long k=0;k<eg->nbianchors;k++) { ii=i-2; ia=i+2; ji=j-2; ja=j+2; FORCERANGE(ii,0,eb->Xsize-1); FORCERANGE(ia,0,eb->Xsize-1); FORCERANGE(ji,0,eb->Zsize-1); FORCERANGE(ja,0,eb->Zsize-1); for (long j2=ji;j2<=ja;j2++) for (long i2=ii;i2<=ia;i2++) { eg2=&eb->Backg[i2+j2*eb->Xsize]; for (long k2=0;k2<eg2->nbianchors;k2++) { // don't treat currently treated anchor if (eg->ianchors[k] == eg2->ianchors[k2]) continue; memcpy(&p1,&eb->anchors[eg->ianchors[k]].pos,sizeof(EERIE_3D)); memcpy(&p2,&eb->anchors[eg2->ianchors[k2]].pos,sizeof(EERIE_3D)); p1.y+=10.f; p2.y+=10.f; float dist=TRUEEEDistance3D(&p1,&p2); if (dist>120.f) continue; if (EEfabs(p1.y-p2.y)>80.f) continue; if ((eb->anchors[eg->ianchors[k]].radius>=40) && (eb->anchors[eg2->ianchors[k2]].radius>=40)) continue; { // found 2 usable anchors EERIE_3D pos; pos.x=(p1.x+p2.x)*DIV2; pos.y=(p1.y+p2.y)*DIV2; pos.z=(p1.z+p2.z)*DIV2; if (AddAnchor(eb,eg,&pos,MUST_BE_BIG)) usable++; } } } } }*/ }
void AnchorData_Create_Original_Method(EERIE_BACKGROUND * eb) { char text[256]; AnchorData_ClearAll(eb); EERIE_BKG_INFO * eg; EERIEPOLY * ep; EERIE_3D pos; #define DECALLL 20.f long k; float count = 0; long lastper = -1; long per; float total = ARX_CLEAN_WARN_CAST_FLOAT(eb->Zsize * eb->Xsize * 9); for (long j = 0; j < eb->Zsize; j++) for (long i = 0; i < eb->Xsize; i++) { long LASTFOUND = 0; for (long divv = 0; divv < 9; divv++) { long divvx, divvy; switch (divv) { case 0: divvx = 0; divvy = 0; break; case 1: divvx = 1; divvy = 0; break; case 2: divvx = 2; divvy = 0; break; case 3: divvx = 0; divvy = 1; break; case 4: divvx = 1; divvy = 1; break; case 5: divvx = 2; divvy = 1; break; case 6: divvx = 0; divvy = 2; break; case 7: divvx = 1; divvy = 2; break; case 8: divvx = 2; divvy = 2; break; } float current_y = 99999999999.f; F2L((float)count / total * 100.f, &per); if (per != lastper) { sprintf(text, "Anchor Generation: %d%%", per); lastper = per; _ShowText(text); } count += 1.f; danaeApp.WinManageMess(); if (LASTFOUND) break; eg = &eb->Backg[i+j*eb->Xsize]; pos.x = (float)((float)((float)i + 0.33f * (float)divvx) * (float)eb->Xdiv); pos.y = 0.f; pos.z = (float)((float)((float)j + 0.33f * (float)divvy) * (float)eb->Zdiv); ep = GetMinPoly(pos.x, pos.y, pos.z); k = 0; EERIE_CYLINDER currcyl; currcyl.radius = 20 - (4.f * divv); currcyl.height = -120.f; currcyl.origin.x = pos.x; currcyl.origin.y = pos.y; currcyl.origin.z = pos.z; if (ep) { EERIEPOLY * epmax; epmax = GetMaxPoly(pos.x, pos.y, pos.z); float roof = 9999999.f; if (ep) roof = ep->min.y - 300; if (epmax) roof = epmax->min.y - 300; current_y = ep->max.y; while (current_y > roof) { currcyl.origin.y = current_y; EERIEPOLY * ep2 = ANCHOR_CheckInPolyPrecis(currcyl.origin.x, currcyl.origin.y - 30.f, currcyl.origin.z); if (ep2 && !(ep2->type & POLY_DOUBLESIDED) && (ep2->norm.y > 0.f)) ep2 = NULL; if ((ep2) && !(ep2->type & POLY_NOPATH)) { BOOL bval = ANCHOR_AttemptValidCylinderPos(&currcyl, NULL, CFLAG_NO_INTERCOL | CFLAG_EXTRA_PRECISION | CFLAG_RETURN_HEIGHT | CFLAG_ANCHOR_GENERATION); if ((bval) && (currcyl.origin.y - 10.f <= current_y)) { EERIEPOLY * ep2 = ANCHOR_CheckInPolyPrecis(currcyl.origin.x, currcyl.origin.y - 38.f, currcyl.origin.z); if (ep2 && !(ep2->type & POLY_DOUBLESIDED) && (ep2->norm.y > 0.f)) { current_y -= 10.f; } else if ((ep2) && (ep2->type & POLY_NOPATH)) { current_y -= 10.f; } else if (AddAnchor_Original_Method(eb, eg, &currcyl.origin, 0)) { LASTFOUND++; current_y = currcyl.origin.y + currcyl.height; } else current_y -= 10.f; } else current_y -= 10.f; } else current_y -= 10.f; } } } } AnchorData_Create_Phase_II_Original_Method(eb); AnchorData_Create_Links_Original_Method(eb); }
void AnchorData_Create_Phase_II_Original_Method(EERIE_BACKGROUND * eb) { char text[256]; EERIE_BKG_INFO * eg; EERIE_3D pos; long k; float count = 0; long lastper = -1; long per; float total = ARX_CLEAN_WARN_CAST_FLOAT(eb->Zsize * eb->Xsize); for (long j = 0; j < eb->Zsize; j++) for (long i = 0; i < eb->Xsize; i++) { float current_y = 99999999999.f; F2L((float)count / total * 100.f, &per); if (per != lastper) { sprintf(text, "Anchor Generation: %d%% (Pass II)", per); lastper = per; _ShowText(text); } count += 1.f; danaeApp.WinManageMess(); eg = &eb->Backg[i+j*eb->Xsize]; pos.x = (float)((float)((float)i) * (float)eb->Xdiv); pos.y = 0.f; pos.z = (float)((float)((float)j) * (float)eb->Zdiv); k = 0; EERIE_CYLINDER currcyl; currcyl.radius = 30; currcyl.height = -150.f; currcyl.origin.x = pos.x; currcyl.origin.y = pos.y; currcyl.origin.z = pos.z; if (eg->nbpolyin) { long ok = 0; for (long kkk = 0; kkk < eg->nbpolyin; kkk++) { EERIEPOLY * ep = eg->polyin[kkk]; if (ep->type & POLY_PRECISE_PATH) { ok = 1; break; } } if (!ok) continue; float roof = GetTileMinY(i, j); current_y = GetTileMaxY(i, j); while (current_y > roof) { long added = 0; for (float pposz = 0.f; pposz < 1.f; pposz += 0.1f) for (float pposx = 0.f; pposx < 1.f; pposx += 0.1f) { currcyl.origin.x = pos.x + pposx * eb->Xdiv; currcyl.origin.z = pos.z + pposz * eb->Zdiv; currcyl.origin.y = current_y; EERIEPOLY * ep2 = ANCHOR_CheckInPolyPrecis(currcyl.origin.x, currcyl.origin.y - 10.f, currcyl.origin.z); if (!ep2) continue; if (!(ep2->type & POLY_DOUBLESIDED) && (ep2->norm.y > 0.f)) continue; if (ep2->type & POLY_NOPATH) continue; if (ANCHOR_AttemptValidCylinderPos(&currcyl, NULL, CFLAG_NO_INTERCOL | CFLAG_EXTRA_PRECISION | CFLAG_RETURN_HEIGHT | CFLAG_ANCHOR_GENERATION)) { EERIEPOLY * ep2 = ANCHOR_CheckInPolyPrecis(currcyl.origin.x, currcyl.origin.y - 10.f, currcyl.origin.z); if (!ep2) continue; if (!(ep2->type & POLY_DOUBLESIDED) && (ep2->norm.y > 0.f)) continue; if (ep2->type & POLY_NOPATH) continue; if (DirectAddAnchor_Original_Method(eb, eg, &currcyl.origin, 0)) { added = 1; } } } if (added) current_y -= 160.f; current_y -= 50.f; } } } }