mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2026-05-14 11:54:32 +08:00
Ability to edit YTYP files and MLO Entity Defintions + Revisions to grass brush (#33)
* - Add ability to edit/add ytyp files to project. - Add ability to edit/add ytyp archetype files to ytyp. - Add ability to add/remove entities from mlo archetype defs. - Add ability to save ytyp files. - Add dialog popup before optimizing grass batches. - Fix grass batches not being selected when chaning selection in project explorer. - Merged with upstream/master. - Squashed last 4 commits for PR cleanliness. * Fixed windows forms reference error. * - Added error checking to deleting mlo entities. - Fixed various bugs with deleting mlo entities. - Fixed edit archetype panel Asset Type box. - Removed redundant/unnecessary. - Removed backwards references between MCEntityDef and YmapEntityDef. All ymap entity to mcentity references are grabbed using indecies in the MloInstanceData class. - Fixed "YmapMenu" not showing when selecting entities/mlo entities in project form. Current bugs: - Loading a ytyp file -- mlo entities are not editiable, and are created in the world. - entitysets are not editable (properly). - Removing an mloinstancedef from a ymap does not delete the mlo instance's gizmo from the world, and it's still selectable. (Although all references are lost, and I believe collected by the GC?) * - Moved archetype initialization methods YmapFile.InitYmapEntityArchetypes(GameFileCache gfc) and MloInstanceData.InitYmapEntityArchetypes(GameFileCache gfc) - Added ability to load mlo instance defs through ymap files. - Fixed add method for mlo archetypes. * - Removed SetOrientationInv. - Removed unreachable code + updated comment. - Renamed CreateEntity to CreateYmapEntity, and renamed params for consistency. * Split calls to CreateYmapEntity() and MloArchetype.AddEntity(). * Fixed redundant rotation inversions. * - Added ability to select rooms. - Changed tree view grouping for mlo entities. - Fixed projectexplorer selection bugs. - Added ability to toggle mlo entity sets. - Fixed some change events when editing archetypes.
This commit is contained in:
committed by
dexyfex
Unverified
parent
4da1e3d8c7
commit
462e464c2f
@@ -1804,116 +1804,6 @@ namespace CodeWalker.GameFiles
|
||||
}
|
||||
|
||||
|
||||
public void InitYmapEntityArchetypes(YmapFile file)
|
||||
{
|
||||
if (file == null) return;
|
||||
if (file.AllEntities != null)
|
||||
{
|
||||
for (int i = 0; i < file.AllEntities.Length; i++)
|
||||
{
|
||||
var ent = file.AllEntities[i];
|
||||
var arch = GetArchetype(ent.CEntityDef.archetypeName);
|
||||
ent.SetArchetype(arch);
|
||||
|
||||
if (ent.MloInstance != null)
|
||||
{
|
||||
var entities = ent.MloInstance.Entities;
|
||||
if (entities != null)
|
||||
{
|
||||
for (int j = 0; j < entities.Length; j++)
|
||||
{
|
||||
var ient = entities[j];
|
||||
var iarch = GetArchetype(ient.CEntityDef.archetypeName);
|
||||
ient.SetArchetype(iarch);
|
||||
if (iarch == null)
|
||||
{ } //can't find archetype - des stuff eg {des_prologue_door}
|
||||
}
|
||||
|
||||
|
||||
//update archetype room AABB's.. bad to have this here? where else to put it?
|
||||
var mloa = arch as MloArchetype;
|
||||
if (mloa != null)
|
||||
{
|
||||
Vector3 mlobbmin = Vector3.Zero;
|
||||
Vector3 mlobbmax = Vector3.Zero;
|
||||
Vector3[] c = new Vector3[8];
|
||||
var rooms = mloa.rooms;
|
||||
if (rooms != null)
|
||||
{
|
||||
for (int j = 0; j < rooms.Length; j++)
|
||||
{
|
||||
var room = rooms[j];
|
||||
if ((room.AttachedObjects == null) || (room.AttachedObjects.Length == 0)) continue;
|
||||
Vector3 min = new Vector3(float.MaxValue);
|
||||
Vector3 max = new Vector3(float.MinValue);
|
||||
for (int k = 0; k < room.AttachedObjects.Length; k++)
|
||||
{
|
||||
var objid = room.AttachedObjects[k];
|
||||
if (objid < entities.Length)
|
||||
{
|
||||
var rooment = entities[objid];
|
||||
if ((rooment != null) && (rooment.Archetype != null))
|
||||
{
|
||||
var earch = rooment.Archetype;
|
||||
var pos = rooment._CEntityDef.position;
|
||||
var ori = rooment.Orientation;
|
||||
Vector3 abmin = earch.BBMin * rooment.Scale; //entity box
|
||||
Vector3 abmax = earch.BBMax * rooment.Scale;
|
||||
c[0] = abmin;
|
||||
c[1] = new Vector3(abmin.X, abmin.Y, abmax.Z);
|
||||
c[2] = new Vector3(abmin.X, abmax.Y, abmin.Z);
|
||||
c[3] = new Vector3(abmin.X, abmax.Y, abmax.Z);
|
||||
c[4] = new Vector3(abmax.X, abmin.Y, abmin.Z);
|
||||
c[5] = new Vector3(abmax.X, abmin.Y, abmax.Z);
|
||||
c[6] = new Vector3(abmax.X, abmax.Y, abmin.Z);
|
||||
c[7] = abmax;
|
||||
for (int n = 0; n < 8; n++)
|
||||
{
|
||||
Vector3 corn = ori.Multiply(c[n]) + pos;
|
||||
min = Vector3.Min(min, corn);
|
||||
max = Vector3.Max(max, corn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
room.BBMin_CW = min;
|
||||
room.BBMax_CW = max;
|
||||
mlobbmin = Vector3.Min(mlobbmin, min);
|
||||
mlobbmax = Vector3.Max(mlobbmax, max);
|
||||
}
|
||||
}
|
||||
mloa.BBMin = mlobbmin;
|
||||
mloa.BBMax = mlobbmax;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
if (file.GrassInstanceBatches != null)
|
||||
{
|
||||
for (int i = 0; i < file.GrassInstanceBatches.Length; i++)
|
||||
{
|
||||
var batch = file.GrassInstanceBatches[i];
|
||||
batch.Archetype = GetArchetype(batch.Batch.archetypeName);
|
||||
}
|
||||
}
|
||||
|
||||
if (file.TimeCycleModifiers != null)
|
||||
{
|
||||
for (int i = 0; i < file.TimeCycleModifiers.Length; i++)
|
||||
{
|
||||
var tcm = file.TimeCycleModifiers[i];
|
||||
World.TimecycleMod wtcm;
|
||||
if (TimeCycleModsDict.TryGetValue(tcm.CTimeCycleModifier.name.Hash, out wtcm))
|
||||
{
|
||||
tcm.TimeCycleModData = wtcm;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1955,8 +1845,9 @@ namespace CodeWalker.GameFiles
|
||||
if (req.Loaded) AddTextureLookups(req as YtdFile);
|
||||
break;
|
||||
case GameFileType.Ymap:
|
||||
req.Loaded = LoadFile(req as YmapFile);
|
||||
if (req.Loaded) InitYmapEntityArchetypes(req as YmapFile);
|
||||
YmapFile y = req as YmapFile;
|
||||
req.Loaded = LoadFile(y);
|
||||
if (req.Loaded) y.InitYmapEntityArchetypes(this);
|
||||
break;
|
||||
case GameFileType.Yft:
|
||||
req.Loaded = LoadFile(req as YftFile);
|
||||
|
||||
Reference in New Issue
Block a user