MCPcopy Create free account
hub / github.com/aardappel/lobster / CreateParticleGroup

Method CreateParticleGroup

dev/include/Box2D/Particle/b2ParticleSystem.cpp:1047–1113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1045}
1046
1047b2ParticleGroup* b2ParticleSystem::CreateParticleGroup(
1048 const b2ParticleGroupDef& groupDef)
1049{
1050 b2Assert(m_world->IsLocked() == false);
1051 if (m_world->IsLocked())
1052 {
1053 return 0;
1054 }
1055
1056 b2Transform transform;
1057 transform.Set(groupDef.position, groupDef.angle);
1058 int32 firstIndex = m_count;
1059 if (groupDef.shape)
1060 {
1061 CreateParticlesWithShapeForGroup(groupDef.shape, groupDef, transform);
1062 }
1063 if (groupDef.shapes)
1064 {
1065 CreateParticlesWithShapesForGroup(
1066 groupDef.shapes, groupDef.shapeCount, groupDef, transform);
1067 }
1068 if (groupDef.particleCount)
1069 {
1070 b2Assert(groupDef.positionData);
1071 for (int32 i = 0; i < groupDef.particleCount; i++)
1072 {
1073 b2Vec2 p = groupDef.positionData[i];
1074 CreateParticleForGroup(groupDef, transform, p);
1075 }
1076 }
1077 int32 lastIndex = m_count;
1078
1079 void* mem = m_world->m_blockAllocator.Allocate(sizeof(b2ParticleGroup));
1080 b2ParticleGroup* group = new (mem) b2ParticleGroup();
1081 group->m_system = this;
1082 group->m_firstIndex = firstIndex;
1083 group->m_lastIndex = lastIndex;
1084 group->m_strength = groupDef.strength;
1085 group->m_userData = groupDef.userData;
1086 group->m_transform = transform;
1087 group->m_prev = NULL;
1088 group->m_next = m_groupList;
1089 if (m_groupList)
1090 {
1091 m_groupList->m_prev = group;
1092 }
1093 m_groupList = group;
1094 ++m_groupCount;
1095 for (int32 i = firstIndex; i < lastIndex; i++)
1096 {
1097 m_groupBuffer[i] = group;
1098 }
1099 SetGroupFlags(group, groupDef.groupFlags);
1100
1101 // Create pairs and triads between particles in the group.
1102 ConnectionFilter filter;
1103 UpdateContacts(true);
1104 UpdatePairsAndTriads(firstIndex, lastIndex, filter);

Callers 1

AddPhysicsFunction · 0.80

Calls 3

IsLockedMethod · 0.80
SetMethod · 0.45
AllocateMethod · 0.45

Tested by

no test coverage detected