• R/O
  • SSH
  • HTTPS

marathon: コミット


コミットメタ情報

リビジョン282 (tree)
日時2007-05-03 18:17:58
作者hogepiyo

ログメッセージ

*** empty log message ***

変更サマリ

差分

--- marathon/trunk/MapEditorOne/src/MapEditorSDI.cpp (revision 281)
+++ marathon/trunk/MapEditorOne/src/MapEditorSDI.cpp (revision 282)
@@ -805,3 +805,8 @@
805805 CString str(path);
806806 return str;
807807 }
808+
809+void addPolygon(polygon_data* data)
810+{
811+ PolygonList.push_back(*data);
812+}
--- marathon/trunk/MapEditorOne/src/MapEditorSDIView.h (revision 281)
+++ marathon/trunk/MapEditorOne/src/MapEditorSDIView.h (revision 282)
@@ -114,6 +114,10 @@
114114 public:
115115 afx_msg void On32808();
116116 afx_msg void OnTextureFloor();
117+public:
118+ afx_msg void OnEditCopy();
119+public:
120+ afx_msg void OnEditPaste();
117121 };
118122
119123 #ifndef _DEBUG // MapEditorSDIView.cpp のデバッグ バージョン
--- marathon/trunk/MapEditorOne/src/MapEditorSDI.h (revision 281)
+++ marathon/trunk/MapEditorOne/src/MapEditorSDI.h (revision 282)
@@ -298,6 +298,8 @@
298298 //コピーアンドペースト用のデータリスト
299299 //ペースト時にこれらを元に新規作成します
300300 hpl::aleph::map::HPLRealMapData storedMapData;
301+ //その場に展開すると重なるので、どれだけずらすか(world座標)
302+ int storedDataPointDelta[2];
301303
302304 //変更点の履歴
303305 hpl::aleph::map::HPLDoneHistory history;
@@ -413,6 +415,8 @@
413415
414416 int addLine(int beginPointIndex, int endPointIndex);
415417
418+void addPolygon(polygon_data* data);
419+
416420 /**
417421 get line index from point of edge.
418422 @return index of point
--- marathon/trunk/MapEditorOne/src/MapEditorSDIView.cpp (revision 281)
+++ marathon/trunk/MapEditorOne/src/MapEditorSDIView.cpp (revision 282)
@@ -55,6 +55,8 @@
5555 ON_COMMAND(ID_MODE_POLYGONTYPE, &CMapEditorSDIView::OnModePolygontype)
5656 ON_COMMAND(ID_32808, &CMapEditorSDIView::On32808)
5757 ON_COMMAND(ID_TEXTURE_FLOOR, OnTextureFloor)
58+ ON_COMMAND(ID_EDIT_COPY, &CMapEditorSDIView::OnEditCopy)
59+ ON_COMMAND(ID_EDIT_PASTE, &CMapEditorSDIView::OnEditPaste)
5860 END_MESSAGE_MAP()
5961
6062 // CMapEditorSDIView コンストラクション/デストラクション
@@ -909,3 +911,154 @@
909911 }
910912
911913
914+
915+//view座標
916+const int DELTA = 10;
917+void CMapEditorSDIView::OnEditCopy()
918+{
919+
920+ //選択範囲を保持する
921+ theApp.storedMapData.set(&theApp.selectDatas);
922+ theApp.storedDataPointDelta[0] = DELTA;
923+ theApp.storedDataPointDelta[1] = DELTA;
924+}
925+
926+
927+void CMapEditorSDIView::OnEditPaste()
928+{
929+ //点→線→壁→ポリゴン→オブジェクトの順で作成
930+ //コピー元のIDで線、点の関係性を求め、新しいIDで作成する
931+
932+ std::map<int, endpoint_data>* cpoints = theApp.storedMapData.getPoints();
933+ std::map<int, line_data>* clines = theApp.storedMapData.getLines();
934+ std::map<int, side_data>* csides = theApp.storedMapData.getSides();
935+ std::map<int, polygon_data>* cpolygons = theApp.storedMapData.getPolygons();
936+ std::map<int, map_object>* cobjects = theApp.storedMapData.getObjects();
937+ //新しく作ったポリゴンのIDと、コピー元のIDの対応[元,新]
938+ std::map<int, int> pointIndexTable;
939+ std::map<int, int> lineIndexTable;
940+ std::map<int, int> sideIndexTable;
941+ std::map<int, int> polygonIndexTable;
942+ std::map<int, int> objectIndexTable;
943+
944+ theApp.selectDatas.clear();
945+
946+ for(std::map<int, endpoint_data>::iterator it = cpoints->begin();
947+ it != cpoints->end(); it ++){
948+ //コピー元のID
949+ int cid = it->first;
950+ endpoint_data cep = it->second;
951+ //
952+ endpoint_data ep;
953+ memcpy(&ep, &cep, sizeof(endpoint_data));
954+
955+ //位置修正
956+ ep.vertex.x += theApp.storedDataPointDelta[0] * theApp.zoomDivision;
957+ ep.vertex.y += theApp.storedDataPointDelta[1] * theApp.zoomDivision;
958+
959+ //他は触らず。
960+ EndpointList.push_back(ep);
961+ int newIndex = (int)EndpointList.size() - 1;
962+ pointIndexTable[cid] = newIndex;
963+ int offset[] = {0,0};
964+ theApp.selectDatas.addSelPoint(newIndex, offset);
965+ }
966+ //線
967+ for(std::map<int, line_data>::iterator it = clines->begin();
968+ it != clines->end(); it ++){
969+ //コピー元のID
970+ int cid = it->first;
971+ line_data cep = it->second;
972+ //
973+ line_data ep;
974+ memcpy(&ep, &cep, sizeof(line_data));
975+
976+ for(int i = 0; i < 2; i ++){
977+ ep.endpoint_indexes[i] = pointIndexTable[ep.endpoint_indexes[i]];
978+ }
979+ //polygon番号が古いままなので、setupPolygon()で修正すること
980+
981+ LineList.push_back(ep);
982+ int newIndex = (int)LineList.size() - 1;
983+ lineIndexTable[cid] = newIndex;
984+ int offset[][2] = {{0,0},{0,0}};
985+ theApp.selectDatas.addSelLine(newIndex, offset);
986+ }
987+ //壁
988+ for(std::map<int, side_data>::iterator it = csides->begin();
989+ it != csides->end(); it ++){
990+ //コピー元のID
991+ int cid = it->first;
992+ side_data cep = it->second;
993+ //
994+ side_data ep;
995+ memcpy(&ep, &cep, sizeof(side_data));
996+
997+ //乗ってる線の番号
998+ ep.line_index = lineIndexTable[cep.line_index];
999+
1000+ SideList.push_back(ep);
1001+ int newIndex = (int)SideList.size() - 1;
1002+ sideIndexTable[cid] = newIndex;
1003+ theApp.selectDatas.addSelSide(newIndex);
1004+ }
1005+ //ポリゴン
1006+ for(std::map<int, polygon_data>::iterator it = cpolygons->begin();
1007+ it != cpolygons->end(); it ++){
1008+ //コピー元のID
1009+ int cid = it->first;
1010+ polygon_data cep = it->second;
1011+ //
1012+ polygon_data ep;
1013+ memcpy(&ep, &cep, sizeof(polygon_data));
1014+
1015+ //
1016+ ep.center.x += theApp.storedDataPointDelta[0] * theApp.zoomDivision;
1017+ ep.center.y += theApp.storedDataPointDelta[1] * theApp.zoomDivision;
1018+ for(int i = 0; i < ep.vertex_count; i ++){
1019+ ep.endpoint_indexes[i] = pointIndexTable[cep.endpoint_indexes[i]];
1020+ }
1021+ for(int i = 0; i < ep.vertex_count - 1; i ++){
1022+ ep.line_indexes[i] = lineIndexTable[cep.line_indexes[i]];
1023+ }
1024+ ep.first_object = NONE;
1025+
1026+ //TODO 他の項目はよくわからん
1027+
1028+ PolygonList.push_back(ep);
1029+ int newIndex = (int)PolygonList.size() - 1;
1030+ polygonIndexTable[cid] = newIndex;
1031+ int offset[8][2];
1032+ for(int i = 0; i < 8; i ++){
1033+ offset[i][0] = 0;
1034+ offset[i][1] = 0;
1035+ }
1036+ theApp.selectDatas.addSelPolygon(newIndex, offset, ep.vertex_count);
1037+ }
1038+ //オブジェクト
1039+ for(std::map<int, map_object>::iterator it = cobjects->begin();
1040+ it != cobjects->end(); it ++){
1041+ //コピー元のID
1042+ int cid = it->first;
1043+ map_object cep = it->second;
1044+ //
1045+ map_object ep;
1046+ memcpy(&ep, &cep, sizeof(map_object));
1047+
1048+ //
1049+ ep.location.x += theApp.storedDataPointDelta[0] * theApp.zoomDivision;
1050+ ep.location.y += theApp.storedDataPointDelta[1] * theApp.zoomDivision;
1051+
1052+ SavedObjectList.push_back(ep);
1053+ int newIndex = (int)SavedObjectList.size() - 1;
1054+ objectIndexTable[cid] = newIndex;
1055+ int offset[2] = {0,0};
1056+ theApp.selectDatas.addSelObject(newIndex, offset);
1057+ }
1058+
1059+ theApp.selectDatas.setSelected(true);
1060+
1061+ theApp.storedDataPointDelta[0] += DELTA;
1062+ theApp.storedDataPointDelta[1] += DELTA;
1063+
1064+}
--- marathon/trunk/MapEditorOne/src/MapEditorSDIView_Event.cpp (revision 281)
+++ marathon/trunk/MapEditorOne/src/MapEditorSDIView_Event.cpp (revision 282)
@@ -72,7 +72,8 @@
7272
7373 //既に選択している状態
7474 //group selected
75- if(theApp.isSelectingGroup && theApp.selectDatas.isSelected()){
75+ if(//theApp.isSelectingGroup &&
76+ theApp.selectDatas.isSelected()){
7677
7778 //点をクリックしたかどうか
7879 //is point in objects/points/lines/polygons?
@@ -163,7 +164,7 @@
163164
164165 }else {
165166 //ctrlを押さずにクリック→選択
166-
167+ //グループ選択ではない
167168 //シフトキーと一緒に押した?(選択の追加)
168169 bool isWithShift = (nFlags & MK_SHIFT) != 0;
169170 if(!isWithShift){
--- marathon/trunk/HPLLib/HPLDoneHistory.cpp (nonexistent)
+++ marathon/trunk/HPLLib/HPLDoneHistory.cpp (revision 282)
@@ -0,0 +1,6 @@
1+#include "HPLDoneHistory.h"
2+
3+hpl::aleph::map::HPLDoneHistory::HPLDoneHistory(){
4+}
5+hpl::aleph::map::HPLDoneHistory::~HPLDoneHistory(){
6+}
\ No newline at end of file
--- marathon/trunk/HPLLib/HPLSelectData.cpp (revision 281)
+++ marathon/trunk/HPLLib/HPLSelectData.cpp (revision 282)
@@ -233,7 +233,9 @@
233233 }
234234 void hpl::aleph::map::HPLSelectData::addSelSide(int index)
235235 {
236- struct
236+/* struct hpl::aleph::map::SelSide sp;
237+ sp.index = index;
238+ selsides.push_back(sp);*/
237239 this->side.index = index;
238240 this->setSelected(true);
239241 }
--- marathon/trunk/HPLLib/HPLMapTool.cpp (revision 281)
+++ marathon/trunk/HPLLib/HPLMapTool.cpp (revision 282)
@@ -190,7 +190,7 @@
190190 std::vector<struct hpl::aleph::map::SelPoint>* selpoints =
191191 selectInfo->getSelPoints();
192192 for(int i = 0; i < (int)selpoints->size(); i ++){
193- endpoint_data* ep = &EndpointList[selobjects->at(i).index];
193+ endpoint_data* ep = &EndpointList[selpoints->at(i).index];
194194 int x = ep->vertex.x;
195195 int y = ep->vertex.y;
196196 int drawX = (x + offsetWorldX)/div + offsetViewX;
@@ -207,7 +207,7 @@
207207 std::vector<struct hpl::aleph::map::SelLine>* sellines =
208208 selectInfo->getSelLines();
209209 for(int i = 0; i < (int)sellines->size(); i ++){
210- line_data* line = &LineList[selobjects->at(i).index];
210+ line_data* line = &LineList[sellines->at(i).index];
211211 endpoint_data* begin = &EndpointList[line->endpoint_indexes[0]];
212212 endpoint_data* end = &EndpointList[line->endpoint_indexes[1]];
213213 if(hpl::aleph::map::isSelectLine(px, py, begin->vertex.x, begin->vertex.y,
@@ -274,10 +274,10 @@
274274 //二つの線AB,BCが織り成す角度を求める
275275 double firstDegree = hpl::aleph::map::getTwoLinesDegree(pointA, pointB, pointB, pointC);
276276 //optimize degree to [0,360)
277- double optFirstDeg = hpl::math::optimizeDegree(deg);
277+ double optFirstDeg = hpl::math::optimizeDegree(firstDegree);
278278 //if degree is in [180,360),
279279
280- return false;
280+ return true;
281281 }
282282
283283 /**
--- marathon/trunk/HPLLib/HPLRealMapData.cpp (revision 281)
+++ marathon/trunk/HPLLib/HPLRealMapData.cpp (revision 282)
@@ -17,48 +17,70 @@
1717 //objects
1818 for(int i = 0; i < (int)copyTargetData->getSelObjects()->size(); i ++){
1919 int index = copyTargetData->getSelObjects()->at(i).index;
20- map_object* org = &SavedObjectList[index];
21- map_object copy;
22- memcpy(&copy, org, sizeof(map_object));
23- this->realObjects[index] = copy;
20+ addObject(index);
2421 }
2522 //points
2623 for(int i = 0; i < (int)copyTargetData->getSelPoints()->size(); i ++){
2724 int index = copyTargetData->getSelPoints()->at(i).index;
28- endpoint_data* org = get_endpoint_data(index);
29- endpoint_data copy;
30- memcpy(&copy, org, sizeof(endpoint_data));
31- this->realPoints[index] = copy;
3225 }
3326
3427
3528 //lines
3629 for(int i = 0; i < (int)copyTargetData->getSelLines()->size(); i ++){
37- int index = copyTargetData->getSelLines()->at(i).index;
38- line_data* org = get_line_data(index);
39- line_data copy;
40- memcpy(&copy, org, sizeof(line_data));
41- this->realLines[index] = copy;
30+ addLine(copyTargetData->getSelLines()->at(i).index);
4231
43- //線に所属する点を追加する
4432 }
4533 //sides
4634 for(int i = 0; i < (int)copyTargetData->getSelSides()->size(); i ++){
4735 int index = copyTargetData->getSelSides()->at(i).index;
48- side_data* org = get_side_data(index);
49- side_data copy;
50- memcpy(&copy, org, sizeof(side_data));
51- this->realSides[index] = copy;
5236 }
5337 //polygons
5438 for(int i = 0; i < (int)copyTargetData->getSelPolygons()->size(); i ++){
5539 int index = copyTargetData->getSelPolygons()->at(i).index;
56- polygon_data* org = get_polygon_data(index);
57- polygon_data copy;
58- memcpy(&copy, org, sizeof(polygon_data));
59- this->realPolygons[index] = copy;
6040 }
6141 }
42+
43+void hpl::aleph::map::HPLRealMapData::addObject(int index){
44+ map_object* org = &SavedObjectList[index];
45+ map_object copy;
46+ memcpy(&copy, org, sizeof(map_object));
47+ this->realObjects[index] = copy;
48+}
49+void hpl::aleph::map::HPLRealMapData::addPoint(int index){
50+ endpoint_data* org = get_endpoint_data(index);
51+ endpoint_data copy;
52+ memcpy(&copy, org, sizeof(endpoint_data));
53+ this->realPoints[index] = copy;
54+}
55+void hpl::aleph::map::HPLRealMapData::addLine(int index){
56+ line_data* org = get_line_data(index);
57+ line_data copy;
58+ memcpy(&copy, org, sizeof(line_data));
59+ this->realLines[index] = copy;
60+
61+ //線に所属する点を追加する
62+ for(int i = 0; i < 2; i ++){
63+ addPoint(copy.endpoint_indexes[i]);
64+ }
65+}
66+void hpl::aleph::map::HPLRealMapData::addPolygon(int index){
67+ polygon_data* org = get_polygon_data(index);
68+ polygon_data copy;
69+ memcpy(&copy, org, sizeof(polygon_data));
70+ this->realPolygons[index] = copy;
71+
72+ //lines
73+ int vertexCount = copy.vertex_count;
74+ for(int i = 0; i < vertexCount - 1; i ++){
75+ addLine(copy.line_indexes[i]);
76+ }
77+}
78+void hpl::aleph::map::HPLRealMapData::addSide(int index){
79+ side_data* org = get_side_data(index);
80+ side_data copy;
81+ memcpy(&copy, org, sizeof(side_data));
82+ this->realSides[index] = copy;
83+}
6284 //所持するデータを消します
6385 void hpl::aleph::map::HPLRealMapData::removeAll()
6486 {
@@ -68,23 +90,23 @@
6890 this->realPolygons.clear();
6991 this->realSides.clear();
7092 }
71-std::map<int, map_object> hpl::aleph::map::HPLRealMapData::getObjects()
93+std::map<int, map_object>* hpl::aleph::map::HPLRealMapData::getObjects()
7294 {
73- return this->realObjects;
95+ return &this->realObjects;
7496 }
75-std::map<int, endpoint_data> ghpl::aleph::map::HPLRealMapData::getPoints()
97+std::map<int, endpoint_data>* hpl::aleph::map::HPLRealMapData::getPoints()
7698 {
77- return this->realPoints;
99+ return &this->realPoints;
78100 }
79-std::map<int, line_data> hpl::aleph::map::HPLRealMapData::getLines()
101+std::map<int, line_data>* hpl::aleph::map::HPLRealMapData::getLines()
80102 {
81- return this->realLines;
103+ return &this->realLines;
82104 }
83-std::map<int, polygon_data> hpl::aleph::map::HPLRealMapData::getPolygons()
105+std::map<int, polygon_data>* hpl::aleph::map::HPLRealMapData::getPolygons()
84106 {
85- return this->realPolygons;
107+ return &this->realPolygons;
86108 }
87-std::map<int, side_data> hpl::aleph::map::HPLRealMapData::getSides()
109+std::map<int, side_data>* hpl::aleph::map::HPLRealMapData::getSides()
88110 {
89- return this->realSides;
111+ return &this->realSides;
90112 }
--- marathon/trunk/HPLLib/HPLDoneHistory.h (revision 281)
+++ marathon/trunk/HPLLib/HPLDoneHistory.h (revision 282)
@@ -9,7 +9,7 @@
99 #ifndef _HPL_DONE_HISTORY_
1010 #define _HPL_DONE_HISTORY_
1111
12-#include <list>
12+#include <vector>
1313 #include "HPLSelectData.h"
1414 #include "HPLRealMapData.h"
1515
@@ -23,17 +23,31 @@
2323 Modify,
2424 };
2525 };
26-
26+
2727 class HPLDoneHistory{
2828 private:
2929 //触ったデータ情報
30- list<HPLSelectData> dataList;
30+ std::vector<HPLSelectData> dataList;
3131
3232 //触った実データの控え
33- list<HPLRealMapData> realList;
33+ std::vector<HPLRealMapData> realList;
3434 public:
3535 HPLDoneHistory();
3636 ~HPLDoneHistory();
37+
38+ public:
39+ /**
40+ 情報を追加します
41+ */
42+ void push_back(HPLSelectData selectData);
43+
44+ /**
45+ 最後からindex番目の要素を取り出します。
46+ 最大記憶量を超えていたらNULLが入り、falseが返ります
47+ */
48+ bool getLastIndexOf(int index,
49+ HPLSelectData* selectData, HPLRealMapData* realData);
50+ private:
3751 };
3852 };
3953 };
--- marathon/trunk/HPLLib/HPLRealMapData.h (revision 281)
+++ marathon/trunk/HPLLib/HPLRealMapData.h (revision 282)
@@ -37,12 +37,18 @@
3737 public:
3838 //コピー対象のマップデータ(選択部分)
3939 void set(hpl::aleph::map::HPLSelectData* copyTargetData);
40- std::map<int, map_object> getObjects();
41- std::map<int, endpoint_data> getPoints();
42- std::map<int, line_data> getLines();
43- std::map<int, polygon_data> getPolygons();
44- std::map<int, side_data> getSides();
40+ std::map<int, map_object>* getObjects();
41+ std::map<int, endpoint_data>* getPoints();
42+ std::map<int, line_data>* getLines();
43+ std::map<int, polygon_data>* getPolygons();
44+ std::map<int, side_data>* getSides();
45+
4546 private:
47+ void addObject(int index);
48+ void addPoint(int index);
49+ void addLine(int index);
50+ void addSide(int index);
51+ void addPolygon(int index);
4652 //所持するデータを消します
4753 void removeAll();
4854
--- marathon/trunk/HPLLib/HPLMath.cpp (revision 281)
+++ marathon/trunk/HPLLib/HPLMath.cpp (revision 282)
@@ -287,7 +287,7 @@
287287
288288 return radABCD;
289289 }
290-double hpl::math::getTwoLinesRadian(double pax, double pay, double pbx, double pby,
290+double hpl::math::getTwoLinesDegree(double pax, double pay, double pbx, double pby,
291291 double pcx, double pcy, double pdx, double pdy)
292292 {
293293 double rad = hpl::math::getTwoLinesRadian(pax, pay, pbx, pby, pcx, pcy, pdx, pdy);
@@ -297,15 +297,18 @@
297297
298298 /**
299299 ベクトルの角度を求めます(0 deg = (1,0))
300-*/
300+*
301301 double hpl::math::getDegreeFromVector(double x, double y){
302302 double rad = hpl::math::getRadianFromVector(x,y);
303303 double deg = hpl::math::getDegreeFromRadian(rad);
304304 return rad;
305305 }
306-
306+*/
307307 double hpl::math::getRadianFromVector(double x, double y){
308- //atanで求める
308+ double deg = hpl::math::getDegreeFromVector(x, y);
309+ double rad = hpl::math::getRadianFromDegree(deg);
310+ return rad;
311+/* //atanで求める
309312 //垂直
310313 if(x == 0){
311314 if(y > 0){
@@ -330,6 +333,7 @@
330333 float rad = atan(div) + PI;
331334 return rad;
332335 }
336+ */
333337 }
334338
335339 /**
旧リポジトリブラウザで表示