-
-
Notifications
You must be signed in to change notification settings - Fork 43
Add Valve-220 map format support to quemap. #831
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
8248995
321b356
57352fc
e7b59e0
44aa8e0
e9f7cdf
fb54f81
0eebee1
48dfdb8
d50b78c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,6 +78,11 @@ typedef struct brush_side_s { | |
| */ | ||
| vec2_t scale; | ||
|
|
||
| /** | ||
| * @brief True if this brush side uses Valve-220 explicit texture axes. | ||
| */ | ||
| bool valve; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this boolean probably belongs as a global, right? We'd never encounter a .map file that uses some Valve brushes and some legacy / standard brushes, right? |
||
|
|
||
| /** | ||
| * @brief The texture axis for S and T, in xyz + offset notation. | ||
| */ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -168,6 +168,15 @@ int32_t BSP_Main(void) { | |
|
|
||
| LoadMapFile(map_name); | ||
|
|
||
| bool valve = false; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea, what probably makes sense here is to introduce typedef enum {
MAP_QUAKE2,
MAP_VALVE_220
} map_format_t;And have map_format = LoadMapFile(map_name);And then everywhere downstream can just check |
||
| for (int32_t i = 0; i < num_brush_sides; i++) { | ||
| if (brush_sides[i].valve) { | ||
| valve = true; | ||
| break; | ||
| } | ||
| } | ||
| Com_Print("Map format: %s\n", valve ? "Quake3 (Valve)" : "Quake3"); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Com_Verbose. |
||
|
|
||
| EmitPlanes(); | ||
| EmitMaterials(); | ||
| EmitBrushes(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,6 +68,32 @@ static void TextureAxisForPlane(const plane_t *plane, vec3_t *xv, vec3_t *yv) { | |
| */ | ||
| void TextureVectorsForBrushSide(brush_side_t *side, const vec3_t origin) { | ||
|
|
||
| if (side->valve) { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if (map_format == MAP_VALVE_220) { |
||
| // Valve-220: axes are already stored in side->axis as (direction, shift). | ||
| // Note that this function is called once during parsing (origin = 0) and may be called | ||
| // a second time when applying entity origin offsets. | ||
| const vec2_t scale = { | ||
| .x = side->scale.x ?: 1.f, | ||
| .y = side->scale.y ?: 1.f, | ||
| }; | ||
|
|
||
| if (!Vec3_Equal(origin, Vec3_Zero())) { | ||
| // Axis xyz are already scaled from the first pass; only apply the origin offset. | ||
| for (int32_t i = 0; i < 2; i++) { | ||
| side->axis[i].w += Vec3_Dot(origin, side->axis[i].xyz); | ||
| } | ||
| return; | ||
| } | ||
|
|
||
| // First pass: apply scale. | ||
| for (int32_t i = 0; i < 2; i++) { | ||
| for (int32_t j = 0; j < 3; j++) { | ||
| side->axis[i].xyzw[j] /= scale.xy[i]; | ||
| } | ||
| } | ||
| return; | ||
| } | ||
|
|
||
| vec3_t axis[2]; | ||
| TextureAxisForPlane(&planes[side->plane], &axis[0], &axis[1]); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤣 Oh, fucking Windows...