OpenSubdiv
Loading...
Searching...
No Matches
bufferDescriptor.h
Go to the documentation of this file.
1//
2// Copyright 2015 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://opensubdiv.org/license.
6//
7
8#ifndef OPENSUBDIV3_OSD_BUFFER_DESCRIPTOR_H
9#define OPENSUBDIV3_OSD_BUFFER_DESCRIPTOR_H
10
11#include "../version.h"
12#include <string.h>
13
14namespace OpenSubdiv {
15namespace OPENSUBDIV_VERSION {
16
17namespace Osd {
18
29
30// example:
31// n
32// -----+----------------------------------------+-------------------------
33// | vertex 0 |
34// -----+----------------------------------------+-------------------------
35// | X Y Z R G B A Xu Yu Zu Xv Yv Zv |
36// -----+----------------------------------------+-------------------------
37// <------------- stride = 13 -------------->
38//
39// - XYZ (offset = n+0, length = 3, stride = 13)
40// - RGBA (offset = n+3, length = 4, stride = 13)
41// - uTangent (offset = n+7, length = 3, stride = 13)
42// - vTangent (offset = n+10, length = 3, stride = 13)
43//
45
48
50 BufferDescriptor(int o, int l, int s) : offset(o), length(l), stride(s) { }
51
53 int GetLocalOffset() const {
54 return stride > 0 ? offset % stride : 0;
55 }
56
58 bool IsValid() const {
59 return ((length > 0) &&
61 }
62
64 void Reset() {
65 offset = length = stride = 0;
66 }
67
69 bool operator == (BufferDescriptor const &other) const {
70 return (offset == other.offset &&
71 length == other.length &&
72 stride == other.stride);
73 }
74
76 bool operator != (BufferDescriptor const &other) const {
77 return !(this->operator==(other));
78 }
79
81 int offset;
83 int length;
85 int stride;
86};
87
88} // end namespace Osd
89
90} // end namespace OPENSUBDIV_VERSION
91using namespace OPENSUBDIV_VERSION;
92
93} // end namespace OpenSubdiv
94
95#endif // OPENSUBDIV3_OSD_BUFFER_DESCRIPTOR_H
BufferDescriptor is a struct which describes buffer elements in interleaved data buffers....
void Reset()
Resets the descriptor to default.
bool operator!=(BufferDescriptor const &other) const
True if the descriptors are not identical.
bool operator==(BufferDescriptor const &other) const
True if the descriptors are identical.
bool IsValid() const
True if the descriptor values are internally consistent.
int GetLocalOffset() const
Returns the relative offset within a stride.