Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Every old model class removed and deleted from git * A new generic model class was created to replace the deleted ones * Changed `d3d_model_create` to return an int like other resource functions for consistency * Removed `d3d_model_part_draw` functions because their name is inconsistent (e.g, should be `draw_part` like `draw_background_part`) and because they are not clear enough for a model class which optimizes and combines primitives together, `d3d_model_draw_primitive` with an index to the primitive would be a better function. We also no longer use these functions anywhere, tiles use the vertex and index buffer abstractions directly now which offer range arguments in their submit functions. * Added a new function `d3d_model_vertex_data` that allows one to specify the model's vertex data in a single function call, but requires a vertex format be provided. * Updated `GSmodel.h` with comments specifying the preconditions for each group of model specification functions * Renamed `d3d_model_add_*` functions to remove the `_add_` part of their name to match the original `d3d_model_vertex` function from GM for consistency. * Added the following new vertex functions: * `vertex_format_exists()`: This non-id version of the function will tell us if we are between `vertex_format_begin` and `vertex_format_end` calls. In other words, it tells us if we are still defining a new vertex format. * `vertex_format_get_stride()`: Non-id version returns the stride of the vertex format currently being specified. * `vertex_format_get_hash()`: Non-id version returns the hash of the vertex format currently being specified. * `vertex_format_get_stride(id)`: Returns the stride of the vertex format with the given id. This is basically the number of vertex attributes, it is not the size of a vertex in bytes. * `vertex_format_get_hash(id)`: Returns a hash of the vertex format and its type/usage pairs. * `vertex_set_format(buffer,format)`: Allows one to change the vertex format of a vertex buffer, which essentially allows the vertex buffer to hold the same data for differently formatted primitives. * Made `vertex_format_end` set the `enigma::vertexFormat` pointer to 0 so there can be no further accidental mutation of it once it is moved to the vector and assigned a real id for the user. * Made `vertex_get_number`, `vertex_get_size`, and their index buffer equivalents return the correct value when in the middle of `vertex_begin` and `vertex_end` which previously they would not. This required marking the vertex and index buffers dirty in `vertex_begin` instead of `vertex_end` so that the dirty flag could be used to determine where to grab the number of vertices/indices from. * Added a non-fatal error message for `vertex_data` that shows in debug mode if the user calls the function but the vertex buffer does not have a valid vertex format, since one is required for the function to correctly decompose the arguments. * Removed all `d3d_model_has_*` functions because we aren't using them anywhere and we don't need them. * Changed `graphics_reset_client_state` to unbind the vertex and index buffers (bind the target to 0) in OpenGL1 because it will screw up primitive rendering that uses `glVertexPointer` with a client-side array. This caused issues in Wild Racing GMK because `d3d_draw_floor` was not being drawn and I could not figure out why. * Removed `d3d_model_get_stride` and `d3d_model_format` as well as calls to them in the context managers in Bridges because the function no longer makes sense. The model class in this pr has a format for each primitive, hence the entire model doesn't have a consistent stride or format. * Removed `d3d_model_index` because the new model class doesn't support indexing yet. * Added caching of both vertex formats and vertex format peers. The peers are non-trivial to construct and we also don't want the user being wasteful with the former either. Caching both independently gave separate performance boosts, so both are necessary. Because of this change, `vertex_format_end` may now return the same id multiple times and never actually return a unique id if the hashes of the vertex format specified are always logically equivalent to another format. * Fixed a typo in `d3d_model_set_rotation_x` for D3D9, it should have had `gs_scalar` not `double` like its signature in the general header. * Added a `dynamic` flag to `vertex_freeze` so the user can indicate such usage. By default I set the parameter to false, because freezing the vertex is to be synonymous with making it static (never changing). If the user passes true for dynamic, that is like saying they will update the vertex buffer infrequently (aka GL_DYNAMIC_DRAW). If the user intends to update the vertex buffer every frame, then they should not call `vertex_freeze` just like in GMS (aka this indicates GL_STREAM_DRAW).
- Loading branch information