@@ -91,22 +91,84 @@ namespace Util {
9191 }
9292 };
9393
94+ template <> struct SerializeTraits <std::vector<BoneMod>> {
95+ static void Write ( Writer& stream, const std::vector<BoneMod>& boneMods ) {
96+ stream.WriteSize ( boneMods.size () );
97+ stream.WriteData ( boneMods.data (), boneMods.size () * sizeof ( BoneMod ) );
98+ }
99+
100+ static std::vector<BoneMod> Read ( Reader& stream ) {
101+ std::vector<BoneMod> boneMods;
102+ const size_t size = stream.ReadSize <BoneMod>();
103+ boneMods.resize ( size );
104+ stream.ReadData ( boneMods.data (), size * sizeof ( BoneMod ) );
105+ return boneMods;
106+ }
107+ };
108+
94109 // Use that bone optimization for refEntity_t
95110 template <> struct SerializeTraits <refEntity_t> {
96111 static void Write (Writer& stream, const refEntity_t& ent)
97112 {
98- stream.WriteData (&ent, offsetof (refEntity_t, skeleton));
99- stream.Write <refSkeleton_t>(ent.skeleton );
113+ stream.WriteData (&ent, offsetof (refEntity_t, tag));
114+ stream.Write <std::string>( ent.tag );
115+ stream.Write <std::vector<BoneMod>>( ent.boneMods );
116+ // stream.Write<refSkeleton_t>(ent.skeleton);
100117 }
118+
101119 static refEntity_t Read (Reader& stream)
102120 {
103121 refEntity_t ent;
104- stream.ReadData (&ent, offsetof (refEntity_t, skeleton));
105- ent.skeleton = stream.Read <refSkeleton_t>();
122+ stream.ReadData (&ent, offsetof (refEntity_t, tag));
123+ ent.tag = stream.Read <std::string>();
124+ ent.boneMods = stream.Read <std::vector<BoneMod>>();
125+ // ent.skeleton = stream.Read<refSkeleton_t>();
126+ return ent;
127+ }
128+ };
129+
130+ template <> struct SerializeTraits <EntityUpdate> {
131+ static void Write ( Writer& stream, const EntityUpdate& ent ) {
132+ stream.Write <refEntity_t>( ent.ent );
133+ stream.Write <uint16_t >( ent.id );
134+ }
135+
136+ static EntityUpdate Read ( Reader& stream ) {
137+ EntityUpdate ent;
138+ ent.ent = stream.Read <refEntity_t>();
139+ ent.id = stream.Read <uint16_t >();
106140 return ent;
107141 }
108142 };
109143
144+ template <> struct SerializeTraits <LerpTagUpdate> {
145+ static void Write ( Writer& stream, const LerpTagUpdate& tag ) {
146+ stream.Write <std::string>( tag.tag );
147+ stream.Write <uint16_t >( tag.id );
148+ }
149+
150+ static LerpTagUpdate Read ( Reader& stream ) {
151+ LerpTagUpdate tag;
152+ tag.tag = stream.Read <std::string>();
153+ tag.id = stream.Read <uint16_t >();
154+ return tag;
155+ }
156+ };
157+
158+ template <> struct SerializeTraits <LerpTagSync> {
159+ static void Write ( Writer& stream, const LerpTagSync& tag ) {
160+ stream.Write <orientation_t >( tag.entityOrientation );
161+ stream.Write <orientation_t >( tag.orientation );
162+ }
163+
164+ static LerpTagSync Read ( Reader& stream ) {
165+ LerpTagSync tag;
166+ tag.entityOrientation = stream.Read <orientation_t >();
167+ tag.orientation = stream.Read <orientation_t >();
168+ return tag;
169+ }
170+ };
171+
110172 template <>
111173 struct SerializeTraits <Color::Color> {
112174 static void Write (Writer& stream, const Color::Color& value)
@@ -166,6 +228,8 @@ enum cgameImport_t
166228 CG_R_REGISTERFONT,
167229 CG_R_CLEARSCENE,
168230 CG_R_ADDREFENTITYTOSCENE,
231+ CG_R_SYNCREFENTITIES,
232+ CG_R_SYNCLERPTAGS,
169233 CG_R_ADDPOLYTOSCENE,
170234 CG_R_ADDPOLYSTOSCENE,
171235 CG_R_ADDLIGHTTOSCENE,
@@ -179,7 +243,6 @@ enum cgameImport_t
179243 CG_R_DRAWSTRETCHPIC,
180244 CG_R_DRAWROTATEDPIC,
181245 CG_R_MODELBOUNDS,
182- CG_R_LERPTAG,
183246 CG_R_REMAP_SHADER,
184247 CG_R_BATCHINPVS,
185248 CG_R_LIGHTFORPOINT,
@@ -319,10 +382,6 @@ namespace Render {
319382 IPC::Message<IPC::Id<VM::QVM, CG_R_MODELBOUNDS>, int >,
320383 IPC::Reply<std::array<float , 3 >, std::array<float , 3 >>
321384 >;
322- using LerpTagMsg = IPC::SyncMessage<
323- IPC::Message<IPC::Id<VM::QVM, CG_R_LERPTAG>, refEntity_t, std::string, int >,
324- IPC::Reply<orientation_t , int >
325- >;
326385 using RemapShaderMsg = IPC::Message<IPC::Id<VM::QVM, CG_R_REMAP_SHADER>, std::string, std::string, std::string>;
327386 // TODO not a renderer call, handle in CM in the VM?
328387 using BatchInPVSMsg = IPC::SyncMessage<
@@ -379,6 +438,11 @@ namespace Render {
379438 using ScissorSetMsg = IPC::Message<IPC::Id<VM::QVM, CG_R_SCISSOR_SET>, int , int , int , int >;
380439 using ClearSceneMsg = IPC::Message<IPC::Id<VM::QVM, CG_R_CLEARSCENE>>;
381440 using AddRefEntityToSceneMsg = IPC::Message<IPC::Id<VM::QVM, CG_R_ADDREFENTITYTOSCENE>, refEntity_t>;
441+ using SyncRefEntitiesMsg = IPC::Message<IPC::Id<VM::QVM, CG_R_SYNCREFENTITIES>, std::vector<EntityUpdate>>;
442+ using SyncLerpTagsMsg = IPC::SyncMessage<IPC::Message<IPC::Id<VM::QVM, CG_R_SYNCLERPTAGS>,
443+ std::vector<LerpTagUpdate>>,
444+ IPC::Reply<std::vector<LerpTagSync>>
445+ >;
382446 using AddPolyToSceneMsg = IPC::Message<IPC::Id<VM::QVM, CG_R_ADDPOLYTOSCENE>, int , std::vector<polyVert_t>>;
383447 using AddPolysToSceneMsg = IPC::Message<IPC::Id<VM::QVM, CG_R_ADDPOLYSTOSCENE>, int , std::vector<polyVert_t>, int , int >;
384448 using AddLightToSceneMsg = IPC::Message<IPC::Id<VM::QVM, CG_R_ADDLIGHTTOSCENE>, std::array<float , 3 >, float , float , float , float , int >;
0 commit comments