1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2013 by the OpenSG Forum *
7 * contact: dirk@opensg.org, gerrit.voss@vossg.org, carsten_neumann@gmx.net *
9 \*---------------------------------------------------------------------------*/
10 /*---------------------------------------------------------------------------*\
13 * This library is free software; you can redistribute it and/or modify it *
14 * under the terms of the GNU Library General Public License as published *
15 * by the Free Software Foundation, version 2. *
17 * This library is distributed in the hope that it will be useful, but *
18 * WITHOUT ANY WARRANTY; without even the implied warranty of *
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
20 * Library General Public License for more details. *
22 * You should have received a copy of the GNU Library General Public *
23 * License along with this library; if not, write to the Free Software *
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
26 \*---------------------------------------------------------------------------*/
27 /*---------------------------------------------------------------------------*\
35 \*---------------------------------------------------------------------------*/
37 //---------------------------------------------------------------------------
39 //---------------------------------------------------------------------------
44 bool MultiPropertySSBOChunk::check_invariant() const
46 UInt32 num = getNumProperties();
48 if (_mfCardinalities.empty() && num == 0)
50 if (_mfCardinalities.empty() && num != 0)
53 if (_mfTypes.size() != _mfCardinality.size())
58 card = _mfCardinalities[FLOAT_T]; if (num * card != _mfFloatValues .size()) return false;
59 card = _mfCardinalities[DOUBLE_T]; if (num * card != _mfDoubleValues.size()) return false;
60 card = _mfCardinalities[INT_T]; if (num * card != _mfIntValues .size()) return false;
61 card = _mfCardinalities[UINT_T]; if (num * card != _mfUIntValues .size()) return false;
62 card = _mfCardinalities[BOOL_T]; if (num * card != _mfBoolValues .size()) return false;
63 card = _mfCardinalities[VEC3_T]; if (num * card != _mfVec3Values .size()) return false;
64 card = _mfCardinalities[VEC4_T]; if (num * card != _mfVec4Values .size()) return false;
65 card = _mfCardinalities[MAT4_T]; if (num * card != _mfMatrixValues.size()) return false;
71 UInt32 MultiPropertySSBOChunk::getNumProperties() const
73 return Inherited::getNumProperties();
77 Real32 MultiPropertySSBOChunk::getFloatProperty(UInt32 idx, UInt32 num) const
79 OSG_ASSERT(!_mfCardinalities.empty());
80 OSG_ASSERT(idx < getNumProperties());
81 OSG_ASSERT(num <= _mfCardinalities[FLOAT_T]);
82 UInt32 i = idx * _mfCardinalities[FLOAT_T] + num - 1;
83 OSG_ASSERT(i < _mfFloatValues.size());
84 return Inherited::getFloatValues(i);
88 Real64 MultiPropertySSBOChunk::getDoubleProperty(UInt32 idx, UInt32 num) const
90 OSG_ASSERT(!_mfCardinalities.empty());
91 OSG_ASSERT(idx < getNumProperties());
92 OSG_ASSERT(num <= _mfCardinalities[DOUBLE_T]);
93 UInt32 i = idx * _mfCardinalities[DOUBLE_T] + num - 1;
94 OSG_ASSERT(i < _mfDoubleValues.size());
95 return Inherited::getDoubleValues(i);
99 Int32 MultiPropertySSBOChunk::getIntProperty(UInt32 idx, UInt32 num) const
101 OSG_ASSERT(!_mfCardinalities.empty());
102 OSG_ASSERT(idx < getNumProperties());
103 OSG_ASSERT(num <= _mfCardinalities[INT_T]);
104 UInt32 i = idx * _mfCardinalities[INT_T] + num - 1;
105 OSG_ASSERT(i < _mfIntValues.size());
106 return Inherited::getIntValues(i);
110 UInt32 MultiPropertySSBOChunk::getUIntProperty(UInt32 idx, UInt32 num) const
112 OSG_ASSERT(!_mfCardinalities.empty());
113 OSG_ASSERT(idx < getNumProperties());
114 OSG_ASSERT(num <= _mfCardinalities[UINT_T]);
115 UInt32 i = idx * _mfCardinalities[UINT_T] + num - 1;
116 OSG_ASSERT(i < _mfUIntValues.size());
117 return Inherited::getUIntValues(i);
121 bool MultiPropertySSBOChunk::getBoolProperty(UInt32 idx, UInt32 num) const
123 OSG_ASSERT(!_mfCardinalities.empty());
124 OSG_ASSERT(idx < getNumProperties());
125 OSG_ASSERT(num <= _mfCardinalities[BOOL_T]);
126 UInt32 i = idx * _mfCardinalities[BOOL_T] + num - 1;
127 OSG_ASSERT(i < _mfBoolValues.size());
128 return Inherited::getBoolValues(i);
132 const Vec3f& MultiPropertySSBOChunk::getVec3Property(UInt32 idx, UInt32 num) const
134 OSG_ASSERT(!_mfCardinalities.empty());
135 OSG_ASSERT(idx < getNumProperties());
136 OSG_ASSERT(num <= _mfCardinalities[VEC3_T]);
137 UInt32 i = idx * _mfCardinalities[VEC3_T] + num - 1;
138 OSG_ASSERT(i < _mfVec3Values.size());
139 return Inherited::getVec3Values(i);
143 const Vec4f& MultiPropertySSBOChunk::getVec4Property(UInt32 idx, UInt32 num) const
145 OSG_ASSERT(!_mfCardinalities.empty());
146 OSG_ASSERT(idx < getNumProperties());
147 OSG_ASSERT(num <= _mfCardinalities[VEC4_T]);
148 UInt32 i = idx * _mfCardinalities[VEC4_T] + num - 1;
149 OSG_ASSERT(i < _mfVec4Values.size());
150 return Inherited::getVec4Values(i);
154 const Matrix& MultiPropertySSBOChunk::getMat4Property(UInt32 idx, UInt32 num) const
156 OSG_ASSERT(!_mfCardinalities.empty());
157 OSG_ASSERT(idx < getNumProperties());
158 OSG_ASSERT(num <= _mfCardinalities[MAT4_T]);
159 UInt32 i = idx * _mfCardinalities[MAT4_T] + num - 1;
160 OSG_ASSERT(i < _mfMatrixValues.size());
161 return Inherited::getMatrixValues(i);
165 void MultiPropertySSBOChunk::setFloatProperty(UInt32 idx, UInt32 num, Real32 value)
167 OSG_ASSERT(!_mfCardinalities.empty());
168 OSG_ASSERT(idx < getNumProperties());
169 OSG_ASSERT(num <= _mfCardinalities[FLOAT_T]);
170 UInt32 i = idx * _mfCardinalities[FLOAT_T] + num - 1;
171 OSG_ASSERT(i < _mfFloatValues.size());
172 editFloatValues(i) = value;
176 void MultiPropertySSBOChunk::setDoubleProperty(UInt32 idx, UInt32 num, Real64 value)
178 OSG_ASSERT(!_mfCardinalities.empty());
179 OSG_ASSERT(idx < getNumProperties());
180 OSG_ASSERT(num <= _mfCardinalities[DOUBLE_T]);
181 UInt32 i = idx * _mfCardinalities[DOUBLE_T] + num - 1;
182 OSG_ASSERT(i < _mfDoubleValues.size());
183 editDoubleValues(i) = value;
187 void MultiPropertySSBOChunk::setIntProperty(UInt32 idx, UInt32 num, Int32 value)
189 OSG_ASSERT(!_mfCardinalities.empty());
190 OSG_ASSERT(idx < getNumProperties());
191 OSG_ASSERT(num <= _mfCardinalities[INT_T]);
192 UInt32 i = idx * _mfCardinalities[INT_T] + num - 1;
193 OSG_ASSERT(i < _mfIntValues.size());
194 editIntValues(i) = value;
198 void MultiPropertySSBOChunk::setUIntProperty(UInt32 idx, UInt32 num, UInt32 value)
200 OSG_ASSERT(!_mfCardinalities.empty());
201 OSG_ASSERT(idx < getNumProperties());
202 OSG_ASSERT(num <= _mfCardinalities[UINT_T]);
203 UInt32 i = idx * _mfCardinalities[UINT_T] + num - 1;
204 OSG_ASSERT(i < _mfUIntValues.size());
205 editUIntValues(i) = value;
209 void MultiPropertySSBOChunk::setBoolProperty(UInt32 idx, UInt32 num, bool value)
211 OSG_ASSERT(!_mfCardinalities.empty());
212 OSG_ASSERT(idx < getNumProperties());
213 OSG_ASSERT(num <= _mfCardinalities[BOOL_T]);
214 UInt32 i = idx * _mfCardinalities[BOOL_T] + num - 1;
215 OSG_ASSERT(i < _mfBoolValues.size());
216 editBoolValues(i) = value;
220 void MultiPropertySSBOChunk::setVec3Property(UInt32 idx, UInt32 num, const Vec3f& value)
222 OSG_ASSERT(!_mfCardinalities.empty());
223 OSG_ASSERT(idx < getNumProperties());
224 OSG_ASSERT(num <= _mfCardinalities[VEC3_T]);
225 UInt32 i = idx * _mfCardinalities[VEC3_T] + num - 1;
226 OSG_ASSERT(i < _mfVec3Values.size());
227 editVec3Values(i) = value;
231 void MultiPropertySSBOChunk::setVec4Property(UInt32 idx, UInt32 num, const Vec4f& value)
233 OSG_ASSERT(!_mfCardinalities.empty());
234 OSG_ASSERT(idx < getNumProperties());
235 OSG_ASSERT(num <= _mfCardinalities[VEC4_T]);
236 UInt32 i = idx * _mfCardinalities[VEC4_T] + num - 1;
237 OSG_ASSERT(i < _mfVec4Values.size());
238 editVec4Values(i) = value;
242 void MultiPropertySSBOChunk::setMat4Property(UInt32 idx, UInt32 num, const Matrix& value)
244 OSG_ASSERT(!_mfCardinalities.empty());
245 OSG_ASSERT(idx < getNumProperties());
246 OSG_ASSERT(num <= _mfCardinalities[MAT4_T]);
247 UInt32 i = idx * _mfCardinalities[MAT4_T] + num - 1;
248 OSG_ASSERT(i < _mfMatrixValues.size());
249 editMatrixValues(i) = value;