Bool kDOPTree::LineCheck( kDOPNode* pNode, const Ray3f& pRay ) const { if( Intersect( pRay, pNode->mBoundingBox ) ) { // At the root. if( pNode->mTriangleIndices.size() != 0 ) { // Check each triangles. const Trianglef* tri; for( UInt32 i = 0; i < pNode->mTriangleIndices.size(); i++ ) { tri = &mTriangles[pNode->mTriangleIndices[i]]; if( IntersectTriangle( mVertices[tri->mIndices[0]], mVertices[tri->mIndices[1]], mVertices[tri->mIndices[2]], pRay ) ) return true; } return false; } else { // Check childs. return LineCheck( mNodes[pNode->mChildsIndex + 0], pRay ) || LineCheck( mNodes[pNode->mChildsIndex + 1], pRay ); } } return false; }
Bool kDOPTree::LineCheck( const Ray3f& pRay ) const { if( mNodes.size() > 0 ) return LineCheck( mNodes[0], pRay ); return false; }
void FollowLine() { Lon->Write(true); while(LineCheck()==0) Move();//skip "first" line(as it is part of starting box) while(LineCheck()!=0) Move();//skiping the "first" line. while(LineCheck()==0) Move(); Count2Blue();//shot 1 while(LineCheck()==0) Move(); Count2Blue(); while(LineCheck()==0); Count2Blue(); SeeRed(); Lon->Write(false); }
void SeeRed() { double a=1.3,b=1.3,c=1.3; while(CTest() != 2) { LineCheck(); Move(); a=b*c; //waist time } }
void TurnLeft() { LeftDirection->Write(true); RightDirection->Write(false); IRightSpeed = ILeftSpeed = TurnSpeed; Move(); wait(RotationsPer90dTurn);//#of rotations to do a turn LeftDirection->Write(false); while(LineCheck()==0xFFFF) Move(); }
void Count2Blue() { int DT=0; while(CTest() != 1) { Count1(); DT++; LineCheck(); Move(); } ShootTarget(); Return(DT); }
void Return(int Steps) { int i;int tp; for(i=0;i<Steps;i++) { Count1(); LineCheck(); tp=ILeftSpeed; ILeftSpeed=IRightSpeed; IRightSpeed=tp; } TurnRight(); //now (just now) does it return to Navigate. }
task main() { waitForStart(); wait1Msec(1450); MotorEncoderTarget(2, 11, 11, 65, 10); if (SensorValue[IRSeeker] > 2) { MotorEncoderTarget(2, 20, 20, 65, 10); Temp1++; if (SensorValue[IRSeeker] > 2) { MotorEncoderTarget(2, 21, 21, 65, 10); Temp1++; } } wait10Msec(20); MotorEncoderTarget(1, -2100, 2100, 60, 30); //MotorEncoderTarget(1, (-2000 + Temp1*50), (1950 - Temp1*50), 60, 30); if(Temp1 == 1) { MoveLift(1, 3000, 30); } else { MoveLift(1, 600, 30); } MotorEncoderTarget(2, 30, 30, 70, 30); LineCheck(7 * 115); motor[motorL] = 0; motor[motorR] = 0; if(Temp1 == 1) { MoveLift(2, 1200, 30); } else { MoveLift(2, 550, 30); } MotorEncoderTarget(2, -36, -36, 80, 10); MotorEncoderTarget(1, 2100, -2100, 80, 10); switch (Temp1) { case 0: MotorEncoderTarget(2, -10, -10, 80, 10); break; case 1: MotorEncoderTarget(2, -30, -30, 80, 10); break; case 2: MotorEncoderTarget(2, -55, -55, 80, 10); break; } }
bool FTraceInfo::TraceTraverse (int ptflags) { // Do a 3D floor check in the starting sector Setup3DFloors(); FPathTraverse it(Start.X, Start.Y, Vec.X * MaxDist, Vec.Y * MaxDist, ptflags | PT_DELTA, startfrac); intercept_t *in; int lastsplashsector = -1; while ((in = it.Next())) { // Deal with splashes in 3D floors (but only run once per sector, not each iteration - and stop if something was found.) if (Results->Crossed3DWater == NULL && lastsplashsector != CurSector->sectornum) { for (auto rover : CurSector->e->XFloor.ffloors) { if ((rover->flags & FF_EXISTS) && (rover->flags&FF_SWIMMABLE)) { if (Check3DFloorPlane(rover, false)) { // only consider if the plane is above the actual floor. if (rover->top.plane->ZatPoint(Results->HitPos) > CurSector->floorplane.ZatPoint(Results->HitPos)) { Results->Crossed3DWater = rover; Results->Crossed3DWaterPos = Results->HitPos; Results->Distance = 0; } } } } lastsplashsector = CurSector->sectornum; } double dist = MaxDist * in->frac; DVector3 hit = Start + Vec * dist; // Crossed a floor portal? if (Vec.Z < 0 && !CurSector->PortalBlocksMovement(sector_t::floor)) { // calculate position where the portal is crossed double portz = CurSector->GetPortalPlaneZ(sector_t::floor); if (hit.Z < portz && limitz > portz) { limitz = portz; EnterSectorPortal(it, sector_t::floor, (portz - Start.Z) / (Vec.Z * MaxDist), CurSector); continue; } } // ... or a ceiling portal? else if (Vec.Z > 0 && !CurSector->PortalBlocksMovement(sector_t::ceiling)) { // calculate position where the portal is crossed double portz = CurSector->GetPortalPlaneZ(sector_t::ceiling); if (hit.Z > portz && limitz < portz) { limitz = portz; EnterSectorPortal(it, sector_t::ceiling, (portz - Start.Z) / (Vec.Z * MaxDist), CurSector); continue; } } if (in->isaline) { if (in->d.line->isLinePortal() && P_PointOnLineSidePrecise(Start, in->d.line) == 0) { sector_t *entersector = in->d.line->backsector; if (entersector == NULL || (hit.Z >= entersector->floorplane.ZatPoint(hit) && hit.Z <= entersector->ceilingplane.ZatPoint(hit))) { FLinePortal *port = in->d.line->getPortal(); // The caller cannot handle portals without global offset. if (port->mType == PORTT_LINKED || !(TraceFlags & TRACE_PortalRestrict)) { EnterLinePortal(it, in); continue; } } } if (!LineCheck(in, dist, hit)) break; } else if ((in->d.thing->flags & ActorMask) && in->d.thing != IgnoreThis) { if (!ThingCheck(in, dist, hit)) break; } } if (Results->HitType == TRACE_HitNone) { if (CurSector->PortalBlocksMovement(sector_t::floor) && CheckSectorPlane(CurSector, true)) { Results->HitType = TRACE_HitFloor; Results->HitTexture = CurSector->GetTexture(sector_t::floor); } else if (CurSector->PortalBlocksMovement(sector_t::ceiling) && CheckSectorPlane(CurSector, false)) { Results->HitType = TRACE_HitCeiling; Results->HitTexture = CurSector->GetTexture(sector_t::ceiling); } } // check for intersection with floor/ceiling Results->Sector = &level.sectors[CurSector->sectornum]; if (Results->CrossedWater == NULL && CurSector->heightsec != NULL && CurSector->heightsec->floorplane.ZatPoint(Start) < Start.Z && CurSector->heightsec->floorplane.ZatPoint(Results->HitPos) >= Results->HitPos.Z) { // Save the result so that the water check doesn't destroy it. FTraceResults *res = Results; FTraceResults hsecResult; Results = &hsecResult; if (CheckSectorPlane(CurSector->heightsec, true)) { Results->CrossedWater = &level.sectors[CurSector->sectornum]; Results->CrossedWaterPos = Results->HitPos; Results->Distance = 0; } Results = res; } if (Results->HitType == TRACE_HitNone && Results->Distance == 0) { Results->HitPos = Start + Vec * MaxDist; SetSourcePosition(); Results->Distance = MaxDist; Results->Fraction = 1.; } return Results->HitType != TRACE_HitNone; }