File: Doom3AasFileSettings.cpp

package info (click to toggle)
darkradiant 3.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 41,080 kB
  • sloc: cpp: 264,743; ansic: 10,659; python: 1,852; xml: 1,650; sh: 92; makefile: 21
file content (162 lines) | stat: -rw-r--r-- 4,728 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#include "Doom3AasFileSettings.h"

#include "string/convert.h"
#include "string/trim.h"
#include "Util.h"

namespace map
{

Doom3AasFileSettings::Doom3AasFileSettings() :
    numBoundingBoxes(1),
    usePatches(false),
    writeBrushMap(false),
    playerFlood(false),
    noOptimize(false),
    allowSwimReachabilities(false),
    allowFlyReachabilities(false),
	fileExtension("aas48"),
	gravity(0, 0, -1066),
	gravityDir(gravity.getNormalised()),
	invGravityDir(-gravityDir),
    gravityValue(static_cast<float>(gravity.getLength())),
	maxStepHeight(14.0f),
	maxBarrierHeight(32.0f),
	maxWaterJumpHeight(20.0f),
	maxFallHeight(64.0f),
	minFloorCos(0.7f),
	tt_barrierJump(100),
	tt_startCrouching(100),
	tt_waterJump(100),
	tt_startWalkOffLedge(100)
{
    boundingBoxes[0] = AABB::createFromMinMax(Vector3(-16, -16, 0), Vector3(16, 16, 72));
}

void Doom3AasFileSettings::parseFromTokens(parser::DefTokeniser& tok)
{
    tok.assertNextToken("{");

    while (tok.hasMoreTokens())
    {
        std::string token = tok.nextToken();

        if (token == "}")
        {
            break;
        }
        else if (token == "bboxes")
        {
            // Parse bboxes
            tok.assertNextToken("{");

            std::size_t index = 0;

            while (tok.hasMoreTokens() && index < MAX_AAS_BOUNDING_BOXES)
            {
                if (tok.peek() == "}")
                {
                    tok.nextToken();
                    break;
                }

                // Parse bbox
                boundingBoxes[index].origin = parseVector3(tok);
                tok.assertNextToken("-");
                boundingBoxes[index].extents = parseVector3(tok);

                ++index;
            }
        }
        else if (token == "usePatches")
        {
            tok.assertNextToken("=");
            usePatches = string::convert<bool>(tok.nextToken());
        }
        else if (token == "writeBrushMap")
        {
            tok.assertNextToken("=");
            writeBrushMap = string::convert<bool>(tok.nextToken());
        }
        else if (token == "playerFlood")
        {
            tok.assertNextToken("=");
            playerFlood = string::convert<bool>(tok.nextToken());
        }
        else if (token == "allowSwimReachabilities")
        {
            tok.assertNextToken("=");
            allowSwimReachabilities = string::convert<bool>(tok.nextToken());
        }
        else if (token == "allowFlyReachabilities")
        {
            tok.assertNextToken("=");
            allowFlyReachabilities = string::convert<bool>(tok.nextToken());
        }
        else if (token == "fileExtension")
        {
            tok.assertNextToken("=");
            fileExtension = string::trim_copy(tok.nextToken(), "\"");
        }
        else if (token == "gravity")
        {
            tok.assertNextToken("=");
            gravity = parseVector3(tok);

            gravityDir = gravity.getNormalised();
			gravityValue = static_cast<float>(gravity.getLength());
			invGravityDir = -gravityDir;
        }
        else if (token == "maxStepHeight")
        {
            tok.assertNextToken("=");
            maxStepHeight = string::convert<float>(tok.nextToken());
        }
        else if (token == "maxBarrierHeight")
        {
            tok.assertNextToken("=");
            maxBarrierHeight = string::convert<float>(tok.nextToken());
        }
        else if (token == "maxWaterJumpHeight")
        {
            tok.assertNextToken("=");
            maxWaterJumpHeight = string::convert<float>(tok.nextToken());
        }
        else if (token == "maxFallHeight")
        {
            tok.assertNextToken("=");
            maxFallHeight = string::convert<float>(tok.nextToken());
        }
        else if (token == "minFloorCos")
        {
            tok.assertNextToken("=");
            minFloorCos = string::convert<float>(tok.nextToken());
        }
        else if (token == "tt_barrierJump")
        {
            tok.assertNextToken("=");
            tt_barrierJump = string::convert<int>(tok.nextToken());
        }
        else if (token == "tt_startCrouching")
        {
            tok.assertNextToken("=");
            tt_startCrouching = string::convert<int>(tok.nextToken());
        }
        else if (token == "tt_waterJump")
        {
            tok.assertNextToken("=");
            tt_waterJump = string::convert<int>(tok.nextToken());
        }
        else if (token == "tt_startWalkOffLedge")
        {
            tok.assertNextToken("=");
            tt_startWalkOffLedge = string::convert<int>(tok.nextToken());
        }
        else
        {
            throw parser::ParseException("Unknown settings token: " + token);
        }
    }
}

}