SEGS  0.6.1-develop [d2cac982]
Super Entity Game Server
MapRef.h
Go to the documentation of this file.
1 /*
2  * SEGS - Super Entity Game Server
3  * http://www.segs.io/
4  * Copyright (c) 2006 - 2019 SEGS Team (see AUTHORS.md)
5  * This software is licensed under the terms of the 3-clause BSD License. See LICENSE.md for details.
6  */
7 
8 #pragma once
10 
11 #include <QtCore/QString>
12 #include <string>
13 
14 class MapRef
15 {
16 public:
17  int m_idx=0;
19  glm::mat4x3 m_matrix;
21  QString m_name;
22  MapRef(int idx,const glm::mat4x3 &mat,const QString &name) :
23  m_idx(idx),
24  m_matrix(mat),
25  m_name(name)
26  {
27  reduced_transform=false;
28  }
29  MapRef(int idx,const QString &name,glm::vec3 &pos,glm::vec3 &rot) : m_idx(idx),m_name(name)
30  {
31  reduced_transform=true;
32  m_transforms=TransformStruct(pos,rot,glm::vec3(),true,true,false);
33  }
34  MapRef(): m_name(""){}
36  {
37  m_idx = src.GetPackedBits(1);
38  if(m_idx<0) return;
39  src.GetString(m_name);
40  getTransformMatrix(src,m_matrix);
41  }
42  void serializeto(BitStream &tgt) const
43  {
44  tgt.StorePackedBits(16,m_idx); //def_id
45  //tgt.StoreString(m_name);
46  if(reduced_transform)
47  {
48  storeTransformMatrix(tgt,m_transforms);
49  }
50  else
51  {
52  storeTransformMatrix(tgt,m_matrix);
53  }
54  }
55 
56  template<class Archive>
57  void serialize(Archive &ar)
58  {
59  ar(m_idx,reduced_transform,m_matrix,m_transforms,m_name);
60  }
61 
62 };
glm::mat4x3 m_matrix
Definition: MapRef.h:19
int m_idx
Definition: MapRef.h:17
bool reduced_transform
Definition: MapRef.h:18
int32_t GetPackedBits(uint32_t minbits)
Definition: BitStream.cpp:290
Definition: BitStream.h:34
Definition: MapRef.h:14
void StorePackedBits(uint32_t nBits, uint32_t dataBits)
Definition: BitStream.cpp:161
void serializeto(BitStream &tgt) const
Definition: MapRef.h:42
void storeTransformMatrix(BitStream &tgt, const glm::mat4x3 &src)
Definition: CommonNetStructures.cpp:87
MapRef(int idx, const glm::mat4x3 &mat, const QString &name)
Definition: MapRef.h:22
MapRef(int idx, const QString &name, glm::vec3 &pos, glm::vec3 &rot)
Definition: MapRef.h:29
void GetString(QString &str)
Retrieves a null-terminated C-style string from the bit stream.
Definition: BitStream.cpp:331
MapRef()
Definition: MapRef.h:34
Definition: CommonNetStructures.h:17
QString m_name
Definition: MapRef.h:21
TransformStruct m_transforms
Definition: MapRef.h:20
void getTransformMatrix(BitStream &bs, glm::mat4x3 &src)
Definition: CommonNetStructures.cpp:116
void serializefrom(BitStream &src)
Definition: MapRef.h:35
void serialize(Archive &ar)
Definition: MapRef.h:57