Skip to content

Commit

Permalink
Circle collision improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
erayzesen committed Sep 10, 2024
1 parent 8839030 commit 42ddd67
Show file tree
Hide file tree
Showing 320 changed files with 12,939 additions and 3,781 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "doxygen-awesome-css"]
path = doxygen-awesome-css
url = https://github.com/jothepro/doxygen-awesome-css.git
5 changes: 3 additions & 2 deletions Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -1283,7 +1283,8 @@ HTML_STYLESHEET =
# list). For an example see the documentation.
# This tag requires that the tag GENERATE_HTML is set to YES.

HTML_EXTRA_STYLESHEET =
HTML_EXTRA_STYLESHEET =doxygen-awesome-css/doxygen-awesome.css \
doxygen-awesome-css/doxygen-awesome-sidebar-only.css

# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
# other source files which should be copied to the HTML output directory. Note
Expand Down Expand Up @@ -1582,7 +1583,7 @@ DISABLE_INDEX = NO
# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.

GENERATE_TREEVIEW = NO
GENERATE_TREEVIEW = YES

# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that
# doxygen will group on one line in the generated HTML documentation.
Expand Down
3 changes: 1 addition & 2 deletions QuarkPhysics/extensions/qspatialhashing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ void QSpatialHashing::Update() {
void QSpatialHashing::GetAllPairs(std::unordered_set<std::pair<QBody*, QBody*>,QBody::BodyPairHash,QBody::BodyPairEqual> &pairs) {


int aabbTestCount=0;
for (auto& cell : cells) {
std::vector<QBody*>& cellBodies = cell.second;
size_t numBodies = cellBodies.size();
Expand All @@ -129,7 +128,7 @@ void QSpatialHashing::GetAllPairs(std::unordered_set<std::pair<QBody*, QBody*>,Q
if (!BodiesCanCollide(bodyA, bodyB))
continue;

aabbTestCount+=1;

if(bodyA->GetAABB().GetMax().x >= bodyB->GetAABB().GetMin().x){
if( bodyA->GetAABB().GetMin().y <= bodyB->GetAABB().GetMax().y &&
bodyA->GetAABB().GetMax().y >= bodyB->GetAABB().GetMin().y) {
Expand Down
11 changes: 9 additions & 2 deletions QuarkPhysics/qbody.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,16 @@ bool QBody::CanCollide(QBody *bodyA, QBody *bodyB,bool checkBodiesAreEnabled)
if (bodyA->GetEnabled()==false || bodyB->GetEnabled()==false)
return false;

QWorld *world=bodyA->world;

//Check Static and Sleeping Modes
if((bodyA->isSleeping || bodyA->mode==QBody::Modes::STATIC) && (bodyB->isSleeping || bodyB->mode==QBody::Modes::STATIC ))
return false;
//Check Layers Bits
if( ( ((bodyA->layersBit & bodyB->collidableLayersBit)==0 ) && (bodyB->layersBit & bodyA->collidableLayersBit)==0 ) )
return false;

QWorld *world=bodyA->world;

if( world->CheckCollisionException(bodyA,bodyB)==true ){
return false;
}
Expand Down Expand Up @@ -191,8 +193,13 @@ void QBody::UpdateMeshTransforms(){
float nx=originVec.x*rotVecUnit.x-originVec.y*rotVecUnit.y;
float ny=originVec.y*rotVecUnit.x+originVec.x*rotVecUnit.y;
QVector newPos=mesh->globalPosition+QVector(nx,ny);
if (bodyType==QBody::BodyTypes::RIGID){
particle->SetPreviousGlobalPosition(particle->GetGlobalPosition());
}else{
particle->SetPreviousGlobalPosition(newPos);
}
particle->SetGlobalPosition(newPos);
particle->SetPreviousGlobalPosition(newPos);

}
}

Expand Down
11 changes: 8 additions & 3 deletions QuarkPhysics/qcollision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,11 @@ void QCollision::CircleAndCircle(vector<QParticle*> &particlesA,vector<QParticle
bboxSizeA=QVector(specifiedRadius,specifiedRadius);
}

size_t particlesASize=particlesA.size();
size_t particlesBSize=particlesB.size();

//A. Start the loop for all points of circleparticlesA
for(size_t i=0;i<particlesA.size();i++){
for(size_t i=0;i<particlesASize;i++){
QParticle *pA=particlesA[i];

//Optimization phase: aabb test
Expand All @@ -538,7 +541,7 @@ void QCollision::CircleAndCircle(vector<QParticle*> &particlesA,vector<QParticle


//B. Start the loop for all points of circleparticlesB
for(;n<particlesB.size();n++){
for(;n<particlesBSize;n++){
QParticle *pB=particlesB[n];
if(pA==pB) continue;

Expand All @@ -564,7 +567,9 @@ void QCollision::CircleAndCircle(vector<QParticle*> &particlesA,vector<QParticle
if(positionalPenetrationSq<totalRadiusPow){
//The penetration is the difference between the existing penetration and the total radius of the objA and the objB.
positionalPenetration=sqrt(positionalPenetrationSq);
normal=distVec.Normalized();
//normal=distVec.Normalized();
//The normal with previous positions gives us more realistic collision normals in the simulation.
normal=(pB->GetPreviousGlobalPosition()-pA->GetPreviousGlobalPosition()).Normalized();

penetration=totalRadius-positionalPenetration;

Expand Down
80 changes: 54 additions & 26 deletions documentation/annotated.html

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions documentation/annotated_dup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
var annotated_dup =
[
[ "Building Examples", "index.html#autotoc_md0", null ],
[ "Using", "index.html#autotoc_md1", null ],
[ "Third Party", "index.html#autotoc_md2", null ],
[ "License", "index.html#autotoc_md3", null ],
[ "QAABB", "classQAABB.html", "classQAABB" ],
[ "QAreaBody", "classQAreaBody.html", "classQAreaBody" ],
[ "QBody", "classQBody.html", "classQBody" ],
[ "QBroadPhase", "classQBroadPhase.html", "classQBroadPhase" ],
[ "QCollision", "classQCollision.html", "classQCollision" ],
[ "QGizmo", "classQGizmo.html", "classQGizmo" ],
[ "QGizmoCircle", "classQGizmoCircle.html", "classQGizmoCircle" ],
[ "QGizmoLine", "classQGizmoLine.html", "classQGizmoLine" ],
[ "QGizmoRect", "classQGizmoRect.html", "classQGizmoRect" ],
[ "QJoint", "classQJoint.html", "classQJoint" ],
[ "QManifold", "classQManifold.html", "classQManifold" ],
[ "QManifoldKey", "structQManifoldKey.html", "structQManifoldKey" ],
[ "QMesh", "structQMesh.html", "structQMesh" ],
[ "QObjectPool", "classQObjectPool.html", "classQObjectPool" ],
[ "QParticle", "classQParticle.html", "classQParticle" ],
[ "QRaycast", "classQRaycast.html", "classQRaycast" ],
[ "QRigidBody", "classQRigidBody.html", "classQRigidBody" ],
[ "QSoftBody", "classQSoftBody.html", "classQSoftBody" ],
[ "QSpring", "classQSpring.html", "classQSpring" ],
[ "QVector", "structQVector.html", "structQVector" ],
[ "QWorld", "classQWorld.html", "classQWorld" ]
];
37 changes: 31 additions & 6 deletions documentation/classQAABB-members.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="doxygen-awesome.css" rel="stylesheet" type="text/css"/>
<link href="doxygen-awesome-sidebar-only.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
Expand Down Expand Up @@ -46,6 +52,23 @@
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('classQAABB.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
Expand All @@ -60,7 +83,6 @@
</iframe>
</div>

</div><!-- top -->
<div class="header">
<div class="headertitle">
<div class="title">QAABB Member List</div> </div>
Expand All @@ -70,9 +92,9 @@
<p>This is the complete list of members for <a class="el" href="classQAABB.html">QAABB</a>, including all inherited members.</p>
<table class="directory">
<tr bgcolor="#f0f0f0" class="even"><td class="entry"><b>Combine</b>(QAABB &amp;b1, QAABB &amp;b2) (defined in <a class="el" href="classQAABB.html">QAABB</a>)</td><td class="entry"><a class="el" href="classQAABB.html">QAABB</a></td><td class="entry"><span class="mlabel">inline</span><span class="mlabel">static</span></td></tr>
<tr bgcolor="#f0f0f0"><td class="entry"><b>Fatted</b>(float amount) const (defined in <a class="el" href="classQAABB.html">QAABB</a>)</td><td class="entry"><a class="el" href="classQAABB.html">QAABB</a></td><td class="entry"><span class="mlabel">inline</span></td></tr>
<tr bgcolor="#f0f0f0" class="even"><td class="entry"><b>FattedWithRate</b>(float rate) const (defined in <a class="el" href="classQAABB.html">QAABB</a>)</td><td class="entry"><a class="el" href="classQAABB.html">QAABB</a></td><td class="entry"><span class="mlabel">inline</span></td></tr>
<tr bgcolor="#f0f0f0"><td class="entry"><b>Fatten</b>(float amount) (defined in <a class="el" href="classQAABB.html">QAABB</a>)</td><td class="entry"><a class="el" href="classQAABB.html">QAABB</a></td><td class="entry"><span class="mlabel">inline</span></td></tr>
<tr bgcolor="#f0f0f0" class="even"><td class="entry"><b>Fattened</b>(float amount) const (defined in <a class="el" href="classQAABB.html">QAABB</a>)</td><td class="entry"><a class="el" href="classQAABB.html">QAABB</a></td><td class="entry"><span class="mlabel">inline</span></td></tr>
<tr bgcolor="#f0f0f0"><td class="entry"><b>FattenedWithRate</b>(float rate) const (defined in <a class="el" href="classQAABB.html">QAABB</a>)</td><td class="entry"><a class="el" href="classQAABB.html">QAABB</a></td><td class="entry"><span class="mlabel">inline</span></td></tr>
<tr bgcolor="#f0f0f0" class="even"><td class="entry"><b>GetArea</b>() const (defined in <a class="el" href="classQAABB.html">QAABB</a>)</td><td class="entry"><a class="el" href="classQAABB.html">QAABB</a></td><td class="entry"><span class="mlabel">inline</span></td></tr>
<tr bgcolor="#f0f0f0"><td class="entry"><b>GetCenterPosition</b>() const (defined in <a class="el" href="classQAABB.html">QAABB</a>)</td><td class="entry"><a class="el" href="classQAABB.html">QAABB</a></td><td class="entry"><span class="mlabel">inline</span></td></tr>
<tr bgcolor="#f0f0f0" class="even"><td class="entry"><b>GetMax</b>() (defined in <a class="el" href="classQAABB.html">QAABB</a>)</td><td class="entry"><a class="el" href="classQAABB.html">QAABB</a></td><td class="entry"><span class="mlabel">inline</span></td></tr>
Expand All @@ -86,9 +108,12 @@
<tr bgcolor="#f0f0f0" class="even"><td class="entry"><b>QAABB</b>(QVector minPosition, QVector maxPosition) (defined in <a class="el" href="classQAABB.html">QAABB</a>)</td><td class="entry"><a class="el" href="classQAABB.html">QAABB</a></td><td class="entry"><span class="mlabel">inline</span></td></tr>
<tr bgcolor="#f0f0f0"><td class="entry"><b>SetMinMax</b>(QVector minPosition, QVector maxPosition) (defined in <a class="el" href="classQAABB.html">QAABB</a>)</td><td class="entry"><a class="el" href="classQAABB.html">QAABB</a></td><td class="entry"><span class="mlabel">inline</span></td></tr>
</table></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1
</small></address>
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1 </li>
</ul>
</div>
</body>
</html>
46 changes: 36 additions & 10 deletions documentation/classQAABB.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="doxygen-awesome.css" rel="stylesheet" type="text/css"/>
<link href="doxygen-awesome-sidebar-only.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
Expand Down Expand Up @@ -46,6 +52,23 @@
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('classQAABB.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
Expand All @@ -60,7 +83,6 @@
</iframe>
</div>

</div><!-- top -->
<div class="header">
<div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
Expand Down Expand Up @@ -106,12 +128,12 @@
<tr class="memitem:ae3115260fff1404d4872cf3740b78cb9"><td class="memItemLeft" align="right" valign="top"><a id="ae3115260fff1404d4872cf3740b78cb9"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><b>Fatten</b> (float amount)</td></tr>
<tr class="separator:ae3115260fff1404d4872cf3740b78cb9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6d56965c8152d3aa8361f7d0bc98c576"><td class="memItemLeft" align="right" valign="top"><a id="a6d56965c8152d3aa8361f7d0bc98c576"></a>
<a class="el" href="classQAABB.html">QAABB</a>&#160;</td><td class="memItemRight" valign="bottom"><b>Fatted</b> (float amount) const</td></tr>
<tr class="separator:a6d56965c8152d3aa8361f7d0bc98c576"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a61d6ac93eff391875ba43d4cb875b369"><td class="memItemLeft" align="right" valign="top"><a id="a61d6ac93eff391875ba43d4cb875b369"></a>
<a class="el" href="classQAABB.html">QAABB</a>&#160;</td><td class="memItemRight" valign="bottom"><b>FattedWithRate</b> (float rate) const</td></tr>
<tr class="separator:a61d6ac93eff391875ba43d4cb875b369"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2b7c7ed20ea724ab4ec05fc055829154"><td class="memItemLeft" align="right" valign="top"><a id="a2b7c7ed20ea724ab4ec05fc055829154"></a>
<a class="el" href="classQAABB.html">QAABB</a>&#160;</td><td class="memItemRight" valign="bottom"><b>Fattened</b> (float amount) const</td></tr>
<tr class="separator:a2b7c7ed20ea724ab4ec05fc055829154"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7cef066c2c10399a157d5040b6a50745"><td class="memItemLeft" align="right" valign="top"><a id="a7cef066c2c10399a157d5040b6a50745"></a>
<a class="el" href="classQAABB.html">QAABB</a>&#160;</td><td class="memItemRight" valign="bottom"><b>FattenedWithRate</b> (float rate) const</td></tr>
<tr class="separator:a7cef066c2c10399a157d5040b6a50745"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a070693c56004ad082994f2167ef92288"><td class="memItemLeft" align="right" valign="top"><a id="a070693c56004ad082994f2167ef92288"></a>
bool&#160;</td><td class="memItemRight" valign="bottom"><b>isCollidingWith</b> (const <a class="el" href="classQAABB.html">QAABB</a> &amp;otherAABB) const</td></tr>
<tr class="separator:a070693c56004ad082994f2167ef92288"><td class="memSeparator" colspan="2">&#160;</td></tr>
Expand All @@ -126,9 +148,13 @@
<li>QuarkPhysics/<a class="el" href="qaabb_8h_source.html">qaabb.h</a></li>
</ul>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1
</small></address>
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="classQAABB.html">QAABB</a></li>
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1 </li>
</ul>
</div>
</body>
</html>
18 changes: 18 additions & 0 deletions documentation/classQAABB.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
var classQAABB =
[
[ "QAABB", "classQAABB.html#a6e524e1c708e2c360a79f4064f2d99b4", null ],
[ "QAABB", "classQAABB.html#a4c687527be56f1635d2967411aed1d51", null ],
[ "Fatten", "classQAABB.html#ae3115260fff1404d4872cf3740b78cb9", null ],
[ "Fattened", "classQAABB.html#a2b7c7ed20ea724ab4ec05fc055829154", null ],
[ "FattenedWithRate", "classQAABB.html#a7cef066c2c10399a157d5040b6a50745", null ],
[ "GetArea", "classQAABB.html#a6fa5171c0563e52cc95753166eb3b1d2", null ],
[ "GetCenterPosition", "classQAABB.html#a983f3f25c2e89e08de6837e90fcb45fe", null ],
[ "GetMax", "classQAABB.html#aeeed38733be11d76c70d6678f4723bd7", null ],
[ "GetMin", "classQAABB.html#a4af90f1e53eb6cabe630657aad55537c", null ],
[ "GetPerimeter", "classQAABB.html#ac8613bb855fde16fbc9591baa3223678", null ],
[ "GetSize", "classQAABB.html#aec22976af0d609ddc8150ed50e50a368", null ],
[ "GetVolume", "classQAABB.html#a46b9d3092df51d1b41beed8ff348d562", null ],
[ "isCollidingWith", "classQAABB.html#a070693c56004ad082994f2167ef92288", null ],
[ "isContain", "classQAABB.html#a14892c3614b435353840aa973be0214a", null ],
[ "SetMinMax", "classQAABB.html#a614aed295b6098e3519fd46f988e2fd3", null ]
];
Loading

0 comments on commit 42ddd67

Please sign in to comment.