Skip to content

Commit

Permalink
use vector when constructing geometries
Browse files Browse the repository at this point in the history
  • Loading branch information
markaren committed Oct 4, 2024
1 parent ff58feb commit e3f61e4
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 41 deletions.
10 changes: 5 additions & 5 deletions src/threepp/geometries/BoxGeometry.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

#include "threepp/geometries/BoxGeometry.hpp"

#include <list>
#include <vector>

using namespace threepp;

Expand All @@ -12,10 +12,10 @@ namespace {
unsigned int numberOfVertices = 0;
int groupStart = 0;

std::list<unsigned int> indices;
std::list<float> vertices;
std::list<float> normals;
std::list<float> uvs;
std::vector<unsigned int> indices;
std::vector<float> vertices;
std::vector<float> normals;
std::vector<float> uvs;

explicit Helper(BoxGeometry& g, unsigned int widthSegments, unsigned int heightSegments, unsigned int depthSegments) {

Expand Down
8 changes: 4 additions & 4 deletions src/threepp/geometries/CircleGeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "threepp/geometries/CircleGeometry.hpp"

#include <cmath>
#include <list>
#include <vector>

using namespace threepp;

Expand All @@ -11,10 +11,10 @@ CircleGeometry::CircleGeometry(const Params& params) {

// buffers

std::list<unsigned int> indices;
std::vector<unsigned int> indices;
std::vector<float> vertices;
std::list<float> normals;
std::list<float> uvs;
std::vector<float> normals;
std::vector<float> uvs;

// helper variables

Expand Down
10 changes: 5 additions & 5 deletions src/threepp/geometries/CylinderGeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "threepp/geometries/CylinderGeometry.hpp"

#include <cmath>
#include <list>
#include <vector>

using namespace threepp;

Expand All @@ -12,10 +12,10 @@ CylinderGeometry::CylinderGeometry(const Params& params)
radiusBottom(params.radiusBottom),
height(params.height) {

std::list<unsigned int> indices;
std::list<float> vertices;
std::list<float> normals;
std::list<float> uvs;
std::vector<unsigned int> indices;
std::vector<float> vertices;
std::vector<float> normals;
std::vector<float> uvs;

unsigned int index = 0;
const auto halfHeight = height / 2;
Expand Down
10 changes: 5 additions & 5 deletions src/threepp/geometries/RingGeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "threepp/geometries/RingGeometry.hpp"

#include <cmath>
#include <list>
#include <vector>

using namespace threepp;

Expand All @@ -12,10 +12,10 @@ RingGeometry::RingGeometry(const Params& params) {
unsigned int thetaSegments = std::max(3u, params.thetaSegments);
unsigned int phiSegments = std::max(1u, params.phiSegments);

std::list<unsigned int> indices;
std::list<float> vertices;
std::list<float> normals;
std::list<float> uvs;
std::vector<unsigned int> indices;
std::vector<float> vertices;
std::vector<float> normals;
std::vector<float> uvs;

// some helper variables

Expand Down
9 changes: 4 additions & 5 deletions src/threepp/geometries/SphereGeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@

#include <algorithm>
#include <cmath>
#include <list>
#include <vector>

using namespace threepp;

SphereGeometry::SphereGeometry(const Params& params)
: radius(params.radius) {

std::list<unsigned int> indices;
std::list<float> vertices;
std::list<float> normals;
std::list<float> uvs;
std::vector<unsigned int> indices;
std::vector<float> vertices;
std::vector<float> normals;
std::vector<float> uvs;

unsigned int widthSegments = std::max(3u, params.widthSegments);
unsigned int heightSegments = std::max(2u, params.heightSegments);
Expand Down
10 changes: 5 additions & 5 deletions src/threepp/geometries/TorusGeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "threepp/geometries/TorusGeometry.hpp"

#include <cmath>
#include <list>
#include <vector>

using namespace threepp;

Expand All @@ -11,10 +11,10 @@ TorusGeometry::TorusGeometry(float radius, float tube, unsigned int radialSegmen

// buffers

std::list<unsigned int> indices;
std::list<float> vertices;
std::list<float> normals;
std::list<float> uvs;
std::vector<unsigned int> indices;
std::vector<float> vertices;
std::vector<float> normals;
std::vector<float> uvs;

// helper variables

Expand Down
10 changes: 5 additions & 5 deletions src/threepp/geometries/TorusKnotGeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "threepp/math/MathUtils.hpp"

#include <cmath>
#include <list>
#include <vector>

using namespace threepp;

Expand All @@ -28,10 +28,10 @@ TorusKnotGeometry::TorusKnotGeometry(float radius, float tube, unsigned int tubu

// buffers

std::list<unsigned int> indices;
std::list<float> vertices;
std::list<float> normals;
std::list<float> uvs;
std::vector<unsigned int> indices;
std::vector<float> vertices;
std::vector<float> normals;
std::vector<float> uvs;

// helper variables

Expand Down
10 changes: 5 additions & 5 deletions src/threepp/geometries/TubeGeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <cmath>
#include <functional>
#include <list>
#include <vector>

using namespace threepp;

Expand All @@ -21,10 +21,10 @@ TubeGeometry::TubeGeometry(std::shared_ptr<Curve3> path, const Params& params)

// buffer

std::list<float> vertices;
std::list<float> normals;
std::list<float> uvs;
std::list<unsigned int> indices;
std::vector<float> vertices;
std::vector<float> normals;
std::vector<float> uvs;
std::vector<unsigned int> indices;

// functions

Expand Down
6 changes: 4 additions & 2 deletions src/threepp/geometries/WireframeGeometry.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@

#include "threepp/geometries/WireframeGeometry.hpp"

#include <list>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace threepp;

WireframeGeometry::WireframeGeometry(const BufferGeometry& geometry) {

// buffer

std::list<float> vertices;
std::vector<float> vertices;

// helper variables

Expand Down

0 comments on commit e3f61e4

Please sign in to comment.