AGX Dynamics  2.35.0.1
pack.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #ifndef AGX_PACK_H
18 #define AGX_PACK_H
19 
20 namespace agx
21 {
22 
24  struct uint32_t_struct {
25  uint32_t byte3:8,byte2:8,byte1:8,byte0:8;
26  };
28  uint32_t integer;
29  };
30 
35  inline uint32_t PACK_UINT32(uint8_t b0, uint8_t b1, uint8_t b2, uint8_t b3)
36  {
38  v.integer=0;
39 
40  v.bytes.byte0 = b0;
41  v.bytes.byte1 = b1;
42  v.bytes.byte2 = b2;
43  v.bytes.byte3 = b3;
44 
45  return v.integer;
46  }
47 
48 
52  inline void UNPACK_UINT32(uint32_t val, uint8_t& c0, uint8_t& c1, uint8_t& c2, uint8_t& c3)
53  {
55  v.integer = val;
56  c0 = v.bytes.byte0;
57  c1 = v.bytes.byte1;
58  c2 = v.bytes.byte2;
59  c3 = v.bytes.byte3;
60  }
61 }
62 #endif
63 
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
uint32_t PACK_UINT32(uint8_t b0, uint8_t b1, uint8_t b2, uint8_t b3)
Pack 4 8 bit unsigned integers into one 32bit unsigned integer.
Definition: pack.h:35
void UNPACK_UINT32(uint32_t val, uint8_t &c0, uint8_t &c1, uint8_t &c2, uint8_t &c3)
Unpack 4 8 bit unsigned integers from one unsigned 32bit integer.
Definition: pack.h:52
uint32_t_struct bytes
Definition: pack.h:27
uint32_t integer
Definition: pack.h:28