MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / buildSlopes

Method buildSlopes

source/camera/SlopeWalk.cpp:43–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41}
42
43void SlopeWalk::buildSlopes()
44{
45 //A value of how much we are to enlarge our polygon
46 //chosen experimentally too large values slows down
47 //the culling and may provide some glitches
48 mVertices.sort();
49 mRightSlopes.clear();
50 mLeftSlopes.clear();
51 mRightVertices.clear();
52 mLeftVertices.clear();
53
54 // find minimal and maximal values of y coordinate at left and right path
55 findMinMaxLeft(mVertices.mMyArray);
56 findMinMaxRight(mVertices.mMyArray);
57
58 // for each pair of consecutive vertexes on right path create a slope value , which is equal to 'a' as in equation ax + b = 0
59 // also put slopes of value 0 at the begging and the end of path
60
61 mRightSlopes.push_back(0);
62 for(int ii = mTopRightIndex; ii != mDownRightIndex ; ++ii, ii %= mVertices.mMyArray.size())
63 {
64 mRightSlopes.push_back((mVertices[ii].x - mVertices[ii+1].x) * VectorInt64::UNIT / (mVertices[ii].y - mVertices[ii+1].y));
65 mRightVertices.push_back(ii);
66
67 }
68 mRightSlopes.push_back(0);
69 mRightVertices.push_back(mDownRightIndex);
70
71 // for each pair of consecutive vertexes on left path create a slope value , which is equal to 'a' as in equation ax + b = 0
72 // also put slopes of value 0 at the begging and the end of path
73
74 mLeftSlopes.push_back(0);
75 for(int ii = mTopLeftIndex; ii != mDownLeftIndex ; ii+=mVertices.mMyArray.size() - 1, ii%=mVertices.mMyArray.size())
76 {
77 mLeftSlopes.push_back((mVertices[ii].x - mVertices[ii-1].x) * VectorInt64::UNIT / (mVertices[ii].y - mVertices[ii-1].y));
78 mLeftVertices.push_back(ii);
79 }
80 mLeftSlopes.push_back(0);
81 mLeftVertices.push_back(mDownLeftIndex);
82}
83
84// reset indexes to the begginging of containers
85void SlopeWalk::prepareWalk()

Callers 3

cullTilesMethod · 0.80
startTileCullingMethod · 0.80
stopTileCullingMethod · 0.80

Calls 2

clearMethod · 0.80
sortMethod · 0.45

Tested by

no test coverage detected