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
131 EntityItem* entityB;131 EntityItem* entityB;
132 if (_entities->findSpherePenetration(center, radius, penetration, (void**)&entityB, Octree::NoLock)) {132 if (_entities->findSpherePenetration(center, radius, penetration, (void**)&entityB, Octree::NoLock)) {
133 // NOTE: 'penetration' is the depth that 'entityA' overlaps 'entityB'. It points from A into B.133 // NOTE: 'penetration' is the depth that 'entityA' overlaps 'entityB'. It points from A into B.
134
135qDebug() << "penetration:" << penetration << "in meters";
136
137 glm::vec3 penetrationInTreeUnits = penetration / (float)(TREE_SCALE);134 glm::vec3 penetrationInTreeUnits = penetration / (float)(TREE_SCALE);
138 135
139qDebug() << "penetrationInTreeUnits:" << penetrationInTreeUnits;
140
141 // Even if the Entities overlap... when the Entities are already moving appart136 // Even if the Entities overlap... when the Entities are already moving appart
142 // we don't want to count this as a collision.137 // we don't want to count this as a collision.
143 glm::vec3 relativeVelocity = entityA->getVelocity() - entityB->getVelocity();138 glm::vec3 relativeVelocity = entityA->getVelocity() - entityB->getVelocity();
144 139
145qDebug() << "A old velocity:" << entityA->getVelocity() * (float)TREE_SCALE << "in meters";
146qDebug() << "B old velocity:" << entityB->getVelocity() * (float)TREE_SCALE << "in meters";
147qDebug() << "relativeVelocity:" << relativeVelocity * (float)TREE_SCALE << "in meters";
148
149 bool movingTowardEachOther = glm::dot(relativeVelocity, penetrationInTreeUnits) > 0.0f;140 bool movingTowardEachOther = glm::dot(relativeVelocity, penetrationInTreeUnits) > 0.0f;
150 bool doCollisions = true;141 bool doCollisions = true;
151 142
152 if (doCollisions) {143 if (doCollisions) {
153 //entityA->collisionWithEntity(entityB, penetration);144 entityA->collisionWithEntity(entityB, penetration);
154 //entityB->collisionWithEntity(entityA, penetration * -1.0f); // the penetration is reversed145 entityB->collisionWithEntity(entityA, penetration * -1.0f); // the penetration is reversed
155 146
156 CollisionInfo collision;147 CollisionInfo collision;
157 collision._penetration = penetration;148 collision._penetration = penetration;
158 // for now the contactPoint is the average between the the two paricle centers149 // for now the contactPoint is the average between the the two paricle centers
159 collision._contactPoint = (0.5f * (float)TREE_SCALE) * (entityA->getPosition() + entityB->getPosition());150 collision._contactPoint = (0.5f * (float)TREE_SCALE) * (entityA->getPosition() + entityB->getPosition());
160 //emitGlobalEntityCollisionWithEntity(entityA, entityB, collision);151 emitGlobalEntityCollisionWithEntity(entityA, entityB, collision);
161 152
162 glm::vec3 axis = glm::normalize(penetration);153 glm::vec3 axis = glm::normalize(penetration);
163 glm::vec3 axialVelocity = glm::dot(relativeVelocity, axis) * axis;154 glm::vec3 axialVelocity = glm::dot(relativeVelocity, axis) * axis;
@@ -165,85 +156,33 @@ qDebug() << "relativeVelocity:" << relativeVelocity * (float)TREE_SCALE << "in m · 1 unmodified line
165 float massA = entityA->getMass();156 float massA = entityA->getMass();
166 float massB = entityB->getMass();157 float massB = entityB->getMass();
167 float totalMass = massA + massB;158 float totalMass = massA + massB;
168qDebug() << "massA:" << massA;
169qDebug() << "massB:" << massB;
170qDebug() << "totalMass:" << totalMass;
171 159
172 // handle Entity A160 // handle Entity A
173 161 glm::vec3 newVelocityA = entityA->getVelocity() - axialVelocity * (2.0f * massB / totalMass);
174qDebug() << "OLD - VALUES - entityA ----";162 glm::vec3 newPositionA = entityA->getPosition() - 0.5f * penetrationInTreeUnits;
175qDebug() << "entityA->getVelocity():" << entityA->getVelocity() << "no scaling";
176qDebug() << "entityA->getVelocity():" << entityA->getVelocity() * (float)TREE_SCALE << "in meters";
177qDebug() << "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
183qDebug() << "A new Velocity:" << newVelocity * (float)TREE_SCALE << "in meters";
184qDebug() << "A new Position:" << newPosition * (float)TREE_SCALE << "in meters";
185 163
186 EntityItemProperties propertiesA = entityA->getProperties();164 EntityItemProperties propertiesA = entityA->getProperties();
187
188qDebug() << "propertiesA = entityA->getProperties() --- BEFORE SETTING ----";
189qDebug() << " propertiesA.getPosition():" << propertiesA.getPosition() << "in meters";
190qDebug() << " propertiesA.getVelocity():" << propertiesA.getVelocity() << "in meters";
191qDebug() << " propertiesA.getMaximumAACubeInTreeUnits():" << propertiesA.getMaximumAACubeInTreeUnits();
192
193 EntityItemID idA(entityA->getID());165 EntityItemID idA(entityA->getID());
194 propertiesA.setVelocity(newVelocity * (float)TREE_SCALE);166 propertiesA.setVelocity(newVelocityA * (float)TREE_SCALE);
195 propertiesA.setPosition(newPosition * (float)TREE_SCALE);167 propertiesA.setPosition(newPositionA * (float)TREE_SCALE);
196
197qDebug() << "updateEntity(idA, propertiesA)....";
198qDebug() << " idA:" << idA;
199qDebug() << " propertiesA.getPosition():" << propertiesA.getPosition() << "in meters";
200qDebug() << " propertiesA.getVelocity():" << propertiesA.getVelocity() << "in meters";
201qDebug() << " propertiesA.getMaximumAACubeInTreeUnits():" << propertiesA.getMaximumAACubeInTreeUnits();
202 168
203 _entities->updateEntity(idA, propertiesA);169 _entities->updateEntity(idA, propertiesA);
204
205qDebug() << "AFTER updateEntity()....";
206qDebug() << " entityA->getVelocity():" << entityA->getVelocity() << "no scaling";
207qDebug() << " entityA->getPosition():" << entityA->getPosition() * (float)TREE_SCALE << "in meters";
208
209
210 _packetSender->queueEditEntityMessage(PacketTypeEntityAddOrEdit, idA, propertiesA);170 _packetSender->queueEditEntityMessage(PacketTypeEntityAddOrEdit, idA, propertiesA);
211 //queueEntityMessage(PacketTypeEntityAddOrEdit, entityID, properties);
212
213qDebug() << "OLD - VALUES - entityB ----";
214qDebug() << " entityB->getVelocity():" << entityB->getVelocity() << "no scaling";
215qDebug() << " entityB->getPosition():" << entityB->getPosition() * (float)TREE_SCALE << "in meters";
216 171
217 glm::vec3 newVelocityB = entityB->getVelocity() + axialVelocity * (2.0f * massA / totalMass);172 glm::vec3 newVelocityB = entityB->getVelocity() + axialVelocity * (2.0f * massA / totalMass);
218 glm::vec3 newPositionB = entityB->getPosition() + 0.5f * penetrationInTreeUnits;173 glm::vec3 newPositionB = entityB->getPosition() + 0.5f * penetrationInTreeUnits;
219 174
220qDebug() << "B new Velocity:" << newVelocityB << "no scaling";
221qDebug() << "B new Position:" << newPositionB * (float)TREE_SCALE << "in meters";
222
223 EntityItemProperties propertiesB = entityB->getProperties();175 EntityItemProperties propertiesB = entityB->getProperties();
224 176
225qDebug() << "propertiesB = entityB->getProperties()";
226qDebug() << " propertiesB.getPosition():" << propertiesB.getPosition() << "not scaled, should be meters";
227qDebug() << " propertiesB.getVelocity():" << propertiesB.getVelocity() << "not scaled, should be ???";
228qDebug() << " propertiesB.getMaximumAACubeInTreeUnits():" << propertiesB.getMaximumAACubeInTreeUnits();
229
230 EntityItemID idB(entityB->getID());177 EntityItemID idB(entityB->getID());
231 propertiesB.setVelocity(newVelocityB * (float)TREE_SCALE);178 propertiesB.setVelocity(newVelocityB * (float)TREE_SCALE);
232 propertiesB.setPosition(newPositionB * (float)TREE_SCALE);179 propertiesB.setPosition(newPositionB * (float)TREE_SCALE);
233 180
234qDebug() << "updateEntity(idB, propertiesB)....";
235qDebug() << " idB:" << idB;
236qDebug() << " propertiesB.getPosition():" << propertiesB.getPosition();
237qDebug() << " propertiesB.getVelocity():" << propertiesB.getVelocity();
238qDebug() << " propertiesB.getMaximumAACubeInTreeUnits():" << propertiesB.getMaximumAACubeInTreeUnits();
239
240 _entities->updateEntity(idB, propertiesB);181 _entities->updateEntity(idB, propertiesB);
241 182
242qDebug() << "AFTER updateEntity()....";
243qDebug() << " entityB->getVelocity():" << entityB->getVelocity() << "no scaling";
244qDebug() << " entityB->getPosition():" << entityB->getPosition() * (float)TREE_SCALE << "in meters";
245
246 _packetSender->queueEditEntityMessage(PacketTypeEntityAddOrEdit, idB, propertiesB);183 _packetSender->queueEditEntityMessage(PacketTypeEntityAddOrEdit, idB, propertiesB);
184
185 // TODO: Do we need this?
247 //_packetSender->releaseQueuedMessages();186 //_packetSender->releaseQueuedMessages();
248 187
249 //updateCollisionSound(entityA, penetration, COLLISION_FREQUENCY);188 //updateCollisionSound(entityA, penetration, COLLISION_FREQUENCY);
@@ -252,6 +191,8 @@ qDebug() << " entityB->getPosition():" << entityB->getPosition() * (float)TRE · 2 unmodified lines
252}191}
253 192
254void EntityCollisionSystem::updateCollisionWithAvatars(EntityItem* entity) {193void EntityCollisionSystem::updateCollisionWithAvatars(EntityItem* entity) {
194
195 // TODO: implement support for colliding with avatars
255 196
256#if 0197#if 0
257 // Entities that are in hand, don't collide with avatars198 // 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