Просмотр исходного кода

Made IRect cut safer for culling.

David Piuva 5 лет назад
Родитель
Сommit
f0337bf788
2 измененных файлов с 10 добавлено и 11 удалено
  1. 10 6
      Source/DFPSR/math/IRect.h
  2. 0 5
      Source/SDK/sandbox/sprite/importer.cpp

+ 10 - 6
Source/DFPSR/math/IRect.h

@@ -52,13 +52,17 @@ public:
 	IVector2D lowerRight() const { return IVector2D(this->l + this->w, this->t + this->h); }
 	bool hasArea() const { return this->w > 0 && this->h > 0; }
 	IRect expanded(int units) const { return IRect(this->l - units, this->t - units, this->w + units * 2, this->h + units * 2); }
-	// Returns the intersection between a and b or a rectangle that has no area if overlaps(a, b) is false
+	// Returns the intersection between a and b or a rectangle that has no width nor height if overlaps(a, b) is false
 	static IRect cut(const IRect &a, const IRect &b) {
-		int32_t leftSide = std::max(a.left(), b.left());
-		int32_t topSide = std::max(a.top(), b.top());
-		int32_t rightSide = std::min(a.right(), b.right());
-		int32_t bottomSide = std::min(a.bottom(), b.bottom());
-		return IRect(leftSide, topSide, rightSide - leftSide, bottomSide - topSide);
+		if (overlaps(a, b)) {
+			int32_t leftSide = std::max(a.left(), b.left());
+			int32_t topSide = std::max(a.top(), b.top());
+			int32_t rightSide = std::min(a.right(), b.right());
+			int32_t bottomSide = std::min(a.bottom(), b.bottom());
+			return IRect(leftSide, topSide, rightSide - leftSide, bottomSide - topSide);
+		} else {
+			return IRect();
+		}
 	}
 	// Returns a bounding box of the union
 	static IRect merge(const IRect &a, const IRect &b) {

+ 0 - 5
Source/SDK/sandbox/sprite/importer.cpp

@@ -309,11 +309,6 @@ static FVector3D getAverageNormal(const Model& model, int part, int poly) {
 	return normalize(normalSum);
 }
 
-// TODO: Create a compact model format for dense vertex models where positions are stored as 16.16 fixed precision aligned with vertex data to avoid random access
-// TODO: Create a triangle rasterizer optimized for many small triangles by just adding edge offsets, normals and colors.
-// TODO: Allow creating freely rotated and scaled 3D models as a part of the passively drawn background.
-// TODO: Allow creating freely rotated and scaled 3D models as dynamic items of a slightly lower detail level.
-
 void importer_generateNormalsIntoTextureCoordinates(Model model) {
 	int pointCount = model_getNumberOfPoints(model);
 	Array<FVector3D> normalPoints(pointCount, FVector3D());