vehiclecurve.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686
  1. /*
  2. ** Command & Conquer Generals(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : LevelEdit *
  23. * *
  24. * $Archive:: /Commando/Code/wwmath/vehiclecurve.cpp $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 6/12/01 10:02a $*
  29. * *
  30. * $Revision:: 8 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "vehiclecurve.h"
  36. #include "vector3.h"
  37. #include "matrix3d.h"
  38. #include "persistfactory.h"
  39. #include "wwmathids.h"
  40. #include "wwmemlog.h"
  41. //////////////////////////////////////////////////////////////////////
  42. // Save-Load stuff
  43. //////////////////////////////////////////////////////////////////////
  44. SimplePersistFactoryClass<VehicleCurveClass,WWMATH_CHUNKID_VEHICLECURVE> _VehicleCurveFactory;
  45. ////////////////////////////////////////////////////////////////
  46. // Save/Load constants
  47. ////////////////////////////////////////////////////////////////
  48. enum
  49. {
  50. CHUNKID_PARENT = 0x11071217,
  51. CHUNKID_ARC_INFO,
  52. CHUNKID_VARIABLES
  53. };
  54. enum
  55. {
  56. VARID_IS_DIRTY = 1,
  57. VARID_RADIUS,
  58. };
  59. //////////////////////////////////////////////////////////////////////
  60. // Local prototypes
  61. //////////////////////////////////////////////////////////////////////
  62. bool Find_Tangent (const Vector3 &center, float radius, const Vector3 &point, bool clockwise, float *result);
  63. float Get_Angle_Delta (float angle1, float angle2, bool clockwise);
  64. void Find_Turn_Arc (const Matrix3D &transform, float radius, const Vector3 &prev_pt, const Vector3 &curr_pt, const Vector3 &next_pt, Vector3 *arc_center, bool *is_right_turn);
  65. void Find_Tangents (float radius, const Vector3 &prev_pt, const Vector3 &curr_pt, const Vector3 &next_pt, const Vector3 &arc_center, bool is_right_turn, float *point_angle, float *angle_in_delta, float *angle_out_delta);
  66. //////////////////////////////////////////////////////////////////////
  67. //
  68. // Find_Tangent
  69. //
  70. //////////////////////////////////////////////////////////////////////
  71. bool
  72. Find_Tangent
  73. (
  74. const Vector3 & center,
  75. float radius,
  76. const Vector3 & point,
  77. bool clockwise,
  78. float * result
  79. )
  80. {
  81. bool retval = false;
  82. //
  83. // Calculate the distance from the point to the center of the circle
  84. //
  85. float delta_x = point.X - center.X;
  86. float delta_y = point.Y - center.Y;
  87. float dist = ::sqrt (delta_x * delta_x + delta_y * delta_y);
  88. if (dist >= radius) {
  89. //
  90. // Determine the offset angle (from the line between the point and center)
  91. // where the 2 tangent points lie.
  92. //
  93. float angle_offset = WWMath::Acos (radius / dist);
  94. float base_angle = WWMath::Atan2 (delta_x, -delta_y);
  95. base_angle = WWMath::Wrap (base_angle, 0, DEG_TO_RADF (360));
  96. //
  97. // Determine which tangent angle we would come across first, depending
  98. // on our orientation
  99. //
  100. float angle = 0;
  101. if (clockwise) {
  102. angle = base_angle - angle_offset;
  103. } else {
  104. angle = base_angle + angle_offset;
  105. }
  106. angle = WWMath::Wrap (angle, 0, DEG_TO_RADF (360));
  107. (*result) = angle;
  108. retval = true;
  109. }
  110. return retval;
  111. }
  112. //////////////////////////////////////////////////////////////////////
  113. //
  114. // Get_Angle_Delta
  115. //
  116. // Angle deltas need to be wrapped around 360 degrees differently
  117. // depending on the orientation (clockwise/counterclockwise). This
  118. // function takes orientation into consideration when determining
  119. // the delta.
  120. //
  121. //////////////////////////////////////////////////////////////////////
  122. float
  123. Get_Angle_Delta
  124. (
  125. float angle1,
  126. float angle2,
  127. bool clockwise
  128. )
  129. {
  130. float result = angle1 - angle2;
  131. if (clockwise) {
  132. if (angle1 < angle2) {
  133. result = angle1 - (angle2 - DEG_TO_RADF (360));
  134. }
  135. } else {
  136. if (angle1 > angle2) {
  137. result = (angle1 - DEG_TO_RADF (360)) - angle2;
  138. }
  139. }
  140. return result;
  141. }
  142. //////////////////////////////////////////////////////////////////////
  143. //
  144. // Find_Turn_Arc
  145. //
  146. //////////////////////////////////////////////////////////////////////
  147. void
  148. Find_Turn_Arc
  149. (
  150. const Matrix3D & transform,
  151. float radius,
  152. const Vector3 & prev_pt,
  153. const Vector3 & curr_pt,
  154. const Vector3 & next_pt,
  155. Vector3 * arc_center,
  156. bool * is_right_turn
  157. )
  158. {
  159. //
  160. // The center of the turn arc can lie anywhere on the circle centered
  161. // at the current point and 'radius' meters in radius.
  162. //
  163. // We will assume the optimal center of the turn arc will lie at
  164. // the point halfway between the angles formed by the (prev-curr) and
  165. // (next-curr) vectors.
  166. //
  167. float angle1 = ::WWMath::Atan2 ((prev_pt.Y - curr_pt.Y), prev_pt.X - curr_pt.X);
  168. angle1 = WWMath::Wrap (angle1, 0, DEG_TO_RADF (360));
  169. float angle2 = ::WWMath::Atan2 ((next_pt.Y - curr_pt.Y), next_pt.X - curr_pt.X);
  170. angle2 = WWMath::Wrap (angle2, 0, DEG_TO_RADF (360));
  171. float avg_angle = (angle1 + angle2) * 0.5F;
  172. //
  173. // Find the shortest delta between the two angles (either clockwise or
  174. // counterclockwise).
  175. //
  176. float delta1 = WWMath::Fabs (::Get_Angle_Delta (angle1, angle2, true));
  177. float delta2 = WWMath::Fabs (::Get_Angle_Delta (angle1, angle2, false));
  178. if (delta1 < delta2) {
  179. avg_angle = angle1 - (delta1 * 0.5F);
  180. } else {
  181. avg_angle = angle1 + (delta2 * 0.5F);
  182. }
  183. //
  184. // Find the point on the circle at this angle
  185. //
  186. arc_center->X = curr_pt.X + (radius * ::WWMath::Cos (avg_angle));
  187. arc_center->Y = curr_pt.Y + (radius * ::WWMath::Sin (avg_angle));
  188. arc_center->Z = curr_pt.Z;
  189. //
  190. // Will we be making a right turn or a left turn?
  191. //
  192. Vector3 rel_center;
  193. Matrix3D::Inverse_Transform_Vector (transform, *arc_center, &rel_center);
  194. (*is_right_turn) = (rel_center.Y > 0);
  195. return ;
  196. }
  197. //////////////////////////////////////////////////////////////////////
  198. //
  199. // Find_Tangents
  200. //
  201. //////////////////////////////////////////////////////////////////////
  202. void
  203. Find_Tangents
  204. (
  205. float radius,
  206. const Vector3 & prev_pt,
  207. const Vector3 & curr_pt,
  208. const Vector3 & next_pt,
  209. const Vector3 & arc_center,
  210. bool is_right_turn,
  211. float * point_angle,
  212. float * angle_in_delta,
  213. float * angle_out_delta
  214. )
  215. {
  216. //
  217. // Find the 'in' and 'out' tangent angles
  218. //
  219. float angle_in = 0;
  220. float angle_out = 0;
  221. bool valid_in = ::Find_Tangent (arc_center, radius, prev_pt, is_right_turn, &angle_in);
  222. bool valid_out = ::Find_Tangent (arc_center, radius, next_pt, !is_right_turn, &angle_out);
  223. //
  224. // Find the angle where the current position lies on the turn arc
  225. //
  226. (*point_angle) = ::WWMath::Atan2 (curr_pt.X - arc_center.X, -(curr_pt.Y - arc_center.Y));
  227. (*point_angle) = WWMath::Wrap ((*point_angle), 0, DEG_TO_RADF (360));
  228. //
  229. // If the tangent-in is valid, find its delta from the 'point angle.
  230. //
  231. if (valid_in) {
  232. (*angle_in_delta) = ::Get_Angle_Delta (angle_in, (*point_angle), is_right_turn);
  233. } else {
  234. (*angle_in_delta) = 0;
  235. }
  236. //
  237. // If the tangent-out is valid, find its delta from the 'point angle.
  238. //
  239. if (valid_out) {
  240. (*angle_out_delta) = ::Get_Angle_Delta (angle_out, (*point_angle), !is_right_turn);
  241. } else {
  242. (*angle_out_delta) = 0;
  243. }
  244. return ;
  245. }
  246. //////////////////////////////////////////////////////////////////////
  247. //
  248. // Update_Arc_List
  249. //
  250. //////////////////////////////////////////////////////////////////////
  251. void
  252. VehicleCurveClass::Update_Arc_List (void)
  253. {
  254. WWMEMLOG(MEM_PATHFIND);
  255. m_ArcList.Delete_All ();
  256. //
  257. // Bail out if there is nothing to do
  258. //
  259. int count = Key_Count ();
  260. if (count == 0) {
  261. return ;
  262. }
  263. //
  264. // Add a record for the starting point of the arc...
  265. //
  266. ArcInfoStruct arc_start;
  267. arc_start.point_in = Keys[0].Point;
  268. arc_start.point_out = Keys[0].Point;
  269. arc_start.center = Keys[0].Point;
  270. arc_start.point_angle = 0;
  271. arc_start.radius = 0;
  272. arc_start.angle_in_delta = 0;
  273. arc_start.angle_out_delta = 0;
  274. m_ArcList.Add (arc_start);
  275. //
  276. // Loop over each 'interior' point and generate arc information
  277. // for each.
  278. //
  279. for (int index = 1; index < count - 1; index ++) {
  280. //
  281. // Get information about the previous, next, and current points.
  282. //
  283. Vector3 prev_pt;
  284. Vector3 next_pt;
  285. Vector3 curr_pt;
  286. float time = 0;
  287. Get_Key (index-1, &prev_pt, &time);
  288. Get_Key (index, &curr_pt, &time);
  289. Get_Key (index+1, &next_pt, &time);
  290. //
  291. // Determine the last known point on the path
  292. //
  293. Vector3 last_path_pt = m_ArcList[index-1].point_out;
  294. //
  295. // Create a transformation matrix to simulate the vehicle's position and
  296. // orientation at the last point...
  297. //
  298. Vector3 x_vector (curr_pt - last_path_pt);
  299. Vector3 z_vector (0, 0, 1);
  300. x_vector.Normalize ();
  301. #ifdef ALLOW_TEMPORARIES
  302. Vector3 y_vector = Vector3::Cross_Product (x_vector, z_vector);
  303. #else
  304. Vector3 y_vector;
  305. Vector3::Cross_Product (x_vector, z_vector, &y_vector);
  306. #endif
  307. Matrix3D tm (x_vector, y_vector, z_vector, last_path_pt);
  308. //
  309. // Find where the turn arc should be centered and whether we should
  310. // make a right-turn or a left turn...
  311. //
  312. bool is_right_turn = false;
  313. Vector3 arc_center (0, 0, 0);
  314. ::Find_Turn_Arc ( tm,
  315. m_Radius,
  316. last_path_pt,
  317. curr_pt,
  318. next_pt,
  319. &arc_center,
  320. &is_right_turn);
  321. //
  322. // Determine where the vehicle should enter and exit the turn
  323. //
  324. float angle_in_delta = 0;
  325. float angle_out_delta = 0;
  326. float point_angle = 0;
  327. ::Find_Tangents ( m_Radius,
  328. last_path_pt,
  329. curr_pt,
  330. next_pt,
  331. arc_center,
  332. is_right_turn,
  333. &point_angle,
  334. &angle_in_delta,
  335. &angle_out_delta);
  336. //
  337. // Determine at what points these angles intersect the arc
  338. //
  339. Vector3 point_in (0, 0, 0);
  340. point_in.X = arc_center.X + (m_Radius * ::WWMath::Sin (point_angle + angle_in_delta));
  341. point_in.Y = arc_center.Y + (m_Radius * -::WWMath::Cos (point_angle + angle_in_delta));
  342. Vector3 point_out (0, 0, 0);
  343. point_out.X = arc_center.X + (m_Radius * ::WWMath::Sin (point_angle + angle_out_delta));
  344. point_out.Y = arc_center.Y + (m_Radius * -::WWMath::Cos (point_angle + angle_out_delta));
  345. //
  346. // Sanity check to ensure the vehicle doesn't try to go the long way around the
  347. // turn arc...
  348. //
  349. if ( angle_in_delta > DEG_TO_RADF (200) || angle_out_delta > DEG_TO_RADF (200) ||
  350. angle_in_delta < -DEG_TO_RADF (200) || angle_out_delta < -DEG_TO_RADF (200) )
  351. {
  352. //
  353. // Record information about this arc
  354. //
  355. ArcInfoStruct arc_info;
  356. arc_info.center = curr_pt;
  357. arc_info.point_angle = 0;
  358. arc_info.point_in = curr_pt;
  359. arc_info.point_out = curr_pt;
  360. arc_info.radius = 0;
  361. arc_info.angle_in_delta = 0;
  362. arc_info.angle_out_delta = 0;
  363. m_ArcList.Add (arc_info);
  364. } else {
  365. //
  366. // Record information about this arc
  367. //
  368. ArcInfoStruct arc_info;
  369. arc_info.center = arc_center;
  370. arc_info.point_angle = point_angle;
  371. arc_info.point_in = point_in;
  372. arc_info.point_out = point_out;
  373. arc_info.radius = m_Radius;
  374. arc_info.angle_in_delta = angle_in_delta;
  375. arc_info.angle_out_delta = angle_out_delta;
  376. m_ArcList.Add (arc_info);
  377. }
  378. }
  379. //
  380. // Add a record for the starting point of the arc...
  381. //
  382. if (count > 1) {
  383. ArcInfoStruct arc_end;
  384. arc_end.point_in = Keys[count-1].Point;
  385. arc_end.point_out = Keys[count-1].Point;
  386. arc_end.center = Keys[count-1].Point;
  387. arc_end.point_angle = 0;
  388. arc_end.radius = 0;
  389. arc_end.angle_in_delta = 0;
  390. arc_end.angle_out_delta = 0;
  391. m_ArcList.Add (arc_end);
  392. }
  393. m_IsDirty = false;
  394. return ;
  395. }
  396. //////////////////////////////////////////////////////////////////////
  397. //
  398. // Evaluate
  399. //
  400. //////////////////////////////////////////////////////////////////////
  401. void
  402. VehicleCurveClass::Evaluate (float time, Vector3 *set_val)
  403. {
  404. int count = Keys.Count ();
  405. m_Sharpness = 0;
  406. if (time < Keys[0].Time) {
  407. *set_val = Keys[0].Point;
  408. m_LastTime = Keys[0].Time;
  409. return;
  410. }
  411. if (time >= Keys[count - 1].Time) {
  412. *set_val = Keys[count - 1].Point;
  413. m_LastTime = Keys[count - 1].Time;
  414. return;
  415. }
  416. //
  417. // Update the arc information if any of the keys have changed...
  418. //
  419. if (m_IsDirty) {
  420. Update_Arc_List ();
  421. }
  422. //
  423. // Determine which segment we are on
  424. //
  425. int index0 = 0;
  426. int index1 = 0;
  427. float seg_time = 0;
  428. Find_Interval (time, &index0, &index1, &seg_time);
  429. ArcInfoStruct &arc_info0 = m_ArcList[index0];
  430. ArcInfoStruct &arc_info1 = m_ArcList[index1];
  431. //
  432. // Determine the lengths of each segment of this curve.
  433. // The segments are:
  434. // - Exit curve from prev point
  435. // - Straight line from exit of last curve to enter of this curve
  436. // - Enter curve for the current point
  437. //
  438. float arc_length0 = arc_info0.radius * WWMath::Fabs (arc_info0.angle_out_delta);
  439. float arc_length1 = arc_info1.radius * WWMath::Fabs (arc_info1.angle_in_delta);
  440. float other_length = ((arc_info1.point_in - arc_info0.point_out).Length ()) / 2;
  441. float total_length = arc_length0 + arc_length1 + other_length;
  442. //
  443. // Determine at what times we should switch between parts of the segment
  444. //
  445. float time1 = arc_length0 / total_length;
  446. float time2 = (arc_length0 + other_length) / total_length;
  447. //
  448. // Determine which part of the segment we are on
  449. //
  450. if (seg_time < time1) {
  451. //
  452. // We are on the initial curve of the segment, so calculate where
  453. // on the curve we are...
  454. //
  455. //float percent = seg_time / time1;
  456. //float angle = arc_info0.point_angle + (arc_info0.angle_out_delta) * percent;
  457. float angle = arc_info0.point_angle + arc_info0.angle_out_delta;
  458. set_val->X = arc_info0.center.X + (arc_info0.radius * ::WWMath::Sin (angle));
  459. set_val->Y = arc_info0.center.Y + (arc_info0.radius * -::WWMath::Cos (angle));
  460. m_Sharpness = WWMath::Clamp (WWMath::Fabs (arc_info0.angle_out_delta) / DEG_TO_RADF (15), 0, 1.0F);
  461. m_SharpnessPos.X = set_val->X;
  462. m_SharpnessPos.Y = set_val->Y;
  463. m_SharpnessPos.Z = Keys[index0].Point.Z + (Keys[index1].Point.Z - Keys[index0].Point.Z) * seg_time;
  464. m_LastTime = Keys[index0].Time + (Keys[index1].Time - Keys[index0].Time) * time1;
  465. } else if (seg_time < time2) {
  466. //
  467. // We are on the line between the two curves, so calculate where on
  468. // the line we are
  469. //
  470. float percent = (seg_time - time1) / (time2 - time1);
  471. if (percent == 0) {
  472. set_val->X = arc_info0.point_out.X;
  473. set_val->Y = arc_info0.point_out.Y;
  474. } else {
  475. set_val->X = arc_info1.point_in.X;
  476. set_val->Y = arc_info1.point_in.Y;
  477. }
  478. //set_val->X = arc_info0.point_out.X + (arc_info1.point_in.X - arc_info0.point_out.X) * percent;
  479. //set_val->Y = arc_info0.point_out.Y + (arc_info1.point_in.Y - arc_info0.point_out.Y) * percent;
  480. m_Sharpness = WWMath::Clamp (WWMath::Fabs (arc_info1.angle_out_delta) / DEG_TO_RADF (15), 0, 1.0F);
  481. m_SharpnessPos = arc_info1.point_in;
  482. m_LastTime = Keys[index0].Time + (Keys[index1].Time - Keys[index0].Time) * time2;
  483. } else {
  484. //
  485. // We are on the ending curve of the segment, so calculate where
  486. // on the curve we are...
  487. //
  488. /*float percent = 1.0F - ((seg_time - time2) / (1.0F - time2));
  489. float angle = arc_info1.point_angle + (arc_info1.angle_in_delta * percent);
  490. set_val->X = arc_info1.center.X + (arc_info1.radius * ::WWMath::Sin (angle));
  491. set_val->Y = arc_info1.center.Y + (arc_info1.radius * -::WWMath::Cos (angle)); */
  492. float angle = arc_info1.point_angle + (arc_info1.angle_out_delta);
  493. set_val->X = arc_info1.center.X + (arc_info1.radius * ::WWMath::Sin (angle));
  494. set_val->Y = arc_info1.center.Y + (arc_info1.radius * -::WWMath::Cos (angle));
  495. m_Sharpness = WWMath::Clamp (WWMath::Fabs (arc_info1.angle_out_delta) / DEG_TO_RADF (15), 0, 1.0F);
  496. m_SharpnessPos.X = set_val->X;
  497. m_SharpnessPos.Y = set_val->Y;
  498. m_SharpnessPos.Z = Keys[index0].Point.Z + (Keys[index1].Point.Z - Keys[index0].Point.Z) * seg_time;
  499. m_LastTime = Keys[index1].Time;
  500. }
  501. //
  502. // Our Z value is just a linear interpolation
  503. //
  504. set_val->Z = Keys[index0].Point.Z + (Keys[index1].Point.Z - Keys[index0].Point.Z) * seg_time;
  505. return ;
  506. }
  507. const PersistFactoryClass & VehicleCurveClass::Get_Factory(void) const
  508. {
  509. return _VehicleCurveFactory;
  510. }
  511. ////////////////////////////////////////////////////////////////////////////////////////////
  512. //
  513. // Save
  514. //
  515. ////////////////////////////////////////////////////////////////////////////////////////////
  516. bool
  517. VehicleCurveClass::Save (ChunkSaveClass &csave)
  518. {
  519. csave.Begin_Chunk (CHUNKID_PARENT);
  520. Curve3DClass::Save (csave);
  521. csave.End_Chunk ();
  522. csave.Begin_Chunk (CHUNKID_VARIABLES);
  523. //
  524. // Save each variable to its own microchunk
  525. //
  526. WRITE_MICRO_CHUNK (csave, VARID_IS_DIRTY, m_IsDirty);
  527. WRITE_MICRO_CHUNK (csave, VARID_RADIUS, m_Radius);
  528. csave.End_Chunk ();
  529. //
  530. // Save each arc info struct to its own chunk
  531. //
  532. for (int index = 0; index < m_ArcList.Count (); index ++) {
  533. ArcInfoStruct &arc_info = m_ArcList[index];
  534. csave.Begin_Chunk (CHUNKID_ARC_INFO);
  535. csave.Write (&arc_info, sizeof (arc_info));
  536. csave.End_Chunk ();
  537. }
  538. return true;
  539. }
  540. ////////////////////////////////////////////////////////////////////////////////////////////
  541. //
  542. // Load
  543. //
  544. ////////////////////////////////////////////////////////////////////////////////////////////
  545. bool
  546. VehicleCurveClass::Load (ChunkLoadClass &cload)
  547. {
  548. while (cload.Open_Chunk ()) {
  549. switch (cload.Cur_Chunk_ID ()) {
  550. case CHUNKID_PARENT:
  551. Curve3DClass::Load (cload);
  552. break;
  553. case CHUNKID_ARC_INFO:
  554. {
  555. ArcInfoStruct arc_info;
  556. cload.Read (&arc_info, sizeof (arc_info));
  557. m_ArcList.Add (arc_info);
  558. }
  559. break;
  560. case CHUNKID_VARIABLES:
  561. Load_Variables (cload);
  562. break;
  563. }
  564. cload.Close_Chunk ();
  565. }
  566. return true;
  567. }
  568. ///////////////////////////////////////////////////////////////////////
  569. //
  570. // Load_Variables
  571. //
  572. ///////////////////////////////////////////////////////////////////////
  573. void
  574. VehicleCurveClass::Load_Variables (ChunkLoadClass &cload)
  575. {
  576. //
  577. // Loop through all the microchunks that define the variables
  578. //
  579. while (cload.Open_Micro_Chunk ()) {
  580. switch (cload.Cur_Micro_Chunk_ID ()) {
  581. READ_MICRO_CHUNK (cload, VARID_IS_DIRTY, m_IsDirty);
  582. READ_MICRO_CHUNK (cload, VARID_RADIUS, m_Radius);
  583. }
  584. cload.Close_Micro_Chunk ();
  585. }
  586. return ;
  587. }