Loading...
Searching...
No Matches
bufferDescriptor.h
Go to the documentation of this file.
//
// Copyright 2015 Pixar
//
// Licensed under the Apache License, Version 2.0 (the "Apache License")
// with the following modification; you may not use this file except in
// compliance with the Apache License and the following modification to it:
// Section 6. Trademarks. is deleted and replaced with:
//
// 6. Trademarks. This License does not grant permission to use the trade
// names, trademarks, service marks, or product names of the Licensor
// and its affiliates, except as required to comply with Section 4(c) of
// the License and to reproduce the content of the NOTICE file.
//
// You may obtain a copy of the Apache License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the Apache License with the above modification is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the Apache License for the specific
// language governing permissions and limitations under the Apache License.
//
#ifndef OPENSUBDIV3_OSD_BUFFER_DESCRIPTOR_H
#define OPENSUBDIV3_OSD_BUFFER_DESCRIPTOR_H
#include "../version.h"
#include <string.h>
namespace OpenSubdiv {
namespace OPENSUBDIV_VERSION {
namespace Osd {
// example:
// n
// -----+----------------------------------------+-------------------------
// | vertex 0 |
// -----+----------------------------------------+-------------------------
// | X Y Z R G B A Xu Yu Zu Xv Yv Zv |
// -----+----------------------------------------+-------------------------
// <------------- stride = 13 -------------->
//
// - XYZ (offset = n+0, length = 3, stride = 13)
// - RGBA (offset = n+3, length = 4, stride = 13)
// - uTangent (offset = n+7, length = 3, stride = 13)
// - vTangent (offset = n+10, length = 3, stride = 13)
//
struct BufferDescriptor {
BufferDescriptor() : offset(0), length(0), stride(0) { }
BufferDescriptor(int o, int l, int s) : offset(o), length(l), stride(s) { }
int GetLocalOffset() const {
return stride > 0 ? offset % stride : 0;
}
bool IsValid() const {
return ((length > 0) &&
(length <= stride - GetLocalOffset()));
}
void Reset() {
offset = length = stride = 0;
}
bool operator == (BufferDescriptor const &other) const {
return (offset == other.offset &&
length == other.length &&
stride == other.stride);
}
bool operator != (BufferDescriptor const &other) const {
return !(this->operator==(other));
}
int offset;
int length;
int stride;
};
} // end namespace Osd
} // end namespace OPENSUBDIV_VERSION
using namespace OPENSUBDIV_VERSION;
} // end namespace OpenSubdiv
#endif // OPENSUBDIV3_OSD_BUFFER_DESCRIPTOR_H
OpenSubdiv
Definition error.h:30
OpenSubdiv::OPENSUBDIV_VERSION::Osd::BufferDescriptor
BufferDescriptor is a struct which describes buffer elements in interleaved data buffers....
Definition bufferDescriptor.h:61
OpenSubdiv::OPENSUBDIV_VERSION::Osd::BufferDescriptor::stride
int stride
stride to the next element
Definition bufferDescriptor.h:102
OpenSubdiv::OPENSUBDIV_VERSION::Osd::BufferDescriptor::Reset
void Reset()
Resets the descriptor to default.
Definition bufferDescriptor.h:81
OpenSubdiv::OPENSUBDIV_VERSION::Osd::BufferDescriptor::BufferDescriptor
BufferDescriptor()
Default Constructor.
Definition bufferDescriptor.h:64
OpenSubdiv::OPENSUBDIV_VERSION::Osd::BufferDescriptor::BufferDescriptor
BufferDescriptor(int o, int l, int s)
Constructor.
Definition bufferDescriptor.h:67
OpenSubdiv::OPENSUBDIV_VERSION::Osd::BufferDescriptor::length
int length
number or length of the data
Definition bufferDescriptor.h:100
OpenSubdiv::OPENSUBDIV_VERSION::Osd::BufferDescriptor::operator!=
bool operator!=(BufferDescriptor const &other) const
True if the descriptors are not identical.
Definition bufferDescriptor.h:93
OpenSubdiv::OPENSUBDIV_VERSION::Osd::BufferDescriptor::operator==
bool operator==(BufferDescriptor const &other) const
True if the descriptors are identical.
Definition bufferDescriptor.h:86
OpenSubdiv::OPENSUBDIV_VERSION::Osd::BufferDescriptor::IsValid
bool IsValid() const
True if the descriptor values are internally consistent.
Definition bufferDescriptor.h:75
OpenSubdiv::OPENSUBDIV_VERSION::Osd::BufferDescriptor::GetLocalOffset
int GetLocalOffset() const
Returns the relative offset within a stride.
Definition bufferDescriptor.h:70
OpenSubdiv::OPENSUBDIV_VERSION::Osd::BufferDescriptor::offset
int offset
offset to desired element data
Definition bufferDescriptor.h:98