MCPcopy Create free account
hub / github.com/Meridian59/Meridian59 / CmEditAdd

Method CmEditAdd

roomedit/source/editcli.cpp:4035–4276  ·  view source on GitHub ↗

//////////////////////////////////////////////////////////////// TEditorClient ------------- Insert an object at pointer location

Source from the content-addressed store, hash-verified

4033// -------------
4034// Insert an object at pointer location
4035void TEditorClient::CmEditAdd ()
4036{
4037 // Ignore if "insert object" mode
4038 if ( InsertingObject )
4039 return;
4040
4041 SET_HELP_CONTEXT(Add_object);
4042
4043 SelPtr cur;
4044
4045 // first special case: if several Vertices are selected, add new LineDefs
4046 if (EditMode == OBJ_VERTEXES && Selected != NULL && Selected->next != NULL)
4047 {
4048 // UNDO
4049 StartUndoRecording("Add LineDefs");
4050
4051 SHORT firstv;
4052
4053 if (Selected->next->next != NULL) firstv = Selected->objnum;
4054 else firstv = -1;
4055
4056 // create LineDefs between the Vertices
4057 for (cur = Selected; cur->next != NULL; cur = cur->next)
4058 {
4059
4060 // check if there is already a LineDef between the two Vertices
4061 for (CurObject = 0; CurObject < NumLineDefs; CurObject++)
4062 {
4063 LineDef *pCurLineDef = &LineDefs[CurObject];
4064 SHORT start = pCurLineDef->start;
4065 SHORT end = pCurLineDef->end;
4066
4067 if ( (start == cur->next->objnum && end == cur->objnum) ||
4068 (end == cur->next->objnum && start == cur->objnum) )
4069 break;
4070 }
4071
4072 // If no LineDef, add one
4073 if (CurObject >= NumLineDefs)
4074 {
4075 InsertObject (OBJ_LINEDEFS, -1, 0, 0);
4076 CurObject = NumLineDefs - 1;
4077 LineDefs[CurObject].start = cur->next->objnum;
4078 LineDefs[CurObject].end = cur->objnum;
4079 }
4080 cur->objnum = CurObject;
4081 }
4082
4083 // If SHIFT key pressed and if there are more than 2 Vertices,
4084 // close the polygon
4085 if (firstv >= 0 && (GetAsyncKeyState(VK_SHIFT) & 0x8000))
4086 {
4087 // check if there is already a LineDef between the two Vertices
4088 for (CurObject = 0; CurObject < NumLineDefs; CurObject++)
4089 {
4090 LineDef *pCurLineDef = &LineDefs[CurObject];
4091 SHORT start = pCurLineDef->start;
4092 SHORT end = pCurLineDef->end;

Callers

nothing calls this directly

Calls 13

StartUndoRecordingFunction · 0.85
InsertObjectFunction · 0.85
UnSelectObjectFunction · 0.85
StopUndoRecordingFunction · 0.85
BeepFunction · 0.85
NotifyFunction · 0.85
ForgetSelectionFunction · 0.85
SelectObjectFunction · 0.85
GetMaxObjectNumFunction · 0.85
DeleteObjectFunction · 0.85
TInput2DialogClass · 0.85
AutoMergeVerticesFunction · 0.85

Tested by

no test coverage detected