std::string Plane::SerializeToString() const { char str[256]; char *s = SerializeFloat(normal.x, str); *s = ','; ++s; s = SerializeFloat(normal.y, s); *s = ','; ++s; s = SerializeFloat(normal.z, s); *s = ','; ++s; s = SerializeFloat(d, s); assert(s+1 - str < 256); MARK_UNUSED(s); return str; }
std::string Sphere::SerializeToString() const { char str[256]; char *s = SerializeFloat(pos.x, str); *s = ','; ++s; s = SerializeFloat(pos.y, s); *s = ','; ++s; s = SerializeFloat(pos.z, s); *s = ','; ++s; s = SerializeFloat(r, s); assert(s+1 - str < 256); MARK_UNUSED(s); return str; }
std::string MUST_USE_RESULT Quat::SerializeToString() const { char str[256]; char *s = SerializeFloat(x, str); *s = ','; ++s; s = SerializeFloat(y, s); *s = ','; ++s; s = SerializeFloat(z, s); *s = ','; ++s; s = SerializeFloat(w, s); assert(s+1 - str < 256); MARK_UNUSED(s); return str; }
void SerializePhysicsInfo(XFILE *fp, int mode, physics_info *pi) { SerializeFloat(fp, mode, pi->mass); SerializeFloat(fp, mode, pi->drag); SerializeVector(fp, mode, &pi->max_thrust); SerializeVector(fp, mode, &pi->max_rotthrust); SerializeFloat(fp, mode, pi->turnroll); SerializeInt(fp, mode, pi->flags); SerializeVector(fp, mode, &pi->velocity); SerializeVector(fp, mode, &pi->rotvel); SerializeVector(fp, mode, &pi->thrust); SerializeVector(fp, mode, &pi->rotthrust); }
void SerializeGrid(XFILE *fp, int mode, grid *gridp) { int i; SerializeInt(fp, mode, gridp->nrows); SerializeInt(fp, mode, gridp->ncols); SerializeMatrix(fp, mode, &gridp->gmatrix); SerializePhysicsInfo(fp, mode, &gridp->physics); SerializeFloat(fp, mode, gridp->square_size); SerializeFloat(fp, mode, gridp->planeD); for (i=0; i<MAX_GRID_POINTS; i++) SerializeVector(fp, mode, &gridp->gpoints[i]); }
Uint64 GetSerializedFloatSize(double data) { Byte* p = nullptr; Uint64 size = SerializeFloat(data, p); if (p != nullptr) delete p; return size; }
static void SerializeFloats( CUtlBuffer &buf, int nCount, const float *pFloats ) { for ( int i = 0; i < nCount; ++i ) { SerializeFloat( buf, pFloats[i] ); if ( i != nCount-1 ) { buf.PutChar( ' ' ); } } }
bool Serialize( CUtlBuffer &buf, const float &src ) { if ( buf.IsText() ) { SerializeFloat( buf, src ); } else { buf.PutFloat( src ); } return buf.IsValid(); }
bool WriteEbmlElement(IMkvWriter* writer, uint64 type, float value) { if (!writer) return false; if (WriteID(writer, type)) return false; if (WriteUInt(writer, 4)) return false; if (SerializeFloat(writer, value)) return false; return true; }
///////////////////////////////////////////////////////////////////////////// // CFREDDoc serialization void SerializeObject(XFILE *fp, int mode, object *objp) { SerializeInt(fp, mode, objp->signature); SerializeInt(fp, mode, objp->type); SerializeInt(fp, mode, objp->parent); SerializeInt(fp, mode, objp->parent_sig); SerializeInt(fp, mode, objp->parent_type); SerializeInt(fp, mode, objp->instance); SerializeInt(fp, mode, objp->flags); SerializeFloat(fp, mode, objp->radius); // SerializeInt(fp, mode, objp->wing); SerializePhysicsInfo(fp, mode, &objp->phys_info); SerializeVector(fp, mode, &objp->pos); SerializeMatrix(fp, mode, &objp->orient); }
///////////////////////////////////////////////////////////////////////////// // CFREDDoc serialization void SerializeObject(XFILE *fp, int mode, object *objp) { SerializeInt(fp, mode, objp->signature); SerializeInt(fp, mode, objp->type); SerializeInt(fp, mode, objp->parent); SerializeInt(fp, mode, objp->parent_sig); SerializeInt(fp, mode, objp->parent_type); SerializeInt(fp, mode, objp->instance); SerializeInt(fp, mode, objp->flags); SerializeInt(fp, mode, objp->flags2); // Goober5000 - code is obsolete, but I added this just in case SerializeFloat(fp, mode, objp->radius); // SerializeInt(fp, mode, objp->wing); SerializePhysicsInfo(fp, mode, &objp->phys_info); SerializeVector(fp, mode, &objp->pos); SerializeMatrix(fp, mode, &objp->orient); }
std::string AABB::SerializeToString() const { char str[256]; char *s = SerializeFloat(minPoint.x, str); *s = ','; ++s; s = SerializeFloat(minPoint.y, s); *s = ','; ++s; s = SerializeFloat(minPoint.z, s); *s = ','; ++s; s = SerializeFloat(maxPoint.x, s); *s = ','; ++s; s = SerializeFloat(maxPoint.y, s); *s = ','; ++s; s = SerializeFloat(maxPoint.z, s); assert(s+1 - str < 256); MARK_UNUSED(s); return str; }
void SerializeVector(XFILE *fp, int mode, vector *v) { SerializeFloat(fp, mode, v->x); SerializeFloat(fp, mode, v->y); SerializeFloat(fp, mode, v->z); }
std::string float3x4::SerializeToString() const { char str[512]; char *s = SerializeFloat(v[0][0], str); *s = ','; ++s; s = SerializeFloat(v[0][1], s); *s = ','; ++s; s = SerializeFloat(v[0][2], s); *s = ','; ++s; s = SerializeFloat(v[0][3], s); *s = ','; ++s; s = SerializeFloat(v[1][0], s); *s = ','; ++s; s = SerializeFloat(v[1][1], s); *s = ','; ++s; s = SerializeFloat(v[1][2], s); *s = ','; ++s; s = SerializeFloat(v[1][3], s); *s = ','; ++s; s = SerializeFloat(v[2][0], s); *s = ','; ++s; s = SerializeFloat(v[2][1], s); *s = ','; ++s; s = SerializeFloat(v[2][2], s); *s = ','; ++s; s = SerializeFloat(v[2][3], s); assert(s+1 - str < 512); MARK_UNUSED(s); return str; }