示例#1
0
void Thread3(PVOID pvoid)

{

    HDC                           hdc;

    int                   iNum = 0, iNext = 1, iLine = 0, iTemp;

    PPARAMS               pparams;

    TCHAR                         szBuffer[16];



    pparams = (PPARAMS)pvoid;

    while (!pparams->bKill)

    {

        if (iNum < 0)

        {

            iNum = 0;

            iNext = 1;

        }

        iLine = CheckBottom(pparams->hwnd, pparams->cyClient,

                            pparams->cyChar, iLine);


        hdc = GetDC(pparams->hwnd);



        TextOut(hdc, 0, iLine * pparams->cyChar, szBuffer,

                wsprintf(szBuffer, TEXT("%d"), iNum));



        ReleaseDC(pparams->hwnd, hdc);

        iTemp = iNum;

        iNum = iNext;

        iNext += iTemp;

        iLine++;

    }

    _endthread();

}
示例#2
0
void CreateGrid (qboolean force) {
// ====path stuff
//int i;
// ====path stuff
int x,y,z,cnt=0;
vec3_t v,endpt;
trace_t tr1,tr2;
float v0,v1,v2;

  vec3_t min1={0,0,0};  // width 6x6
  vec3_t max1={0,0,0};

  vec3_t min2={-16,-16,0};// width 32x32 (was 24x24)
  vec3_t max2={+16,+16,0};

    numnodes=0;

	if (!force && LoadGrid())
		return;

  for (x=0;x<maxx;x++) {
    v0=g2v0(x); // convert grid(x) to v[0]
    for (y=0;y<maxy;y++) {
      v1=g2v1(y); // convert grid(y) to v[1]
      for (z=maxz-1;z>=0;z--) {
        v2=g2v2(z); // convert grid(z) to v[2]
        //--------------------------------------
        VectorSet(v,v0,v1,v2);
        // Skip world locations in solid/lava/slime/window/ladder
        if (gi.pointcontents(v) & MASK_OPAQUE) { z--; continue; }
        //-----------------------------------------------
        // At this point,v(x,y,z) is a point in mid-air
        //-----------------------------------------------
        // Trace small bbox down to see what is below
        VectorSet(endpt,v[0],v[1],-8192);
        // Stop at world locations in solid/lava/slime/window/ladder
        tr1=gi.trace(v,min1,max1,endpt,NULL,MASK_OPAQUE);
        // Set for-loop index to our endpt's grid(z)
        z=gridz(tr1.endpos[2]);
        // Skip if trace endpt hit func entity.
        if (tr1.ent && (tr1.ent->use || tr1.ent->think || tr1.ent->blocked)) continue;
        // Skip if trace endpt hit lava/slime/window/ladder.
        if (tr1.contents & (CONTENTS_LAVA|CONTENTS_SLIME|CONTENTS_WINDOW)) continue;
        // Skip if trace endpt hit non-walkable slope
        if (tr1.plane.normal[2]<0.7) continue;
        //----------------------------------------
        // Test vertical clearance above v(x,y,z)
        //----------------------------------------
        VectorCopy(tr1.endpos,endpt);
        //tr1.endpos[2]+=2; // set start just above surface
        endpt[2]+=32;     // endpt at approx crouch height
        tr2=gi.trace(endpt,min2,max2,tr1.endpos,NULL,MASK_OPAQUE);//GHz - push down instead of up
        // Skip if not reachable by crouched bbox - trace incomplete?
       // if (tr2.fraction != 1.0) continue;
        // Skip if linewidth inside solid - too close to adjoining surface?
		if (tr2.startsolid || tr2.allsolid) continue;

		// GHz: check final position to see if it intersects with a solid
		tr1=gi.trace(tr2.endpos,min2,max2,tr2.endpos,NULL,MASK_OPAQUE);
		if (tr1.fraction != 1.0 || tr1.startsolid || tr1.allsolid)
			continue;
		if (!CheckBottom(tr2.endpos, min2, max2))
			continue;

		VectorCopy(tr2.endpos, endpt);//GHz
		endpt[2]+=32;//GHz
		//if (tr2.allsolid) continue;
        //-------------------------------------
        // Now, adjust downward for uniformity
        //-------------------------------------
       // AdjustDownward(NULL,endpt);
        // Houston,we have a valid node!
		if (NearbyGridNode(endpt, cnt))
			continue;//GHz
        VectorCopy(endpt,pathnode[cnt]); // copy to pathnode[] array
        cnt++; } } }

  numnodes=cnt;
  CullGrid();

  gi.dprintf("%d Nodes Created\n",numnodes);

//=====================================================
//================== pathfinding stuff ================
//=====================================================
/*
  // allocate memory for node array
  node = (node_t *) V_Malloc(numnodes*sizeof(node_t), TAG_LEVEL);

  // copy all the pathnode stuff to new node array
  for (i=0;i<numnodes;i++)
  {
	  VectorCopy(pathnode[i], node[i].origin);
	  node[i].nodenum = i;
  }
*/

  if (!force)
	SaveGrid();
}
示例#3
0
void Thread2(PVOID pvoid)

{

    HDC                           hdc;

    int                           iNum = 1, iLine = 0, i, iSqrt;

    PPARAMS               pparams;

    TCHAR                         szBuffer[16];



    pparams = (PPARAMS)pvoid;

    while (!pparams->bKill)

    {

        do

        {

            if (++iNum < 0)

                iNum = 0;

            iSqrt = (int)sqrt((float)iNum);

            for (i = 2; i <= iSqrt; i++)

                if (iNum % i == 0)

                    break;

        }

        while (i <= iSqrt);

        iLine = CheckBottom(pparams->hwnd, pparams->cyClient,

                            pparams->cyChar, iLine);



        hdc = GetDC(pparams->hwnd);



        TextOut(hdc, 0, iLine * pparams->cyChar, szBuffer,

                wsprintf(szBuffer, TEXT("%d"), iNum));



        ReleaseDC(pparams->hwnd, hdc);

        iLine++;

    }

    _endthread();

}