• R/O
  • SSH
  • HTTPS

marathon: コミット


コミットメタ情報

リビジョン360 (tree)
日時2007-07-03 19:15:46
作者hogepiyo

ログメッセージ

*** empty log message ***

変更サマリ

差分

--- marathon/trunk/MapEditorWX/src/LinePropDialog.cpp (revision 359)
+++ marathon/trunk/MapEditorWX/src/LinePropDialog.cpp (revision 360)
@@ -170,10 +170,10 @@
170170 text_ctrl_45->SetValue(getString("%d", line->length));
171171 text_ctrl_46->SetValue(getString("%d", line->highest_adjacent_floor));
172172 text_ctrl_47->SetValue(getString("%d", line->lowest_adjacent_ceiling));
173- checkbox_45->SetValue(LINE_IS_LANDSCAPED(line));
174- checkbox_52->SetValue(LINE_IS_ELEVATION(line));
175- checkbox_53->SetValue(LINE_IS_VARIABLE_ELEVATION(line));
176- checkbox_54->SetValue(LINE_HAS_TRANSPARENT_SIDE(line));
173+ checkbox_45->SetValue(LINE_IS_LANDSCAPED(line) != 0);
174+ checkbox_52->SetValue(LINE_IS_ELEVATION(line) != 0);
175+ checkbox_53->SetValue(LINE_IS_VARIABLE_ELEVATION(line) != 0);
176+ checkbox_54->SetValue(LINE_HAS_TRANSPARENT_SIDE(line) != 0);
177177 int sel = LINE_IS_SOLID(line) ? 0: 1;
178178 radio_box_1->SetSelection(sel);
179179 index = line->clockwise_polygon_side_index;
--- marathon/trunk/MapEditorWX/src/MainFrameLeftDown.cpp (revision 359)
+++ marathon/trunk/MapEditorWX/src/MainFrameLeftDown.cpp (revision 360)
@@ -426,8 +426,8 @@
426426 }else{
427427 //でなけば線を作成する
428428 line_data line;
429- if(!hpl::aleph::map::createLine(wxGetApp().prevPointIndex,
430- pointIndex, &line))wxFAIL;//hpl::error::halt("line creation failure");
429+ hpl::aleph::map::createLine(wxGetApp().prevPointIndex,
430+ pointIndex, &line);
431431 int newLineIndex = hpl::aleph::map::addLine(line);
432432 }
433433 wxGetApp().prevPointIndex = pointIndex;
@@ -482,17 +482,21 @@
482482
483483 //点を追加
484484 endpoint_data ep;
485- assert(hpl::aleph::map::createPoint(wpoint, &ep));
485+ hpl::aleph::map::createPoint(wpoint, &ep);
486486 int newPointIndex = hpl::aleph::map::addEndpoint(ep);
487- assert(newPointIndex != NONE);
487+#ifdef __WXDEBUG__
488+ wxASSERT(newPointIndex != NONE);
489+#endif
488490 endpoint_data *newEp = get_endpoint_data(newPointIndex);
489491
490492 //始点→点の線を追加
491493 line_data newLine1;
492- assert(hpl::aleph::map::createLine(epStartIndex,
493- newPointIndex, &newLine1));
494+ hpl::aleph::map::createLine(epStartIndex,
495+ newPointIndex, &newLine1);
494496 int newLine1Index = hpl::aleph::map::addLine(newLine1);
495- assert(newLine1Index != NONE);
497+#ifdef __WXDEBUG__
498+ wxASSERT(newLine1Index != NONE);
499+#endif
496500
497501 //点→終点の線を追加
498502 line_data newLine2;
@@ -499,6 +503,9 @@
499503 hpl::aleph::map::createLine(newPointIndex, epEndIndex,
500504 &newLine2);
501505 int newLine2Index = hpl::aleph::map::addLine(newLine2);
506+#ifdef __WXDEBUG__
507+ wxASSERT(newLine2Index != NONE);
508+#endif
502509
503510
504511 if(wxGetApp().isFirstOfLineToAdd){
@@ -506,9 +513,7 @@
506513 }else{
507514 //前回→今回の点の間に線を追加
508515 line_data newLine;
509- if(!hpl::aleph::map::createLine(wxGetApp().prevPointIndex, newPointIndex, &newLine)){
510- hpl::error::halt("line creation failure");
511- }
516+ hpl::aleph::map::createLine(wxGetApp().prevPointIndex, newPointIndex, &newLine);
512517 int lineIndex = hpl::aleph::map::addLine(newLine);
513518 }
514519 wxGetApp().prevPointIndex = newPointIndex;
@@ -516,7 +521,7 @@
516521 }else{
517522 //新規追加
518523 endpoint_data ep;
519- assert(hpl::aleph::map::createPoint(wpoint, &ep));
524+ hpl::aleph::map::createPoint(wpoint, &ep);
520525 int newPointIndex = hpl::aleph::map::addEndpoint(ep);
521526 if(wxGetApp().isFirstOfLineToAdd){
522527 //最初の点なので追加しない
@@ -523,7 +528,7 @@
523528 }else{
524529 //線を追加する
525530 line_data line;
526- assert(hpl::aleph::map::createLine(wxGetApp().prevPointIndex, newPointIndex, &line));
531+ hpl::aleph::map::createLine(wxGetApp().prevPointIndex, newPointIndex, &line);
527532 int newLineIndex = hpl::aleph::map::addLine(line);
528533 }
529534
--- marathon/trunk/MapEditorWX/src/MainFrameMenuEvent.cpp (revision 359)
+++ marathon/trunk/MapEditorWX/src/MainFrameMenuEvent.cpp (revision 360)
@@ -440,31 +440,23 @@
440440
441441 void MapEditorMainFrame::OnLineProp(wxCommandEvent& ev)
442442 {
443- LinePropDialog dlg;
444- dlg.Create(this, wxID_ANY);
445- dlg.setLineIndex(wxGetApp().popupLineIndex);
446- dlg.ShowModal();
443+ this->linePropDialog.setLineIndex(wxGetApp().popupLineIndex);
444+ this->linePropDialog.Show(true);
447445 }
448446 void MapEditorMainFrame::OnClockwiseSide(wxCommandEvent& ev)
449447 {
450448 //TODO
451- SidePropDialog dlg;
452- dlg.Create(this, wxID_ANY);
453- dlg.setIndex(get_line_data(wxGetApp().popupLineIndex)->clockwise_polygon_side_index);
454- dlg.ShowModal();
449+ this->sidePropDialog.setIndex(get_line_data(wxGetApp().popupLineIndex)->clockwise_polygon_side_index);
450+ this->sidePropDialog->Show(true);
455451 }
456452 void MapEditorMainFrame::OnCounterclockwiseSide(wxCommandEvent& ev)
457453 {
458454 //TODO
459- SidePropDialog dlg;
460- dlg.Create(this, wxID_ANY);
461- dlg.setIndex(get_line_data(wxGetApp().popupLineIndex)->counterclockwise_polygon_side_index);
462- dlg.ShowModal();
455+ this->sidePropDialog.setIndex(get_line_data(wxGetApp().popupLineIndex)->counterclockwise_polygon_side_index);
456+ this->sidePropDialog->Show(true);
463457 }
464458 void MapEditorMainFrame::OnPointProp(wxCommandEvent& ev)
465459 {
466- PointPropDialog dlg;
467- dlg.Create(this, wxID_ANY);
468- dlg.setIndex(wxGetApp().popupEndpointIndex);
469- dlg.ShowModal();
460+ this->pointPropDialog.setIndex(wxGetApp().popupEndpointIndex);
461+ this->pointPropDialog.Show(true);
470462 }
--- marathon/trunk/MapEditorWX/WXTODOリスト.txt (revision 359)
+++ marathon/trunk/MapEditorWX/WXTODOリスト.txt (revision 360)
@@ -185,4 +185,5 @@
185185 ?ɂ???ă|?C???^?A?h???X???ω????邱?Ƃ?????B
186186 ?lj??E?폜?????ꍇ?A????܂łɕێ????Ă???line_data*?Ȃǂ̃|?C???^?͎g??Ȃ????ƁI
187187
188-quickSort?̌???
188+?ς? quickSort?̌???
189+TODO ???lj????ƒlj??I???i?J?n?O?j?ƂŃJ?[?\???̌`??ς???
--- marathon/trunk/HPLLib/HPLMapToolModifier.cpp (revision 359)
+++ marathon/trunk/HPLLib/HPLMapToolModifier.cpp (revision 360)
@@ -6,8 +6,172 @@
66 #include "HPLError.h"
77 #include "HPLStringModifier.h"
88 #include "map.h"
9+#include "HPLStockManager.h"
10+//角度の最大
11+const double DEG_ROUND = 360.0;
912
13+//////////////////////////////////////////////////////
14+/////// add delete and modify
1015 /**
16+ 点情報を追加します
17+ @param ep 追加する点データ(値渡しなのでコピーされます)
18+ @return 追加された点のインデックス値
19+*/
20+int hpl::aleph::map::addEndpoint(endpoint_data ep)
21+{
22+ EndpointList.push_back(ep);
23+ dynamic_world->endpoint_count = (int16)EndpointList.size();
24+ int index = dynamic_world->endpoint_count - 1;
25+ return index;
26+}
27+int hpl::aleph::map::addLine(line_data line)
28+{
29+ LineList.push_back(line);
30+ dynamic_world->line_count = (int16)LineList.size();
31+ int index = dynamic_world->line_count - 1;
32+ return index;
33+}
34+int hpl::aleph::map::addSide(side_data side, bool isClockwise)
35+{
36+ SideList.push_back(side);
37+ dynamic_world->side_count = (int16)SideList.size();
38+ int index = dynamic_world->side_count - 1;
39+ //依存するものを修正する
40+ //・線
41+ //・ポリゴン
42+ //・Side
43+ //TODO 左右の確認が必要
44+ side_data* newSide = get_side_data(index);
45+ line_data* line = get_line_data(newSide->line_index);
46+#ifdef __WXDEBUG__
47+ wxASSERT(line);
48+#else
49+ if(!line){
50+ hpl::error::halt("line[%d] doesn't exist", newSide->line_index);
51+ }
52+#endif
53+ polygon_data* poly = get_polygon_data(newSide->polygon_index);
54+#ifdef __WXDEBUG__
55+ wxASSERT(poly);
56+#else
57+ if(!poly){
58+ hpl::error::halt("polygon[%d] doesn't exist", newSide->polygon_index);
59+ }
60+#endif
61+ if(isClockwise){
62+ line->clockwise_polygon_side_index = index;
63+ }else{
64+ line->counterclockwise_polygon_side_index = index;
65+ }
66+
67+ //ポリゴン
68+ int lineIndexInPolygon = NONE;
69+ for(int i = 0; i < poly->vertex_count; i ++){
70+ if(poly->line_indexes[i] == newSide->line_index){
71+ lineIndexInPolygon = i;
72+ break;
73+ }
74+ }
75+#ifdef __WXDEBUG__
76+ wxASSERT(lineIndexInPolygon != NONE);
77+#else
78+ if(lineIndexInPolygon == NONE){
79+ hpl::error::halt("line[%d] doesn't exist in polygon[%d]'s line_index", side->line_index, side->polygon_index);
80+ }
81+#endif
82+ poly->side_indexes[lineIndexInPolygon] = index;
83+
84+
85+ return index;
86+}
87+int hpl::aleph::map::addPolygon(polygon_data polygon)
88+{
89+ PolygonList.push_back(polygon);
90+ dynamic_world->polygon_count = (int16)PolygonList.size();
91+ int index = dynamic_world->polygon_count - 1;
92+
93+ polygon_data* poly = get_polygon_data(index);
94+
95+ //以下の依存する項目を修正する
96+ //・点(adjacent)
97+ //・線(owner)
98+ //・Side
99+ //TODO
100+ for(int i = 0; i < poly->vertex_count; i ++){
101+ int next = i + 1;
102+ if(next >= poly->vertex_count){
103+ next = 0;
104+ }
105+ endpoint_data* ep1 = get_endpoint_data(poly->endpoint_indexes[i]);
106+ //関連ポリゴンの指定が無ければ指定
107+ if(ep1->supporting_polygon_index == NONE){
108+ ep1->supporting_polygon_index = index;
109+ }
110+
111+ endpoint_data* ep2 = get_endpoint_data(poly->endpoint_indexes[next]);
112+
113+ //線
114+ line_data* line = get_line_data(poly->line_indexes[i]);
115+ if(line->endpoint_indexes[0] == poly->endpoint_indexes[i]){
116+ //順向き→clockwise
117+ line->clockwise_polygon_owner = index;
118+ side_data* side = get_side_data(line->clockwise_polygon_side_index);
119+ if(side)
120+ side->polygon_index = index;
121+ }else if(line->endpoint_indexes[0] == poly->endpoint_indexes[next]){
122+ //逆向き→counterclockwise
123+ line->counterclockwise_polygon_owner = index;
124+ side_data* side = get_side_data(line->counterclockwise_polygon_side_index);
125+ if(side)
126+ side->polygon_index = index;
127+ }else{
128+#ifdef __WXDEBUG__
129+ wxASSERT(false);
130+#else
131+ hpl::error::halt("invalid polygon frame");
132+#endif
133+ }
134+ }
135+ return index;
136+}
137+int hpl::aleph::map::addMapSavedObject(map_object object)
138+{
139+ SavedObjectList.push_back(object);
140+ //TODO
141+ //プレースメント情報に付加
142+
143+ //TODO どれを集計すれば良いのか?
144+// dynamic_world->object_count ++;// SavedObjectList.size();
145+ dynamic_world->initial_objects_count = (int16)SavedObjectList.size();
146+ int index = dynamic_world->initial_objects_count - 1;
147+
148+ map_object* obj = &SavedObjectList[index];
149+
150+ //依存する項目を修正する
151+ //・ポリゴン
152+ polygon_data* poly = get_polygon_data(obj->polygon_index);
153+#ifdef __WXDEBUG__
154+ wxASSERT(poly);
155+#else
156+ if(!poly){
157+ hpl::error::halt("poly[%d] not found", obj->polygon_index);
158+ }
159+#endif
160+ if(poly->first_object == NONE){
161+ poly->first_object = index;
162+ }
163+ return index;
164+}
165+int hpl::aleph::map::addAnnotation(map_annotation annotation)
166+{
167+ MapAnnotationList.push_back(annotation);
168+/* dynamic_world-> = MapAnnotationList.size();
169+ int index = dynamic_world->annotation_count - 1;*/
170+ int index = (int16)MapAnnotationList.size() - 1;
171+ return index;
172+}
173+
174+/**
11175 マップアイテム(点・線・Side・ポリゴン・オブジェクト)
12176 を削除します
13177 手法としては、
@@ -133,3 +297,461 @@
133297
134298 return true;
135299 }
300+
301+///////////////////////////////////////////////////////
302+///////////////////////////////////////////////////////
303+/// add
304+/**
305+ 基本の線&点からつながる線のうち、サイズがもっとも小さくなるように
306+ 点のリストを取得します。点の並びはポリゴン指定にそのまま使える物となっています。
307+
308+ 再帰的に呼び出します。
309+ @param pointIndexes これまでにつなげてきた点のリスト。この個数がMAXIMUM_VERTEX_PER_POLYGON
310+ を超えたら見つからなかったものとする
311+ @return ポリゴンが完結した場合真
312+*/
313+static bool getValidLines(int basePointIndex, int baseLineIndex,
314+ std::vector<int> *pointIndexes,
315+ hpl::aleph::HPLStockManager* smgr,
316+ int rotRem, std::set<int>* doneList,
317+ int zMin, int zMax,
318+ world_point2d& wpoint)
319+{
320+ //最大の角度
321+ double maxDeg = 0;
322+ int maxLineIndex = NONE;
323+
324+ line_data* baseLine = get_line_data(baseLineIndex);
325+ int startBasePointIndex = baseLine->endpoint_indexes[0];
326+ int endBasePointIndex = baseLine->endpoint_indexes[1];
327+ if(startBasePointIndex == basePointIndex){
328+ //入れ替え
329+ hpl::math::exchange(&startBasePointIndex, &endBasePointIndex);
330+ }else if(endBasePointIndex == basePointIndex){
331+ }else{
332+ hpl::error::halt("invalid basePointIndex");
333+ }
334+
335+ int lastPointIndex = NONE;
336+ //ベースポイントに繋がる線を取り出す
337+ std::vector<int> conLines = hpl::aleph::map::getLineIndexesIncludePoint(basePointIndex);
338+ for(int k = 0; k < (int)conLines.size(); k ++){
339+ int conLineIndex = conLines[k];
340+ if(doneList->find(conLines[k]) != doneList->end()){
341+ //既に見つけ出したものは省く
342+ continue;
343+ }
344+ //delLinesは省く
345+ if(smgr->delLines[conLineIndex]){
346+ continue;
347+ }
348+ //ベースの線と一緒の場合も除外する
349+ if(baseLineIndex == conLineIndex){
350+ continue;
351+ }
352+
353+ line_data* line = get_line_data(conLineIndex);
354+ if(!line)hpl::error::halt("line is null");
355+ //高さチェック
356+ if(!hpl::aleph::map::isValidHeight(line->highest_adjacent_floor,
357+ line->lowest_adjacent_ceiling, zMin, zMax))
358+ {
359+ continue;
360+ }
361+
362+ int ep0Index = line->endpoint_indexes[0];
363+ int ep1Index = line->endpoint_indexes[1];
364+ if(basePointIndex == ep0Index){
365+ }else if(basePointIndex == ep1Index){
366+ //入れ替え
367+ hpl::math::exchange(&ep0Index, &ep1Index);
368+ }else{
369+ assert(false);
370+ }
371+
372+ endpoint_data* ep0 = get_endpoint_data(ep0Index);
373+ if(!ep0)hpl::error::halt("ep0 is null");
374+ endpoint_data* ep1 = get_endpoint_data(ep1Index);
375+ if(!ep1)hpl::error::halt("ep1 is null");
376+
377+ double l0x = ep0->vertex.x;
378+ double l0y = ep0->vertex.y;
379+ double l1x = ep1->vertex.x;
380+ double l1y = ep1->vertex.y;
381+ //線から指定点に対する角度を求める(左右の確認)
382+ int rot = hpl::math::getPointRotationTypeFromLine(
383+ wpoint.x, wpoint.y, l0x, l0y, l1x, l1y);
384+ //最初の線と違う(逆向き)に指定点が来ている場合は正しくないものとする。
385+ if(rotRem != rot){
386+ continue;
387+ }
388+
389+ //前の線の始点→共有点→最後の点で角度を求める
390+ //前の線の始点
391+ endpoint_data* prevStartEp = get_endpoint_data(startBasePointIndex);
392+ assert(prevStartEp);
393+ double deg = hpl::math::getTwoLinesDegree(prevStartEp->vertex.x,
394+ prevStartEp->vertex.y, l0x, l0y,
395+ l0x, l0y, l1x, l1y);
396+ //[0,360)に制限する
397+ deg = hpl::math::optimizeDegree(deg);
398+ if(deg > DEG_ROUND / 2.0){
399+ deg = DEG_ROUND - deg;
400+ }
401+ //角度が現在最大かどうか確認する
402+ if(deg > maxDeg){
403+ maxDeg = deg;
404+ //今までより大きい
405+ maxLineIndex = conLineIndex;
406+ //最後の点
407+ lastPointIndex = ep1Index;
408+ }
409+ //済み
410+ doneList->insert(conLineIndex);
411+ }
412+
413+ if(maxLineIndex == NONE){
414+ //見つからなかった
415+ //よって戻っていく
416+ return false;
417+ }else{
418+ //見つかった
419+ //最後に追加する
420+ pointIndexes->push_back(lastPointIndex);
421+
422+ //最後の点がpointIndexes[0]と同一(一周してきた)だったら
423+ //終わったとする
424+ if(lastPointIndex == pointIndexes->at(0)){
425+ //ポリゴンとして成立するセットを見つけ出せた
426+ return true;
427+ }else{
428+ //まだまだ
429+ if(pointIndexes->size() >= MAXIMUM_VERTICES_PER_POLYGON + 1){
430+ return false;
431+ }
432+ //もう最大数を超えている
433+ //次を探す
434+ baseLineIndex = maxLineIndex;
435+ basePointIndex = lastPointIndex;
436+ bool found = getValidLines(basePointIndex, baseLineIndex, pointIndexes,
437+ smgr, rotRem, doneList, zMin, zMax, wpoint);
438+ //結局見つかったかどうかは子供だけが知っている
439+ return found;
440+ }
441+ }
442+}
443+
444+/**
445+ 座標を取り囲むポリゴンのうち、ポリゴンとして成立しているものをさがします
446+ すでにポリゴンが存在している場合は無視します
447+ @param wpoint 探索基点。ここを囲むポリゴンを探す
448+ @return ポリゴンの実データ候補。これを元に生成すると良い。データはcreatePolygonで生成すべし
449+*/
450+std::vector<polygon_data> hpl::aleph::map::searchValidPolygon(world_point2d wpoint,
451+ hpl::aleph::HPLStockManager* smgr,
452+ int zMin, int zMax)
453+{
454+ std::vector<polygon_data> polyDatas;
455+
456+ int max = (int)LineList.size();
457+ //線への垂線の距離順で整列する
458+ //全部の線への垂線を求める
459+ struct hpl::math::qsort::Pair<double>* pairs = new struct hpl::math::qsort::Pair<double>[max];
460+ for(int i = 0; i < max; i ++){
461+ line_data* line = get_line_data(i);
462+ assert(line);
463+ endpoint_data* epStart = get_endpoint_data(line->endpoint_indexes[0]);
464+ assert(epStart);
465+ endpoint_data* epEnd = get_endpoint_data(line->endpoint_indexes[1]);
466+ assert(epEnd);
467+ pairs[i].data = hpl::math::getPointDistanceFromLine(wpoint.x, wpoint.y,
468+ epStart->vertex.x, epStart->vertex.y, epEnd->vertex.x, epEnd->vertex.y);
469+ }
470+ hpl::math::qsort::quickSort<double>(pairs, max);
471+
472+ //既に調べたリスト(線のインデックス値を入れる)
473+ std::set<int> doneList;
474+
475+ //近くにある線から見ていく
476+ for(int i = 0; i < max; i ++){
477+ //削除対象なら無視
478+ if(smgr->delLines[i]){
479+ continue;
480+ }
481+ //すでに調べた線なら無視
482+ if(doneList.find(i) != doneList.end()){
483+ continue;
484+ }
485+ int lineIndexBase = pairs[i].index;
486+ line_data* startLine = get_line_data(lineIndexBase);
487+ if(!startLine)hpl::error::halt("startLine is null");
488+ //高さチェック
489+ if(!hpl::aleph::map::isValidHeight(startLine->highest_adjacent_floor,
490+ startLine->lowest_adjacent_ceiling, zMin, zMax))
491+ {
492+ continue;
493+ }
494+
495+ int startPointIndex = startLine->endpoint_indexes[0];
496+ endpoint_data* epStart = get_endpoint_data(startPointIndex);
497+ if(!epStart)hpl::error::halt("epStart is null");
498+ int endPointIndex = startLine->endpoint_indexes[1];
499+ endpoint_data* epEnd = get_endpoint_data(endPointIndex);
500+ if(!epEnd)hpl::error::halt("epEnd is null");
501+
502+ //線の左右どちらの側に点があるかをチェックします
503+ int rotRem = hpl::math::getPointRotationTypeFromLine(
504+ wpoint.x, wpoint.y, epStart->vertex.x, epStart->vertex.y,
505+ epEnd->vertex.x, epEnd->vertex.y);
506+ if(rotRem == hpl::math::RotationType::Clockwise &&
507+ startLine->counterclockwise_polygon_owner != NONE)
508+ {
509+ //右周りで、かつ線の右側(指定点のある領域)
510+ //にポリゴンが既にある場合スキップ
511+ hpl::error::caution("already polygon exists");
512+ continue;
513+ }
514+ if(rotRem == hpl::math::RotationType::Counterclockwise &&
515+ startLine->clockwise_polygon_owner != NONE)
516+ {
517+ hpl::error::caution("already polygon exists");
518+ continue;
519+ }
520+ //これ以降はすでに指定点の部分にポリゴンがないと仮定する
521+
522+ //基点
523+ int nowBasePointIndex = endPointIndex;
524+ int prevLineIndex = lineIndexBase;
525+ //TODO
526+ //startLine->endpoint_indexes[1]からつながる線を調べる
527+ std::vector<int> pointIndexes;
528+ //最初の二つを代入しておく
529+ pointIndexes.push_back(startPointIndex);
530+ pointIndexes.push_back(endPointIndex);
531+
532+ bool found = getValidLines(nowBasePointIndex, prevLineIndex,
533+ &pointIndexes, smgr, rotRem, &doneList,
534+ zMin, zMax, wpoint);
535+ if(found){
536+ //発見!
537+ //点インデックス(値渡し用)
538+ int indexes[MAXIMUM_VERTICES_PER_POLYGON];
539+
540+ //点データ集計
541+ for(int l = 0; l < (int)pointIndexes.size() - 1; l ++){
542+ //
543+ indexes[l] = pointIndexes[l];
544+ }
545+ int vertexCount = (int)pointIndexes.size() - 1;
546+ //ポリゴン作成
547+ polygon_data poly;
548+ hpl::aleph::map::createPolygon(indexes, vertexCount, &poly);
549+
550+ polyDatas.push_back(poly);
551+
552+ //TODO 複数見つけ出すのか?
553+ //高さ順?何のことかね?
554+ //感覚的に近い線を取ればいいんじゃね?
555+ break;
556+ }
557+ doneList.insert(i);
558+ }
559+
560+ //解放
561+ delete pairs;
562+ return polyDatas;
563+}
564+
565+/**
566+ 世界座標からポリゴンデータを作ります
567+ TODO 整合性
568+ @param points 世界座標
569+ @param ep 生成された点データ
570+ @param ld 生成された線データ
571+ @param n n角形
572+*
573+polygon_data hpl::aleph::map::createPolygon(world_point2d points[],
574+ endpoint_data epd[], line_data ld[],
575+ int n)
576+{
577+ //点生成
578+ for(int i = 0; i < n; i ++){
579+ epd[i].flags = 0;
580+ epd[i].highest_adjacent_floor_height = 0;
581+ epd[i].lowest_adjacent_ceiling_height = WORLD_ONE;
582+ epd[i].vertex.x = points[i].x;
583+ epd[i].vertex.y = points[i].y;
584+
585+ epd[i].supporting_polygon_index = 0;
586+ }
587+
588+ //線
589+ for(int i = 0; i < n ; i ++){
590+ ld[i].endpoint_indexes[0] = i;
591+ ld[i].endpoint_indexes[1] = i + 1;
592+ if(i == n - 1){
593+ ld[i].endpoint_indexes[0] = i;
594+ ld[i].endpoint_indexes[1] = 0;
595+ }
596+ ld[i].flags = SOLID_LINE_BIT | ELEVATION_LINE_BIT;
597+
598+ ld[i].highest_adjacent_floor = 0;
599+ ld[i].lowest_adjacent_ceiling = WORLD_ONE;
600+ ld[i].clockwise_polygon_side_index = NONE;
601+ ld[i].counterclockwise_polygon_side_index = NONE;
602+
603+ ld[i].clockwise_polygon_owner = 0;
604+ ld[i].counterclockwise_polygon_owner = NONE;
605+
606+ ld[i].length = (world_distance)hpl::aleph::map::getPointsDistance(
607+ epd[ld[i].endpoint_indexes[0]].vertex, epd[ld[i].endpoint_indexes[1]].vertex);
608+ }
609+
610+ //ポリゴン
611+ polygon_data pdata;
612+ pdata.type = _polygon_is_normal;
613+ pdata.flags = 0;
614+ pdata.permutation = 0;
615+
616+ pdata.vertex_count = n;
617+ for(int i = 0; i < n; i ++){
618+ pdata.endpoint_indexes[i] = i; //* clockwise *
619+ pdata.line_indexes[i] = i;
620+ pdata.side_indexes[i] = NONE;
621+ }
622+
623+ pdata.floor_texture = NONE;
624+ pdata.ceiling_texture = NONE;
625+ pdata.floor_height = 0;
626+ pdata.ceiling_height = WORLD_ONE;
627+ pdata.floor_lightsource_index = NONE;
628+ pdata.ceiling_lightsource_index = NONE;
629+
630+// pdata.area;
631+
632+ pdata.first_object = NONE;
633+
634+// pdata.first_exclusion_zone_index;
635+// pdata.line_exclusion_zone_count;
636+// pdata.point_exclusion_zone_count;
637+
638+ pdata.floor_transfer_mode = 0;
639+ pdata.ceiling_transfer_mode = 0;
640+
641+// pdata.adjacent_polygon_indexes[MAXIMUM_VERTICES_PER_POLYGON];
642+
643+ pdata.first_neighbor_index = NONE;
644+ pdata.neighbor_count = 0;
645+
646+ //
647+// pdata.center;
648+
649+// pdata.side_indexes[MAXIMUM_VERTICES_PER_POLYGON];
650+
651+// pdata.floor_origin;
652+// pdata.ceiling_origin;
653+
654+ pdata.media_index = NONE;
655+ pdata.media_lightsource_index = NONE;
656+
657+ pdata.sound_source_indexes = NONE;
658+
659+ pdata.ambient_sound_image_index = NONE;
660+ pdata.random_sound_image_index = NONE;
661+
662+ return pdata;
663+}
664+*/
665+/**
666+ 独立したポリゴンデータを追加します
667+*
668+void hpl::aleph::map::addNewPolygon(polygon_data& pdata, endpoint_data epd[],
669+ line_data ld[], int n)
670+{
671+ //点
672+ std::map<int,int> epIndexTable;
673+ std::string str;
674+ for(int i = 0; i < n; i ++){
675+ //点の追加
676+ int newIndex = hpl::aleph::map::addEndpoint(epd[i]);
677+ epIndexTable[i] = newIndex;
678+
679+ }
680+// const char *buf = str.c_str();
681+
682+ //線の追加
683+ std::map<int,int> lIndexTable;
684+ for(int i = 0; i < n; i ++){
685+ //修正
686+ for(int j = 0; j < 2; j ++){
687+ ld[i].endpoint_indexes[j] = epIndexTable[ld[i].endpoint_indexes[j]];
688+ }
689+
690+
691+ int newIndex = hpl::aleph::map::addLine(ld[i]);
692+ lIndexTable[i] = newIndex;
693+ }
694+
695+ //ポリゴン情報修正
696+ for(int i = 0; i < n; i ++){
697+ pdata.endpoint_indexes[i] = epIndexTable[pdata.endpoint_indexes[i]];
698+ pdata.line_indexes[i] = lIndexTable[pdata.line_indexes[i]];
699+ pdata.side_indexes[i] = NONE;
700+ }
701+
702+ //ポリゴン追加
703+ int newPolygonIndex = hpl::aleph::map::addPolygon(pdata);
704+ //線情報修正
705+ for(int i = 0; i < n; i ++){
706+ int newIndex = epIndexTable[i];
707+ endpoint_data* ep = get_endpoint_data(newIndex);
708+ ep->supporting_polygon_index = newPolygonIndex;
709+ }
710+ for(int i = 0; i < n - 1; i ++){
711+ int newIndex = lIndexTable[i];
712+ line_data* l = &(LineList[newIndex]);
713+ l->clockwise_polygon_owner = newPolygonIndex;
714+ l->counterclockwise_polygon_owner = NONE;
715+ }
716+
717+}
718+*/
719+
720+void hpl::aleph::map::addNewPolygon(world_distance points[][2], int n)
721+{
722+ world_point2d pt[MAXIMUM_VERTICES_PER_POLYGON];
723+ for(int i = 0; i < n; i ++){
724+ pt[i].x = points[i][0];
725+ pt[i].y = points[i][1];
726+ }
727+ hpl::aleph::map::addNewPolygon(pt, n);
728+}
729+void hpl::aleph::map::addNewPolygon(world_point2d points[], int n)
730+{
731+ //endpointの作成
732+ int epIndexes[MAXIMUM_VERTICES_PER_POLYGON];
733+ for(int i = 0; i < n; i ++){
734+ //endpointの生成
735+ endpoint_data ep;
736+ hpl::aleph::map::createPoint(points[i], &ep);
737+ int epIndex = hpl::aleph::map::addEndpoint(ep);
738+ epIndexes[i] = epIndex;
739+ }
740+
741+ //lineの作成
742+ //int lineIndexes[MAXIMUM_VERTICES_PER_POLYGON];
743+ for(int i = 0; i < n; i ++){
744+ int next = i + 1;
745+ if(next >= n){
746+ next = 0;
747+ }
748+ line_data line;
749+ hpl::aleph::map::createLine(epIndexes[i], epIndexes[next], &line);
750+ int lineIndex = hpl::aleph::map::addLine(line);
751+ //lineIndexes[i] = lineIndex;
752+ }
753+ polygon_data poly;
754+ hpl::aleph::map::createPolygon(epIndexes, n, &poly);
755+ hpl::aleph::map::addPolygon(poly);
756+}
757+
--- marathon/trunk/HPLLib/HPLMapTool.cpp (revision 359)
+++ marathon/trunk/HPLLib/HPLMapTool.cpp (revision 360)
@@ -17,8 +17,6 @@
1717 //色情報の次元
1818 const int COL_NUM = 3;
1919
20-//角度の最大
21-const double DEG_ROUND = 360.0;
2220
2321 /**
2422 直線距離を求めます
@@ -35,7 +33,11 @@
3533 {
3634 std::ifstream ifs(filePath);
3735 if(!ifs.is_open()){
36+#ifdef __WXDEBUG__
37+ wxASSERT(ifs.is_open());
38+#else
3839 hpl::error::halt("Fail to open tag file:%s", filePath);
40+#endif
3941 }
4042 int lineCounter = 0;
4143 char buf[BUF_MAX];
@@ -616,442 +618,10 @@
616618 */
617619 }
618620
619-/**
620- 基本の線&点からつながる線のうち、サイズがもっとも小さくなるように
621- 点のリストを取得します。点の並びはポリゴン指定にそのまま使える物となっています。
622621
623- 再帰的に呼び出します。
624- @param pointIndexes これまでにつなげてきた点のリスト。この個数がMAXIMUM_VERTEX_PER_POLYGON
625- を超えたら見つからなかったものとする
626- @return ポリゴンが完結した場合真
627-*/
628-static bool getValidLines(int basePointIndex, int baseLineIndex,
629- std::vector<int> *pointIndexes,
630- hpl::aleph::HPLStockManager* smgr,
631- int rotRem, std::set<int>* doneList,
632- int zMin, int zMax,
633- world_point2d& wpoint)
634-{
635- //最大の角度
636- double maxDeg = 0;
637- int maxLineIndex = NONE;
638622
639- line_data* baseLine = get_line_data(baseLineIndex);
640- int startBasePointIndex = baseLine->endpoint_indexes[0];
641- int endBasePointIndex = baseLine->endpoint_indexes[1];
642- if(startBasePointIndex == basePointIndex){
643- //入れ替え
644- hpl::math::exchange(&startBasePointIndex, &endBasePointIndex);
645- }else if(endBasePointIndex == basePointIndex){
646- }else{
647- hpl::error::halt("invalid basePointIndex");
648- }
649623
650- int lastPointIndex = NONE;
651- //ベースポイントに繋がる線を取り出す
652- std::vector<int> conLines = hpl::aleph::map::getLineIndexesIncludePoint(basePointIndex);
653- for(int k = 0; k < (int)conLines.size(); k ++){
654- int conLineIndex = conLines[k];
655- if(doneList->find(conLines[k]) != doneList->end()){
656- //既に見つけ出したものは省く
657- continue;
658- }
659- //delLinesは省く
660- if(smgr->delLines[conLineIndex]){
661- continue;
662- }
663- //ベースの線と一緒の場合も除外する
664- if(baseLineIndex == conLineIndex){
665- continue;
666- }
667-
668- line_data* line = get_line_data(conLineIndex);
669- if(!line)hpl::error::halt("line is null");
670- //高さチェック
671- if(!hpl::aleph::map::isValidHeight(line->highest_adjacent_floor,
672- line->lowest_adjacent_ceiling, zMin, zMax))
673- {
674- continue;
675- }
676-
677- int ep0Index = line->endpoint_indexes[0];
678- int ep1Index = line->endpoint_indexes[1];
679- if(basePointIndex == ep0Index){
680- }else if(basePointIndex == ep1Index){
681- //入れ替え
682- hpl::math::exchange(&ep0Index, &ep1Index);
683- }else{
684- assert(false);
685- }
686-
687- endpoint_data* ep0 = get_endpoint_data(ep0Index);
688- if(!ep0)hpl::error::halt("ep0 is null");
689- endpoint_data* ep1 = get_endpoint_data(ep1Index);
690- if(!ep1)hpl::error::halt("ep1 is null");
691-
692- double l0x = ep0->vertex.x;
693- double l0y = ep0->vertex.y;
694- double l1x = ep1->vertex.x;
695- double l1y = ep1->vertex.y;
696- //線から指定点に対する角度を求める(左右の確認)
697- int rot = hpl::math::getPointRotationTypeFromLine(
698- wpoint.x, wpoint.y, l0x, l0y, l1x, l1y);
699- //最初の線と違う(逆向き)に指定点が来ている場合は正しくないものとする。
700- if(rotRem != rot){
701- continue;
702- }
703-
704- //前の線の始点→共有点→最後の点で角度を求める
705- //前の線の始点
706- endpoint_data* prevStartEp = get_endpoint_data(startBasePointIndex);
707- assert(prevStartEp);
708- double deg = hpl::math::getTwoLinesDegree(prevStartEp->vertex.x,
709- prevStartEp->vertex.y, l0x, l0y,
710- l0x, l0y, l1x, l1y);
711- //[0,360)に制限する
712- deg = hpl::math::optimizeDegree(deg);
713- if(deg > DEG_ROUND / 2.0){
714- deg = DEG_ROUND - deg;
715- }
716- //角度が現在最大かどうか確認する
717- if(deg > maxDeg){
718- maxDeg = deg;
719- //今までより大きい
720- maxLineIndex = conLineIndex;
721- //最後の点
722- lastPointIndex = ep1Index;
723- }
724- //済み
725- doneList->insert(conLineIndex);
726- }
727-
728- if(maxLineIndex == NONE){
729- //見つからなかった
730- //よって戻っていく
731- return false;
732- }else{
733- //見つかった
734- //最後に追加する
735- pointIndexes->push_back(lastPointIndex);
736-
737- //最後の点がpointIndexes[0]と同一(一周してきた)だったら
738- //終わったとする
739- if(lastPointIndex == pointIndexes->at(0)){
740- //ポリゴンとして成立するセットを見つけ出せた
741- return true;
742- }else{
743- //まだまだ
744- if(pointIndexes->size() >= MAXIMUM_VERTICES_PER_POLYGON + 1){
745- return false;
746- }
747- //もう最大数を超えている
748- //次を探す
749- baseLineIndex = maxLineIndex;
750- basePointIndex = lastPointIndex;
751- bool found = getValidLines(basePointIndex, baseLineIndex, pointIndexes,
752- smgr, rotRem, doneList, zMin, zMax, wpoint);
753- //結局見つかったかどうかは子供だけが知っている
754- return found;
755- }
756- }
757-}
758-
759624 /**
760- 座標を取り囲むポリゴンのうち、ポリゴンとして成立しているものをさがします
761- すでにポリゴンが存在している場合は無視します
762- @param wpoint 探索基点。ここを囲むポリゴンを探す
763- @return ポリゴンの実データ候補。これを元に生成すると良い。データはcreatePolygonで生成すべし
764-*/
765-std::vector<polygon_data> hpl::aleph::map::searchValidPolygon(world_point2d wpoint,
766- hpl::aleph::HPLStockManager* smgr,
767- int zMin, int zMax)
768-{
769- std::vector<polygon_data> polyDatas;
770-
771- int max = (int)LineList.size();
772- //線への垂線の距離順で整列する
773- //全部の線への垂線を求める
774- struct hpl::math::qsort::Pair<double>* pairs = new struct hpl::math::qsort::Pair<double>[max];
775- for(int i = 0; i < max; i ++){
776- line_data* line = get_line_data(i);
777- assert(line);
778- endpoint_data* epStart = get_endpoint_data(line->endpoint_indexes[0]);
779- assert(epStart);
780- endpoint_data* epEnd = get_endpoint_data(line->endpoint_indexes[1]);
781- assert(epEnd);
782- pairs[i].data = hpl::math::getPointDistanceFromLine(wpoint.x, wpoint.y,
783- epStart->vertex.x, epStart->vertex.y, epEnd->vertex.x, epEnd->vertex.y);
784- }
785- hpl::math::qsort::quickSort<double>(pairs, max);
786-
787- //既に調べたリスト(線のインデックス値を入れる)
788- std::set<int> doneList;
789-
790- //近くにある線から見ていく
791- for(int i = 0; i < max; i ++){
792- //削除対象なら無視
793- if(smgr->delLines[i]){
794- continue;
795- }
796- //すでに調べた線なら無視
797- if(doneList.find(i) != doneList.end()){
798- continue;
799- }
800- int lineIndexBase = pairs[i].index;
801- line_data* startLine = get_line_data(lineIndexBase);
802- if(!startLine)hpl::error::halt("startLine is null");
803- //高さチェック
804- if(!hpl::aleph::map::isValidHeight(startLine->highest_adjacent_floor,
805- startLine->lowest_adjacent_ceiling, zMin, zMax))
806- {
807- continue;
808- }
809-
810- int startPointIndex = startLine->endpoint_indexes[0];
811- endpoint_data* epStart = get_endpoint_data(startPointIndex);
812- if(!epStart)hpl::error::halt("epStart is null");
813- int endPointIndex = startLine->endpoint_indexes[1];
814- endpoint_data* epEnd = get_endpoint_data(endPointIndex);
815- if(!epEnd)hpl::error::halt("epEnd is null");
816-
817- //線の左右どちらの側に点があるかをチェックします
818- int rotRem = hpl::math::getPointRotationTypeFromLine(
819- wpoint.x, wpoint.y, epStart->vertex.x, epStart->vertex.y,
820- epEnd->vertex.x, epEnd->vertex.y);
821- if(rotRem == hpl::math::RotationType::Clockwise &&
822- startLine->counterclockwise_polygon_owner != NONE)
823- {
824- //右周りで、かつ線の右側(指定点のある領域)
825- //にポリゴンが既にある場合スキップ
826- hpl::error::caution("already polygon exists");
827- continue;
828- }
829- if(rotRem == hpl::math::RotationType::Counterclockwise &&
830- startLine->clockwise_polygon_owner != NONE)
831- {
832- hpl::error::caution("already polygon exists");
833- continue;
834- }
835- //これ以降はすでに指定点の部分にポリゴンがないと仮定する
836-
837- //基点
838- int nowBasePointIndex = endPointIndex;
839- int prevLineIndex = lineIndexBase;
840- //TODO
841- //startLine->endpoint_indexes[1]からつながる線を調べる
842- std::vector<int> pointIndexes;
843- //最初の二つを代入しておく
844- pointIndexes.push_back(startPointIndex);
845- pointIndexes.push_back(endPointIndex);
846-
847- bool found = getValidLines(nowBasePointIndex, prevLineIndex,
848- &pointIndexes, smgr, rotRem, &doneList,
849- zMin, zMax, wpoint);
850- if(found){
851- //発見!
852- //点インデックス(値渡し用)
853- int indexes[MAXIMUM_VERTICES_PER_POLYGON];
854-
855- //点データ集計
856- for(int l = 0; l < pointIndexes.size() - 1; l ++){
857- //
858- indexes[l] = pointIndexes[l];
859- }
860- int vertexCount = pointIndexes.size() - 1;
861- //ポリゴン作成
862- polygon_data poly;
863- bool result = hpl::aleph::map::createPolygon(indexes, vertexCount, &poly);
864- if(!result)hpl::error::halt("polygon creation failure");
865- polyDatas.push_back(poly);
866-
867- //TODO 複数見つけ出すのか?
868- //高さ順?何のことかね?
869- //感覚的に近い線を取ればいいんじゃね?
870- break;
871- }
872- doneList.insert(i);
873- }
874-
875- //解放
876- delete pairs;
877- return polyDatas;
878-}
879-
880-/**
881- 世界座標からポリゴンデータを作ります
882- TODO 整合性
883- @param points 世界座標
884- @param ep 生成された点データ
885- @param ld 生成された線データ
886- @param n n角形
887-*/
888-polygon_data hpl::aleph::map::createPolygon(world_point2d points[],
889- endpoint_data epd[], line_data ld[],
890- int n)
891-{
892- //点生成
893- for(int i = 0; i < n; i ++){
894- epd[i].flags = 0;
895- epd[i].highest_adjacent_floor_height = 0;
896- epd[i].lowest_adjacent_ceiling_height = WORLD_ONE;
897- epd[i].vertex.x = points[i].x;
898- epd[i].vertex.y = points[i].y;
899-
900- epd[i].supporting_polygon_index = 0;
901- }
902-
903- //線
904- for(int i = 0; i < n ; i ++){
905- ld[i].endpoint_indexes[0] = i;
906- ld[i].endpoint_indexes[1] = i + 1;
907- if(i == n - 1){
908- ld[i].endpoint_indexes[0] = i;
909- ld[i].endpoint_indexes[1] = 0;
910- }
911- ld[i].flags = SOLID_LINE_BIT | ELEVATION_LINE_BIT;
912-
913- ld[i].highest_adjacent_floor = 0;
914- ld[i].lowest_adjacent_ceiling = WORLD_ONE;
915- ld[i].clockwise_polygon_side_index = NONE;
916- ld[i].counterclockwise_polygon_side_index = NONE;
917-
918- ld[i].clockwise_polygon_owner = 0;
919- ld[i].counterclockwise_polygon_owner = NONE;
920-
921- ld[i].length = (world_distance)hpl::aleph::map::getPointsDistance(
922- epd[ld[i].endpoint_indexes[0]].vertex, epd[ld[i].endpoint_indexes[1]].vertex);
923- }
924-
925- //ポリゴン
926- polygon_data pdata;
927- pdata.type = _polygon_is_normal;
928- pdata.flags = 0;
929- pdata.permutation = 0;
930-
931- pdata.vertex_count = n;
932- for(int i = 0; i < n; i ++){
933- pdata.endpoint_indexes[i] = i; /* clockwise */
934- pdata.line_indexes[i] = i;
935- pdata.side_indexes[i] = NONE;
936- }
937-
938- pdata.floor_texture = NONE;
939- pdata.ceiling_texture = NONE;
940- pdata.floor_height = 0;
941- pdata.ceiling_height = WORLD_ONE;
942- pdata.floor_lightsource_index = NONE;
943- pdata.ceiling_lightsource_index = NONE;
944-
945-// pdata.area; /* in world_distance^2 units */
946-
947- pdata.first_object = NONE;
948-
949-// pdata.first_exclusion_zone_index;
950-// pdata.line_exclusion_zone_count;
951-// pdata.point_exclusion_zone_count;
952-
953- pdata.floor_transfer_mode = 0;
954- pdata.ceiling_transfer_mode = 0;
955-
956-// pdata.adjacent_polygon_indexes[MAXIMUM_VERTICES_PER_POLYGON];
957-
958- pdata.first_neighbor_index = NONE;
959- pdata.neighbor_count = 0;
960-
961- //
962-// pdata.center;
963-
964-// pdata.side_indexes[MAXIMUM_VERTICES_PER_POLYGON];
965-
966-// pdata.floor_origin;
967-// pdata.ceiling_origin;
968-
969- pdata.media_index = NONE;
970- pdata.media_lightsource_index = NONE;
971-
972- pdata.sound_source_indexes = NONE;
973-
974- pdata.ambient_sound_image_index = NONE;
975- pdata.random_sound_image_index = NONE;
976-
977- return pdata;
978-}
979-/**
980- 独立したポリゴンデータを追加します
981-*/
982-void hpl::aleph::map::addNewPolygon(polygon_data& pdata, endpoint_data epd[],
983- line_data ld[], int n)
984-{
985- //点
986- std::map<int,int> epIndexTable;
987- std::string str;
988- for(int i = 0; i < n; i ++){
989- //点の追加
990- int newIndex = hpl::aleph::map::addEndpoint(epd[i]);
991- epIndexTable[i] = newIndex;
992-
993-/* char buf[256];
994- sprintf(buf, "%d,", newIndex);
995- str += std::string(buf);
996- const char *bauf = str.c_str();
997- const char *baauf = str.c_str();*/
998- }
999-// const char *buf = str.c_str();
1000-
1001- //線の追加
1002- std::map<int,int> lIndexTable;
1003- for(int i = 0; i < n; i ++){
1004- //修正
1005- for(int j = 0; j < 2; j ++){
1006- ld[i].endpoint_indexes[j] = epIndexTable[ld[i].endpoint_indexes[j]];
1007- }
1008-
1009-
1010- int newIndex = hpl::aleph::map::addLine(ld[i]);
1011- lIndexTable[i] = newIndex;
1012- }
1013-
1014- //ポリゴン情報修正
1015- for(int i = 0; i < n; i ++){
1016- pdata.endpoint_indexes[i] = epIndexTable[pdata.endpoint_indexes[i]];
1017- pdata.line_indexes[i] = lIndexTable[pdata.line_indexes[i]];
1018- pdata.side_indexes[i] = NONE;
1019- }
1020-
1021- //ポリゴン追加
1022- int newPolygonIndex = hpl::aleph::map::addPolygon(pdata);
1023- //線情報修正
1024- for(int i = 0; i < n; i ++){
1025- int newIndex = epIndexTable[i];
1026- endpoint_data* ep = get_endpoint_data(newIndex);
1027- ep->supporting_polygon_index = newPolygonIndex;
1028- }
1029- for(int i = 0; i < n - 1; i ++){
1030- int newIndex = lIndexTable[i];
1031- line_data* l = &(LineList[newIndex]);
1032- l->clockwise_polygon_owner = newPolygonIndex;
1033- l->counterclockwise_polygon_owner = NONE;
1034- }
1035-
1036-}
1037-void hpl::aleph::map::addNewPolygon(world_distance points[][2], int n)
1038-{
1039- world_point2d pt[MAXIMUM_VERTICES_PER_POLYGON];
1040- for(int i = 0; i < n; i ++){
1041- pt[i].x = points[i][0];
1042- pt[i].y = points[i][1];
1043- }
1044- hpl::aleph::map::addNewPolygon(pt, n);
1045-}
1046-void hpl::aleph::map::addNewPolygon(world_point2d points[], int n)
1047-{
1048- endpoint_data epd[MAXIMUM_VERTICES_PER_POLYGON];
1049- line_data ld[8];
1050- polygon_data pdata = hpl::aleph::map::createPolygon(points, epd, ld, n);
1051- hpl::aleph::map::addNewPolygon(pdata, epd, ld, n);
1052-}
1053-
1054-/**
1055625 二つの線が織り成す角度を求めます
1056626 @param pIndexA1,2 線分A1-A2の点インデックス
1057627 @param pIndexB1,2 線分B1-B2の点インデックス
@@ -1107,70 +677,11 @@
1107677 return isPointIn;
1108678 }
1109679
1110-//////////////////////////////////////////////////////
1111-/////// add delete and modify
1112-/**
1113- 点情報を追加します
1114- @param ep 追加する点データ(値渡しなのでコピーされます)
1115- @return 追加された点のインデックス値
1116-*/
1117-int hpl::aleph::map::addEndpoint(endpoint_data ep)
1118-{
1119- EndpointList.push_back(ep);
1120- dynamic_world->endpoint_count = (int16)EndpointList.size();
1121- int index = dynamic_world->endpoint_count - 1;
1122- return index;
1123-}
1124-int hpl::aleph::map::addLine(line_data line)
1125-{
1126- LineList.push_back(line);
1127- dynamic_world->line_count = (int16)LineList.size();
1128- int index = dynamic_world->line_count - 1;
1129- return index;
1130-}
1131-int hpl::aleph::map::addSide(side_data side)
1132-{
1133- SideList.push_back(side);
1134- dynamic_world->side_count = (int16)SideList.size();
1135- int index = dynamic_world->side_count - 1;
1136- return index;
1137-}
1138-int hpl::aleph::map::addPolygon(polygon_data polygon)
1139-{
1140- PolygonList.push_back(polygon);
1141- dynamic_world->polygon_count = (int16)PolygonList.size();
1142- int index = dynamic_world->polygon_count - 1;
1143680
1144- polygon_data* poly = get_polygon_data(index);
1145- //点、線に登録する
1146- //TODO for(int i = 0; i < poly->
1147- return index;
1148-}
1149-int hpl::aleph::map::addMapSavedObject(map_object object)
1150-{
1151- SavedObjectList.push_back(object);
1152- //TODO
1153- //プレースメント情報に付加
1154-
1155- //TODO どれを集計すれば良いのか?
1156-// dynamic_world->object_count ++;// SavedObjectList.size();
1157- dynamic_world->initial_objects_count = (int16)SavedObjectList.size();
1158- int index = dynamic_world->initial_objects_count - 1;
1159- return index;
1160-}
1161-int hpl::aleph::map::addAnnotation(map_annotation annotation)
1162-{
1163- MapAnnotationList.push_back(annotation);
1164-/* dynamic_world-> = MapAnnotationList.size();
1165- int index = dynamic_world->annotation_count - 1;*/
1166- int index = (int16)MapAnnotationList.size() - 1;
1167- return index;
1168-}
1169-
1170681 /**
1171682 簡略バージョン
1172683 */
1173-bool hpl::aleph::map::createPoint(world_point2d& wpoint, endpoint_data* ep)
684+void hpl::aleph::map::createPoint(world_point2d& wpoint, endpoint_data* ep)
1174685 {
1175686 //TODO
1176687 ep->flags = 1;
@@ -1180,12 +691,11 @@
1180691 ep->highest_adjacent_floor_height = 0;
1181692 ep->lowest_adjacent_ceiling_height = WORLD_ONE;
1182693 ep->supporting_polygon_index = NONE;
1183- return true;
1184694 }
1185695 /**
1186696 @param polyIndex 載せるポリゴンのインデックス
1187697 */
1188-bool hpl::aleph::map::createObject(world_point2d& wpoint, int polyIndex, map_object* obj,
698+void hpl::aleph::map::createObject(world_point2d& wpoint, int polyIndex, map_object* obj,
1189699 int flags)
1190700 {
1191701 //TODO
@@ -1193,9 +703,13 @@
1193703 obj->location.x = wpoint.x;
1194704 obj->location.y = wpoint.y;
1195705 polygon_data* poly = get_polygon_data(polyIndex);
706+#ifdef __WXDEBUG__
707+ wxASSERT(poly);
708+#else
1196709 if(poly == NULL){
1197- return false;
710+ hpl::error::halt("poly[%d] doesn't exist", polyIndex);
1198711 }
712+#endif
1199713 //TODO flag?
1200714 if(flags & _map_object_hanging_from_ceiling){
1201715 obj->location.z = poly->ceiling_height;
@@ -1203,15 +717,14 @@
1203717 obj->location.z = poly->floor_height;
1204718 }
1205719 obj->flags = flags;
1206- return true;
1207720 }
1208721
1209-bool hpl::aleph::map::createLine(int beginPointIndex, int endPointIndex, line_data* line)
722+void hpl::aleph::map::createLine(int beginPointIndex, int endPointIndex, line_data* line)
1210723 {
1211724 endpoint_data* begin = get_endpoint_data(beginPointIndex);
1212725 endpoint_data* end = get_endpoint_data(endPointIndex);
1213726 if(begin == NULL || end == NULL){
1214- return false;
727+ hpl::error::halt("begin / end endpoint doesn't exist");
1215728 }
1216729 line->clockwise_polygon_owner = NONE;
1217730 line->clockwise_polygon_side_index = NONE;
@@ -1225,18 +738,22 @@
1225738 end->highest_adjacent_floor_height);
1226739 line->lowest_adjacent_ceiling = MAX(begin->lowest_adjacent_ceiling_height,
1227740 end->lowest_adjacent_ceiling_height);
1228- return true;
1229741 }
1230742
1231-bool hpl::aleph::map::createPolygon(int pointIndexes[], int n, polygon_data* poly)
743+void hpl::aleph::map::createPolygon(int pointIndexes[], int n, polygon_data* poly)
1232744 {
1233745 endpoint_data* ep[MAXIMUM_VERTICES_PER_POLYGON];
1234746
747+ //点の登録
1235748 for(int i = 0; i < n; i ++){
1236749 ep[i] = get_endpoint_data(pointIndexes[i]);
750+#ifdef __WXDEBUG__
751+ wxASSERT(ep[i]);
752+#else
1237753 if(ep[i] == NULL){
1238- return false;
754+ hpl::error::halt("endpoint[%d] doesn't exist", pointIndexes[i]);
1239755 }
756+#endif
1240757 poly->endpoint_indexes[i] = pointIndexes[i];
1241758 }
1242759 for(int i = 0; i < n; i ++){
@@ -1245,9 +762,13 @@
1245762 next = 0;
1246763 }
1247764 int lIndex = hpl::aleph::map::getLineIndexFromTwoLPoints(pointIndexes[i], pointIndexes[next]);
765+#ifdef __WXDEBUG__
766+ wxASSERT(lIndex != NONE);
767+#else
1248768 if(lIndex == NONE){
1249- return false;
769+ hpl::error::halt("endpoint[%d] doesn't exist", pointIndexes[i]);
1250770 }
771+#endif
1251772 poly->line_indexes[i] = lIndex;
1252773 poly->side_indexes[i] = NONE;
1253774 }
@@ -1288,7 +809,6 @@
1288809 //poly->sound_source_indexes;
1289810 poly->type = _polygon_is_normal;
1290811 poly->vertex_count = n;
1291- return true;
1292812 }
1293813
1294814 /**
@@ -1336,11 +856,25 @@
1336856 for(int i = 0; i < (int)sel->getSelPolygons()->size(); i ++){
1337857 hpl::aleph::map::SelPolygon* selpoly = &sel->getSelPolygons()->at(i);
1338858 polygon_data* poly = get_polygon_data(selpoly->index);
859+#ifdef __WXDEBUG__
860+ wxASSERT(poly);
861+#else
862+ if(!poly){
863+ hpl::error::halt("polygon[%d] doesn't exist", selpoly->index);
864+ }
865+#endif
1339866 int n = poly->vertex_count;
1340867 selpoly->num = n;
1341868 for(int j = 0; j < n; j ++){
1342869 int vpoint[2];
1343870 endpoint_data* ep = get_endpoint_data(poly->endpoint_indexes[j]);
871+#ifdef __WXDEBUG__
872+ wxASSERT(ep);
873+#else
874+ if(!ep){
875+ hpl::error::halt("endpoint[%d] doesn't exist", poly->endpoint_indexes[j]);
876+ }
877+#endif
1344878 hpl::aleph::map::getViewPointFromWorldPoint2D(ep->vertex, vpoint,
1345879 woffsetX, woffsetY, div, voffsetX, voffsetY);
1346880
--- marathon/trunk/HPLLib/HPLMapTool.h (revision 359)
+++ marathon/trunk/HPLLib/HPLMapTool.h (revision 360)
@@ -5,6 +5,7 @@
55 #include <vector>
66 #include <map>
77 #include <string>
8+#include <set>
89
910 #include "map.h"
1011 #include "wad.h"
@@ -13,6 +14,12 @@
1314 #include "HPLSelectData.h"
1415 //#include "HPLStockManager.h"
1516
17+
18+#ifdef __WXDEBUG__
19+#include <wx/defs.h>
20+#include <wx/debug.h>
21+#endif
22+
1623 namespace hpl{namespace aleph{
1724 class HPLStockManager;
1825 }};
@@ -336,7 +343,7 @@
336343 */
337344 int addEndpoint(endpoint_data ep);
338345 int addLine(line_data line);
339- int addSide(side_data side);
346+ int addSide(side_data side, bool isClockwise);
340347 int addPolygon(polygon_data polygon);
341348 int addMapSavedObject(map_object object);
342349 int addAnnotation(map_annotation annotation);
@@ -347,11 +354,11 @@
347354 /**
348355 簡略バージョン
349356 */
350- bool createPoint(world_point2d& wpoint, endpoint_data* ep);
357+ void createPoint(world_point2d& wpoint, endpoint_data* ep);
351358 /**
352359 @param polyIndex 載せるポリゴンのインデックス
353360 */
354- bool createObject(world_point2d& wpoint, int polyIndex, map_object* obj,
361+ void createObject(world_point2d& wpoint, int polyIndex, map_object* obj,
355362 int flags);
356363
357364 /**
@@ -358,8 +365,8 @@
358365 既存の点を用いて線やポリゴンを作成します
359366 <en> create new line and polygon with points already exist
360367 */
361- bool createLine(int beginPointIndex, int endPointIndex, line_data* line);
362- bool createPolygon(int pointIndexes[], int n, polygon_data* poly);
368+ void createLine(int beginPointIndex, int endPointIndex, line_data* line);
369+ void createPolygon(int pointIndexes[], int n, polygon_data* poly);
363370
364371 /**
365372 点情報を削除します
旧リポジトリブラウザで表示