*/}}
瀏覽代碼

Fixes, events and object parenting

ChengduLittleA 1 年之前
父節點
當前提交
a709b7442f
共有 8 個文件被更改,包括 33 次插入19 次删除
  1. 9 10
      la_kernel.c
  2. 2 1
      la_tns.h
  3. 3 2
      la_tns_kernel.c
  4. 1 1
      la_tns_mesh.c
  5. 4 0
      la_util.c
  6. 2 0
      la_util.h
  7. 10 3
      resources/la_modelling.c
  8. 2 2
      resources/la_properties.c

+ 9 - 10
la_kernel.c

@@ -1220,7 +1220,7 @@ void la_SaveEvent(SYSWINDOW hwnd, laEvent *e, int use_last_pos){
     laMappingRequestEval();
 };
 void la_SendKeyboardEvent(SYSWINDOW hwnd, int type, int key){
-    laEvent *e = memAcquireSimple(sizeof(laEvent)); e->Type = type; e->key = key;
+    laEvent *e = memAcquireSimple(sizeof(laEvent)); e->Type = type; e->key = tolowerGuarded(key);
     la_SaveEvent(hwnd, e, 1);
 };
 void la_SendInputEvent(SYSWINDOW hwnd, uint32_t Input){
@@ -6097,7 +6097,7 @@ laKeyMapItem *laAssignNewKey(laKeyMapper *km, char *Path, char *Operation, char
 
     kmi->SpecialKeyBits = SpecialKeyBits;
     kmi->EventType = EventType;
-    kmi->Key = Key;
+    kmi->Key = tolowerGuarded(Key);
     kmi->SelectBase = SelectBase;
 
     lstAppendItem(&km->Items, kmi);
@@ -6823,10 +6823,10 @@ LRESULT CALLBACK LA_WindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
         }
         break;
 
-    //case WM_SYSKEYDOWN:
-    //    if (lparam & 0x40000000) break;
-    //    if (la_SendSpecialKey(hwnd, LA_STATE_DOWN, wparam))
-    //        break;
+    case WM_SYSKEYDOWN:
+        if (lparam & 0x40000000) break;
+        la_SendKeyboardEvent(hwnd, LA_KEY_DOWN, la_TranslateSpecialKey(wparam));
+        break;
     case WM_KEYDOWN:
         if (lparam & 0x40000000) break;
         la_SendKeyboardEvent(hwnd, LA_KEY_DOWN, la_TranslateSpecialKey(wparam));
@@ -6834,10 +6834,9 @@ LRESULT CALLBACK LA_WindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
     case WM_KEYUP:
         la_SendKeyboardEvent(hwnd, LA_KEY_UP, la_TranslateSpecialKey(wparam));
         break;
-    
-    //case WM_SYSKEYUP:
-    //    if (la_SendSpecialKey(hwnd, LA_STATE_UP, wparam));
-    //    break;
+    case WM_SYSKEYUP:
+        la_SendKeyboardEvent(hwnd, LA_KEY_UP, la_TranslateSpecialKey(wparam));
+        break;
     case WM_UNICHAR:
         la_SendInputEvent(hwnd, wparam);
         break;

+ 2 - 1
la_tns.h

@@ -519,6 +519,7 @@ STRUCTURE(tnsObject){
     tnsEvaluateData Evaluated; // runtime
     tnsEvaluateData EvaluatedPlay;
     tnsObject* PlayDuplicate;
+    tnsObject* EditDuplicateTemp;
 };
 
 NEED_STRUCTURE(laNodeInSocket);
@@ -1036,7 +1037,7 @@ tnsMeshObject *tnsCreateMeshEmpty(tnsObject *under, char *Name, real AtX, real A
 tnsMeshObject *tnsCreateMeshPlane(tnsObject *under, char *Name, real AtX, real AtY, real AtZ, real size);
 
 int tnsMergeMeshObjects(tnsMeshObject* into, tnsMeshObject* mo);
-tnsMeshObject* tnsDuplicateMeshObjects(tnsMeshObject* from);
+tnsMeshObject* tnsDuplicateMeshObject(tnsMeshObject* from);
 
 void tnsInitMeshPlane(tnsMeshObject* mo, real size);
 void tnsAddMMeshPlane(tnsMeshObject* mo, real size);

+ 3 - 2
la_tns_kernel.c

@@ -3249,8 +3249,9 @@ void tnsInitObjectBase(tnsObject *o, tnsObject *under, char *Name, int Type,
     tnsLoadIdentity44d(o->DeltaTransform);
     tnsSelfTransformValueChanged(o);
     lstAppendItem(&T->World->AllObjects, o);
-    if (under){ lstAppendPointer(&under->ChildObjects, o);
-        tnsObject* root=under->Type==TNS_OBJECT_ROOT?under:under->InRoot; memAssignRef(o, &o->InRoot, root); 
+    if (under){ lstAppendPointer(&under->ChildObjects, o); int isroot=(under->Type==TNS_OBJECT_ROOT);
+        tnsObject* root=isroot?under:under->InRoot; memAssignRef(o, &o->InRoot, root);
+        if(!isroot){ o->ParentObject=under; }
     }
 }
 int tnsCheckParentable(tnsObject* child, tnsObject* parent){

+ 1 - 1
la_tns_mesh.c

@@ -114,7 +114,7 @@ int tnsMergeMeshObjects(tnsMeshObject* into, tnsMeshObject* mo){
     }
     tnsDestroyObject(mo); return 1;
 }
-tnsMeshObject* tnsDuplicateMeshObjects(tnsMeshObject* from){
+tnsMeshObject* tnsDuplicateMeshObject(tnsMeshObject* from){
     if(from->Base.Type!=TNS_OBJECT_MESH) return 0;
     tnsMeshObject* to = memAcquireHyper(sizeof(tnsMeshObject));
     tnsInitObjectBase(to, from->Base.ParentObject?from->Base.ParentObject:from->Base.InRoot, from->Base.Name->Ptr, TNS_OBJECT_MESH,0,0,0,0,0,0,0,0,1);

+ 4 - 0
la_util.c

@@ -1445,6 +1445,10 @@ void strToLower(char *Str){
         p++;
     }
 }
+int tolowerGuarded(int a) {
+    if (a >= 'A' && a <= 'Z') a -= 'A' - 'a';
+    return a;
+}
 
 laStringSplitor *strSplitPath(char *path,char terminator){
     laStringPart *sp;

+ 2 - 0
la_util.h

@@ -31,6 +31,7 @@
 #include "la_icon.h"
 #include <stddef.h>
 #include <stdint.h>
+#include <ctype.h>
 #ifdef __linux__
 #include <fcntl.h>
 #include <unistd.h>
@@ -639,6 +640,7 @@ void strMakeDifferentName(char * Target);
 void strReplaceCharacter(char * Str, char Find, char Replace);
 void strToUpper(char * Str);
 void strToLower(char * Str);
+int tolowerGuarded(int a);
 
 laStringSplitor *strSplitPath(char *path,char terminator);
 int strMakeInstructions(laStringSplitor** result,char * content);

+ 10 - 3
resources/la_modelling.c

@@ -1346,11 +1346,18 @@ int OPINV_Duplicate(laOperator *a, laEvent *e){
     if(!mo || mo->Base.Type!=TNS_OBJECT_MESH || mo->Mode==TNS_MESH_EDIT_MODE){ return LA_CANCELED; }
 
     laListHandle pending={0}; la_PopulateSelectedMeshObjects(root,&pending);
-    tnsMeshObject* o; tnsMeshObject* no;while(o=lstPopPointer(&pending)){ if(o->Mode==TNS_MESH_EDIT_MODE) continue;
-        if(no=tnsDuplicateMeshObjects(o)){ no->Base.Flags|=TNS_OBJECT_FLAGS_SELECTED; o->Base.Flags&=(~TNS_OBJECT_FLAGS_SELECTED); 
-            if(mo==o){ memAssignRef(root,&root->Active,no); } ran++; 
+    tnsMeshObject* o; tnsMeshObject* no; laListItemPointer* lip;
+    for(lip=pending.pFirst;lip;lip=lip->pNext){ o=lip->p; o->Base.EditDuplicateTemp=0; if (o->Mode == TNS_MESH_EDIT_MODE) continue;
+        if (no = tnsDuplicateMeshObject(o)){ o->Base.EditDuplicateTemp=no;
+            no->Base.Flags |= TNS_OBJECT_FLAGS_SELECTED; o->Base.Flags &= (~TNS_OBJECT_FLAGS_SELECTED);
+            if (mo == o) { memAssignRef(root, &root->Active, no); } ran++;
         }
     }
+    for (lip = pending.pFirst;lip;lip=lip->pNext){ o=lip->p; no = o->Base.EditDuplicateTemp;
+        tnsObject* NewParent=o->Base.ParentObject?o->Base.ParentObject->EditDuplicateTemp:0;
+        if(NewParent){ tnsUnparentObject(no,1); tnsParentObject(no,NewParent,1); }
+    }
+    while(o=lstPopPointer(&pending)){ o->Base.EditDuplicateTemp=0; }
     
     if(ran){
         laRecordAndPush(0,"tns.world","Merge mesh objects",TNS_HINT_GEOMETRY); laNotifyUsers("tns.world");

+ 2 - 2
resources/la_properties.c

@@ -563,8 +563,8 @@ void *tnsget_FirstChildObject(tnsObject *ob){
     return ob->ChildObjects.pFirst;
 }
 
-void tnsset_ObjectLocation(tnsObject* o, real val, int n){ o->Location[n]=val; tnsSelfTransformValueChanged(o); laNotifyUsers("tns.world"); }
-void tnsset_ObjectRotation(tnsObject* o, real val, int n){ o->Rotation[n]=val; tnsSelfTransformValueChanged(o); laNotifyUsers("tns.world"); }
+void tnsset_ObjectLocation(tnsObject* o, int n, real val){ o->Location[n]=val; tnsSelfTransformValueChanged(o); laNotifyUsers("tns.world"); }
+void tnsset_ObjectRotation(tnsObject* o, int n, real val){ o->Rotation[n]=val; tnsSelfTransformValueChanged(o); laNotifyUsers("tns.world"); }
 void tnsset_ObjectScale(tnsObject* o, real val){ o->Scale=val; tnsSelfTransformValueChanged(o); laNotifyUsers("tns.world"); }
 void tnsset_ObjectDLocationARR(tnsObject* o, real* arr){ tnsVectorCopy3d(arr,o->DLocation); tnsDeltaTransformValueChanged(o); laNotifyUsers("tns.world"); }
 void tnsset_ObjectDRotationARR(tnsObject* o, real* arr){ tnsVectorCopy3d(arr,o->DRotation); tnsDeltaTransformValueChanged(o); laNotifyUsers("tns.world"); }