MLR_I_C_DT_PMesh.cpp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  1. //===========================================================================//
  2. // Copyright (C) Microsoft Corporation. All rights reserved. //
  3. //===========================================================================//
  4. #include "MLRHeaders.hpp"
  5. #if defined(TRACE_ENABLED) && defined(MLR_TRACE)
  6. BitTrace *MLR_I_C_DT_PMesh_Clip;
  7. #endif
  8. //#############################################################################
  9. //###### MLRIndexedPolyMesh with color but no lighting two texture layers ####$
  10. //#############################################################################
  11. MLR_I_C_DT_PMesh::ClassData*
  12. MLR_I_C_DT_PMesh::DefaultData = NULL;
  13. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  14. //
  15. void
  16. MLR_I_C_DT_PMesh::InitializeClass()
  17. {
  18. Verify(!DefaultData);
  19. Verify(gos_GetCurrentHeap() == StaticHeap);
  20. DefaultData =
  21. new ClassData(
  22. MLR_I_C_DT_PMeshClassID,
  23. "MidLevelRenderer::MLR_I_C_DT_PMesh",
  24. MLR_I_DT_PMesh::DefaultData,
  25. (MLRPrimitiveBase::Factory)&Make
  26. );
  27. Register_Object(DefaultData);
  28. #if defined(TRACE_ENABLED) && defined(MLR_TRACE)
  29. MLR_I_C_DT_PMesh_Clip = new BitTrace("MLR_I_C_DT_PMesh_Clip");
  30. Register_Object(MLR_I_C_DT_PMesh_Clip);
  31. #endif
  32. }
  33. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  34. //
  35. void
  36. MLR_I_C_DT_PMesh::TerminateClass()
  37. {
  38. Unregister_Object(DefaultData);
  39. delete DefaultData;
  40. DefaultData = NULL;
  41. #if defined(TRACE_ENABLED) && defined(MLR_TRACE)
  42. Unregister_Object(MLR_I_C_DT_PMesh_Clip);
  43. delete MLR_I_C_DT_PMesh_Clip;
  44. #endif
  45. }
  46. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  47. //
  48. MLR_I_C_DT_PMesh::MLR_I_C_DT_PMesh(
  49. ClassData *class_data,
  50. MemoryStream *stream,
  51. int version
  52. ):
  53. MLR_I_DT_PMesh(class_data, stream, version)
  54. {
  55. Check_Pointer(this);
  56. Check_Pointer(stream);
  57. Verify(gos_GetCurrentHeap() == Heap);
  58. switch(version)
  59. {
  60. case 1:
  61. case 2:
  62. {
  63. STOP(("This class got created only after version 2 !"));
  64. }
  65. break;
  66. default:
  67. {
  68. #if COLOR_AS_DWORD
  69. MemoryStreamIO_Read(stream, &colors);
  70. #else
  71. Stuff::DynamicArrayOf<DWORD> smallColors;
  72. MemoryStreamIO_Read(stream, &smallColors);
  73. int i, len = smallColors.GetLength();
  74. colors.SetLength(len);
  75. DWORD theColor;
  76. for(i=0;i<len;i++)
  77. {
  78. theColor = smallColors[i];
  79. colors[i].blue = (theColor & 0xff) * One_Over_256;
  80. theColor = theColor>>8;
  81. colors[i].green = (theColor & 0xff) * One_Over_256;
  82. theColor = theColor>>8;
  83. colors[i].red = (theColor & 0xff) * One_Over_256;
  84. theColor = theColor>>8;
  85. colors[i].alpha = (theColor & 0xff) * One_Over_256;
  86. }
  87. #endif
  88. }
  89. break;
  90. }
  91. }
  92. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  93. //
  94. MLR_I_C_DT_PMesh::MLR_I_C_DT_PMesh(ClassData *class_data):
  95. MLR_I_DT_PMesh(class_data), colors(0)
  96. {
  97. Verify(gos_GetCurrentHeap() == Heap);
  98. Check_Pointer(this);
  99. }
  100. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  101. //
  102. MLR_I_C_DT_PMesh::~MLR_I_C_DT_PMesh()
  103. {
  104. Check_Object(this);
  105. }
  106. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  107. //
  108. MLR_I_C_DT_PMesh*
  109. MLR_I_C_DT_PMesh::Make(
  110. MemoryStream *stream,
  111. int version
  112. )
  113. {
  114. Check_Object(stream);
  115. gos_PushCurrentHeap(Heap);
  116. MLR_I_C_DT_PMesh* mesh = new MLR_I_C_DT_PMesh(DefaultData, stream, version);
  117. gos_PopCurrentHeap();
  118. return mesh;
  119. }
  120. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  121. //
  122. void
  123. MLR_I_C_DT_PMesh::Save(MemoryStream *stream)
  124. {
  125. Check_Object(this);
  126. Check_Object(stream);
  127. MLR_I_DT_PMesh::Save(stream);
  128. #if COLOR_AS_DWORD
  129. MemoryStreamIO_Write(stream, &colors);
  130. #else
  131. Stuff::DynamicArrayOf<DWORD> smallColors;
  132. int i, len = colors.GetLength();
  133. const Stuff::RGBAColor *data = colors.GetData();
  134. smallColors.SetLength(len);
  135. for(i=0;i<len;i++)
  136. {
  137. smallColors[i] = GOSCopyColor(data+i);
  138. }
  139. MemoryStreamIO_Write(stream, &smallColors);
  140. #endif
  141. }
  142. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  143. //
  144. void
  145. MLR_I_C_DT_PMesh::TestInstance() const
  146. {
  147. Verify(IsDerivedFrom(DefaultData));
  148. }
  149. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  150. //
  151. void
  152. MLR_I_C_DT_PMesh::SetColorData(
  153. #if COLOR_AS_DWORD
  154. const DWORD *data,
  155. #else
  156. const RGBAColor *data,
  157. #endif
  158. int dataSize
  159. )
  160. {
  161. Check_Object(this);
  162. Check_Pointer(data);
  163. Verify(coords.GetLength() == 0 || dataSize == coords.GetLength());
  164. // Verify(texCoords.GetLength() == 0 || dataSize == texCoords.GetLength());
  165. colors.AssignData(data, dataSize);
  166. }
  167. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  168. //
  169. void
  170. MLR_I_C_DT_PMesh::GetColorData(
  171. #if COLOR_AS_DWORD
  172. DWORD **data,
  173. #else
  174. RGBAColor **data,
  175. #endif
  176. int *dataSize
  177. )
  178. {
  179. Check_Object(this);
  180. *data = colors.GetData();
  181. *dataSize = colors.GetLength();
  182. }
  183. //
  184. void
  185. MLR_I_C_DT_PMesh::PaintMe(
  186. #if COLOR_AS_DWORD
  187. const DWORD *paintMe
  188. #else
  189. const RGBAColor *paintMe
  190. #endif
  191. )
  192. {
  193. Check_Object(this);
  194. // original color is lost !!!;
  195. int k, len = colors.GetLength();
  196. #if COLOR_AS_DWORD
  197. DWORD argb = GOSCopyColor(paintMe);
  198. for(k=0;k<len;k++)
  199. {
  200. colors[k] = argb;
  201. }
  202. #else
  203. for(k=0;k<len;k++)
  204. {
  205. colors[k] = *paintMe;
  206. }
  207. #endif
  208. }
  209. #define I_SAY_YES_TO_DUAL_TEXTURES
  210. #define I_SAY_YES_TO_COLOR
  211. #undef I_SAY_YES_TO_LIGHTING
  212. #define CLASSNAME MLR_I_C_DT_PMesh
  213. #if defined(TRACE_ENABLED) && defined(MLR_TRACE)
  214. #define SET_MLR_PMESH_CLIP() MLR_I_C_DT_PMesh_Clip->Set()
  215. #define CLEAR_MLR_PMESH_CLIP() MLR_I_C_DT_PMesh_Clip->Clear()
  216. #else
  217. #define SET_MLR_PMESH_CLIP()
  218. #define CLEAR_MLR_PMESH_CLIP()
  219. #endif
  220. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  221. // This include contains follwing functions:
  222. // void MLR_I_C_DT_PMesh::TransformNoClip(Matrix4D*, GOSVertexPool*);
  223. // int MLR_I_C_DT_PMesh::Clip(MLRClippingState, GOSVertexPool*);
  224. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  225. #include <MLR\MLRPrimitiveClipping.hpp>
  226. #undef I_SAY_YES_TO_DUAL_TEXTURES
  227. #undef I_SAY_YES_TO_COLOR
  228. #undef CLASSNAME
  229. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  230. //
  231. MLR_I_C_DT_PMesh*
  232. MidLevelRenderer::CreateIndexedCube_Color_NoLit_2Tex(
  233. Scalar half,
  234. RGBAColor *eightColors,
  235. MLRState *state,
  236. MLRState *state1
  237. )
  238. {
  239. gos_PushCurrentHeap(Heap);
  240. MLR_I_C_DT_PMesh *ret = new MLR_I_C_DT_PMesh;
  241. Register_Object(ret);
  242. Point3D *coords = new Point3D [8];
  243. Register_Pointer(coords);
  244. coords[0] = Point3D( half, -half, half);
  245. coords[1] = Point3D(-half, -half, half);
  246. coords[2] = Point3D( half, -half, -half);
  247. coords[3] = Point3D(-half, -half, -half);
  248. coords[4] = Point3D(-half, half, half);
  249. coords[5] = Point3D( half, half, half);
  250. coords[6] = Point3D( half, half, -half);
  251. coords[7] = Point3D(-half, half, -half);
  252. unsigned char *lengths = new unsigned char [6];
  253. Register_Pointer(lengths);
  254. int i;
  255. for(i=0;i<6;i++)
  256. {
  257. lengths[i] = 4;
  258. }
  259. ret->SetSubprimitiveLengths(lengths, 6);
  260. ret->SetCoordData(coords, 8);
  261. unsigned short *index = new unsigned short [6*4];
  262. Register_Pointer(index);
  263. index[0] = 0;
  264. index[1] = 2;
  265. index[2] = 6;
  266. index[3] = 5;
  267. index[4] = 0;
  268. index[5] = 5;
  269. index[6] = 4;
  270. index[7] = 1;
  271. index[8] = 5;
  272. index[9] = 6;
  273. index[10] = 7;
  274. index[11] = 4;
  275. index[12] = 2;
  276. index[13] = 3;
  277. index[14] = 7;
  278. index[15] = 6;
  279. index[16] = 1;
  280. index[17] = 4;
  281. index[18] = 7;
  282. index[19] = 3;
  283. index[20] = 0;
  284. index[21] = 1;
  285. index[22] = 3;
  286. index[23] = 2;
  287. ret->SetIndexData(index, 6*4);
  288. ret->FindFacePlanes();
  289. if(eightColors!=NULL)
  290. {
  291. #if COLOR_AS_DWORD
  292. DWORD *dwColor = new DWORD [8];
  293. Register_Object(dwColor);
  294. for(i=0;i<8;i++)
  295. {
  296. dwColor[i] = GOSCopyColor(eightColors+i);
  297. }
  298. ret->SetColorData(dwColor, 8);
  299. Unregister_Pointer(dwColor);
  300. delete [] dwColor;
  301. #else
  302. ret->SetColorData(eightColors, 8);
  303. #endif
  304. }
  305. Vector2DScalar *texCoords = new Vector2DScalar[16];
  306. Register_Pointer(texCoords);
  307. for(i=0;i<16;i++)
  308. {
  309. texCoords[i] = Vector2DScalar(0.0f, 0.0f);
  310. }
  311. if(state != NULL)
  312. {
  313. ret->SetReferenceState(*state);
  314. if(state->GetTextureHandle() > 0)
  315. {
  316. texCoords[0] = Vector2DScalar(0.0f, 0.0f);
  317. texCoords[1] = Vector2DScalar(1.0f, 0.0f);
  318. texCoords[2] = Vector2DScalar(0.25f, 0.25f);
  319. texCoords[3] = Vector2DScalar(0.75f, 0.25f);
  320. texCoords[4] = Vector2DScalar(1.0f, 1.0f);
  321. texCoords[5] = Vector2DScalar(0.0f, 1.0f);
  322. texCoords[6] = Vector2DScalar(0.25f, 0.75f);
  323. texCoords[7] = Vector2DScalar(0.75f, 0.75f);
  324. }
  325. ret->SetReferenceState(*state1, 1);
  326. if(state1->GetTextureHandle() > 0)
  327. {
  328. texCoords[8] = texCoords[0];
  329. texCoords[9] = texCoords[1];
  330. texCoords[10] = texCoords[2];
  331. texCoords[11] = texCoords[3];
  332. texCoords[12] = texCoords[4];
  333. texCoords[13] = texCoords[5];
  334. texCoords[14] = texCoords[6];
  335. texCoords[15] = texCoords[7];
  336. }
  337. }
  338. ret->SetTexCoordData(texCoords, 16);
  339. Unregister_Pointer(texCoords);
  340. delete [] texCoords;
  341. Unregister_Pointer(lengths);
  342. delete [] lengths;
  343. Unregister_Pointer(index);
  344. delete [] index;
  345. Unregister_Pointer(coords);
  346. delete [] coords;
  347. gos_PopCurrentHeap();
  348. return ret;
  349. }
  350. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  351. //
  352. MLRShape*
  353. MidLevelRenderer::CreateIndexedIcosahedron_Color_NoLit_2Tex(
  354. IcoInfo& icoInfo,
  355. MLRState *state,
  356. MLRState *state2
  357. )
  358. {
  359. gos_PushCurrentHeap(Heap);
  360. MLRShape *ret = new MLRShape(20);
  361. Register_Object(ret);
  362. int i, j, k;
  363. long nrTri = (long) ceil (icoInfo.all * pow (4.0f, icoInfo.depth));
  364. Point3D v[3];
  365. if(3*nrTri >= Limits::Max_Number_Vertices_Per_Mesh)
  366. {
  367. nrTri = Limits::Max_Number_Vertices_Per_Mesh/3;
  368. }
  369. unsigned char *lengths = new unsigned char [nrTri];
  370. Register_Pointer(lengths);
  371. for(i=0;i<nrTri;i++)
  372. {
  373. lengths[i] = 3;
  374. }
  375. Point3D *coords = new Point3D [nrTri*3];
  376. Register_Pointer(coords);
  377. Point3D *collapsedCoords = NULL;
  378. if(icoInfo.indexed==true)
  379. {
  380. collapsedCoords = new Point3D [nrTri*3];
  381. Register_Pointer(collapsedCoords);
  382. }
  383. unsigned short *index = new unsigned short [nrTri*3];
  384. Register_Pointer(index);
  385. Vector2DScalar *texCoords = new Vector2DScalar[2*nrTri*3];
  386. Register_Pointer(texCoords);
  387. RGBAColor *colors = new RGBAColor[nrTri*3];
  388. Register_Pointer(colors);
  389. int uniquePoints = 0;
  390. for (k=0;k<20;k++)
  391. {
  392. MidLevelRenderer::triDrawn = 0;
  393. MLR_I_C_DT_PMesh *mesh = new MLR_I_C_DT_PMesh();
  394. Register_Object(mesh);
  395. // setup vertex position information
  396. for (j=0;j<3;j++)
  397. {
  398. v[j].x = vdata[tindices[k][j]][0];
  399. v[j].y = vdata[tindices[k][j]][1];
  400. v[j].z = vdata[tindices[k][j]][2];
  401. }
  402. subdivide (coords, v[0], v[1], v[2], icoInfo.depth, nrTri, icoInfo.radius);
  403. mesh->SetSubprimitiveLengths(lengths, nrTri);
  404. if(icoInfo.indexed==true)
  405. {
  406. uniquePoints = 1;
  407. collapsedCoords[0] = coords[0];
  408. index[0] = 0;
  409. for(i=1;i<nrTri*3;i++)
  410. {
  411. for(j=0;j<uniquePoints;j++)
  412. {
  413. if(coords[i] == collapsedCoords[j])
  414. {
  415. break;
  416. }
  417. }
  418. if(j==uniquePoints)
  419. {
  420. collapsedCoords[uniquePoints++] = coords[i];
  421. }
  422. index[i] = static_cast<unsigned short>(j);
  423. }
  424. mesh->SetCoordData(collapsedCoords, uniquePoints);
  425. }
  426. else
  427. {
  428. uniquePoints = nrTri*3;
  429. for(i=0;i<nrTri*3;i++)
  430. {
  431. index[i] = static_cast<unsigned short>(i);
  432. }
  433. mesh->SetCoordData(coords, nrTri*3);
  434. }
  435. mesh->SetIndexData(index, nrTri*3);
  436. mesh->FindFacePlanes();
  437. if(state == NULL)
  438. {
  439. for(i=0;i<2*uniquePoints;i++)
  440. {
  441. texCoords[i] = Vector2DScalar(0.0f, 0.0f);
  442. }
  443. }
  444. else
  445. {
  446. mesh->SetReferenceState(*state);
  447. if(state->GetTextureHandle() > 0)
  448. {
  449. if(icoInfo.indexed==true)
  450. {
  451. for(i=0;i<uniquePoints;i++)
  452. {
  453. texCoords[i] =
  454. Vector2DScalar(
  455. (1.0f + collapsedCoords[i].x)/2.0f,
  456. (1.0f + collapsedCoords[i].y)/2.0f
  457. );
  458. texCoords[i+uniquePoints] =
  459. Vector2DScalar(
  460. (1.0f + collapsedCoords[i].x)/2.0f,
  461. (1.0f + collapsedCoords[i].z)/2.0f
  462. );
  463. }
  464. }
  465. else
  466. {
  467. for(i=0;i<nrTri;i++)
  468. {
  469. texCoords[3*i] =
  470. Vector2DScalar(
  471. (1.0f + coords[3*i].x)/2.0f,
  472. (1.0f + coords[3*i].y)/2.0f
  473. );
  474. texCoords[3*i+1] =
  475. Vector2DScalar(
  476. (1.0f + coords[3*i+1].x)/2.0f,
  477. (1.0f + coords[3*i+1].y)/2.0f
  478. );
  479. texCoords[3*i+2] =
  480. Vector2DScalar(
  481. (1.0f + coords[3*i+2].x)/2.0f,
  482. (1.0f + coords[3*i+2].y)/2.0f
  483. );
  484. texCoords[3*i+nrTri] =
  485. Vector2DScalar(
  486. (1.0f + coords[3*i].x)/2.0f,
  487. (1.0f + coords[3*i].z)/2.0f
  488. );
  489. texCoords[3*i+1+nrTri] =
  490. Vector2DScalar(
  491. (1.0f + coords[3*i+1].x)/2.0f,
  492. (1.0f + coords[3*i+1].z)/2.0f
  493. );
  494. texCoords[3*i+2+nrTri] =
  495. Vector2DScalar(
  496. (1.0f + coords[3*i+2].x)/2.0f,
  497. (1.0f + coords[3*i+2].z)/2.0f
  498. );
  499. }
  500. }
  501. }
  502. else
  503. {
  504. for(i=0;i<2*uniquePoints;i++)
  505. {
  506. texCoords[i] = Vector2DScalar(0.0f, 0.0f);
  507. }
  508. }
  509. }
  510. mesh->SetTexCoordData(texCoords, 2*uniquePoints);
  511. if(icoInfo.indexed==true)
  512. {
  513. for(i=0;i<uniquePoints;i++)
  514. {
  515. colors[i] =
  516. RGBAColor(
  517. (1.0f + collapsedCoords[i].x)/2.0f,
  518. (1.0f + collapsedCoords[i].y)/2.0f,
  519. (1.0f + collapsedCoords[i].z)/2.0f,
  520. 1.0f
  521. );
  522. }
  523. }
  524. else
  525. {
  526. for(i=0;i<uniquePoints;i++)
  527. {
  528. colors[i] =
  529. RGBAColor(
  530. (1.0f + coords[i].x)/2.0f,
  531. (1.0f + coords[i].y)/2.0f,
  532. (1.0f + coords[i].z)/2.0f,
  533. 1.0f
  534. );
  535. }
  536. }
  537. mesh->SetColorData(colors, uniquePoints);
  538. mesh->SetReferenceState(*state2, 1);
  539. ret->Add(mesh);
  540. mesh->DetachReference();
  541. }
  542. Unregister_Pointer(colors);
  543. delete [] colors;
  544. Unregister_Pointer(texCoords);
  545. delete [] texCoords;
  546. Unregister_Pointer(index);
  547. delete [] index;
  548. if(icoInfo.indexed==true)
  549. {
  550. Unregister_Pointer(collapsedCoords);
  551. delete [] collapsedCoords;
  552. }
  553. Unregister_Pointer(coords);
  554. delete [] coords;
  555. Unregister_Pointer(lengths);
  556. delete [] lengths;
  557. gos_PopCurrentHeap();
  558. return ret;
  559. }