I use 2 arrayusing 2 arrays instead of a list would also be faster to store screenbased coordinates..
Type MyTypePolygon (Polygon_ID as int, ListPoint as List)
Type MyVertices (X as Float,Y as Float, Z as Float)
Dim ListPolygon as List
.....
ListPolygon.initialize
Dim NewPolygon as MyTypePolygon
NewPolygon.Initialize
NewPolygon.ID=100
NewPolygon.ListPoint.Initialize
Dim Point as MyVertices
Point.Initialize
Point.X=0
Point.Y=1
Point.Z=2
NewPolygon.ListPoint.Ad(Point)
ListPolygon.Add(NewPolygon)
ListPolygon
Type MyTypePolygon (Polygon_ID as int, ListIndex_Of_Point as List)
Type MyVertices (X as Float,Y as Float, Z as Float)
Dim ListPolygon as List
Dim ListVertices as List
.....
ListPolygon.Initialize
ListVertices.Initialize
Dim Point as MyVertices
Point.Initialize
Point.X=0
Point.Y=1
Point.Z=2
Dim Position_InTo_ListVertice as int = AddVertice_If_not_Exist(ListVertices,Point)
Dim NewPolygon as MyTypePolygon
NewPolygon.Initialize
NewPolygon.ID=100
NewPolygon.ListIndex_Of_Point.Initialize
NewPolygon.ListIndex_Of_Point.Add(Position_InTo_ListVertice)
.....
Actually you could do something likeDim Position_InTo_ListVertice as int = AddVertice_If_not_Exist(ListVertices,Point)
Dim newPoint as MyVertices = AddVertice_If_not_Exist(ArrayVertices, Point)
Dim newPoint as MyVertices = AddVertice_If_not_Exist(ArrayVertices, X, Y, Z)
In fact, this is how I do in my library, this was just an example to explain the concept of shared points.Another thought: Don't pass Point (a MyVertices object) to the AddVertice_If_not_Exist method, but the coordinates. This way you do not allocate a MyVertices object in case it does not need allocation. The method can decide if it needs to create a a MyVertices object or return an existing MyVertices object.
B4X:Dim newPoint as MyVertices = AddVertice_If_not_Exist(ArrayVertices, X, Y, Z)
Excellent reflection, I still reason with the old basic that did not have the pointersAnother thought: Don't pass Point (a MyVertices object) to the AddVertice_If_not_Exist method, but the coordinates. This way you do not allocate a MyVertices object in case it does not need allocation. The method can decide if it needs to create a a MyVertices object or return an existing MyVertices object.
B4X:Dim newPoint as MyVertices = AddVertice_If_not_Exist(ArrayVertices, X, Y, Z)
Although theoretically you save computation time and it should be fast, managing multiple lists, indexing and searching if points already exist lower performance.
with the XUI interface, without using native APIs, I think we can not go beyond, at least with my limited knowledge.
since the rotation are done with Sin and cos
Apologies for the interruption. Have you looked into using less accurate math?Now pause
It is very interesting, I did not know of the existence of less accurate mathematics.Apologies for the interruption. Have you looked into using less accurate math?
http://www.java-gaming.org/topics/fast-math-sin-cos-lookup-tables/24191/view.html
https://github.com/mini2Dx/gdx-math
The gdx-math lib is Java based and therefore not cross platform (iOS), but it may have some good ideas/hints.
I did not pick the best wording. I just happened to remember that sin/cos and other computer intensive mathematics can usually be done in other ways that may prove faster, by trading accuracy for speed. With today's hardware, that may be a moot point.I did not know of the existence of less accurate mathematics
From what little I have understood to not calulate SIN and COS every time required, it keeps a vector containing all the values of SIN and COS from 0 to 360 degrees.I did not pick the best wording. I just happened to remember that sin/cos and other computer intensive mathematics can usually be done in other ways that may prove faster, by trading accuracy for speed. With today's hardware, that may be a moot point.
B4XCanvas is not slower than the "native" Canvas objects. The performance of both is exactly the same.with the XUI interface, without using native APIs, I think we can not go beyond,
YES I understood this, I meant native APIs for 3D. the API we use for the revolutions of the views (RotateX, RotateY).B4XCanvas is not slower than the "native" Canvas objects. The performance of both is exactly the same.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?