mirror of
https://github.com/open-goal/jak-project
synced 2026-09-12 20:56:09 -04:00
Merge remote-tracking branch 'water111/master' into shrubbery
This commit is contained in:
@@ -11,6 +11,20 @@ void StripDraw::serialize(Serializer& ser) {
|
||||
ser.from_ptr(&num_triangles);
|
||||
}
|
||||
|
||||
void InstancedStripDraw::serialize(Serializer& ser) {
|
||||
ser.from_ptr(&mode);
|
||||
ser.from_ptr(&tree_tex_id);
|
||||
ser.from_pod_vector(&vertex_index_stream);
|
||||
ser.from_pod_vector(&instance_groups);
|
||||
ser.from_ptr(&num_triangles);
|
||||
}
|
||||
|
||||
void TieWindInstance::serialize(Serializer& ser) {
|
||||
ser.from_ptr(&matrix);
|
||||
ser.from_ptr(&wind_idx);
|
||||
ser.from_ptr(&stiffness);
|
||||
}
|
||||
|
||||
void TfragTree::serialize(Serializer& ser) {
|
||||
ser.from_ptr(&kind);
|
||||
|
||||
@@ -38,6 +52,24 @@ void TieTree::serialize(Serializer& ser) {
|
||||
draw.serialize(ser);
|
||||
}
|
||||
|
||||
if (ser.is_saving()) {
|
||||
ser.save<size_t>(instanced_wind_draws.size());
|
||||
} else {
|
||||
instanced_wind_draws.resize(ser.load<size_t>());
|
||||
}
|
||||
for (auto& draw : instanced_wind_draws) {
|
||||
draw.serialize(ser);
|
||||
}
|
||||
|
||||
if (ser.is_saving()) {
|
||||
ser.save<size_t>(instance_info.size());
|
||||
} else {
|
||||
instance_info.resize(ser.load<size_t>());
|
||||
}
|
||||
for (auto& inst : instance_info) {
|
||||
inst.serialize(ser);
|
||||
}
|
||||
|
||||
ser.from_pod_vector(&vertices);
|
||||
ser.from_pod_vector(&colors);
|
||||
bvh.serialize(ser);
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
// Data format for the tfrag3 renderer.
|
||||
#include <array>
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "common/util/assert.h"
|
||||
#include "common/dma/gs.h"
|
||||
#include "common/util/Serializer.h"
|
||||
#include "common/math/Vector.h"
|
||||
#include "common/util/assert.h"
|
||||
|
||||
namespace tfrag3 {
|
||||
|
||||
constexpr int TFRAG3_VERSION = 7;
|
||||
constexpr int TFRAG3_VERSION = 9;
|
||||
|
||||
// These vertices should be uploaded to the GPU at load time and don't change
|
||||
struct PreloadedVertex {
|
||||
@@ -41,8 +42,8 @@ struct StripDraw {
|
||||
// to do culling, the above vertex stream is grouped.
|
||||
// by following the visgroups and checking the visibility, you can leave out invisible vertices.
|
||||
struct VisGroup {
|
||||
u32 num = 0; // number of vertex indices in this group
|
||||
u32 vis_idx = 0; // the visibility group they belong to
|
||||
u32 num = 0; // number of vertex indices in this group
|
||||
u32 vis_idx_in_pc_bvh = 0; // the visibility group they belong to (in BVH)
|
||||
};
|
||||
std::vector<VisGroup> vis_groups;
|
||||
|
||||
@@ -51,12 +52,34 @@ struct StripDraw {
|
||||
void serialize(Serializer& ser);
|
||||
};
|
||||
|
||||
struct InstancedStripDraw {
|
||||
DrawMode mode; // the OpenGL draw settings.
|
||||
u32 tree_tex_id = 0; // the texture that should be bound for the draw
|
||||
|
||||
// the list of vertices in the draw. This includes the restart code of UINT32_MAX that OpenGL
|
||||
// will use to start a new strip.
|
||||
std::vector<u32> vertex_index_stream;
|
||||
|
||||
// the vertex stream above is segmented by instance.
|
||||
struct InstanceGroup {
|
||||
u32 num = 0; // number of vertex indices in this group
|
||||
u32 instance_idx = 0; // the instance they belong to
|
||||
u32 vis_idx = 0;
|
||||
};
|
||||
std::vector<InstanceGroup> instance_groups;
|
||||
|
||||
// for debug counting.
|
||||
u32 num_triangles = 0;
|
||||
void serialize(Serializer& ser);
|
||||
};
|
||||
|
||||
// node in the BVH.
|
||||
struct VisNode {
|
||||
math::Vector<float, 4> bsphere; // the bounding sphere, in meters (4096 = 1 game meter). w = rad
|
||||
u16 child_id = 0xffff; // the ID of our first child.
|
||||
u8 num_kids = 0xff; // number of children. The children are consecutive in memory
|
||||
u8 flags = 0; // flags. If 1, we have a DrawVisNode child, otherwise a leaf.
|
||||
u16 my_id = 0xffff;
|
||||
u8 num_kids = 0xff; // number of children. The children are consecutive in memory
|
||||
u8 flags = 0; // flags. If 1, we have a DrawVisNode child, otherwise a leaf.
|
||||
};
|
||||
|
||||
// The leaf nodes don't actually exist in the vector of VisNodes, but instead they are ID's used
|
||||
@@ -114,6 +137,13 @@ struct TfragTree {
|
||||
void serialize(Serializer& ser);
|
||||
};
|
||||
|
||||
struct TieWindInstance {
|
||||
std::array<math::Vector4f, 4> matrix;
|
||||
u16 wind_idx;
|
||||
float stiffness;
|
||||
void serialize(Serializer& ser);
|
||||
};
|
||||
|
||||
// A shrub model
|
||||
struct ShrubTree {
|
||||
BVH bvh;
|
||||
@@ -132,7 +162,8 @@ struct TieTree {
|
||||
std::vector<PreloadedVertex> vertices; // mesh vertices
|
||||
std::vector<TimeOfDayColor> colors; // vertex colors (pre-interpolation)
|
||||
|
||||
// TODO wind stuff
|
||||
std::vector<InstancedStripDraw> instanced_wind_draws;
|
||||
std::vector<TieWindInstance> instance_info;
|
||||
|
||||
void serialize(Serializer& ser);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user