mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
PfmFile::flip()
This commit is contained in:
parent
438c297968
commit
98d7643a23
@ -519,6 +519,55 @@ reverse_rows() {
|
|||||||
_table.swap(reversed);
|
_table.swap(reversed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PfmFile::flip
|
||||||
|
// Access: Published
|
||||||
|
// Description: Reverses, transposes, and/or rotates the table
|
||||||
|
// in-place according to the specified parameters. If
|
||||||
|
// flip_x is true, the x axis is reversed; if flip_y is
|
||||||
|
// true, the y axis is reversed. Then, if transpose is
|
||||||
|
// true, the x and y axes are exchanged. These
|
||||||
|
// parameters can be used to select any combination of
|
||||||
|
// 90-degree or 180-degree rotations and flips.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void PfmFile::
|
||||||
|
flip(bool flip_x, bool flip_y, bool transpose) {
|
||||||
|
nassertv(is_valid());
|
||||||
|
|
||||||
|
Table flipped;
|
||||||
|
flipped.reserve(_table.size());
|
||||||
|
|
||||||
|
if (transpose) {
|
||||||
|
// Transposed case. X becomes Y, Y becomes X.
|
||||||
|
for (int xi = 0; xi < _x_size; ++xi) {
|
||||||
|
int source_xi = flip_x ? xi : _x_size - 1 - xi;
|
||||||
|
for (int yi = 0; yi < _y_size; ++yi) {
|
||||||
|
int source_yi = flip_y ? yi : _y_size - 1 - yi;
|
||||||
|
const LPoint3 &p = _table[source_yi * _x_size + source_xi];
|
||||||
|
flipped.push_back(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int t = _x_size;
|
||||||
|
_x_size = _y_size;
|
||||||
|
_y_size = t;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Non-transposed. X is X, Y is Y.
|
||||||
|
for (int yi = 0; yi < _y_size; ++yi) {
|
||||||
|
int source_yi = flip_y ? yi : _y_size - 1 - yi;
|
||||||
|
for (int xi = 0; xi < _x_size; ++xi) {
|
||||||
|
int source_xi = flip_x ? xi : _x_size - 1 - xi;
|
||||||
|
const LPoint3 &p = _table[source_yi * _x_size + source_xi];
|
||||||
|
flipped.push_back(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nassertv(flipped.size() == _table.size());
|
||||||
|
_table.swap(flipped);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: PfmFile::xform
|
// Function: PfmFile::xform
|
||||||
// Access: Published
|
// Access: Published
|
||||||
|
@ -66,6 +66,7 @@ PUBLISHED:
|
|||||||
|
|
||||||
BLOCKING void resize(int new_x_size, int new_y_size);
|
BLOCKING void resize(int new_x_size, int new_y_size);
|
||||||
BLOCKING void reverse_rows();
|
BLOCKING void reverse_rows();
|
||||||
|
BLOCKING void flip(bool flip_x, bool flip_y, bool transpose);
|
||||||
BLOCKING void xform(const LMatrix4 &transform);
|
BLOCKING void xform(const LMatrix4 &transform);
|
||||||
BLOCKING void project(const Lens *lens);
|
BLOCKING void project(const Lens *lens);
|
||||||
BLOCKING void merge(const PfmFile &other);
|
BLOCKING void merge(const PfmFile &other);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user