History

removed some debug

ZappoMan committed 12 years ago

Commit 10865941 parent f43ba4a1 file · +11 −70Browse files

Showing the changes to libraries/entities/src/EntityCollisionSystem.cpp (1 of 1 file). Show all

Unified · Split

libraries/entities/src/EntityCollisionSystem.cpp+11−70
@@ -131,33 +131,24 @@ void EntityCollisionSystem::updateCollisionWithEntities(EntityItem* entityA) { · 130 unmodified lines
131131 EntityItem* entityB;
132132 if (_entities->findSpherePenetration(center, radius, penetration, (void**)&entityB, Octree::NoLock)) {
133133 // NOTE: 'penetration' is the depth that 'entityA' overlaps 'entityB'. It points from A into B.
134−
135−qDebug() << "penetration:" << penetration << "in meters";
136−
137134 glm::vec3 penetrationInTreeUnits = penetration / (float)(TREE_SCALE);
138135
139−qDebug() << "penetrationInTreeUnits:" << penetrationInTreeUnits;
140−
141136 // Even if the Entities overlap... when the Entities are already moving appart
142137 // we don't want to count this as a collision.
143138 glm::vec3 relativeVelocity = entityA->getVelocity() - entityB->getVelocity();
144139
145−qDebug() << "A old velocity:" << entityA->getVelocity() * (float)TREE_SCALE << "in meters";
146−qDebug() << "B old velocity:" << entityB->getVelocity() * (float)TREE_SCALE << "in meters";
147−qDebug() << "relativeVelocity:" << relativeVelocity * (float)TREE_SCALE << "in meters";
148−
149140 bool movingTowardEachOther = glm::dot(relativeVelocity, penetrationInTreeUnits) > 0.0f;
150141 bool doCollisions = true;
151142
152143 if (doCollisions) {
153− //entityA->collisionWithEntity(entityB, penetration);
154− //entityB->collisionWithEntity(entityA, penetration * -1.0f); // the penetration is reversed
144+ entityA->collisionWithEntity(entityB, penetration);
145+ entityB->collisionWithEntity(entityA, penetration * -1.0f); // the penetration is reversed
155146
156147 CollisionInfo collision;
157148 collision._penetration = penetration;
158149 // for now the contactPoint is the average between the the two paricle centers
159150 collision._contactPoint = (0.5f * (float)TREE_SCALE) * (entityA->getPosition() + entityB->getPosition());
160− //emitGlobalEntityCollisionWithEntity(entityA, entityB, collision);
151+ emitGlobalEntityCollisionWithEntity(entityA, entityB, collision);
161152
162153 glm::vec3 axis = glm::normalize(penetration);
163154 glm::vec3 axialVelocity = glm::dot(relativeVelocity, axis) * axis;
@@ -165,85 +156,33 @@ qDebug() << "relativeVelocity:" << relativeVelocity * (float)TREE_SCALE << "in m · 1 unmodified line
165156 float massA = entityA->getMass();
166157 float massB = entityB->getMass();
167158 float totalMass = massA + massB;
168−qDebug() << "massA:" << massA;
169−qDebug() << "massB:" << massB;
170−qDebug() << "totalMass:" << totalMass;
171159
172160 // handle Entity A
173−
174−qDebug() << "OLD - VALUES - entityA ----";
175−qDebug() << "entityA->getVelocity():" << entityA->getVelocity() << "no scaling";
176−qDebug() << "entityA->getVelocity():" << entityA->getVelocity() * (float)TREE_SCALE << "in meters";
177−qDebug() << "entityA->getPosition():" << entityA->getPosition() * (float)TREE_SCALE << "in meters";
178−
179−
180− glm::vec3 newVelocity = entityA->getVelocity() - axialVelocity * (2.0f * massB / totalMass);
181− glm::vec3 newPosition = entityA->getPosition() - 0.5f * penetrationInTreeUnits;
182−
183−qDebug() << "A new Velocity:" << newVelocity * (float)TREE_SCALE << "in meters";
184−qDebug() << "A new Position:" << newPosition * (float)TREE_SCALE << "in meters";
161+ glm::vec3 newVelocityA = entityA->getVelocity() - axialVelocity * (2.0f * massB / totalMass);
162+ glm::vec3 newPositionA = entityA->getPosition() - 0.5f * penetrationInTreeUnits;
185163
186164 EntityItemProperties propertiesA = entityA->getProperties();
187−
188−qDebug() << "propertiesA = entityA->getProperties() --- BEFORE SETTING ----";
189−qDebug() << " propertiesA.getPosition():" << propertiesA.getPosition() << "in meters";
190−qDebug() << " propertiesA.getVelocity():" << propertiesA.getVelocity() << "in meters";
191−qDebug() << " propertiesA.getMaximumAACubeInTreeUnits():" << propertiesA.getMaximumAACubeInTreeUnits();
192−
193165 EntityItemID idA(entityA->getID());
194− propertiesA.setVelocity(newVelocity * (float)TREE_SCALE);
195− propertiesA.setPosition(newPosition * (float)TREE_SCALE);
196−
197−qDebug() << "updateEntity(idA, propertiesA)....";
198−qDebug() << " idA:" << idA;
199−qDebug() << " propertiesA.getPosition():" << propertiesA.getPosition() << "in meters";
200−qDebug() << " propertiesA.getVelocity():" << propertiesA.getVelocity() << "in meters";
201−qDebug() << " propertiesA.getMaximumAACubeInTreeUnits():" << propertiesA.getMaximumAACubeInTreeUnits();
166+ propertiesA.setVelocity(newVelocityA * (float)TREE_SCALE);
167+ propertiesA.setPosition(newPositionA * (float)TREE_SCALE);
202168
203169 _entities->updateEntity(idA, propertiesA);
204−
205−qDebug() << "AFTER updateEntity()....";
206−qDebug() << " entityA->getVelocity():" << entityA->getVelocity() << "no scaling";
207−qDebug() << " entityA->getPosition():" << entityA->getPosition() * (float)TREE_SCALE << "in meters";
208−
209−
210170 _packetSender->queueEditEntityMessage(PacketTypeEntityAddOrEdit, idA, propertiesA);
211− //queueEntityMessage(PacketTypeEntityAddOrEdit, entityID, properties);
212−
213−qDebug() << "OLD - VALUES - entityB ----";
214−qDebug() << " entityB->getVelocity():" << entityB->getVelocity() << "no scaling";
215−qDebug() << " entityB->getPosition():" << entityB->getPosition() * (float)TREE_SCALE << "in meters";
216171
217172 glm::vec3 newVelocityB = entityB->getVelocity() + axialVelocity * (2.0f * massA / totalMass);
218173 glm::vec3 newPositionB = entityB->getPosition() + 0.5f * penetrationInTreeUnits;
219174
220−qDebug() << "B new Velocity:" << newVelocityB << "no scaling";
221−qDebug() << "B new Position:" << newPositionB * (float)TREE_SCALE << "in meters";
222−
223175 EntityItemProperties propertiesB = entityB->getProperties();
224176
225−qDebug() << "propertiesB = entityB->getProperties()";
226−qDebug() << " propertiesB.getPosition():" << propertiesB.getPosition() << "not scaled, should be meters";
227−qDebug() << " propertiesB.getVelocity():" << propertiesB.getVelocity() << "not scaled, should be ???";
228−qDebug() << " propertiesB.getMaximumAACubeInTreeUnits():" << propertiesB.getMaximumAACubeInTreeUnits();
229−
230177 EntityItemID idB(entityB->getID());
231178 propertiesB.setVelocity(newVelocityB * (float)TREE_SCALE);
232179 propertiesB.setPosition(newPositionB * (float)TREE_SCALE);
233180
234−qDebug() << "updateEntity(idB, propertiesB)....";
235−qDebug() << " idB:" << idB;
236−qDebug() << " propertiesB.getPosition():" << propertiesB.getPosition();
237−qDebug() << " propertiesB.getVelocity():" << propertiesB.getVelocity();
238−qDebug() << " propertiesB.getMaximumAACubeInTreeUnits():" << propertiesB.getMaximumAACubeInTreeUnits();
239−
240181 _entities->updateEntity(idB, propertiesB);
241182
242−qDebug() << "AFTER updateEntity()....";
243−qDebug() << " entityB->getVelocity():" << entityB->getVelocity() << "no scaling";
244−qDebug() << " entityB->getPosition():" << entityB->getPosition() * (float)TREE_SCALE << "in meters";
245−
246183 _packetSender->queueEditEntityMessage(PacketTypeEntityAddOrEdit, idB, propertiesB);
184+
185+ // TODO: Do we need this?
247186 //_packetSender->releaseQueuedMessages();
248187
249188 //updateCollisionSound(entityA, penetration, COLLISION_FREQUENCY);
@@ -252,6 +191,8 @@ qDebug() << " entityB->getPosition():" << entityB->getPosition() * (float)TRE · 2 unmodified lines
252191 }
253192
254193 void EntityCollisionSystem::updateCollisionWithAvatars(EntityItem* entity) {
194+
195+ // TODO: implement support for colliding with avatars
255196
256197 #if 0
257198 // Entities that are in hand, don't collide with avatars

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t