Comments (5)
The Source Engine definitions for
ddispinfo_t
mess with how C/C++ packs structs to create some oddly aligned structures
Just kidding, everything is padded automatically
/* chaos_bsp.c */
typedef struct { float x, y, z; } Vector;
struct DispSubNeighbor_t {
unsigned int neighbor;
unsigned char neighborOrient;
unsigned char span;
unsigned char neighborSpan;
};
struct DispNeighbor_t {
struct DispSubNeighbor_t neighbors[2];
};
struct DispCornerNeighbors_t {
unsigned int neighbors[4];
unsigned char neighborCount;
};
#define ALLOWEDVERTS_SIZE 10
struct ddispinfo_t {
Vector startPosition;
int m_iDispVertStart;
int m_iDispTriStart;
int power;
int minTess;
float smoothingAngle;
int contents;
unsigned int m_iMapFace;
int m_iLightmapAlphaStart;
int m_iLightmapSamplePositionStart;
struct DispNeighbor_t m_EdgeNeighbors[4];
struct DispCornerNeighbors_t m_CornerNeighbors[4];
unsigned int m_AllowedVerts[ALLOWEDVERTS_SIZE];
};
int main(int argc, char *argv[]) {
#define SHOW_SIZE(s) printf("%32s | %lu\n", #s, sizeof(s))
SHOW_SIZE(struct DispSubNeighbor_t);
SHOW_SIZE(struct DispNeighbor_t);
SHOW_SIZE(struct DispCornerNeighbors_t);
SHOW_SIZE(struct ddispinfo_t);
#undef SHOW_SIZE
return 0;
}
$ ./chaos_bsp.exe
struct DispSubNeighbor_t | 8
struct DispNeighbor_t | 16
struct DispCornerNeighbors_t | 20
struct ddispinfo_t | 232
So, we only have to add padding members to each child struct & hook up classes
No .from_bytes()
& .as_bytes()
overrides required!
from bsp_tool.
Though I would like to make sure the LumpClasses use inheritance & add num_displacement_vertices
& _triangles
properties.
If .bsp
files can be thought of as SQL tables, I don't see why LumpClasses can't be VIEW
s, rather than just TABLE
s
from bsp_tool.
valve.source.DisplacementInfo
neighbours get read with bad alignment, getting garbage values in enums & padding
from bsp_tool.
We need more robust testing on how displacements are parsed, especially neighbours
This might require new displacement related methods in valve.source
Just testing for valid start positions & displacement face connections would be a start
valid enum & padding == 0
checks are also relatively simple
from bsp_tool.
The __repr__
is also really bad, a prettyprint __repr__
for the big displacement neighbours chunk would be really nice
respawn.apex_legends.BVHNode.__repr__
already has a custom __repr__
, should make for a good reference
We could even mimic the nice code comment diagrams from the Source SDK
from bsp_tool.
Related Issues (20)
- Need a common Image LumpClass base type
- [Test Maps] `genesis3d`
- Configure `pytest` to remove naming convention HOT 2
- Create a `utils` submodule to pull tools out of `branches` HOT 1
- (extensions.editor) `.save_as(filename: str)` method for all `MapFile` classes
- (extensions.editor) MetaPattern string conversion is an ugly mess
- [Apex Archive] Season19 removed pakfiles, where are the cubemaps? HOT 4
- Another wave of geometry refactors HOT 4
- (extensions.decompile) Include TriColl meshes when decompiling Titanfall Engine maps HOT 3
- Move `extensions.editor.generic` into `utils.editor`
- (extensions.decompile) Standardising decompile extraction & processing
- BitField order is backwards, should be the same as C/C++ HOT 3
- [Apex Archive] Identify origins of loose maps, then remove them HOT 1
- [Test Maps] `apex_legends50`
- `bsp.bsp_version` should just be `bsp.version` HOT 1
- Geometry performance could be better HOT 3
- `editor.Brush`-> `List[geometry.Mesh]` HOT 1
- (utils.geometry) remove iterations.batched
- (extensions.lightmaps) Select Faces lump for Source Engine `lightmap_faces`
- [Test Maps] `apex_legends52`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bsp_tool.